diff --git a/MJLite.js b/MJLite.js index 6806e48c2..ae24ea609 100644 --- 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 index 51f0c661b..fd4613ab4 100644 --- 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 index 0e7b3495d..4486b99ca 100644 --- 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 index c44983e60..270d7793f 100644 --- 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%;