Improve JS spacing (#1103)

* Remove dummy spans for spacing around \href

Spacing around \href is handled in the `buildHTML`

* Make bin cancellation aware of children of fragment and anchor

+ Added getOutermostNode function

* Fix tight spacing not applied

* Add surrounding argument to html.buildExpression

It is an array consisting type of nodes that will be added to the left
and the right, and if given, will be used to determine bin cancellation
and spacings of outermost nodes.

* Fix html.buildExpression call in leftright

* Add dummy span only when given

* Update buildHTML.js
This commit is contained in:
ylemkimon
2018-02-13 21:01:56 +09:00
committed by Kevin Barabash
parent 9b2101f6b4
commit 439cea3e6e
3 changed files with 59 additions and 87 deletions

View File

@@ -5,8 +5,6 @@ import delimiter from "../delimiter";
import mathMLTree from "../mathMLTree";
import ParseError from "../ParseError";
import utils from "../utils";
import { calculateSize } from "../units";
import { spacings, tightSpacings } from "../spacingData";
import * as html from "../buildHTML";
import * as mml from "../buildMathML";
@@ -161,7 +159,8 @@ defineFunction({
},
htmlBuilder: (group, options) => {
// Build the inner expression
const inner = html.buildExpression(group.value.body, options, true);
const inner = html.buildExpression(group.value.body, options, true,
[null, "mclose"]);
let innerHeight = 0;
let innerDepth = 0;
@@ -210,18 +209,6 @@ defineFunction({
}
}
const lastChildType = html.getTypeOfDomTree(inner[inner.length - 1]);
const activeSpacings = options.style.isTight() ? tightSpacings : spacings;
if (lastChildType && activeSpacings[lastChildType]["mclose"]) {
const glue =
buildCommon.makeSpan(["mord", "rule"], [], options);
const dimension =
calculateSize(activeSpacings[lastChildType]["mclose"], options);
glue.style.marginRight = `${dimension}em`;
inner.push(glue);
}
let rightDelim;
// Same for the right delimiter
if (group.value.right === ".") {