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
This commit is contained in:
parent
42cc8b1a12
commit
90dfae6924
12
MJLite.js
12
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) {
|
||||
|
|
3
lexer.js
3
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'],
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user