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,9 +1,9 @@
1
1
  // @flow
2
2
  import defineFunction, {normalizeArgument} from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
5
- import utils from "../utils";
6
- import stretchy from "../stretchy";
3
+ import {makeOrd, makeSpan, makeVList, staticSvg, svgData} from "../buildCommon";
4
+ import {getBaseElem, isCharacterBox} from "../utils";
5
+ import {MathNode} from "../mathMLTree";
6
+ import {stretchyMathML, stretchySvg} from "../stretchy";
7
7
  import {assertNodeType} from "../parseNode";
8
8
  import {assertSpan, assertSymbolDomNode} from "../domTree";
9
9
  import {makeEm} from "../units";
@@ -53,7 +53,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
53
53
  const body = html.buildGroup(base, options.havingCrampedStyle());
54
54
 
55
55
  // Does the accent need to shift for the skew of a character?
56
- const mustShift = group.isShifty && utils.isCharacterBox(base);
56
+ const mustShift = group.isShifty && isCharacterBox(base);
57
57
 
58
58
  // Calculate the skew of the accent. This is based on the line "If the
59
59
  // nucleus is not a single character, let s = 0; otherwise set s to the
@@ -64,7 +64,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
64
64
  if (mustShift) {
65
65
  // If the base is a character box, then we want the skew of the
66
66
  // innermost character. To do that, we find the innermost character:
67
- const baseChar = utils.getBaseElem(base);
67
+ const baseChar = getBaseElem(base);
68
68
  // Then, we render its group to get the symbol inside it
69
69
  const baseGroup = html.buildGroup(baseChar, options.havingCrampedStyle());
70
70
  // Finally, we pull the skew off of the symbol.
@@ -95,10 +95,10 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
95
95
  // render combining characters when not preceded by a character.
96
96
  // So now we use an SVG.
97
97
  // If Safari reforms, we should consider reverting to the glyph.
98
- accent = buildCommon.staticSvg("vec", options);
99
- width = buildCommon.svgData.vec[1];
98
+ accent = staticSvg("vec", options);
99
+ width = svgData.vec[1];
100
100
  } else {
101
- accent = buildCommon.makeOrd({mode: group.mode, text: group.label},
101
+ accent = makeOrd({mode: group.mode, text: group.label},
102
102
  options, "textord");
103
103
  accent = assertSymbolDomNode(accent);
104
104
  // Remove the italic correction of the accent, because it only serves to
@@ -110,7 +110,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
110
110
  }
111
111
  }
112
112
 
113
- accentBody = buildCommon.makeSpan(["accent-body"], [accent]);
113
+ accentBody = makeSpan(["accent-body"], [accent]);
114
114
 
115
115
  // "Full" accents expand the width of the resulting symbol to be
116
116
  // at least the width of the accent, and overlap directly onto the
@@ -140,7 +140,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
140
140
  accentBody.style.top = ".2em";
141
141
  }
142
142
 
143
- accentBody = buildCommon.makeVList({
143
+ accentBody = makeVList({
144
144
  positionType: "firstBaseline",
145
145
  children: [
146
146
  {type: "elem", elem: body},
@@ -150,9 +150,9 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
150
150
  }, options);
151
151
 
152
152
  } else {
153
- accentBody = stretchy.svgSpan(group, options);
153
+ accentBody = stretchySvg(group, options);
154
154
 
155
- accentBody = buildCommon.makeVList({
155
+ accentBody = makeVList({
156
156
  positionType: "firstBaseline",
157
157
  children: [
158
158
  {type: "elem", elem: body},
@@ -172,7 +172,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
172
172
  }
173
173
 
174
174
  const accentWrap =
175
- buildCommon.makeSpan(["mord", "accent"], [accentBody], options);
175
+ makeSpan(["mord", "accent"], [accentBody], options);
176
176
 
177
177
  if (supSubGroup) {
178
178
  // Here, we replace the "base" child of the supsub with our newly
@@ -195,10 +195,10 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
195
195
  const mathmlBuilder: MathMLBuilder<"accent"> = (group, options) => {
196
196
  const accentNode =
197
197
  group.isStretchy ?
198
- stretchy.mathMLnode(group.label) :
199
- new mathMLTree.MathNode("mo", [mml.makeText(group.label, group.mode)]);
198
+ stretchyMathML(group.label) :
199
+ new MathNode("mo", [mml.makeText(group.label, group.mode)]);
200
200
 
201
- const node = new mathMLTree.MathNode(
201
+ const node = new MathNode(
202
202
  "mover",
203
203
  [mml.buildGroup(group.base, options), accentNode]);
204
204
 
@@ -1,9 +1,9 @@
1
1
  // @flow
2
2
  // Horizontal overlap functions
3
3
  import defineFunction from "../defineFunction";
4
- import buildCommon from "../buildCommon";
5
- import mathMLTree from "../mathMLTree";
6
- import stretchy from "../stretchy";
4
+ import {makeSpan, makeVList} from "../buildCommon";
5
+ import {MathNode} from "../mathMLTree";
6
+ import {stretchyMathML, stretchySvg} from "../stretchy";
7
7
 
8
8
  import * as html from "../buildHTML";
9
9
  import * as mml from "../buildMathML";
@@ -32,11 +32,11 @@ defineFunction({
32
32
  // Treat under accents much like underlines.
33
33
  const innerGroup = html.buildGroup(group.base, options);
34
34
 
35
- const accentBody = stretchy.svgSpan(group, options);
35
+ const accentBody = stretchySvg(group, options);
36
36
  const kern = group.label === "\\utilde" ? 0.12 : 0;
37
37
 
38
38
  // Generate the vlist, with the appropriate kerns
39
- const vlist = buildCommon.makeVList({
39
+ const vlist = makeVList({
40
40
  positionType: "top",
41
41
  positionData: innerGroup.height,
42
42
  children: [
@@ -46,11 +46,11 @@ defineFunction({
46
46
  ],
47
47
  }, options);
48
48
 
49
- return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options);
49
+ return makeSpan(["mord", "accentunder"], [vlist], options);
50
50
  },
51
51
  mathmlBuilder: (group, options) => {
52
- const accentNode = stretchy.mathMLnode(group.label);
53
- const node = new mathMLTree.MathNode(
52
+ const accentNode = stretchyMathML(group.label);
53
+ const node = new MathNode(
54
54
  "munder",
55
55
  [mml.buildGroup(group.base, options), accentNode]
56
56
  );
@@ -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 stretchy from "../stretchy";
3
+ import {makeSpan, makeVList, wrapFragment} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
+ import {stretchyMathML, stretchySvg} from "../stretchy";
6
6
 
7
7
  import * as html from "../buildHTML";
8
8
  import * as mml from "../buildMathML";
@@ -11,7 +11,7 @@ import type {ParseNode} from "../parseNode";
11
11
 
12
12
  // Helper function
13
13
  const paddedNode = group => {
14
- const node = new mathMLTree.MathNode("mpadded", group ? [group] : []);
14
+ const node = new MathNode("mpadded", group ? [group] : []);
15
15
  node.setAttribute("width", "+0.6em");
16
16
  node.setAttribute("lspace", "0.3em");
17
17
  return node;
@@ -57,7 +57,7 @@ defineFunction({
57
57
  // Some groups can return document fragments. Handle those by wrapping
58
58
  // them in a span.
59
59
  let newOptions = options.havingStyle(style.sup());
60
- const upperGroup = buildCommon.wrapFragment(
60
+ const upperGroup = wrapFragment(
61
61
  html.buildGroup(group.body, newOptions, options), options);
62
62
  const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd";
63
63
  upperGroup.classes.push(arrowPrefix + "-arrow-pad");
@@ -66,14 +66,14 @@ defineFunction({
66
66
  if (group.below) {
67
67
  // Build the lower group
68
68
  newOptions = options.havingStyle(style.sub());
69
- lowerGroup = buildCommon.wrapFragment(
69
+ lowerGroup = wrapFragment(
70
70
  html.buildGroup(group.below, newOptions, options), options);
71
71
  lowerGroup.classes.push(arrowPrefix + "-arrow-pad");
72
72
  }
73
73
 
74
- const arrowBody = stretchy.svgSpan(group, options);
74
+ const arrowBody = stretchySvg(group, options);
75
75
 
76
- // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0.
76
+ // Re shift: Note that stretchySvg returned arrowBody.depth = 0.
77
77
  // The point we want on the math axis is at 0.5 * arrowBody.height.
78
78
  const arrowShift = -options.fontMetrics().axisHeight +
79
79
  0.5 * arrowBody.height;
@@ -90,7 +90,7 @@ defineFunction({
90
90
  const lowerShift = -options.fontMetrics().axisHeight
91
91
  + lowerGroup.height + 0.5 * arrowBody.height
92
92
  + 0.111;
93
- vlist = buildCommon.makeVList({
93
+ vlist = makeVList({
94
94
  positionType: "individualShift",
95
95
  children: [
96
96
  {type: "elem", elem: upperGroup, shift: upperShift},
@@ -99,7 +99,7 @@ defineFunction({
99
99
  ],
100
100
  }, options);
101
101
  } else {
102
- vlist = buildCommon.makeVList({
102
+ vlist = makeVList({
103
103
  positionType: "individualShift",
104
104
  children: [
105
105
  {type: "elem", elem: upperGroup, shift: upperShift},
@@ -111,10 +111,10 @@ defineFunction({
111
111
  // $FlowFixMe: Replace this with passing "svg-align" into makeVList.
112
112
  vlist.children[0].children[0].children[1].classes.push("svg-align");
113
113
 
114
- return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options);
114
+ return makeSpan(["mrel", "x-arrow"], [vlist], options);
115
115
  },
116
116
  mathmlBuilder(group, options) {
117
- const arrowNode = stretchy.mathMLnode(group.label);
117
+ const arrowNode = stretchyMathML(group.label);
118
118
  arrowNode.setAttribute(
119
119
  "minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"
120
120
  );
@@ -124,20 +124,20 @@ defineFunction({
124
124
  const upperNode = paddedNode(mml.buildGroup(group.body, options));
125
125
  if (group.below) {
126
126
  const lowerNode = paddedNode(mml.buildGroup(group.below, options));
127
- node = new mathMLTree.MathNode(
127
+ node = new MathNode(
128
128
  "munderover", [arrowNode, lowerNode, upperNode]
129
129
  );
130
130
  } else {
131
- node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
131
+ node = new MathNode("mover", [arrowNode, upperNode]);
132
132
  }
133
133
  } else if (group.below) {
134
134
  const lowerNode = paddedNode(mml.buildGroup(group.below, options));
135
- node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
135
+ node = new MathNode("munder", [arrowNode, lowerNode]);
136
136
  } else {
137
137
  // This should never happen.
138
138
  // Parser.js throws an error if there is no argument.
139
139
  node = paddedNode();
140
- node = new mathMLTree.MathNode("mover", [arrowNode, node]);
140
+ node = new MathNode("mover", [arrowNode, node]);
141
141
  }
142
142
  return node;
143
143
  },
@@ -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} from "../buildCommon";
4
+ import {MathNode} from "../mathMLTree";
5
5
  import {assertNodeType} from "../parseNode";
6
6
 
7
7
  import type {AnyParseNode} from '../parseNode';
@@ -20,14 +20,14 @@ const htmlBuilder = (group, options) => {
20
20
  // To accomplish this, we wrap the results in a fragment, so the inner
21
21
  // elements will be able to directly interact with their neighbors. For
22
22
  // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
23
- return buildCommon.makeFragment(elements);
23
+ return makeFragment(elements);
24
24
  };
25
25
 
26
26
  const mathmlBuilder = (group, options) => {
27
27
  const inner = mml.buildExpression(group.body,
28
28
  options.withColor(group.color));
29
29
 
30
- const node = new mathMLTree.MathNode("mstyle", inner);
30
+ const node = new MathNode("mstyle", inner);
31
31
 
32
32
  node.setAttribute("mathcolor", group.color);
33
33
 
@@ -2,8 +2,8 @@
2
2
  // Row breaks within tabular environments, and line breaks at top level
3
3
 
4
4
  import defineFunction from "../defineFunction";
5
- import buildCommon from "../buildCommon";
6
- import mathMLTree from "../mathMLTree";
5
+ import {makeSpan} from "../buildCommon";
6
+ import {MathNode} from "../mathMLTree";
7
7
  import {calculateSize, makeEm} from "../units";
8
8
  import {assertNodeType} from "../parseNode";
9
9
 
@@ -36,7 +36,7 @@ defineFunction({
36
36
  // not within tabular/array environments.
37
37
 
38
38
  htmlBuilder(group, options) {
39
- const span = buildCommon.makeSpan(["mspace"], [], options);
39
+ const span = makeSpan(["mspace"], [], options);
40
40
  if (group.newLine) {
41
41
  span.classes.push("newline");
42
42
  if (group.size) {
@@ -48,7 +48,7 @@ defineFunction({
48
48
  },
49
49
 
50
50
  mathmlBuilder(group, options) {
51
- const node = new mathMLTree.MathNode("mspace");
51
+ const node = new MathNode("mspace");
52
52
  if (group.newLine) {
53
53
  node.setAttribute("linebreak", "newline");
54
54
  if (group.size) {
@@ -1,8 +1,8 @@
1
1
  // @flow
2
- import buildCommon from "../buildCommon";
2
+ import {makeSpan} from "../buildCommon";
3
3
  import defineFunction from "../defineFunction";
4
- import delimiter from "../delimiter";
5
- import mathMLTree from "../mathMLTree";
4
+ import {makeLeftRightDelim, makeSizedDelim, sizeToMaxHeight} from "../delimiter";
5
+ import {MathNode} from "../mathMLTree";
6
6
  import ParseError from "../ParseError";
7
7
  import {assertNodeType, checkSymbolNodeType} from "../parseNode";
8
8
  import {makeEm} from "../units";
@@ -34,7 +34,7 @@ const delimiterSizes = {
34
34
  "\\Bigg" : {mclass: "mord", size: 4},
35
35
  };
36
36
 
37
- const delimiters = [
37
+ const delimiters = new Set([
38
38
  "(", "\\lparen", ")", "\\rparen",
39
39
  "[", "\\lbrack", "]", "\\rbrack",
40
40
  "\\{", "\\lbrace", "\\}", "\\rbrace",
@@ -50,7 +50,7 @@ const delimiters = [
50
50
  "\\downarrow", "\\Downarrow",
51
51
  "\\updownarrow", "\\Updownarrow",
52
52
  ".",
53
- ];
53
+ ]);
54
54
 
55
55
  type IsMiddle = {delim: string, options: Options};
56
56
 
@@ -60,7 +60,7 @@ function checkDelimiter(
60
60
  context: FunctionContext,
61
61
  ): SymbolParseNode {
62
62
  const symDelim = checkSymbolNodeType(delim);
63
- if (symDelim && delimiters.includes(symDelim.text)) {
63
+ if (symDelim && delimiters.has(symDelim.text)) {
64
64
  return symDelim;
65
65
  } else if (symDelim) {
66
66
  throw new ParseError(
@@ -98,11 +98,10 @@ defineFunction({
98
98
  if (group.delim === ".") {
99
99
  // Empty delimiters still count as elements, even though they don't
100
100
  // show anything.
101
- return buildCommon.makeSpan([group.mclass]);
101
+ return makeSpan([group.mclass]);
102
102
  }
103
103
 
104
- // Use delimiter.sizedDelim to generate the delimiter.
105
- return delimiter.sizedDelim(
104
+ return makeSizedDelim(
106
105
  group.delim, group.size, options, group.mode, [group.mclass]);
107
106
  },
108
107
  mathmlBuilder: (group) => {
@@ -112,7 +111,7 @@ defineFunction({
112
111
  children.push(mml.makeText(group.delim, group.mode));
113
112
  }
114
113
 
115
- const node = new mathMLTree.MathNode("mo", children);
114
+ const node = new MathNode("mo", children);
116
115
 
117
116
  if (group.mclass === "mopen" ||
118
117
  group.mclass === "mclose") {
@@ -126,7 +125,7 @@ defineFunction({
126
125
  }
127
126
 
128
127
  node.setAttribute("stretchy", "true");
129
- const size = makeEm(delimiter.sizeToMaxHeight[group.size]);
128
+ const size = makeEm(sizeToMaxHeight[group.size]);
130
129
  node.setAttribute("minsize", size);
131
130
  node.setAttribute("maxsize", size);
132
131
 
@@ -232,7 +231,7 @@ defineFunction({
232
231
  } else {
233
232
  // Otherwise, use leftRightDelim to generate the correct sized
234
233
  // delimiter.
235
- leftDelim = delimiter.leftRightDelim(
234
+ leftDelim = makeLeftRightDelim(
236
235
  group.left, innerHeight, innerDepth, options,
237
236
  group.mode, ["mopen"]);
238
237
  }
@@ -249,7 +248,7 @@ defineFunction({
249
248
  const isMiddle: IsMiddle = middleDelim.isMiddle;
250
249
  if (isMiddle) {
251
250
  // Apply the options that were active when \middle was called
252
- inner[i] = delimiter.leftRightDelim(
251
+ inner[i] = makeLeftRightDelim(
253
252
  isMiddle.delim, innerHeight, innerDepth,
254
253
  isMiddle.options, group.mode, []);
255
254
  }
@@ -263,21 +262,21 @@ defineFunction({
263
262
  } else {
264
263
  const colorOptions = group.rightColor ?
265
264
  options.withColor(group.rightColor) : options;
266
- rightDelim = delimiter.leftRightDelim(
265
+ rightDelim = makeLeftRightDelim(
267
266
  group.right, innerHeight, innerDepth, colorOptions,
268
267
  group.mode, ["mclose"]);
269
268
  }
270
269
  // Add it to the end of the expression.
271
270
  inner.push(rightDelim);
272
271
 
273
- return buildCommon.makeSpan(["minner"], inner, options);
272
+ return makeSpan(["minner"], inner, options);
274
273
  },
275
274
  mathmlBuilder: (group, options) => {
276
275
  assertParsed(group);
277
276
  const inner = mml.buildExpression(group.body, options);
278
277
 
279
278
  if (group.left !== ".") {
280
- const leftNode = new mathMLTree.MathNode(
279
+ const leftNode = new MathNode(
281
280
  "mo", [mml.makeText(group.left, group.mode)]);
282
281
 
283
282
  leftNode.setAttribute("fence", "true");
@@ -286,7 +285,7 @@ defineFunction({
286
285
  }
287
286
 
288
287
  if (group.right !== ".") {
289
- const rightNode = new mathMLTree.MathNode(
288
+ const rightNode = new MathNode(
290
289
  "mo", [mml.makeText(group.right, group.mode)]);
291
290
 
292
291
  rightNode.setAttribute("fence", "true");
@@ -326,7 +325,7 @@ defineFunction({
326
325
  if (group.delim === ".") {
327
326
  middleDelim = html.makeNullDelimiter(options, []);
328
327
  } else {
329
- middleDelim = delimiter.sizedDelim(
328
+ middleDelim = makeSizedDelim(
330
329
  group.delim, 1, options,
331
330
  group.mode, []);
332
331
 
@@ -348,7 +347,7 @@ defineFunction({
348
347
  const textNode = (group.delim === "\\vert" || group.delim === "|")
349
348
  ? mml.makeText("|", "text")
350
349
  : mml.makeText(group.delim, group.mode);
351
- const middleNode = new mathMLTree.MathNode("mo", [textNode]);
350
+ const middleNode = new MathNode("mo", [textNode]);
352
351
  middleNode.setAttribute("fence", "true");
353
352
  // MathML gives 5/18em spacing to each <mo> element.
354
353
  // \middle should get delimiter spacing instead.
@@ -1,9 +1,9 @@
1
1
  // @flow
2
2
  import defineFunction from "../defineFunction";
3
- import buildCommon from "../buildCommon";
4
- import mathMLTree from "../mathMLTree";
5
- import utils from "../utils";
6
- import stretchy from "../stretchy";
3
+ import {makeSpan, makeSvgSpan, makeVList, wrapFragment} from "../buildCommon";
4
+ import {isCharacterBox} from "../utils";
5
+ import {MathNode} from "../mathMLTree";
6
+ import {stretchyEnclose} from "../stretchy";
7
7
  import {phasePath} from "../svgGeometry";
8
8
  import {PathNode, SvgNode} from "../domTree";
9
9
  import {calculateSize, makeEm} from "../units";
@@ -17,7 +17,7 @@ const htmlBuilder = (group, options) => {
17
17
  // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase
18
18
  // Some groups can return document fragments. Handle those by wrapping
19
19
  // them in a span.
20
- const inner = buildCommon.wrapFragment(
20
+ const inner = wrapFragment(
21
21
  html.buildGroup(group.body, options), options);
22
22
 
23
23
  const label = group.label.slice(1);
@@ -30,10 +30,10 @@ const htmlBuilder = (group, options) => {
30
30
  // We don't know the width of a group, so as a proxy, we test if
31
31
  // the subject is a single character. This captures most of the
32
32
  // subjects that should get the "tall" treatment.
33
- const isSingleChar = utils.isCharacterBox(group.body);
33
+ const isSingleChar = isCharacterBox(group.body);
34
34
 
35
35
  if (label === "sout") {
36
- img = buildCommon.makeSpan(["stretchy", "sout"]);
36
+ img = makeSpan(["stretchy", "sout"]);
37
37
  img.height = options.fontMetrics().defaultRuleThickness / scale;
38
38
  imgShift = -0.5 * options.fontMetrics().xHeight;
39
39
 
@@ -60,7 +60,7 @@ const htmlBuilder = (group, options) => {
60
60
  "preserveAspectRatio": "xMinYMin slice",
61
61
  });
62
62
  // Wrap it in a span with overflow: hidden.
63
- img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
63
+ img = makeSvgSpan(["hide-tail"], [svgNode], options);
64
64
  img.style.height = makeEm(angleHeight);
65
65
  imgShift = inner.depth + lineWeight + clearance;
66
66
 
@@ -101,7 +101,7 @@ const htmlBuilder = (group, options) => {
101
101
  bottomPad = topPad;
102
102
  }
103
103
 
104
- img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options);
104
+ img = stretchyEnclose(inner, label, topPad, bottomPad, options);
105
105
  if (/fbox|boxed|fcolorbox/.test(label)) {
106
106
  img.style.borderStyle = "solid";
107
107
  img.style.borderWidth = makeEm(ruleThickness);
@@ -121,7 +121,7 @@ const htmlBuilder = (group, options) => {
121
121
 
122
122
  let vlist;
123
123
  if (group.backgroundColor) {
124
- vlist = buildCommon.makeVList({
124
+ vlist = makeVList({
125
125
  positionType: "individualShift",
126
126
  children: [
127
127
  // Put the color background behind inner;
@@ -131,7 +131,7 @@ const htmlBuilder = (group, options) => {
131
131
  }, options);
132
132
  } else {
133
133
  const classes = /cancel|phase/.test(label) ? ["svg-align"] : [];
134
- vlist = buildCommon.makeVList({
134
+ vlist = makeVList({
135
135
  positionType: "individualShift",
136
136
  children: [
137
137
  // Write the \cancel stroke on top of inner.
@@ -159,16 +159,16 @@ const htmlBuilder = (group, options) => {
159
159
 
160
160
  if (/cancel/.test(label) && !isSingleChar) {
161
161
  // cancel does not create horiz space for its line extension.
162
- return buildCommon.makeSpan(["mord", "cancel-lap"], [vlist], options);
162
+ return makeSpan(["mord", "cancel-lap"], [vlist], options);
163
163
  } else {
164
- return buildCommon.makeSpan(["mord"], [vlist], options);
164
+ return makeSpan(["mord"], [vlist], options);
165
165
  }
166
166
  };
167
167
 
168
168
  const mathmlBuilder = (group, options) => {
169
169
  let fboxsep = 0;
170
- const node = new mathMLTree.MathNode(
171
- (group.label.indexOf("colorbox") > -1) ? "mpadded" : "menclose",
170
+ const node = new MathNode(
171
+ group.label.includes("colorbox") ? "mpadded" : "menclose",
172
172
  [mml.buildGroup(group.body, options)]
173
173
  );
174
174
  switch (group.label) {
@@ -3,7 +3,7 @@
3
3
 
4
4
  import {binrelClass} from "./mclass";
5
5
  import defineFunction, {normalizeArgument} from "../defineFunction";
6
- import utils from "../utils";
6
+ import {isCharacterBox} from "../utils";
7
7
 
8
8
  import * as html from "../buildHTML";
9
9
  import * as mml from "../buildMathML";
@@ -71,7 +71,6 @@ defineFunction({
71
71
  },
72
72
  handler: ({parser}, args) => {
73
73
  const body = args[0];
74
- const isCharacterBox = utils.isCharacterBox(body);
75
74
  // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
76
75
  // argument's bin|rel|ord status
77
76
  return {
@@ -86,7 +85,7 @@ defineFunction({
86
85
  body,
87
86
  },
88
87
  ],
89
- isCharacterBox: isCharacterBox,
88
+ isCharacterBox: isCharacterBox(body),
90
89
  };
91
90
  },
92
91
  });