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));
|
return makeSpan("mord", mathit(group.value));
|
||||||
} else if (group.type === "bin") {
|
} else if (group.type === "bin") {
|
||||||
var className = "mbin";
|
var className = "mbin";
|
||||||
if (prev == null || prev.type === "bin" || prev.type === "open") {
|
if (prev == null || _.contains(["bin", "open", "rel"], prev.type)) {
|
||||||
group.type = "ord";
|
group.type = "ord";
|
||||||
className = "mord";
|
className = "mord";
|
||||||
}
|
}
|
||||||
return makeSpan(className, textit(group.value));
|
return makeSpan(className, textit(group.value));
|
||||||
|
} else if (group.type === "rel") {
|
||||||
|
return makeSpan("mrel", textit(group.value));
|
||||||
} else if (group.type === "sup") {
|
} else if (group.type === "sup") {
|
||||||
var sup = makeSpan("msup", buildExpression(group.value.sup));
|
var sup = makeSpan("msup", buildExpression(group.value.sup));
|
||||||
return makeSpan("mord", buildExpression(group.value.base).concat(sup));
|
return makeSpan("mord", buildExpression(group.value.base).concat(sup));
|
||||||
|
@ -76,7 +78,12 @@ var charLookup = {
|
||||||
"\\lvert": "|",
|
"\\lvert": "|",
|
||||||
"\\rvert": "|",
|
"\\rvert": "|",
|
||||||
"\\pm": "\u00b1",
|
"\\pm": "\u00b1",
|
||||||
"\\div": "\u00f7"
|
"\\div": "\u00f7",
|
||||||
|
"\\leq": "\u2264",
|
||||||
|
"\\geq": "\u2265",
|
||||||
|
"\\neq": "\u2260",
|
||||||
|
"\\nleq": "\u2270",
|
||||||
|
"\\ngeq": "\u2271"
|
||||||
};
|
};
|
||||||
|
|
||||||
var textit = function(value) {
|
var textit = function(value) {
|
||||||
|
|
9
lexer.js
9
lexer.js
|
@ -4,6 +4,7 @@ function Lexer() {
|
||||||
var normals = [
|
var normals = [
|
||||||
[/^[/|a-zA-Z0-9.]/, 'ORD'],
|
[/^[/|a-zA-Z0-9.]/, 'ORD'],
|
||||||
[/^[*+-]/, 'BIN'],
|
[/^[*+-]/, 'BIN'],
|
||||||
|
[/^[=<>]/, 'REL'],
|
||||||
[/^\^/, '^'],
|
[/^\^/, '^'],
|
||||||
[/^_/, '_'],
|
[/^_/, '_'],
|
||||||
[/^{/, '{'],
|
[/^{/, '{'],
|
||||||
|
@ -13,8 +14,12 @@ var normals = [
|
||||||
];
|
];
|
||||||
|
|
||||||
var funcs = [
|
var funcs = [
|
||||||
// Symbols
|
// Bin symbols
|
||||||
'cdot', 'lvert', 'rvert', 'pm', 'div',
|
'cdot', 'pm', 'div',
|
||||||
|
// Rel symbols
|
||||||
|
'leq', 'geq', 'neq', 'nleq', 'ngeq',
|
||||||
|
// Open/close symbols
|
||||||
|
'lvert', 'rvert',
|
||||||
// Colors
|
// Colors
|
||||||
'blue', 'orange', 'pink', 'red', 'green', 'gray', 'purple',
|
'blue', 'orange', 'pink', 'red', 'green', 'gray', 'purple',
|
||||||
// Other functions
|
// Other functions
|
||||||
|
|
12
parser.jison
12
parser.jison
|
@ -52,6 +52,16 @@ func
|
||||||
{$$ = [{type: 'open', value: yytext}];}
|
{$$ = [{type: 'open', value: yytext}];}
|
||||||
| 'rvert'
|
| 'rvert'
|
||||||
{$$ = [{type: 'close', value: yytext}];}
|
{$$ = [{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
|
| 'blue' group
|
||||||
{$$ = [{type: 'color', value: {color: 'blue', value: $2}}];}
|
{$$ = [{type: 'color', value: {color: 'blue', value: $2}}];}
|
||||||
| 'orange' group
|
| 'orange' group
|
||||||
|
@ -75,6 +85,8 @@ atom
|
||||||
{$$ = [{type: 'ord', value: yytext}];}
|
{$$ = [{type: 'ord', value: yytext}];}
|
||||||
| 'BIN'
|
| 'BIN'
|
||||||
{$$ = [{type: 'bin', value: yytext}];}
|
{$$ = [{type: 'bin', value: yytext}];}
|
||||||
|
| 'REL'
|
||||||
|
{$$ = [{type: 'rel', value: yytext}];}
|
||||||
| 'OPEN'
|
| 'OPEN'
|
||||||
{$$ = [{type: 'open', value: yytext}];}
|
{$$ = [{type: 'open', value: yytext}];}
|
||||||
| 'CLOSE'
|
| 'CLOSE'
|
||||||
|
|
|
@ -50,6 +50,22 @@ input {
|
||||||
margin-left: 0.22222em;
|
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 {
|
.msub {
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
font-size: 70%;
|
font-size: 70%;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user