katex 0.13.23 → 0.13.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "katex",
3
- "version": "0.13.23",
3
+ "version": "0.13.24",
4
4
  "description": "Fast math typesetting for the web.",
5
5
  "main": "dist/katex.js",
6
6
  "homepage": "https://katex.org",
@@ -8,6 +8,10 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/KaTeX/KaTeX.git"
10
10
  },
11
+ "funding": [
12
+ "https://opencollective.com/katex",
13
+ "https://github.com/sponsors/katex"
14
+ ],
11
15
  "files": [
12
16
  "katex.js",
13
17
  "cli.js",
@@ -45,8 +49,10 @@
45
49
  "css-loader": "^6.0.0",
46
50
  "cssnano": "^5.0.0-rc.1",
47
51
  "eslint": "^8.0.0",
52
+ "eslint-import-resolver-webpack": "^0.13.2",
48
53
  "eslint-plugin-actions": "^2.0.0",
49
54
  "eslint-plugin-flowtype": "^8.0.0",
55
+ "eslint-plugin-import": "^2.25.2",
50
56
  "eslint-plugin-react": "^7.20.3",
51
57
  "flow-bin": "^0.135.0",
52
58
  "fs-extra": "^10.0.0",
@@ -9,7 +9,7 @@ import {SymbolNode, Anchor, Span, PathNode, SvgNode, createClass} from "./domTre
9
9
  import {getCharacterMetrics} from "./fontMetrics";
10
10
  import symbols, {ligatures} from "./symbols";
11
11
  import {wideCharacterFont} from "./wide-character";
12
- import {calculateSize} from "./units";
12
+ import {calculateSize, makeEm} from "./units";
13
13
  import {DocumentFragment} from "./tree";
14
14
 
15
15
  import type Options from "./Options";
@@ -364,7 +364,7 @@ const makeLineSpan = function(
364
364
  thickness || options.fontMetrics().defaultRuleThickness,
365
365
  options.minRuleThickness,
366
366
  );
367
- line.style.borderBottomWidth = line.height + "em";
367
+ line.style.borderBottomWidth = makeEm(line.height);
368
368
  line.maxFontSize = 1.0;
369
369
  return line;
370
370
  };
@@ -550,7 +550,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
550
550
  }
551
551
  pstrutSize += 2;
552
552
  const pstrut = makeSpan(["pstrut"], []);
553
- pstrut.style.height = pstrutSize + "em";
553
+ pstrut.style.height = makeEm(pstrutSize);
554
554
 
555
555
  // Create a new list of actual children at the correct offsets
556
556
  const realChildren = [];
@@ -567,7 +567,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
567
567
  const style = child.wrapperStyle || {};
568
568
 
569
569
  const childWrap = makeSpan(classes, [pstrut, elem], undefined, style);
570
- childWrap.style.top = (-pstrutSize - currPos - elem.depth) + "em";
570
+ childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth);
571
571
  if (child.marginLeft) {
572
572
  childWrap.style.marginLeft = child.marginLeft;
573
573
  }
@@ -586,7 +586,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
586
586
  // This cell's bottom edge will determine the containing table's baseline
587
587
  // without overly expanding the containing line-box.
588
588
  const vlist = makeSpan(["vlist"], realChildren);
589
- vlist.style.height = maxPos + "em";
589
+ vlist.style.height = makeEm(maxPos);
590
590
 
591
591
  // A second row is used if necessary to represent the vlist's depth.
592
592
  let rows;
@@ -598,7 +598,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
598
598
  // So we put another empty span inside the depth strut span.
599
599
  const emptySpan = makeSpan([], []);
600
600
  const depthStrut = makeSpan(["vlist"], [emptySpan]);
601
- depthStrut.style.height = -minPos + "em";
601
+ depthStrut.style.height = makeEm(-minPos);
602
602
 
603
603
  // Safari wants the first row to have inline content; otherwise it
604
604
  // puts the bottom of the *second* row on the baseline.
@@ -626,7 +626,7 @@ const makeGlue = (measurement: Measurement, options: Options): DomSpan => {
626
626
  // Make an empty span for the space
627
627
  const rule = makeSpan(["mspace"], [], options);
628
628
  const size = calculateSize(measurement, options);
629
- rule.style.marginRight = `${size}em`;
629
+ rule.style.marginRight = makeEm(size);
630
630
  return rule;
631
631
  };
632
632
 
@@ -744,17 +744,17 @@ const staticSvg = function(value: string, options: Options): SvgSpan {
744
744
  const [pathName, width, height] = svgData[value];
745
745
  const path = new PathNode(pathName);
746
746
  const svgNode = new SvgNode([path], {
747
- "width": width + "em",
748
- "height": height + "em",
747
+ "width": makeEm(width),
748
+ "height": makeEm(height),
749
749
  // Override CSS rule `.katex svg { width: 100% }`
750
- "style": "width:" + width + "em",
750
+ "style": "width:" + makeEm(width),
751
751
  "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
752
752
  "preserveAspectRatio": "xMinYMin",
753
753
  });
754
754
  const span = makeSvgSpan(["overlay"], [svgNode], options);
755
755
  span.height = height;
756
- span.style.height = height + "em";
757
- span.style.width = width + "em";
756
+ span.style.height = makeEm(height);
757
+ span.style.width = makeEm(width);
758
758
  return span;
759
759
  };
760
760
 
package/src/buildHTML.js CHANGED
@@ -11,6 +11,7 @@ import Style from "./Style";
11
11
  import buildCommon from "./buildCommon";
12
12
  import {Span, Anchor} from "./domTree";
13
13
  import utils from "./utils";
14
+ import {makeEm} from "./units";
14
15
  import {spacings, tightSpacings} from "./spacingData";
15
16
  import {_htmlGroupBuilders as groupBuilders} from "./defineFunction";
16
17
  import {DocumentFragment} from "./tree";
@@ -299,9 +300,9 @@ function buildHTMLUnbreakable(children, options) {
299
300
  // the height of the expression, and the bottom of the HTML element
300
301
  // falls at the depth of the expression.
301
302
  const strut = makeSpan(["strut"]);
302
- strut.style.height = (body.height + body.depth) + "em";
303
+ strut.style.height = makeEm(body.height + body.depth);
303
304
  if (body.depth) {
304
- strut.style.verticalAlign = -body.depth + "em";
305
+ strut.style.verticalAlign = makeEm(-body.depth);
305
306
  }
306
307
  body.children.unshift(strut);
307
308
 
@@ -395,9 +396,9 @@ export default function buildHTML(tree: AnyParseNode[], options: Options): DomSp
395
396
  // (the height of the enclosing htmlNode) for proper vertical alignment.
396
397
  if (tagChild) {
397
398
  const strut = tagChild.children[0];
398
- strut.style.height = (htmlNode.height + htmlNode.depth) + "em";
399
+ strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
399
400
  if (htmlNode.depth) {
400
- strut.style.verticalAlign = (-htmlNode.depth) + "em";
401
+ strut.style.verticalAlign = makeEm(-htmlNode.depth);
401
402
  }
402
403
  }
403
404
 
package/src/delimiter.js CHANGED
@@ -30,6 +30,7 @@ import buildCommon from "./buildCommon";
30
30
  import {getCharacterMetrics} from "./fontMetrics";
31
31
  import symbols from "./symbols";
32
32
  import utils from "./utils";
33
+ import {makeEm} from "./units";
33
34
  import fontMetricsData from "./fontMetricsData";
34
35
 
35
36
  import type Options from "./Options";
@@ -93,7 +94,7 @@ const centerSpan = function(
93
94
  options.fontMetrics().axisHeight;
94
95
 
95
96
  span.classes.push("delimcenter");
96
- span.style.top = shift + "em";
97
+ span.style.top = makeEm(shift);
97
98
  span.height -= shift;
98
99
  span.depth += shift;
99
100
  };
@@ -186,21 +187,21 @@ const makeInner = function(
186
187
  ): VListElem {
187
188
  // Create a span with inline SVG for the inner part of a tall stacked delimiter.
188
189
  const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)]
189
- ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4].toFixed(3)
190
- : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4].toFixed(3);
190
+ ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4]
191
+ : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4];
191
192
  const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
192
193
  const svgNode = new SvgNode([path], {
193
- "width": width + "em",
194
- "height": height + "em",
194
+ "width": makeEm(width),
195
+ "height": makeEm(height),
195
196
  // Override CSS rule `.katex svg { width: 100% }`
196
- "style": "width:" + width + "em",
197
+ "style": "width:" + makeEm(width),
197
198
  "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
198
199
  "preserveAspectRatio": "xMinYMin",
199
200
  });
200
201
  const span = buildCommon.makeSvgSpan([], [svgNode], options);
201
202
  span.height = height;
202
- span.style.height = height + "em";
203
- span.style.width = width + "em";
203
+ span.style.height = makeEm(height);
204
+ span.style.width = makeEm(width);
204
205
  return {type: "elem", elem: span};
205
206
  };
206
207
 
@@ -427,7 +428,7 @@ const sqrtSvg = function(
427
428
  const svg = new SvgNode([pathNode], {
428
429
  // Note: 1000:1 ratio of viewBox to document em width.
429
430
  "width": "400em",
430
- "height": height + "em",
431
+ "height": makeEm(height),
431
432
  "viewBox": "0 0 400000 " + viewBoxHeight,
432
433
  "preserveAspectRatio": "xMinYMin slice",
433
434
  });
@@ -514,7 +515,7 @@ const makeSqrtImage = function(
514
515
  }
515
516
 
516
517
  span.height = texHeight;
517
- span.style.height = spanHeight + "em";
518
+ span.style.height = makeEm(spanHeight);
518
519
 
519
520
  return {
520
521
  span,
package/src/domTree.js CHANGED
@@ -16,6 +16,7 @@ import utils from "./utils";
16
16
  import {path} from "./svgGeometry";
17
17
  import type Options from "./Options";
18
18
  import {DocumentFragment} from "./tree";
19
+ import {makeEm} from "./units";
19
20
 
20
21
  import type {VirtualNode} from "./tree";
21
22
 
@@ -406,7 +407,7 @@ export class SymbolNode implements HtmlDomNode {
406
407
 
407
408
  if (this.italic > 0) {
408
409
  span = document.createElement("span");
409
- span.style.marginRight = this.italic + "em";
410
+ span.style.marginRight = makeEm(this.italic);
410
411
  }
411
412
 
412
413
  if (this.classes.length > 0) {
@@ -8,7 +8,7 @@ import mathMLTree from "../mathMLTree";
8
8
  import ParseError from "../ParseError";
9
9
  import {assertNodeType, assertSymbolNodeType} from "../parseNode";
10
10
  import {checkSymbolNodeType} from "../parseNode";
11
- import {calculateSize} from "../units";
11
+ import {calculateSize, makeEm} from "../units";
12
12
  import utils from "../utils";
13
13
 
14
14
  import * as html from "../buildHTML";
@@ -368,7 +368,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
368
368
  if (!firstSeparator) {
369
369
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
370
370
  colSep.style.width =
371
- options.fontMetrics().doubleRuleSep + "em";
371
+ makeEm(options.fontMetrics().doubleRuleSep);
372
372
  cols.push(colSep);
373
373
  }
374
374
 
@@ -377,13 +377,13 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
377
377
  const separator = buildCommon.makeSpan(
378
378
  ["vertical-separator"], [], options
379
379
  );
380
- separator.style.height = totalHeight + "em";
381
- separator.style.borderRightWidth = `${ruleThickness}em`;
380
+ separator.style.height = makeEm(totalHeight);
381
+ separator.style.borderRightWidth = makeEm(ruleThickness);
382
382
  separator.style.borderRightStyle = lineType;
383
- separator.style.margin = `0 -${ruleThickness / 2}em`;
383
+ separator.style.margin = `0 ${makeEm(-ruleThickness / 2)}`;
384
384
  const shift = totalHeight - offset;
385
385
  if (shift) {
386
- separator.style.verticalAlign = -shift + "em";
386
+ separator.style.verticalAlign = makeEm(-shift);
387
387
  }
388
388
 
389
389
  cols.push(separator);
@@ -406,7 +406,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
406
406
  sepwidth = utils.deflt(colDescr.pregap, arraycolsep);
407
407
  if (sepwidth !== 0) {
408
408
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
409
- colSep.style.width = sepwidth + "em";
409
+ colSep.style.width = makeEm(sepwidth);
410
410
  cols.push(colSep);
411
411
  }
412
412
  }
@@ -437,7 +437,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
437
437
  sepwidth = utils.deflt(colDescr.postgap, arraycolsep);
438
438
  if (sepwidth !== 0) {
439
439
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
440
- colSep.style.width = sepwidth + "em";
440
+ colSep.style.width = makeEm(sepwidth);
441
441
  cols.push(colSep);
442
442
  }
443
443
  }
@@ -523,7 +523,7 @@ const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) {
523
523
  const gap = (group.arraystretch === 0.5)
524
524
  ? 0.1 // {smallmatrix}, {subarray}
525
525
  : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
526
- table.setAttribute("rowspacing", gap.toFixed(4) + "em");
526
+ table.setAttribute("rowspacing", makeEm(gap));
527
527
 
528
528
  // MathML table lines go only between cells.
529
529
  // To place a line on an edge we'll use <menclose>, if necessary.
@@ -6,6 +6,7 @@ import * as html from "../buildHTML";
6
6
  import * as mml from "../buildMathML";
7
7
  import {assertSymbolNodeType} from "../parseNode";
8
8
  import ParseError from "../ParseError";
9
+ import {makeEm} from "../units";
9
10
 
10
11
  import type Parser from "../Parser";
11
12
  import type {ParseNode, AnyParseNode} from "../parseNode";
@@ -257,7 +258,7 @@ defineFunction({
257
258
  const label = buildCommon.wrapFragment(
258
259
  html.buildGroup(group.label, newOptions, options), options);
259
260
  label.classes.push("cd-label-" + group.side);
260
- label.style.bottom = (0.8 - label.depth) + "em";
261
+ label.style.bottom = makeEm(0.8 - label.depth);
261
262
  // Zero out label height & depth, so vertical align of arrow is set
262
263
  // by the arrow height, not by the label.
263
264
  label.height = 0;
@@ -6,6 +6,7 @@ import utils from "../utils";
6
6
  import stretchy from "../stretchy";
7
7
  import {assertNodeType} from "../parseNode";
8
8
  import {assertSpan, assertSymbolDomNode} from "../domTree";
9
+ import {makeEm} from "../units";
9
10
 
10
11
  import * as html from "../buildHTML";
11
12
  import * as mml from "../buildMathML";
@@ -131,7 +132,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
131
132
  left -= width / 2;
132
133
  }
133
134
 
134
- accentBody.style.left = left + "em";
135
+ accentBody.style.left = makeEm(left);
135
136
 
136
137
  // \textcircled uses the \bigcirc glyph, so it needs some
137
138
  // vertical adjustment to match LaTeX.
@@ -161,8 +162,8 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
161
162
  wrapperClasses: ["svg-align"],
162
163
  wrapperStyle: skew > 0
163
164
  ? {
164
- width: `calc(100% - ${2 * skew}em)`,
165
- marginLeft: `${(2 * skew)}em`,
165
+ width: `calc(100% - ${makeEm(2 * skew)})`,
166
+ marginLeft: makeEm(2 * skew),
166
167
  }
167
168
  : undefined,
168
169
  },
@@ -4,7 +4,7 @@
4
4
  import defineFunction from "../defineFunction";
5
5
  import buildCommon from "../buildCommon";
6
6
  import mathMLTree from "../mathMLTree";
7
- import {calculateSize} from "../units";
7
+ import {calculateSize, makeEm} from "../units";
8
8
  import {assertNodeType} from "../parseNode";
9
9
 
10
10
  // \DeclareRobustCommand\\{...\@xnewline}
@@ -41,7 +41,7 @@ defineFunction({
41
41
  span.classes.push("newline");
42
42
  if (group.size) {
43
43
  span.style.marginTop =
44
- calculateSize(group.size, options) + "em";
44
+ makeEm(calculateSize(group.size, options));
45
45
  }
46
46
  }
47
47
  return span;
@@ -53,7 +53,7 @@ defineFunction({
53
53
  node.setAttribute("linebreak", "newline");
54
54
  if (group.size) {
55
55
  node.setAttribute("height",
56
- calculateSize(group.size, options) + "em");
56
+ makeEm(calculateSize(group.size, options)));
57
57
  }
58
58
  }
59
59
  return node;
@@ -6,6 +6,7 @@ import mathMLTree from "../mathMLTree";
6
6
  import ParseError from "../ParseError";
7
7
  import utils from "../utils";
8
8
  import {assertNodeType, checkSymbolNodeType} from "../parseNode";
9
+ import {makeEm} from "../units";
9
10
 
10
11
  import * as html from "../buildHTML";
11
12
  import * as mml from "../buildMathML";
@@ -126,8 +127,9 @@ defineFunction({
126
127
  }
127
128
 
128
129
  node.setAttribute("stretchy", "true");
129
- node.setAttribute("minsize", delimiter.sizeToMaxHeight[group.size] + "em");
130
- node.setAttribute("maxsize", delimiter.sizeToMaxHeight[group.size] + "em");
130
+ const size = makeEm(delimiter.sizeToMaxHeight[group.size]);
131
+ node.setAttribute("minsize", size);
132
+ node.setAttribute("maxsize", size);
131
133
 
132
134
  return node;
133
135
  },
@@ -6,7 +6,7 @@ import utils from "../utils";
6
6
  import stretchy from "../stretchy";
7
7
  import {phasePath} from "../svgGeometry";
8
8
  import {PathNode, SvgNode} from "../domTree";
9
- import {calculateSize} from "../units";
9
+ import {calculateSize, makeEm} from "../units";
10
10
  import {assertNodeType} from "../parseNode";
11
11
 
12
12
  import * as html from "../buildHTML";
@@ -48,20 +48,20 @@ const htmlBuilder = (group, options) => {
48
48
 
49
49
  const angleHeight = inner.height + inner.depth + lineWeight + clearance;
50
50
  // Reserve a left pad for the angle.
51
- inner.style.paddingLeft = (angleHeight / 2 + lineWeight) + "em";
51
+ inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight);
52
52
 
53
53
  // Create an SVG
54
54
  const viewBoxHeight = Math.floor(1000 * angleHeight * scale);
55
55
  const path = phasePath(viewBoxHeight);
56
56
  const svgNode = new SvgNode([new PathNode("phase", path)], {
57
57
  "width": "400em",
58
- "height": `${viewBoxHeight / 1000}em`,
58
+ "height": makeEm(viewBoxHeight / 1000),
59
59
  "viewBox": `0 0 400000 ${viewBoxHeight}`,
60
60
  "preserveAspectRatio": "xMinYMin slice",
61
61
  });
62
62
  // Wrap it in a span with overflow: hidden.
63
63
  img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
64
- img.style.height = angleHeight + "em";
64
+ img.style.height = makeEm(angleHeight);
65
65
  imgShift = inner.depth + lineWeight + clearance;
66
66
 
67
67
  } else {
@@ -104,10 +104,10 @@ const htmlBuilder = (group, options) => {
104
104
  img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options);
105
105
  if (/fbox|boxed|fcolorbox/.test(label)) {
106
106
  img.style.borderStyle = "solid";
107
- img.style.borderWidth = `${ruleThickness}em`;
107
+ img.style.borderWidth = makeEm(ruleThickness);
108
108
  } else if (label === "angl" && ruleThickness !== 0.049) {
109
- img.style.borderTopWidth = `${ruleThickness}em`;
110
- img.style.borderRightWidth = `${ruleThickness}em`;
109
+ img.style.borderTopWidth = makeEm(ruleThickness);
110
+ img.style.borderRightWidth = makeEm(ruleThickness);
111
111
  }
112
112
  imgShift = inner.depth + bottomPad;
113
113
 
@@ -9,7 +9,7 @@ import {assert} from "../utils";
9
9
 
10
10
  import * as html from "../buildHTML";
11
11
  import * as mml from "../buildMathML";
12
- import {calculateSize} from "../units";
12
+ import {calculateSize, makeEm} from "../units";
13
13
 
14
14
  const adjustStyle = (size, originalStyle) => {
15
15
  // Figure out what style this fraction should be in based on the
@@ -196,7 +196,7 @@ const mathmlBuilder = (group, options) => {
196
196
  node.setAttribute("linethickness", "0px");
197
197
  } else if (group.barSize) {
198
198
  const ruleWidth = calculateSize(group.barSize, options);
199
- node.setAttribute("linethickness", ruleWidth + "em");
199
+ node.setAttribute("linethickness", makeEm(ruleWidth));
200
200
  }
201
201
 
202
202
  const style = adjustStyle(group.size, options.style);
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
3
  import type {Measurement} from "../units";
4
- import {calculateSize, validUnit} from "../units";
4
+ import {calculateSize, validUnit, makeEm} from "../units";
5
5
  import ParseError from "../ParseError";
6
6
  import {Img} from "../domTree";
7
7
  import mathMLTree from "../mathMLTree";
@@ -108,7 +108,6 @@ defineFunction({
108
108
 
109
109
  if (group.totalheight.number > 0) {
110
110
  depth = calculateSize(group.totalheight, options) - height;
111
- depth = Number(depth.toFixed(2));
112
111
  }
113
112
 
114
113
  let width = 0;
@@ -116,12 +115,12 @@ defineFunction({
116
115
  width = calculateSize(group.width, options);
117
116
  }
118
117
 
119
- const style: CssStyle = {height: height + depth + "em"};
118
+ const style: CssStyle = {height: makeEm(height + depth)};
120
119
  if (width > 0) {
121
- style.width = width + "em";
120
+ style.width = makeEm(width);
122
121
  }
123
122
  if (depth > 0) {
124
- style.verticalAlign = -depth + "em";
123
+ style.verticalAlign = makeEm(-depth);
125
124
  }
126
125
 
127
126
  const node = new Img(group.src, group.alt, style);
@@ -138,14 +137,13 @@ defineFunction({
138
137
  let depth = 0;
139
138
  if (group.totalheight.number > 0) {
140
139
  depth = calculateSize(group.totalheight, options) - height;
141
- depth = depth.toFixed(2);
142
- node.setAttribute("valign", "-" + depth + "em");
140
+ node.setAttribute("valign", makeEm(-depth));
143
141
  }
144
- node.setAttribute("height", height + depth + "em");
142
+ node.setAttribute("height", makeEm(height + depth));
145
143
 
146
144
  if (group.width.number > 0) {
147
145
  const width = calculateSize(group.width, options);
148
- node.setAttribute("width", width + "em");
146
+ node.setAttribute("width", makeEm(width));
149
147
  }
150
148
  node.setAttribute("src", group.src);
151
149
  return node;
@@ -3,6 +3,7 @@
3
3
  import defineFunction from "../defineFunction";
4
4
  import buildCommon from "../buildCommon";
5
5
  import mathMLTree from "../mathMLTree";
6
+ import {makeEm} from "../units";
6
7
 
7
8
  import * as html from "../buildHTML";
8
9
  import * as mml from "../buildMathML";
@@ -46,9 +47,9 @@ defineFunction({
46
47
  // Otherwise, a tall argument may be misplaced.
47
48
  // This code resolved issue #1153
48
49
  const strut = buildCommon.makeSpan(["strut"]);
49
- strut.style.height = (node.height + node.depth) + "em";
50
+ strut.style.height = makeEm(node.height + node.depth);
50
51
  if (node.depth) {
51
- strut.style.verticalAlign = -node.depth + "em";
52
+ strut.style.verticalAlign = makeEm(-node.depth);
52
53
  }
53
54
  node.children.unshift(strut);
54
55
 
@@ -8,6 +8,7 @@ import utils from "../utils";
8
8
  import Style from "../Style";
9
9
  import {assembleSupSub} from "./utils/assembleSupSub";
10
10
  import {assertNodeType} from "../parseNode";
11
+ import {makeEm} from "../units";
11
12
 
12
13
  import * as html from "../buildHTML";
13
14
  import * as mml from "../buildMathML";
@@ -132,7 +133,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
132
133
  } else {
133
134
  if (baseShift) {
134
135
  base.style.position = "relative";
135
- base.style.top = baseShift + "em";
136
+ base.style.top = makeEm(baseShift);
136
137
  }
137
138
 
138
139
  return base;
@@ -3,7 +3,7 @@ import buildCommon from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
4
  import mathMLTree from "../mathMLTree";
5
5
  import {assertNodeType} from "../parseNode";
6
- import {calculateSize} from "../units";
6
+ import {calculateSize, makeEm} from "../units";
7
7
 
8
8
  defineFunction({
9
9
  type: "rule",
@@ -35,9 +35,9 @@ defineFunction({
35
35
  const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
36
36
 
37
37
  // Style the rule to the right size
38
- rule.style.borderRightWidth = width + "em";
39
- rule.style.borderTopWidth = height + "em";
40
- rule.style.bottom = shift + "em";
38
+ rule.style.borderRightWidth = makeEm(width);
39
+ rule.style.borderTopWidth = makeEm(height);
40
+ rule.style.bottom = makeEm(shift);
41
41
 
42
42
  // Record the height and width
43
43
  rule.width = width;
@@ -58,17 +58,17 @@ defineFunction({
58
58
 
59
59
  const rule = new mathMLTree.MathNode("mspace");
60
60
  rule.setAttribute("mathbackground", color);
61
- rule.setAttribute("width", width + "em");
62
- rule.setAttribute("height", height + "em");
61
+ rule.setAttribute("width", makeEm(width));
62
+ rule.setAttribute("height", makeEm(height));
63
63
 
64
64
  const wrapper = new mathMLTree.MathNode("mpadded", [rule]);
65
65
  if (shift >= 0) {
66
- wrapper.setAttribute("height", "+" + shift + "em");
66
+ wrapper.setAttribute("height", makeEm(shift));
67
67
  } else {
68
- wrapper.setAttribute("height", shift + "em");
69
- wrapper.setAttribute("depth", "+" + (-shift) + "em");
68
+ wrapper.setAttribute("height", makeEm(shift));
69
+ wrapper.setAttribute("depth", makeEm(-shift));
70
70
  }
71
- wrapper.setAttribute("voffset", shift + "em");
71
+ wrapper.setAttribute("voffset", makeEm(shift));
72
72
 
73
73
  return wrapper;
74
74
  },
@@ -2,6 +2,7 @@
2
2
  import buildCommon from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
4
  import mathMLTree from "../mathMLTree";
5
+ import {makeEm} from "../units";
5
6
 
6
7
  import * as html from "../buildHTML";
7
8
  import * as mml from "../buildMathML";
@@ -83,7 +84,7 @@ defineFunction({
83
84
  // in, so we can't reset the size to normal before changing it. Now
84
85
  // that we're passing an options parameter we should be able to fix
85
86
  // this.
86
- node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
87
+ node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
87
88
 
88
89
  return node;
89
90
  },
@@ -4,6 +4,7 @@ import buildCommon from "../buildCommon";
4
4
  import mathMLTree from "../mathMLTree";
5
5
  import delimiter from "../delimiter";
6
6
  import Style from "../Style";
7
+ import {makeEm} from "../units";
7
8
 
8
9
  import * as html from "../buildHTML";
9
10
  import * as mml from "../buildMathML";
@@ -70,7 +71,7 @@ defineFunction({
70
71
  // Shift the sqrt image
71
72
  const imgShift = img.height - inner.height - lineClearance - ruleWidth;
72
73
 
73
- inner.style.paddingLeft = advanceWidth + "em";
74
+ inner.style.paddingLeft = makeEm(advanceWidth);
74
75
 
75
76
  // Overlay the image and the argument.
76
77
  const body = buildCommon.makeVList({
@@ -4,6 +4,7 @@ import buildCommon from "../buildCommon";
4
4
  import {SymbolNode} from "../domTree";
5
5
  import mathMLTree from "../mathMLTree";
6
6
  import utils from "../utils";
7
+ import {makeEm} from "../units";
7
8
  import Style from "../Style";
8
9
 
9
10
  import * as html from "../buildHTML";
@@ -111,7 +112,7 @@ defineFunctionBuilders({
111
112
  // scriptspace is a font-size-independent size, so scale it
112
113
  // appropriately for use as the marginRight.
113
114
  const multiplier = options.sizeMultiplier;
114
- const marginRight = (0.5 / metrics.ptPerEm) / multiplier + "em";
115
+ const marginRight = makeEm((0.5 / metrics.ptPerEm) / multiplier);
115
116
 
116
117
  let marginLeft = null;
117
118
  if (subm) {
@@ -123,7 +124,7 @@ defineFunctionBuilders({
123
124
  (group.base.name === "\\oiint" || group.base.name === "\\oiiint");
124
125
  if (base instanceof SymbolNode || isOiint) {
125
126
  // $FlowFixMe
126
- marginLeft = -base.italic + "em";
127
+ marginLeft = makeEm(-base.italic);
127
128
  }
128
129
  }
129
130