commit 8d85aa464ede9182dbd8571fc9e8acfdacac2f8c
parent 9d2ac2c1326fbac091e98b9ddd96771a6c13b938
Author: Emily Eisenberg <xymostech@gmail.com>
Date: Tue, 9 Jul 2013 00:57:03 -0700
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
Diffstat:
4 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/MJLite.js b/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) {
diff --git a/lexer.js b/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
diff --git a/parser.jison b/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'
diff --git a/static/style.css b/static/style.css
@@ -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%;