Merge pull request #699 from edemaine/middle
Refactor and comment space splicing code
This commit is contained in:
commit
e4b93379fb
|
@ -93,16 +93,22 @@ const buildExpression = function(expression, options, isRealGroup) {
|
||||||
// CSS. So we splice them out of `groups` and into the atoms themselves.
|
// CSS. So we splice them out of `groups` and into the atoms themselves.
|
||||||
for (let i = 0; i < groups.length; i++) {
|
for (let i = 0; i < groups.length; i++) {
|
||||||
const spaces = spliceSpaces(groups, i);
|
const spaces = spliceSpaces(groups, i);
|
||||||
if (spaces && i < groups.length) {
|
if (spaces) {
|
||||||
|
// Splicing of spaces may have removed all remaining groups.
|
||||||
|
if (i < groups.length) {
|
||||||
|
// If there is a following group, move space within it.
|
||||||
if (groups[i] instanceof domTree.symbolNode) {
|
if (groups[i] instanceof domTree.symbolNode) {
|
||||||
groups[i] = makeSpan([].concat(groups[i].classes), [groups[i]]);
|
groups[i] = makeSpan([].concat(groups[i].classes),
|
||||||
|
[groups[i]]);
|
||||||
}
|
}
|
||||||
buildCommon.prependChildren(groups[i], spaces);
|
buildCommon.prependChildren(groups[i], spaces);
|
||||||
} else if (spaces) {
|
} else {
|
||||||
|
// Otherwise, put any spaces back at the end of the groups.
|
||||||
Array.prototype.push.apply(groups, spaces);
|
Array.prototype.push.apply(groups, spaces);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Binary operators change to ordinary symbols in some contexts.
|
// Binary operators change to ordinary symbols in some contexts.
|
||||||
for (let i = 0; i < groups.length; i++) {
|
for (let i = 0; i < groups.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user