www

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

commit e4b93379fbeb73fccb47db6e89cfcc12f9f68b57
parent 7192bd65959df6cc64a5b774746609f4257c765a
Author: Kevin Barabash <kevinb7@gmail.com>
Date:   Sat, 13 May 2017 15:07:05 -0400

Merge pull request #699 from edemaine/middle

Refactor and comment space splicing code
Diffstat:
Msrc/buildHTML.js | 20+++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/buildHTML.js b/src/buildHTML.js @@ -93,14 +93,20 @@ const buildExpression = function(expression, options, isRealGroup) { // CSS. So we splice them out of `groups` and into the atoms themselves. for (let i = 0; i < groups.length; i++) { const spaces = spliceSpaces(groups, i); - if (spaces && i < groups.length) { - if (groups[i] instanceof domTree.symbolNode) { - groups[i] = makeSpan([].concat(groups[i].classes), [groups[i]]); + 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) { + groups[i] = makeSpan([].concat(groups[i].classes), + [groups[i]]); + } + buildCommon.prependChildren(groups[i], spaces); + } else { + // Otherwise, put any spaces back at the end of the groups. + Array.prototype.push.apply(groups, spaces); + break; } - buildCommon.prependChildren(groups[i], spaces); - } else if (spaces) { - Array.prototype.push.apply(groups, spaces); - break; } }