katex 0.16.28 → 0.16.30

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.
Files changed (84) hide show
  1. package/README.md +3 -3
  2. package/cli.js +3 -1
  3. package/contrib/auto-render/auto-render.js +5 -5
  4. package/contrib/auto-render/index.html +3 -2
  5. package/contrib/copy-tex/README.md +2 -2
  6. package/contrib/mathtex-script-type/README.md +5 -5
  7. package/contrib/mhchem/README.md +1 -1
  8. package/dist/README.md +3 -3
  9. package/dist/contrib/auto-render.js +4 -4
  10. package/dist/contrib/auto-render.min.js +1 -1
  11. package/dist/contrib/auto-render.mjs +2 -2
  12. package/dist/contrib/copy-tex.js +2 -2
  13. package/dist/contrib/copy-tex.min.js +1 -1
  14. package/dist/contrib/mathtex-script-type.min.js +1 -1
  15. package/dist/contrib/mhchem.min.js +1 -1
  16. package/dist/contrib/render-a11y-string.min.js +1 -1
  17. package/dist/katex-swap.css +7 -5
  18. package/dist/katex-swap.min.css +1 -1
  19. package/dist/katex.css +6 -4
  20. package/dist/katex.js +460 -555
  21. package/dist/katex.min.css +1 -1
  22. package/dist/katex.min.js +1 -1
  23. package/dist/katex.mjs +415 -508
  24. package/katex.js +2 -2
  25. package/package.json +3 -4
  26. package/src/MacroExpander.js +2 -2
  27. package/src/Parser.js +4 -3
  28. package/src/Settings.js +2 -2
  29. package/src/buildCommon.js +15 -33
  30. package/src/buildHTML.js +11 -9
  31. package/src/buildMathML.js +17 -15
  32. package/src/buildTree.js +5 -5
  33. package/src/delimiter.js +32 -40
  34. package/src/domTree.js +17 -17
  35. package/src/environments/array.js +40 -39
  36. package/src/environments/cd.js +10 -10
  37. package/src/functions/accent.js +17 -17
  38. package/src/functions/accentunder.js +8 -8
  39. package/src/functions/arrow.js +16 -16
  40. package/src/functions/color.js +4 -4
  41. package/src/functions/cr.js +4 -4
  42. package/src/functions/delimsizing.js +18 -19
  43. package/src/functions/enclose.js +15 -15
  44. package/src/functions/font.js +2 -3
  45. package/src/functions/genfrac.js +25 -20
  46. package/src/functions/hbox.js +4 -4
  47. package/src/functions/horizBrace.js +12 -12
  48. package/src/functions/href.js +2 -2
  49. package/src/functions/html.js +2 -2
  50. package/src/functions/htmlmathml.js +3 -2
  51. package/src/functions/includegraphics.js +2 -2
  52. package/src/functions/kern.js +4 -4
  53. package/src/functions/lap.js +11 -11
  54. package/src/functions/mathchoice.js +2 -2
  55. package/src/functions/mclass.js +10 -12
  56. package/src/functions/op.js +20 -20
  57. package/src/functions/operatorname.js +12 -12
  58. package/src/functions/ordgroup.js +3 -3
  59. package/src/functions/overline.js +8 -8
  60. package/src/functions/phantom.js +14 -14
  61. package/src/functions/pmb.js +4 -4
  62. package/src/functions/raisebox.js +4 -4
  63. package/src/functions/rule.js +5 -5
  64. package/src/functions/sizing.js +4 -4
  65. package/src/functions/smash.js +6 -6
  66. package/src/functions/sqrt.js +12 -12
  67. package/src/functions/styling.js +2 -2
  68. package/src/functions/supsub.js +13 -13
  69. package/src/functions/symbolsOp.js +4 -4
  70. package/src/functions/symbolsOrd.js +9 -9
  71. package/src/functions/symbolsSpacing.js +9 -9
  72. package/src/functions/tag.js +6 -6
  73. package/src/functions/text.js +2 -2
  74. package/src/functions/underline.js +8 -8
  75. package/src/functions/utils/assembleSupSub.js +9 -9
  76. package/src/functions/vcenter.js +4 -4
  77. package/src/functions/verb.js +7 -7
  78. package/src/macros.js +5 -2
  79. package/src/mathMLTree.js +5 -12
  80. package/src/stretchy.js +18 -28
  81. package/src/styles/fonts.scss +5 -3
  82. package/src/styles/katex-swap.scss +4 -1
  83. package/src/styles/katex.scss +6 -4
  84. package/src/utils.js +10 -41
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
3
+ import {makeFragment, makeSpan} from "../buildCommon";
4
4
 
5
5
  import * as html from "../buildHTML";
6
6
  import * as mml from "../buildMathML";
@@ -9,10 +9,10 @@ defineFunctionBuilders({
9
9
  type: "ordgroup",
10
10
  htmlBuilder(group, options) {
11
11
  if (group.semisimple) {
12
- return buildCommon.makeFragment(
12
+ return makeFragment(
13
13
  html.buildExpression(group.body, options, false));
14
14
  }
15
- return buildCommon.makeSpan(
15
+ return makeSpan(
16
16
  ["mord"], html.buildExpression(group.body, options, true), options);
17
17
  },
18
18
  mathmlBuilder(group, options) {
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {makeLineSpan, makeSpan, makeVList} from "../buildCommon";
4
+ import {MathNode, TextNode} from "../mathMLTree";
5
5
 
6
6
  import * as html from "../buildHTML";
7
7
  import * as mml from "../buildMathML";
@@ -28,11 +28,11 @@ defineFunction({
28
28
  options.havingCrampedStyle());
29
29
 
30
30
  // Create the line above the body
31
- const line = buildCommon.makeLineSpan("overline-line", options);
31
+ const line = makeLineSpan("overline-line", options);
32
32
 
33
33
  // Generate the vlist, with the appropriate kerns
34
34
  const defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
35
- const vlist = buildCommon.makeVList({
35
+ const vlist = makeVList({
36
36
  positionType: "firstBaseline",
37
37
  children: [
38
38
  {type: "elem", elem: innerGroup},
@@ -42,14 +42,14 @@ defineFunction({
42
42
  ],
43
43
  }, options);
44
44
 
45
- return buildCommon.makeSpan(["mord", "overline"], [vlist], options);
45
+ return makeSpan(["mord", "overline"], [vlist], options);
46
46
  },
47
47
  mathmlBuilder(group, options) {
48
- const operator = new mathMLTree.MathNode(
49
- "mo", [new mathMLTree.TextNode("\u203e")]);
48
+ const operator = new MathNode(
49
+ "mo", [new TextNode("\u203e")]);
50
50
  operator.setAttribute("stretchy", "true");
51
51
 
52
- const node = new mathMLTree.MathNode(
52
+ const node = new MathNode(
53
53
  "mover",
54
54
  [mml.buildGroup(group.body, options), operator]);
55
55
  node.setAttribute("accent", "true");
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import defineFunction, {ordargument} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {makeFragment, makeSpan, makeVList} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
 
6
6
  import * as html from "../buildHTML";
7
7
  import * as mml from "../buildMathML";
@@ -30,11 +30,11 @@ defineFunction({
30
30
 
31
31
  // \phantom isn't supposed to affect the elements it contains.
32
32
  // See "color" for more details.
33
- return buildCommon.makeFragment(elements);
33
+ return makeFragment(elements);
34
34
  },
35
35
  mathmlBuilder: (group, options) => {
36
36
  const inner = mml.buildExpression(group.body, options);
37
- return new mathMLTree.MathNode("mphantom", inner);
37
+ return new MathNode("mphantom", inner);
38
38
  },
39
39
  });
40
40
 
@@ -54,7 +54,7 @@ defineFunction({
54
54
  };
55
55
  },
56
56
  htmlBuilder: (group, options) => {
57
- let node = buildCommon.makeSpan(
57
+ let node = makeSpan(
58
58
  [], [html.buildGroup(group.body, options.withPhantom())]);
59
59
  node.height = 0;
60
60
  node.depth = 0;
@@ -66,18 +66,18 @@ defineFunction({
66
66
  }
67
67
 
68
68
  // See smash for comment re: use of makeVList
69
- node = buildCommon.makeVList({
69
+ node = makeVList({
70
70
  positionType: "firstBaseline",
71
71
  children: [{type: "elem", elem: node}],
72
72
  }, options);
73
73
 
74
74
  // For spacing, TeX treats \smash as a math group (same spacing as ord).
75
- return buildCommon.makeSpan(["mord"], [node], options);
75
+ return makeSpan(["mord"], [node], options);
76
76
  },
77
77
  mathmlBuilder: (group, options) => {
78
78
  const inner = mml.buildExpression(ordargument(group.body), options);
79
- const phantom = new mathMLTree.MathNode("mphantom", inner);
80
- const node = new mathMLTree.MathNode("mpadded", [phantom]);
79
+ const phantom = new MathNode("mphantom", inner);
80
+ const node = new MathNode("mpadded", [phantom]);
81
81
  node.setAttribute("height", "0px");
82
82
  node.setAttribute("depth", "0px");
83
83
  return node;
@@ -100,17 +100,17 @@ defineFunction({
100
100
  };
101
101
  },
102
102
  htmlBuilder: (group, options) => {
103
- const inner = buildCommon.makeSpan(
103
+ const inner = makeSpan(
104
104
  ["inner"],
105
105
  [html.buildGroup(group.body, options.withPhantom())]);
106
- const fix = buildCommon.makeSpan(["fix"], []);
107
- return buildCommon.makeSpan(
106
+ const fix = makeSpan(["fix"], []);
107
+ return makeSpan(
108
108
  ["mord", "rlap"], [inner, fix], options);
109
109
  },
110
110
  mathmlBuilder: (group, options) => {
111
111
  const inner = mml.buildExpression(ordargument(group.body), options);
112
- const phantom = new mathMLTree.MathNode("mphantom", inner);
113
- const node = new mathMLTree.MathNode("mpadded", [phantom]);
112
+ const phantom = new MathNode("mphantom", inner);
113
+ const node = new MathNode("mpadded", [phantom]);
114
114
  node.setAttribute("width", "0px");
115
115
  return node;
116
116
  },
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import defineFunction, {ordargument} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {makeSpan} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
  import * as html from "../buildHTML";
6
6
  import * as mml from "../buildMathML";
7
7
  import {binrelClass} from "./mclass";
@@ -30,14 +30,14 @@ defineFunction({
30
30
  },
31
31
  htmlBuilder(group: ParseNode<"pmb">, options) {
32
32
  const elements = html.buildExpression(group.body, options, true);
33
- const node = buildCommon.makeSpan([group.mclass], elements, options);
33
+ const node = makeSpan([group.mclass], elements, options);
34
34
  node.style.textShadow = "0.02em 0.01em 0.04px";
35
35
  return node;
36
36
  },
37
37
  mathmlBuilder(group: ParseNode<"pmb">, style) {
38
38
  const inner = mml.buildExpression(group.body, style);
39
39
  // Wrap with an <mstyle> element.
40
- const node = new mathMLTree.MathNode("mstyle", inner);
40
+ const node = new MathNode("mstyle", inner);
41
41
  node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
42
42
  return node;
43
43
  },
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {makeVList} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
  import {assertNodeType} from "../parseNode";
6
6
  import {calculateSize} from "../units";
7
7
 
@@ -30,14 +30,14 @@ defineFunction({
30
30
  htmlBuilder(group, options) {
31
31
  const body = html.buildGroup(group.body, options);
32
32
  const dy = calculateSize(group.dy, options);
33
- return buildCommon.makeVList({
33
+ return makeVList({
34
34
  positionType: "shift",
35
35
  positionData: -dy,
36
36
  children: [{type: "elem", elem: body}],
37
37
  }, options);
38
38
  },
39
39
  mathmlBuilder(group, options) {
40
- const node = new mathMLTree.MathNode(
40
+ const node = new MathNode(
41
41
  "mpadded", [mml.buildGroup(group.body, options)]);
42
42
  const dy = group.dy.number + group.dy.unit;
43
43
  node.setAttribute("voffset", dy);
@@ -1,7 +1,7 @@
1
1
  // @flow
2
- import buildCommon from "../buildCommon";
2
+ import {makeSpan} from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
- import mathMLTree from "../mathMLTree";
4
+ import {MathNode} from "../mathMLTree";
5
5
  import {assertNodeType} from "../parseNode";
6
6
  import {calculateSize, makeEm} from "../units";
7
7
 
@@ -29,7 +29,7 @@ defineFunction({
29
29
  },
30
30
  htmlBuilder(group, options) {
31
31
  // Make an empty span for the rule
32
- const rule = buildCommon.makeSpan(["mord", "rule"], [], options);
32
+ const rule = makeSpan(["mord", "rule"], [], options);
33
33
 
34
34
  // Calculate the shift, width, and height of the rule, and account for units
35
35
  const width = calculateSize(group.width, options);
@@ -58,12 +58,12 @@ defineFunction({
58
58
  const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
59
59
  const color = options.color && options.getColor() || "black";
60
60
 
61
- const rule = new mathMLTree.MathNode("mspace");
61
+ const rule = new MathNode("mspace");
62
62
  rule.setAttribute("mathbackground", color);
63
63
  rule.setAttribute("width", makeEm(width));
64
64
  rule.setAttribute("height", makeEm(height));
65
65
 
66
- const wrapper = new mathMLTree.MathNode("mpadded", [rule]);
66
+ const wrapper = new MathNode("mpadded", [rule]);
67
67
  if (shift >= 0) {
68
68
  wrapper.setAttribute("height", makeEm(shift));
69
69
  } else {
@@ -1,7 +1,7 @@
1
1
  // @flow
2
- import buildCommon from "../buildCommon";
2
+ import {makeFragment} from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
- import mathMLTree from "../mathMLTree";
4
+ import {MathNode} from "../mathMLTree";
5
5
  import {makeEm} from "../units";
6
6
 
7
7
  import * as html from "../buildHTML";
@@ -38,7 +38,7 @@ export function sizingGroup(
38
38
  inner[i].depth *= multiplier;
39
39
  }
40
40
 
41
- return buildCommon.makeFragment(inner);
41
+ return makeFragment(inner);
42
42
  }
43
43
 
44
44
  const sizeFuncs = [
@@ -77,7 +77,7 @@ defineFunction({
77
77
  const newOptions = options.havingSize(group.size);
78
78
  const inner = mml.buildExpression(group.body, newOptions);
79
79
 
80
- const node = new mathMLTree.MathNode("mstyle", inner);
80
+ const node = new MathNode("mstyle", inner);
81
81
 
82
82
  // TODO(emily): This doesn't produce the correct size for nested size
83
83
  // changes, because we don't keep state of what style we're currently
@@ -1,8 +1,8 @@
1
1
  // @flow
2
2
  // smash, with optional [tb], as in AMS
3
3
  import defineFunction from "../defineFunction";
4
- import buildCommon from "../buildCommon";
5
- import mathMLTree from "../mathMLTree";
4
+ import {makeSpan, makeVList} from "../buildCommon";
5
+ import {MathNode} from "../mathMLTree";
6
6
  import {assertNodeType} from "../parseNode";
7
7
 
8
8
  import * as html from "../buildHTML";
@@ -54,7 +54,7 @@ defineFunction({
54
54
  };
55
55
  },
56
56
  htmlBuilder: (group, options) => {
57
- const node = buildCommon.makeSpan(
57
+ const node = makeSpan(
58
58
  [], [html.buildGroup(group.body, options)]);
59
59
 
60
60
  if (!group.smashHeight && !group.smashDepth) {
@@ -85,16 +85,16 @@ defineFunction({
85
85
  // makeVList applies "display: table-cell", which prevents the browser
86
86
  // from acting on that line height. So we'll call makeVList now.
87
87
 
88
- const smashedNode = buildCommon.makeVList({
88
+ const smashedNode = makeVList({
89
89
  positionType: "firstBaseline",
90
90
  children: [{type: "elem", elem: node}],
91
91
  }, options);
92
92
 
93
93
  // For spacing, TeX treats \hphantom as a math group (same spacing as ord).
94
- return buildCommon.makeSpan(["mord"], [smashedNode], options);
94
+ return makeSpan(["mord"], [smashedNode], options);
95
95
  },
96
96
  mathmlBuilder: (group, options) => {
97
- const node = new mathMLTree.MathNode(
97
+ const node = new MathNode(
98
98
  "mpadded", [mml.buildGroup(group.body, options)]);
99
99
 
100
100
  if (group.smashHeight) {
@@ -1,8 +1,8 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
5
- import delimiter from "../delimiter";
3
+ import {makeSpan, makeVList, wrapFragment} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
+ import {makeSqrtImage} from "../delimiter";
6
6
  import Style from "../Style";
7
7
  import {makeEm} from "../units";
8
8
 
@@ -39,7 +39,7 @@ defineFunction({
39
39
 
40
40
  // Some groups can return document fragments. Handle those by wrapping
41
41
  // them in a span.
42
- inner = buildCommon.wrapFragment(inner, options);
42
+ inner = wrapFragment(inner, options);
43
43
 
44
44
  // Calculate the minimum size for the \surd delimiter
45
45
  const metrics = options.fontMetrics();
@@ -58,7 +58,7 @@ defineFunction({
58
58
 
59
59
  // Create a sqrt SVG of the required minimum size
60
60
  const {span: img, ruleWidth, advanceWidth} =
61
- delimiter.sqrtImage(minDelimiterHeight, options);
61
+ makeSqrtImage(minDelimiterHeight, options);
62
62
 
63
63
  const delimDepth = img.height - ruleWidth;
64
64
 
@@ -74,7 +74,7 @@ defineFunction({
74
74
  inner.style.paddingLeft = makeEm(advanceWidth);
75
75
 
76
76
  // Overlay the image and the argument.
77
- const body = buildCommon.makeVList({
77
+ const body = makeVList({
78
78
  positionType: "firstBaseline",
79
79
  children: [
80
80
  {type: "elem", elem: inner, wrapperClasses: ["svg-align"]},
@@ -85,7 +85,7 @@ defineFunction({
85
85
  }, options);
86
86
 
87
87
  if (!group.index) {
88
- return buildCommon.makeSpan(["mord", "sqrt"], [body], options);
88
+ return makeSpan(["mord", "sqrt"], [body], options);
89
89
  } else {
90
90
  // Handle the optional root index
91
91
 
@@ -98,28 +98,28 @@ defineFunction({
98
98
  const toShift = 0.6 * (body.height - body.depth);
99
99
 
100
100
  // Build a VList with the superscript shifted up correctly
101
- const rootVList = buildCommon.makeVList({
101
+ const rootVList = makeVList({
102
102
  positionType: "shift",
103
103
  positionData: -toShift,
104
104
  children: [{type: "elem", elem: rootm}],
105
105
  }, options);
106
106
  // Add a class surrounding it so we can add on the appropriate
107
107
  // kerning
108
- const rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]);
108
+ const rootVListWrap = makeSpan(["root"], [rootVList]);
109
109
 
110
- return buildCommon.makeSpan(["mord", "sqrt"],
110
+ return makeSpan(["mord", "sqrt"],
111
111
  [rootVListWrap, body], options);
112
112
  }
113
113
  },
114
114
  mathmlBuilder(group, options) {
115
115
  const {body, index} = group;
116
116
  return index ?
117
- new mathMLTree.MathNode(
117
+ new MathNode(
118
118
  "mroot", [
119
119
  mml.buildGroup(body, options),
120
120
  mml.buildGroup(index, options),
121
121
  ]) :
122
- new mathMLTree.MathNode(
122
+ new MathNode(
123
123
  "msqrt", [mml.buildGroup(body, options)]);
124
124
  },
125
125
  });
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
- import mathMLTree from "../mathMLTree";
3
+ import {MathNode} from "../mathMLTree";
4
4
  import Style from "../Style";
5
5
  import {sizingGroup} from "./sizing";
6
6
 
@@ -54,7 +54,7 @@ defineFunction({
54
54
 
55
55
  const inner = mml.buildExpression(group.body, newOptions);
56
56
 
57
- const node = new mathMLTree.MathNode("mstyle", inner);
57
+ const node = new MathNode("mstyle", inner);
58
58
 
59
59
  const styleAttributes = {
60
60
  "display": ["0", "true"],
@@ -1,9 +1,9 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
3
+ import {makeSpan, makeVList} from "../buildCommon";
4
4
  import {SymbolNode} from "../domTree";
5
- import mathMLTree from "../mathMLTree";
6
- import utils from "../utils";
5
+ import {isCharacterBox} from "../utils";
6
+ import {MathNode} from "../mathMLTree";
7
7
  import {makeEm} from "../units";
8
8
  import Style from "../Style";
9
9
 
@@ -45,7 +45,7 @@ const htmlBuilderDelegate = function(
45
45
  (options.style.size === Style.DISPLAY.size || base.limits);
46
46
  return delegate ? operatorname.htmlBuilder : null;
47
47
  } else if (base.type === "accent") {
48
- return utils.isCharacterBox(base.base) ? accent.htmlBuilder : null;
48
+ return isCharacterBox(base.base) ? accent.htmlBuilder : null;
49
49
  } else if (base.type === "horizBrace") {
50
50
  const isSup = !group.sub;
51
51
  return isSup === base.isOver ? horizBrace.htmlBuilder : null;
@@ -80,11 +80,11 @@ defineFunctionBuilders({
80
80
  let supShift = 0;
81
81
  let subShift = 0;
82
82
 
83
- const isCharacterBox = valueBase && utils.isCharacterBox(valueBase);
83
+ const isCharBox = valueBase && isCharacterBox(valueBase);
84
84
  if (valueSup) {
85
85
  const newOptions = options.havingStyle(options.style.sup());
86
86
  supm = html.buildGroup(valueSup, newOptions, options);
87
- if (!isCharacterBox) {
87
+ if (!isCharBox) {
88
88
  supShift = base.height - newOptions.fontMetrics().supDrop
89
89
  * newOptions.sizeMultiplier / options.sizeMultiplier;
90
90
  }
@@ -93,7 +93,7 @@ defineFunctionBuilders({
93
93
  if (valueSub) {
94
94
  const newOptions = options.havingStyle(options.style.sub());
95
95
  subm = html.buildGroup(valueSub, newOptions, options);
96
- if (!isCharacterBox) {
96
+ if (!isCharBox) {
97
97
  subShift = base.depth + newOptions.fontMetrics().subDrop
98
98
  * newOptions.sizeMultiplier / options.sizeMultiplier;
99
99
  }
@@ -153,7 +153,7 @@ defineFunctionBuilders({
153
153
  {type: "elem", elem: supm, shift: -supShift, marginRight},
154
154
  ];
155
155
 
156
- supsub = buildCommon.makeVList({
156
+ supsub = makeVList({
157
157
  positionType: "individualShift",
158
158
  children: vlistElem,
159
159
  }, options);
@@ -166,7 +166,7 @@ defineFunctionBuilders({
166
166
  const vlistElem =
167
167
  [{type: "elem", elem: subm, marginLeft, marginRight}];
168
168
 
169
- supsub = buildCommon.makeVList({
169
+ supsub = makeVList({
170
170
  positionType: "shift",
171
171
  positionData: subShift,
172
172
  children: vlistElem,
@@ -176,7 +176,7 @@ defineFunctionBuilders({
176
176
  supShift = Math.max(supShift, minSupShift,
177
177
  supm.depth + 0.25 * metrics.xHeight);
178
178
 
179
- supsub = buildCommon.makeVList({
179
+ supsub = makeVList({
180
180
  positionType: "shift",
181
181
  positionData: -supShift,
182
182
  children: [{type: "elem", elem: supm, marginRight}],
@@ -187,8 +187,8 @@ defineFunctionBuilders({
187
187
 
188
188
  // Wrap the supsub vlist in a span.msupsub to reset text-align.
189
189
  const mclass = html.getTypeOfDomTree(base, "right") || "mord";
190
- return buildCommon.makeSpan([mclass],
191
- [base, buildCommon.makeSpan(["msupsub"], [supsub])],
190
+ return makeSpan([mclass],
191
+ [base, makeSpan(["msupsub"], [supsub])],
192
192
  options);
193
193
  },
194
194
  mathmlBuilder(group, options) {
@@ -261,7 +261,7 @@ defineFunctionBuilders({
261
261
  }
262
262
  }
263
263
 
264
- return new mathMLTree.MathNode(nodeType, children);
264
+ return new MathNode(nodeType, children);
265
265
  },
266
266
  });
267
267
 
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {mathsym} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
 
6
6
  import * as mml from "../buildMathML";
7
7
 
@@ -10,11 +10,11 @@ import * as mml from "../buildMathML";
10
10
  defineFunctionBuilders({
11
11
  type: "atom",
12
12
  htmlBuilder(group, options) {
13
- return buildCommon.mathsym(
13
+ return mathsym(
14
14
  group.text, group.mode, options, ["m" + group.family]);
15
15
  },
16
16
  mathmlBuilder(group, options) {
17
- const node = new mathMLTree.MathNode(
17
+ const node = new MathNode(
18
18
  "mo", [mml.makeText(group.text, group.mode)]);
19
19
  if (group.family === "bin") {
20
20
  const variant = mml.getVariant(group, options);
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {makeOrd} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
 
6
6
  import * as mml from "../buildMathML";
7
7
 
@@ -19,10 +19,10 @@ const defaultVariant: {[string]: string} = {
19
19
  defineFunctionBuilders({
20
20
  type: "mathord",
21
21
  htmlBuilder(group, options) {
22
- return buildCommon.makeOrd(group, options, "mathord");
22
+ return makeOrd(group, options, "mathord");
23
23
  },
24
24
  mathmlBuilder(group: ParseNode<"mathord">, options) {
25
- const node = new mathMLTree.MathNode(
25
+ const node = new MathNode(
26
26
  "mi",
27
27
  [mml.makeText(group.text, group.mode, options)]);
28
28
 
@@ -37,7 +37,7 @@ defineFunctionBuilders({
37
37
  defineFunctionBuilders({
38
38
  type: "textord",
39
39
  htmlBuilder(group, options) {
40
- return buildCommon.makeOrd(group, options, "textord");
40
+ return makeOrd(group, options, "textord");
41
41
  },
42
42
  mathmlBuilder(group: ParseNode<"textord">, options) {
43
43
  const text = mml.makeText(group.text, group.mode, options);
@@ -45,13 +45,13 @@ defineFunctionBuilders({
45
45
 
46
46
  let node;
47
47
  if (group.mode === 'text') {
48
- node = new mathMLTree.MathNode("mtext", [text]);
48
+ node = new MathNode("mtext", [text]);
49
49
  } else if (/[0-9]/.test(group.text)) {
50
- node = new mathMLTree.MathNode("mn", [text]);
50
+ node = new MathNode("mn", [text]);
51
51
  } else if (group.text === "\\prime") {
52
- node = new mathMLTree.MathNode("mo", [text]);
52
+ node = new MathNode("mo", [text]);
53
53
  } else {
54
- node = new mathMLTree.MathNode("mi", [text]);
54
+ node = new MathNode("mi", [text]);
55
55
  }
56
56
  if (variant !== defaultVariant[node.type]) {
57
57
  node.setAttribute("mathvariant", variant);
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
3
+ import {mathsym, makeOrd, makeSpan} from "../buildCommon";
4
+ import {MathNode, TextNode} from "../mathMLTree";
5
5
  import ParseError from "../ParseError";
6
6
 
7
7
  // A map of CSS-based spacing functions to their CSS class.
@@ -38,17 +38,17 @@ defineFunctionBuilders({
38
38
  // things has an entry in the symbols table, so these will be turned
39
39
  // into appropriate outputs.
40
40
  if (group.mode === "text") {
41
- const ord = buildCommon.makeOrd(group, options, "textord");
41
+ const ord = makeOrd(group, options, "textord");
42
42
  ord.classes.push(className);
43
43
  return ord;
44
44
  } else {
45
- return buildCommon.makeSpan(["mspace", className],
46
- [buildCommon.mathsym(group.text, group.mode, options)],
45
+ return makeSpan(["mspace", className],
46
+ [mathsym(group.text, group.mode, options)],
47
47
  options);
48
48
  }
49
49
  } else if (cssSpace.hasOwnProperty(group.text)) {
50
50
  // Spaces based on just a CSS class.
51
- return buildCommon.makeSpan(
51
+ return makeSpan(
52
52
  ["mspace", cssSpace[group.text]],
53
53
  [], options);
54
54
  } else {
@@ -59,11 +59,11 @@ defineFunctionBuilders({
59
59
  let node;
60
60
 
61
61
  if (regularSpace.hasOwnProperty(group.text)) {
62
- node = new mathMLTree.MathNode(
63
- "mtext", [new mathMLTree.TextNode("\u00a0")]);
62
+ node = new MathNode(
63
+ "mtext", [new TextNode("\u00a0")]);
64
64
  } else if (cssSpace.hasOwnProperty(group.text)) {
65
65
  // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
66
- return new mathMLTree.MathNode("mspace");
66
+ return new MathNode("mspace");
67
67
  } else {
68
68
  throw new ParseError(`Unknown type of space "${group.text}"`);
69
69
  }
@@ -1,11 +1,11 @@
1
1
  // @flow
2
2
  import {defineFunctionBuilders} from "../defineFunction";
3
- import mathMLTree from "../mathMLTree";
3
+ import {MathNode} from "../mathMLTree";
4
4
 
5
5
  import * as mml from "../buildMathML";
6
6
 
7
7
  const pad = () => {
8
- const padNode = new mathMLTree.MathNode("mtd", []);
8
+ const padNode = new MathNode("mtd", []);
9
9
  padNode.setAttribute("width", "50%");
10
10
  return padNode;
11
11
  };
@@ -13,14 +13,14 @@ const pad = () => {
13
13
  defineFunctionBuilders({
14
14
  type: "tag",
15
15
  mathmlBuilder(group, options) {
16
- const table = new mathMLTree.MathNode("mtable", [
17
- new mathMLTree.MathNode("mtr", [
16
+ const table = new MathNode("mtable", [
17
+ new MathNode("mtr", [
18
18
  pad(),
19
- new mathMLTree.MathNode("mtd", [
19
+ new MathNode("mtd", [
20
20
  mml.buildExpressionRow(group.body, options),
21
21
  ]),
22
22
  pad(),
23
- new mathMLTree.MathNode("mtd", [
23
+ new MathNode("mtd", [
24
24
  mml.buildExpressionRow(group.tag, options),
25
25
  ]),
26
26
  ]),
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import defineFunction, {ordargument} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
3
+ import {makeSpan} from "../buildCommon";
4
4
 
5
5
  import * as html from "../buildHTML";
6
6
  import * as mml from "../buildMathML";
@@ -67,7 +67,7 @@ defineFunction({
67
67
  htmlBuilder(group, options) {
68
68
  const newOptions = optionsWithFont(group, options);
69
69
  const inner = html.buildExpression(group.body, newOptions, true);
70
- return buildCommon.makeSpan(["mord", "text"], inner, newOptions);
70
+ return makeSpan(["mord", "text"], inner, newOptions);
71
71
  },
72
72
  mathmlBuilder(group, options) {
73
73
  const newOptions = optionsWithFont(group, options);