diff --git a/MJLite.js b/MJLite.js index 20c62defe..07bd401f0 100644 --- a/MJLite.js +++ b/MJLite.js @@ -30,8 +30,10 @@ var makeSpan = function(className, children) { }; var buildGroup = function(group, prev) { - if (group.type === "ord") { + if (group.type === "mathord") { return makeSpan("mord", mathit(group.value)); + } else if (group.type === "textord") { + return makeSpan("mord", textit(group.value)); } else if (group.type === "bin") { var className = "mbin"; if (prev == null || _.contains(["bin", "open", "rel"], prev.type)) { @@ -123,13 +125,7 @@ var textit = function(value) { }; var mathit = function(value) { - var text = textit(value); - - if (/[a-zA-Z]/.test(value)) { - return makeSpan("mathit", text); - } else { - return text; - } + return makeSpan("mathit", textit(value)); }; var clearNode = function(node) { diff --git a/lexer.js b/lexer.js index d7d171e3b..69f4b1dd1 100644 --- a/lexer.js +++ b/lexer.js @@ -2,7 +2,8 @@ function Lexer() { }; var normals = [ - [/^[/|a-zA-Z0-9.]/, 'ORD'], + [/^[/|0-9.]+/, 'TEXTORD'], + [/^[a-zA-Z]+/, 'MATHORD'], [/^[*+-]/, 'BIN'], [/^[=<>]/, 'REL'], [/^[,;]/, 'PUNCT'], diff --git a/parser.jison b/parser.jison index aef67b13a..fefcc2cd7 100644 --- a/parser.jison +++ b/parser.jison @@ -143,8 +143,10 @@ func ; atom - : 'ORD' - {$$ = [{type: 'ord', value: yytext}];} + : 'TEXTORD' + {$$ = [{type: 'textord', value: yytext}];} + | 'MATHORD' + {$$ = [{type: 'mathord', value: yytext}];} | 'BIN' {$$ = [{type: 'bin', value: yytext}];} | 'REL'