www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 90dfae69247f4357009a9317dda726636f44e96b
parent 42cc8b1a124d6d8227d6dcb1771212465c8baad6
Author: Emily Eisenberg <xymostech@gmail.com>
Date:   Tue,  9 Jul 2013 22:31:19 -0700

Attempt to merge ords together

Summary:
Try not to waste spans by putting a bunch of numbers or letters
together into the same ord box. I don't think that this breaks any of the
current stuff.

Test Plan:
Write lots of expressions that have ords in them. Make sure that all
the reasonable ords are grouped together, and that the formatting still works.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D52

Diffstat:
MMJLite.js | 12++++--------
Mlexer.js | 3++-
Mparser.jison | 6++++--
3 files changed, 10 insertions(+), 11 deletions(-)

diff --git 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 @@ -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 @@ -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'