Add rels
Summary: Add a bunch of rels, and their css and stuff. Test Plan: Add some rels. Rejoice. Reviewers: spicyj Reviewed By: spicyj Differential Revision: http://phabricator.benalpert.com/D45
This commit is contained in:
parent
9d2ac2c132
commit
8d85aa464e
11
MJLite.js
11
MJLite.js
|
@ -34,11 +34,13 @@ var buildGroup = function(group, prev) {
|
|||
return makeSpan("mord", mathit(group.value));
|
||||
} else if (group.type === "bin") {
|
||||
var className = "mbin";
|
||||
if (prev == null || prev.type === "bin" || prev.type === "open") {
|
||||
if (prev == null || _.contains(["bin", "open", "rel"], prev.type)) {
|
||||
group.type = "ord";
|
||||
className = "mord";
|
||||
}
|
||||
return makeSpan(className, textit(group.value));
|
||||
} else if (group.type === "rel") {
|
||||
return makeSpan("mrel", textit(group.value));
|
||||
} else if (group.type === "sup") {
|
||||
var sup = makeSpan("msup", buildExpression(group.value.sup));
|
||||
return makeSpan("mord", buildExpression(group.value.base).concat(sup));
|
||||
|
@ -76,7 +78,12 @@ var charLookup = {
|
|||
"\\lvert": "|",
|
||||
"\\rvert": "|",
|
||||
"\\pm": "\u00b1",
|
||||
"\\div": "\u00f7"
|
||||
"\\div": "\u00f7",
|
||||
"\\leq": "\u2264",
|
||||
"\\geq": "\u2265",
|
||||
"\\neq": "\u2260",
|
||||
"\\nleq": "\u2270",
|
||||
"\\ngeq": "\u2271"
|
||||
};
|
||||
|
||||
var textit = function(value) {
|
||||
|
|
9
lexer.js
9
lexer.js
|
@ -4,6 +4,7 @@ function Lexer() {
|
|||
var normals = [
|
||||
[/^[/|a-zA-Z0-9.]/, 'ORD'],
|
||||
[/^[*+-]/, 'BIN'],
|
||||
[/^[=<>]/, 'REL'],
|
||||
[/^\^/, '^'],
|
||||
[/^_/, '_'],
|
||||
[/^{/, '{'],
|
||||
|
@ -13,8 +14,12 @@ var normals = [
|
|||
];
|
||||
|
||||
var funcs = [
|
||||
// Symbols
|
||||
'cdot', 'lvert', 'rvert', 'pm', 'div',
|
||||
// Bin symbols
|
||||
'cdot', 'pm', 'div',
|
||||
// Rel symbols
|
||||
'leq', 'geq', 'neq', 'nleq', 'ngeq',
|
||||
// Open/close symbols
|
||||
'lvert', 'rvert',
|
||||
// Colors
|
||||
'blue', 'orange', 'pink', 'red', 'green', 'gray', 'purple',
|
||||
// Other functions
|
||||
|
|
12
parser.jison
12
parser.jison
|
@ -52,6 +52,16 @@ func
|
|||
{$$ = [{type: 'open', value: yytext}];}
|
||||
| 'rvert'
|
||||
{$$ = [{type: 'close', value: yytext}];}
|
||||
| 'leq'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'geq'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'neq'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'nleq'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'ngeq'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'blue' group
|
||||
{$$ = [{type: 'color', value: {color: 'blue', value: $2}}];}
|
||||
| 'orange' group
|
||||
|
@ -75,6 +85,8 @@ atom
|
|||
{$$ = [{type: 'ord', value: yytext}];}
|
||||
| 'BIN'
|
||||
{$$ = [{type: 'bin', value: yytext}];}
|
||||
| 'REL'
|
||||
{$$ = [{type: 'rel', value: yytext}];}
|
||||
| 'OPEN'
|
||||
{$$ = [{type: 'open', value: yytext}];}
|
||||
| 'CLOSE'
|
||||
|
|
|
@ -50,6 +50,22 @@ input {
|
|||
margin-left: 0.22222em;
|
||||
}
|
||||
|
||||
.mrel + .mord {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.mord + .mrel {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.mrel + .mopen {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.mclose + .mrel {
|
||||
margin-left: 0.27778em;
|
||||
}
|
||||
|
||||
.msub {
|
||||
vertical-align: bottom;
|
||||
font-size: 70%;
|
||||
|
|
Loading…
Reference in New Issue
Block a user