katex 0.16.47 → 0.18.0

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 (93) hide show
  1. package/README.md +5 -10
  2. package/cli.js +6 -9
  3. package/contrib/auto-render/index.html +1 -1
  4. package/contrib/copy-tex/README.md +3 -3
  5. package/contrib/copy-tex/index.html +1 -1
  6. package/contrib/mathtex-script-type/README.md +5 -5
  7. package/contrib/mhchem/README.md +1 -1
  8. package/contrib/render-a11y-string/render-a11y-string.ts +1 -1
  9. package/dist/README.md +5 -10
  10. package/dist/contrib/render-a11y-string.js +15 -40
  11. package/dist/contrib/render-a11y-string.min.js +1 -1
  12. package/dist/contrib/render-a11y-string.mjs +13 -33
  13. package/dist/katex-swap.css +159 -164
  14. package/dist/katex-swap.min.css +1 -1
  15. package/dist/katex.css +159 -164
  16. package/dist/katex.js +509 -849
  17. package/dist/katex.min.css +1 -1
  18. package/dist/katex.min.js +1 -1
  19. package/dist/katex.mjs +498 -831
  20. package/katex.ts +1 -1
  21. package/package.json +12 -16
  22. package/src/MacroExpander.ts +11 -8
  23. package/src/Namespace.ts +17 -21
  24. package/src/Options.ts +2 -2
  25. package/src/ParseError.ts +1 -1
  26. package/src/Parser.ts +44 -50
  27. package/src/Settings.ts +1 -1
  28. package/src/SourceLocation.ts +2 -2
  29. package/src/atoms.ts +22 -22
  30. package/src/buildCommon.ts +8 -8
  31. package/src/buildHTML.ts +12 -13
  32. package/src/buildMathML.ts +4 -4
  33. package/src/buildTree.ts +1 -1
  34. package/src/defineEnvironment.ts +1 -2
  35. package/src/defineFunction.ts +104 -112
  36. package/src/environments/array.ts +11 -15
  37. package/src/environments/cd.ts +8 -8
  38. package/src/fontMetrics.ts +2 -4
  39. package/src/functions/accent.ts +12 -15
  40. package/src/functions/accentunder.ts +4 -4
  41. package/src/functions/arrow.ts +5 -5
  42. package/src/functions/char.ts +3 -4
  43. package/src/functions/color.ts +10 -13
  44. package/src/functions/cr.ts +4 -6
  45. package/src/functions/def.ts +15 -19
  46. package/src/functions/delimsizing.ts +23 -23
  47. package/src/functions/enclose.ts +23 -34
  48. package/src/functions/environment.ts +5 -6
  49. package/src/functions/font.ts +15 -27
  50. package/src/functions/genfrac.ts +19 -23
  51. package/src/functions/hbox.ts +6 -6
  52. package/src/functions/horizBrace.ts +4 -4
  53. package/src/functions/href.ts +10 -11
  54. package/src/functions/html.ts +8 -8
  55. package/src/functions/htmlmathml.ts +5 -5
  56. package/src/functions/includegraphics.ts +7 -7
  57. package/src/functions/kern.ts +6 -6
  58. package/src/functions/lap.ts +11 -11
  59. package/src/functions/math.ts +8 -10
  60. package/src/functions/mathchoice.ts +5 -5
  61. package/src/functions/mclass.ts +16 -28
  62. package/src/functions/op.ts +16 -30
  63. package/src/functions/operatorname.ts +4 -4
  64. package/src/functions/overline.ts +4 -4
  65. package/src/functions/phantom.ts +10 -10
  66. package/src/functions/pmb.ts +5 -5
  67. package/src/functions/raisebox.ts +5 -5
  68. package/src/functions/relax.ts +4 -5
  69. package/src/functions/rule.ts +8 -8
  70. package/src/functions/sizing.ts +7 -7
  71. package/src/functions/smash.ts +6 -6
  72. package/src/functions/sqrt.ts +5 -5
  73. package/src/functions/styling.ts +5 -5
  74. package/src/functions/supsub.ts +1 -1
  75. package/src/functions/symbolsOrd.ts +3 -3
  76. package/src/functions/symbolsSpacing.ts +21 -22
  77. package/src/functions/text.ts +7 -7
  78. package/src/functions/underline.ts +5 -5
  79. package/src/functions/utils/assembleSupSub.ts +1 -1
  80. package/src/functions/vcenter.ts +5 -5
  81. package/src/functions/verb.ts +5 -5
  82. package/src/macros.ts +3 -3
  83. package/src/mathMLTree.ts +6 -10
  84. package/src/parseNode.ts +6 -480
  85. package/src/parseTree.ts +1 -6
  86. package/src/spacingData.ts +2 -1
  87. package/src/stretchy.ts +3 -3
  88. package/src/styles/katex.scss +31 -37
  89. package/src/types/index.ts +12 -0
  90. package/src/types/nodes.ts +456 -0
  91. package/src/units.ts +1 -2
  92. package/src/utils.ts +1 -1
  93. package/src/wide-character.ts +2 -2
package/dist/katex.mjs CHANGED
@@ -3732,10 +3732,8 @@ function getGlobalMetrics(size) {
3732
3732
  var metrics = fontMetricsBySizeIndex[sizeIndex] = {
3733
3733
  cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
3734
3734
  };
3735
- for (var key in sigmasAndXis) {
3736
- if (sigmasAndXis.hasOwnProperty(key)) {
3737
- metrics[key] = sigmasAndXis[key][sizeIndex];
3738
- }
3735
+ for (var key of Object.keys(sigmasAndXis)) {
3736
+ metrics[key] = sigmasAndXis[key][sizeIndex];
3739
3737
  }
3740
3738
  }
3741
3739
  return fontMetricsBySizeIndex[sizeIndex];
@@ -4797,16 +4795,16 @@ var boldSymbol = function boldSymbol(value, mode, type) {
4797
4795
  /**
4798
4796
  * Makes either a mathord or textord in the correct font and color.
4799
4797
  */
4800
- var makeOrd = function makeOrd(group, options, type) {
4798
+ var makeOrd = function makeOrd(group, options) {
4799
+ // Spacing nodes are rendered as textord.
4800
+ var type = group.type === "mathord" ? "mathord" : "textord";
4801
4801
  var mode = group.mode;
4802
4802
  var text = group.text;
4803
4803
  var classes = ["mord"];
4804
- var {
4805
- font,
4806
- fontFamily,
4807
- fontWeight,
4808
- fontShape
4809
- } = options;
4804
+ var font = options.font,
4805
+ fontFamily = options.fontFamily,
4806
+ fontWeight = options.fontWeight,
4807
+ fontShape = options.fontShape;
4810
4808
  // Math mode or Old font (i.e. \rm)
4811
4809
  var useFont = mode === "math" || mode === "text" && !!font;
4812
4810
  var fontOrFamily = useFont ? font : fontFamily;
@@ -4836,7 +4834,7 @@ var makeOrd = function makeOrd(group, options, type) {
4836
4834
  }
4837
4835
  if (lookupSymbol(text, fontName, mode).metrics) {
4838
4836
  return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
4839
- } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") {
4837
+ } else if (Object.prototype.hasOwnProperty.call(ligatures, text) && fontName.slice(0, 10) === "Typewriter") {
4840
4838
  // Deconstruct ligatures in monospace fonts (\texttt, \tt).
4841
4839
  var parts = [];
4842
4840
  for (var i = 0; i < text.length; i++) {
@@ -5055,10 +5053,9 @@ var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) {
5055
5053
  * See VListParam documentation above.
5056
5054
  */
5057
5055
  var makeVList = function makeVList(params, options) {
5058
- var {
5059
- children,
5060
- depth
5061
- } = getVListChildrenAndDepth(params);
5056
+ var _getVListChildrenAndD = getVListChildrenAndDepth(params),
5057
+ children = _getVListChildrenAndD.children,
5058
+ depth = _getVListChildrenAndD.depth;
5062
5059
  // Create a strut that is taller than any list item. The strut is added to
5063
5060
  // each item, where it will determine the item's baseline. Since it has
5064
5061
  // `overflow:hidden`, the strut's top edge will sit on the item's line box's
@@ -5250,7 +5247,10 @@ var svgData = {
5250
5247
  };
5251
5248
  var staticSvg = function staticSvg(value, options) {
5252
5249
  // Create a span with inline SVG for the element.
5253
- var [pathName, width, height] = svgData[value];
5250
+ var _svgData$value = svgData[value],
5251
+ pathName = _svgData$value[0],
5252
+ width = _svgData$value[1],
5253
+ height = _svgData$value[2];
5254
5254
  var path = new PathNode(pathName);
5255
5255
  var svgNode = new SvgNode([path], {
5256
5256
  "width": makeEm(width),
@@ -5260,13 +5260,16 @@ var staticSvg = function staticSvg(value, options) {
5260
5260
  "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
5261
5261
  "preserveAspectRatio": "xMinYMin"
5262
5262
  });
5263
- var span = makeSvgSpan(["overlay"], [svgNode], options);
5263
+ var span = makeSvgSpan(["katex-overlay"], [svgNode], options);
5264
5264
  span.height = height;
5265
5265
  span.style.height = makeEm(height);
5266
5266
  span.style.width = makeEm(width);
5267
5267
  return span;
5268
5268
  };
5269
5269
 
5270
+ /**
5271
+ * Describes spaces between different classes of atoms.
5272
+ */
5270
5273
  var thinspace = {
5271
5274
  number: 3,
5272
5275
  unit: "mu"
@@ -5375,29 +5378,15 @@ var _htmlGroupBuilders = {};
5375
5378
  */
5376
5379
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5377
5380
  var _mathmlGroupBuilders = {};
5378
- function defineFunction(_ref) {
5379
- var {
5380
- type,
5381
- names,
5382
- props,
5383
- handler,
5384
- htmlBuilder,
5385
- mathmlBuilder
5386
- } = _ref;
5387
- // Set default values of functions
5388
- var data = {
5389
- type,
5390
- numArgs: props.numArgs,
5391
- argTypes: props.argTypes,
5392
- allowedInArgument: !!props.allowedInArgument,
5393
- allowedInText: !!props.allowedInText,
5394
- allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
5395
- numOptionalArgs: props.numOptionalArgs || 0,
5396
- infix: !!props.infix,
5397
- primitive: !!props.primitive,
5398
- handler
5399
- };
5381
+ function defineFunction(data) {
5382
+ var type = data.type,
5383
+ names = data.names,
5384
+ htmlBuilder = data.htmlBuilder,
5385
+ mathmlBuilder = data.mathmlBuilder;
5400
5386
  for (var i = 0; i < names.length; ++i) {
5387
+ // To avoid destructuring and rebuilding an object,
5388
+ // we store the entire FunctionDefSpec object,
5389
+ // even though Parser only needs the FunctionSpec fields.
5401
5390
  _functions[names[i]] = data;
5402
5391
  }
5403
5392
  if (type) {
@@ -5414,24 +5403,16 @@ function defineFunction(_ref) {
5414
5403
  * if the function's ParseNode is generated in Parser.js rather than via a
5415
5404
  * stand-alone handler provided to `defineFunction`).
5416
5405
  */
5417
- function defineFunctionBuilders(_ref2) {
5418
- var {
5419
- type,
5420
- htmlBuilder,
5421
- mathmlBuilder
5422
- } = _ref2;
5423
- defineFunction({
5424
- type,
5425
- names: [],
5426
- props: {
5427
- numArgs: 0
5428
- },
5429
- handler() {
5430
- throw new Error('Should never be called.');
5431
- },
5432
- htmlBuilder,
5433
- mathmlBuilder
5434
- });
5406
+ function defineFunctionBuilders(_ref) {
5407
+ var type = _ref.type,
5408
+ htmlBuilder = _ref.htmlBuilder,
5409
+ mathmlBuilder = _ref.mathmlBuilder;
5410
+ if (htmlBuilder) {
5411
+ _htmlGroupBuilders[type] = htmlBuilder;
5412
+ }
5413
+ if (mathmlBuilder) {
5414
+ _mathmlGroupBuilders[type] = mathmlBuilder;
5415
+ }
5435
5416
  }
5436
5417
  var normalizeArgument = function normalizeArgument(arg) {
5437
5418
  return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
@@ -5583,7 +5564,7 @@ var _traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, pre
5583
5564
  }
5584
5565
  if (nonspace) {
5585
5566
  prev.node = node;
5586
- } else if (isRoot && node.hasClass("newline")) {
5567
+ } else if (isRoot && node.hasClass("katex-newline")) {
5587
5568
  prev.node = makeSpan(["leftmost"]); // treat like beginning of line
5588
5569
  }
5589
5570
  prev.insertAfter = (index => n => {
@@ -5663,17 +5644,17 @@ var buildGroup$1 = function buildGroup(group, options, baseOptions) {
5663
5644
  };
5664
5645
  /**
5665
5646
  * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
5666
- * into an unbreakable HTML node of class .base, with proper struts to
5647
+ * into an unbreakable HTML node of class .katex-base, with proper struts to
5667
5648
  * guarantee correct vertical extent. `buildHTML` calls this repeatedly to
5668
5649
  * make up the entire expression as a sequence of unbreakable units.
5669
5650
  */
5670
5651
  function buildHTMLUnbreakable(children, options) {
5671
5652
  // Compute height and depth of this chunk.
5672
- var body = makeSpan(["base"], children, options);
5653
+ var body = makeSpan(["katex-base"], children, options);
5673
5654
  // Add strut, which ensures that the top of the HTML element falls at
5674
5655
  // the height of the expression, and the bottom of the HTML element
5675
5656
  // falls at the depth of the expression.
5676
- var strut = makeSpan(["strut"]);
5657
+ var strut = makeSpan(["katex-strut"]);
5677
5658
  strut.style.height = makeEm(body.height + body.depth);
5678
5659
  if (body.depth) {
5679
5660
  strut.style.verticalAlign = makeEm(-body.depth);
@@ -5695,7 +5676,7 @@ function buildHTML(tree, options) {
5695
5676
  // Build the expression contained in the tree
5696
5677
  var expression = buildExpression$1(tree, options, "root");
5697
5678
  var eqnNum;
5698
- if (expression.length === 2 && expression[1].hasClass("tag")) {
5679
+ if (expression.length === 2 && expression[1].hasClass("katex-tag")) {
5699
5680
  // An environment with automatic equation numbers, e.g. {gather}.
5700
5681
  eqnNum = expression.pop();
5701
5682
  }
@@ -5713,7 +5694,7 @@ function buildHTML(tree, options) {
5713
5694
  // Put any post-operator glue on same line as operator.
5714
5695
  // Watch for \nobreak along the way, and stop at \newline.
5715
5696
  var nobreak = false;
5716
- while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) {
5697
+ while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("katex-newline")) {
5717
5698
  i++;
5718
5699
  parts.push(expression[i]);
5719
5700
  if (expression[i].hasClass("nobreak")) {
@@ -5725,7 +5706,7 @@ function buildHTML(tree, options) {
5725
5706
  children.push(buildHTMLUnbreakable(parts, options));
5726
5707
  parts = [];
5727
5708
  }
5728
- } else if (expression[i].hasClass("newline")) {
5709
+ } else if (expression[i].hasClass("katex-newline")) {
5729
5710
  // Write the line except the newline
5730
5711
  parts.pop();
5731
5712
  if (parts.length > 0) {
@@ -5743,7 +5724,7 @@ function buildHTML(tree, options) {
5743
5724
  var tagChild;
5744
5725
  if (tag) {
5745
5726
  tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true), options);
5746
- tagChild.classes = ["tag"];
5727
+ tagChild.classes = ["katex-tag"];
5747
5728
  children.push(tagChild);
5748
5729
  } else if (eqnNum) {
5749
5730
  children.push(eqnNum);
@@ -5808,10 +5789,10 @@ class MathNode {
5808
5789
  */
5809
5790
  toNode() {
5810
5791
  var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
5811
- for (var attr in this.attributes) {
5812
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
5813
- node.setAttribute(attr, this.attributes[attr]);
5814
- }
5792
+ for (var _ref2 of Object.entries(this.attributes)) {
5793
+ var attr = _ref2[0];
5794
+ var value = _ref2[1];
5795
+ node.setAttribute(attr, value);
5815
5796
  }
5816
5797
  if (this.classes.length > 0) {
5817
5798
  node.className = createClass(this.classes);
@@ -5837,12 +5818,12 @@ class MathNode {
5837
5818
  toMarkup() {
5838
5819
  var markup = "<" + this.type;
5839
5820
  // Add the attributes
5840
- for (var attr in this.attributes) {
5841
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
5842
- markup += " " + attr + "=\"";
5843
- markup += escape(this.attributes[attr]);
5844
- markup += "\"";
5845
- }
5821
+ for (var _ref4 of Object.entries(this.attributes)) {
5822
+ var attr = _ref4[0];
5823
+ var value = _ref4[1];
5824
+ markup += " " + attr + "=\"";
5825
+ markup += escape(value);
5826
+ markup += "\"";
5846
5827
  }
5847
5828
  if (this.classes.length > 0) {
5848
5829
  markup += " class =\"" + escape(createClass(this.classes)) + "\"";
@@ -5972,7 +5953,8 @@ var rowLikeTypes = new Set(["mrow", "mtable"]);
5972
5953
  * optional replacement from symbols.js.
5973
5954
  */
5974
5955
  var makeText = function makeText(text, mode, options) {
5975
- if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) {
5956
+ var _options$fontFamily, _options$font;
5957
+ if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(Object.prototype.hasOwnProperty.call(ligatures, text) && ((options == null || (_options$fontFamily = options.fontFamily) == null ? void 0 : _options$fontFamily.slice(4, 6)) === "tt" || (options == null || (_options$font = options.font) == null ? void 0 : _options$font.slice(4, 6)) === "tt"))) {
5976
5958
  text = symbols[mode][text].replace;
5977
5959
  }
5978
5960
  return new TextNode(text);
@@ -6435,7 +6417,7 @@ class Options {
6435
6417
  */
6436
6418
  sizingClasses(oldOptions) {
6437
6419
  if (oldOptions.size !== this.size) {
6438
- return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
6420
+ return ["katex-sizing", "reset-size" + oldOptions.size, "size" + this.size];
6439
6421
  } else {
6440
6422
  return [];
6441
6423
  }
@@ -6446,7 +6428,7 @@ class Options {
6446
6428
  */
6447
6429
  baseSizingClasses() {
6448
6430
  if (this.size !== Options.BASESIZE) {
6449
- return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
6431
+ return ["katex-sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
6450
6432
  } else {
6451
6433
  return [];
6452
6434
  }
@@ -6683,7 +6665,9 @@ var stretchySvg = function stretchySvg(group, options) {
6683
6665
  if (!data) {
6684
6666
  throw new Error("No SVG data for \"" + label + "\".");
6685
6667
  }
6686
- var [paths, _minWidth, _viewBoxHeight] = data;
6668
+ var paths = data[0],
6669
+ _minWidth = data[1],
6670
+ _viewBoxHeight = data[2];
6687
6671
  var _height2 = _viewBoxHeight / 1000;
6688
6672
  var numSvgChildren = paths.length;
6689
6673
  var widthClasses;
@@ -6724,17 +6708,16 @@ var stretchySvg = function stretchySvg(group, options) {
6724
6708
  }
6725
6709
  }
6726
6710
  return {
6727
- span: makeSpan(["stretchy"], spans, options),
6711
+ span: makeSpan(["katex-stretchy"], spans, options),
6728
6712
  minWidth: _minWidth,
6729
6713
  height: _height2
6730
6714
  };
6731
6715
  }
6732
6716
  } // buildSvgSpan_()
6733
- var {
6734
- span,
6735
- minWidth,
6736
- height
6737
- } = buildSvgSpan_();
6717
+ var _buildSvgSpan_ = buildSvgSpan_(),
6718
+ span = _buildSvgSpan_.span,
6719
+ minWidth = _buildSvgSpan_.minWidth,
6720
+ height = _buildSvgSpan_.height;
6738
6721
  // Note that we are returning span.depth = 0.
6739
6722
  // Any adjustments relative to the baseline must be done in buildHTML.
6740
6723
  span.height = height;
@@ -6749,7 +6732,7 @@ var stretchyEnclose = function stretchyEnclose(inner, label, topPad, bottomPad,
6749
6732
  var img;
6750
6733
  var totalHeight = inner.height + inner.depth + topPad + bottomPad;
6751
6734
  if (/fbox|color|angl/.test(label)) {
6752
- img = makeSpan(["stretchy", label], [], options);
6735
+ img = makeSpan(["katex-stretchy", label], [], options);
6753
6736
  if (label === "fbox") {
6754
6737
  var color = options.color && options.getColor();
6755
6738
  if (color) {
@@ -6795,27 +6778,12 @@ var stretchyEnclose = function stretchyEnclose(inner, label, topPad, bottomPad,
6795
6778
  * `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can
6796
6779
  * pull in `isAtom` without dragging in the ~870-line symbol tables.
6797
6780
  */
6798
- // Some of these have a "-token" suffix since these are also used as `ParseNode`
6799
- // types for raw text tokens, and we want to avoid conflicts with higher-level
6800
- // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
6801
- // looking up the `symbols` map.
6802
- var ATOMS = {
6803
- "bin": 1,
6804
- "close": 1,
6805
- "inner": 1,
6806
- "open": 1,
6807
- "punct": 1,
6808
- "rel": 1
6809
- };
6810
- var NON_ATOMS = {
6811
- "accent-token": 1,
6812
- "mathord": 1,
6813
- "op-token": 1,
6814
- "spacing": 1,
6815
- "textord": 1
6816
- };
6781
+ var atomList = ["bin", "close", "inner", "open", "punct", "rel"];
6782
+ var nonAtomList = ["accent-token", "mathord", "op-token", "spacing", "textord"];
6783
+ var Atoms = new Set(atomList);
6784
+ var NonAtoms = new Set(nonAtomList);
6817
6785
  function isAtom(value) {
6818
- return value in ATOMS;
6786
+ return Atoms.has(value);
6819
6787
  }
6820
6788
 
6821
6789
  /**
@@ -6840,11 +6808,11 @@ function assertSymbolNodeType(node) {
6840
6808
  return typedNode;
6841
6809
  }
6842
6810
  /**
6843
- * Returns the node more strictly typed iff it is of the given type. Otherwise,
6811
+ * Returns the node more strictly typed if it is of the given type. Otherwise,
6844
6812
  * returns null.
6845
6813
  */
6846
6814
  function checkSymbolNodeType(node) {
6847
- if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) {
6815
+ if (node.type === "atom" || NonAtoms.has(node.type)) {
6848
6816
  return node;
6849
6817
  }
6850
6818
  return null;
@@ -6925,7 +6893,7 @@ var htmlBuilder$a = (grp, options) => {
6925
6893
  type: "textord",
6926
6894
  mode: group.mode,
6927
6895
  text: group.label
6928
- }, options, "textord");
6896
+ }, options);
6929
6897
  accent = assertSymbolDomNode(accent);
6930
6898
  // Remove the italic correction of the accent, because it only serves to
6931
6899
  // shift the accent over to a place we don't want.
@@ -6946,7 +6914,7 @@ var htmlBuilder$a = (grp, options) => {
6946
6914
  }
6947
6915
  // Shift the accent over by the skew.
6948
6916
  var left = skew;
6949
- // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
6917
+ // CSS defines `.katex .katex-accent .accent-body:not(.accent-full) { width: 0 }`
6950
6918
  // so that the accent doesn't contribute to the bounding box.
6951
6919
  // We need to shift the character by its width (effectively half
6952
6920
  // its width) to compensate.
@@ -6990,7 +6958,7 @@ var htmlBuilder$a = (grp, options) => {
6990
6958
  }]
6991
6959
  });
6992
6960
  }
6993
- var accentWrap = makeSpan(["mord", "accent"], [accentBody], options);
6961
+ var accentWrap = makeSpan(["mord", "katex-accent"], [accentBody], options);
6994
6962
  if (supSubGroup) {
6995
6963
  // Here, we replace the "base" child of the supsub with our newly
6996
6964
  // generated accent.
@@ -7016,9 +6984,7 @@ var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\t
7016
6984
  defineFunction({
7017
6985
  type: "accent",
7018
6986
  names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"],
7019
- props: {
7020
- numArgs: 1
7021
- },
6987
+ numArgs: 1,
7022
6988
  handler: (context, args) => {
7023
6989
  var base = normalizeArgument(args[0]);
7024
6990
  var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
@@ -7039,13 +7005,11 @@ defineFunction({
7039
7005
  defineFunction({
7040
7006
  type: "accent",
7041
7007
  names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
7042
- props: {
7043
- numArgs: 1,
7044
- allowedInText: true,
7045
- allowedInMath: true,
7046
- // unless in strict mode
7047
- argTypes: ["primitive"]
7048
- },
7008
+ numArgs: 1,
7009
+ allowedInText: true,
7010
+ allowedInMath: true,
7011
+ // unless in strict mode
7012
+ argTypes: ["primitive"],
7049
7013
  handler: (context, args) => {
7050
7014
  var base = args[0];
7051
7015
  var mode = context.parser.mode;
@@ -7061,23 +7025,17 @@ defineFunction({
7061
7025
  isShifty: true,
7062
7026
  base: base
7063
7027
  };
7064
- },
7065
- htmlBuilder: htmlBuilder$a,
7066
- mathmlBuilder: mathmlBuilder$9
7028
+ }
7067
7029
  });
7068
7030
 
7069
7031
  // Horizontal overlap functions
7070
7032
  defineFunction({
7071
7033
  type: "accentUnder",
7072
7034
  names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
7073
- props: {
7074
- numArgs: 1
7075
- },
7035
+ numArgs: 1,
7076
7036
  handler: (_ref, args) => {
7077
- var {
7078
- parser,
7079
- funcName
7080
- } = _ref;
7037
+ var parser = _ref.parser,
7038
+ funcName = _ref.funcName;
7081
7039
  var base = args[0];
7082
7040
  return {
7083
7041
  type: "accentUnder",
@@ -7133,15 +7091,11 @@ defineFunction({
7133
7091
  "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium",
7134
7092
  // The next 3 functions are here only to support the {CD} environment.
7135
7093
  "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
7136
- props: {
7137
- numArgs: 1,
7138
- numOptionalArgs: 1
7139
- },
7094
+ numArgs: 1,
7095
+ numOptionalArgs: 1,
7140
7096
  handler(_ref, args, optArgs) {
7141
- var {
7142
- parser,
7143
- funcName
7144
- } = _ref;
7097
+ var parser = _ref.parser,
7098
+ funcName = _ref.funcName;
7145
7099
  return {
7146
7100
  type: "xArrow",
7147
7101
  mode: parser.mode,
@@ -7273,9 +7227,6 @@ function mathmlBuilder$8(group, options) {
7273
7227
  } else if (group.mclass === "mopen" || group.mclass === "mclose") {
7274
7228
  node.attributes.lspace = "0em";
7275
7229
  node.attributes.rspace = "0em";
7276
- } else if (group.mclass === "minner") {
7277
- node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
7278
- node.attributes.width = "+0.1111em";
7279
7230
  }
7280
7231
  // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
7281
7232
  // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
@@ -7286,21 +7237,16 @@ function mathmlBuilder$8(group, options) {
7286
7237
  defineFunction({
7287
7238
  type: "mclass",
7288
7239
  names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
7289
- props: {
7290
- numArgs: 1,
7291
- primitive: true
7292
- },
7240
+ numArgs: 1,
7241
+ primitive: true,
7293
7242
  handler(_ref, args) {
7294
- var {
7295
- parser,
7296
- funcName
7297
- } = _ref;
7243
+ var parser = _ref.parser,
7244
+ funcName = _ref.funcName;
7298
7245
  var body = args[0];
7299
7246
  return {
7300
7247
  type: "mclass",
7301
7248
  mode: parser.mode,
7302
7249
  mclass: "m" + funcName.slice(5),
7303
- // TODO(kevinb): don't prefix with 'm'
7304
7250
  body: ordargument(body),
7305
7251
  isCharacterBox: isCharacterBox(body)
7306
7252
  };
@@ -7325,13 +7271,9 @@ var binrelClass = arg => {
7325
7271
  defineFunction({
7326
7272
  type: "mclass",
7327
7273
  names: ["\\@binrel"],
7328
- props: {
7329
- numArgs: 2
7330
- },
7274
+ numArgs: 2,
7331
7275
  handler(_ref2, args) {
7332
- var {
7333
- parser
7334
- } = _ref2;
7276
+ var parser = _ref2.parser;
7335
7277
  return {
7336
7278
  type: "mclass",
7337
7279
  mode: parser.mode,
@@ -7345,14 +7287,10 @@ defineFunction({
7345
7287
  defineFunction({
7346
7288
  type: "mclass",
7347
7289
  names: ["\\stackrel", "\\overset", "\\underset"],
7348
- props: {
7349
- numArgs: 2
7350
- },
7290
+ numArgs: 2,
7351
7291
  handler(_ref3, args) {
7352
- var {
7353
- parser,
7354
- funcName
7355
- } = _ref3;
7292
+ var parser = _ref3.parser,
7293
+ funcName = _ref3.funcName;
7356
7294
  var baseArg = args[1];
7357
7295
  var shiftedArg = args[0];
7358
7296
  var mclass;
@@ -7372,12 +7310,16 @@ defineFunction({
7372
7310
  suppressBaseShift: funcName !== "\\stackrel",
7373
7311
  body: ordargument(baseArg)
7374
7312
  };
7375
- var supsub = {
7313
+ var supsub = funcName === "\\underset" ? {
7376
7314
  type: "supsub",
7377
7315
  mode: shiftedArg.mode,
7378
7316
  base: baseOp,
7379
- sup: funcName === "\\underset" ? null : shiftedArg,
7380
- sub: funcName === "\\underset" ? shiftedArg : null
7317
+ sub: shiftedArg
7318
+ } : {
7319
+ type: "supsub",
7320
+ mode: shiftedArg.mode,
7321
+ base: baseOp,
7322
+ sup: shiftedArg
7381
7323
  };
7382
7324
  return {
7383
7325
  type: "mclass",
@@ -7386,9 +7328,7 @@ defineFunction({
7386
7328
  body: [supsub],
7387
7329
  isCharacterBox: isCharacterBox(supsub)
7388
7330
  };
7389
- },
7390
- htmlBuilder: htmlBuilder$9,
7391
- mathmlBuilder: mathmlBuilder$8
7331
+ }
7392
7332
  });
7393
7333
 
7394
7334
  // \pmb is a simulation of bold font.
@@ -7398,14 +7338,10 @@ defineFunction({
7398
7338
  defineFunction({
7399
7339
  type: "pmb",
7400
7340
  names: ["\\pmb"],
7401
- props: {
7402
- numArgs: 1,
7403
- allowedInText: true
7404
- },
7341
+ numArgs: 1,
7342
+ allowedInText: true,
7405
7343
  handler(_ref, args) {
7406
- var {
7407
- parser
7408
- } = _ref;
7344
+ var parser = _ref.parser;
7409
7345
  return {
7410
7346
  type: "pmb",
7411
7347
  mode: parser.mode,
@@ -7647,14 +7583,10 @@ function parseCD(parser) {
7647
7583
  defineFunction({
7648
7584
  type: "cdlabel",
7649
7585
  names: ["\\\\cdleft", "\\\\cdright"],
7650
- props: {
7651
- numArgs: 1
7652
- },
7586
+ numArgs: 1,
7653
7587
  handler(_ref, args) {
7654
- var {
7655
- parser,
7656
- funcName
7657
- } = _ref;
7588
+ var parser = _ref.parser,
7589
+ funcName = _ref.funcName;
7658
7590
  return {
7659
7591
  type: "cdlabel",
7660
7592
  mode: parser.mode,
@@ -7692,13 +7624,9 @@ defineFunction({
7692
7624
  defineFunction({
7693
7625
  type: "cdlabelparent",
7694
7626
  names: ["\\\\cdparent"],
7695
- props: {
7696
- numArgs: 1
7697
- },
7627
+ numArgs: 1,
7698
7628
  handler(_ref2, args) {
7699
- var {
7700
- parser
7701
- } = _ref2;
7629
+ var parser = _ref2.parser;
7702
7630
  return {
7703
7631
  type: "cdlabelparent",
7704
7632
  mode: parser.mode,
@@ -7724,14 +7652,10 @@ defineFunction({
7724
7652
  defineFunction({
7725
7653
  type: "textord",
7726
7654
  names: ["\\@char"],
7727
- props: {
7728
- numArgs: 1,
7729
- allowedInText: true
7730
- },
7655
+ numArgs: 1,
7656
+ allowedInText: true,
7731
7657
  handler(_ref, args) {
7732
- var {
7733
- parser
7734
- } = _ref;
7658
+ var parser = _ref.parser;
7735
7659
  var arg = assertNodeType(args[0], "ordgroup");
7736
7660
  var group = arg.body;
7737
7661
  var number = "";
@@ -7779,15 +7703,11 @@ var mathmlBuilder$7 = (group, options) => {
7779
7703
  defineFunction({
7780
7704
  type: "color",
7781
7705
  names: ["\\textcolor"],
7782
- props: {
7783
- numArgs: 2,
7784
- allowedInText: true,
7785
- argTypes: ["color", "original"]
7786
- },
7706
+ numArgs: 2,
7707
+ allowedInText: true,
7708
+ argTypes: ["color", "original"],
7787
7709
  handler(_ref, args) {
7788
- var {
7789
- parser
7790
- } = _ref;
7710
+ var parser = _ref.parser;
7791
7711
  var color = assertNodeType(args[0], "color-token").color;
7792
7712
  var body = args[1];
7793
7713
  return {
@@ -7803,16 +7723,12 @@ defineFunction({
7803
7723
  defineFunction({
7804
7724
  type: "color",
7805
7725
  names: ["\\color"],
7806
- props: {
7807
- numArgs: 1,
7808
- allowedInText: true,
7809
- argTypes: ["color"]
7810
- },
7726
+ numArgs: 1,
7727
+ allowedInText: true,
7728
+ argTypes: ["color"],
7811
7729
  handler(_ref2, args) {
7812
- var {
7813
- parser,
7814
- breakOnTokenText
7815
- } = _ref2;
7730
+ var parser = _ref2.parser,
7731
+ breakOnTokenText = _ref2.breakOnTokenText;
7816
7732
  var color = assertNodeType(args[0], "color-token").color;
7817
7733
  // Set macro \current@color in current namespace to store the current
7818
7734
  // color, mimicking the behavior of color.sty.
@@ -7827,9 +7743,7 @@ defineFunction({
7827
7743
  color,
7828
7744
  body
7829
7745
  };
7830
- },
7831
- htmlBuilder: htmlBuilder$8,
7832
- mathmlBuilder: mathmlBuilder$7
7746
+ }
7833
7747
  });
7834
7748
 
7835
7749
  // Row breaks within tabular environments, and line breaks at top level
@@ -7837,15 +7751,11 @@ defineFunction({
7837
7751
  defineFunction({
7838
7752
  type: "cr",
7839
7753
  names: ["\\\\"],
7840
- props: {
7841
- numArgs: 0,
7842
- numOptionalArgs: 0,
7843
- allowedInText: true
7844
- },
7754
+ numArgs: 0,
7755
+ numOptionalArgs: 0,
7756
+ allowedInText: true,
7845
7757
  handler(_ref, args, optArgs) {
7846
- var {
7847
- parser
7848
- } = _ref;
7758
+ var parser = _ref.parser;
7849
7759
  var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null;
7850
7760
  var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
7851
7761
  return {
@@ -7860,7 +7770,7 @@ defineFunction({
7860
7770
  htmlBuilder(group, options) {
7861
7771
  var span = makeSpan(["mspace"], [], options);
7862
7772
  if (group.newLine) {
7863
- span.classes.push("newline");
7773
+ span.classes.push("katex-newline");
7864
7774
  if (group.size) {
7865
7775
  span.style.marginTop = makeEm(calculateSize(group.size, options));
7866
7776
  }
@@ -7932,15 +7842,11 @@ defineFunction({
7932
7842
  type: "internal",
7933
7843
  names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
7934
7844
  ],
7935
- props: {
7936
- numArgs: 0,
7937
- allowedInText: true
7938
- },
7845
+ numArgs: 0,
7846
+ allowedInText: true,
7939
7847
  handler(_ref) {
7940
- var {
7941
- parser,
7942
- funcName
7943
- } = _ref;
7848
+ var parser = _ref.parser,
7849
+ funcName = _ref.funcName;
7944
7850
  parser.consumeSpaces();
7945
7851
  var token = parser.fetch();
7946
7852
  if (globalMap[token.text]) {
@@ -7960,16 +7866,12 @@ defineFunction({
7960
7866
  defineFunction({
7961
7867
  type: "internal",
7962
7868
  names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
7963
- props: {
7964
- numArgs: 0,
7965
- allowedInText: true,
7966
- primitive: true
7967
- },
7869
+ numArgs: 0,
7870
+ allowedInText: true,
7871
+ primitive: true,
7968
7872
  handler(_ref2) {
7969
- var {
7970
- parser,
7971
- funcName
7972
- } = _ref2;
7873
+ var parser = _ref2.parser,
7874
+ funcName = _ref2.funcName;
7973
7875
  var tok = parser.gullet.popToken();
7974
7876
  var name = tok.text;
7975
7877
  if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
@@ -8009,9 +7911,8 @@ defineFunction({
8009
7911
  }
8010
7912
  }
8011
7913
  // replacement text, enclosed in '{' and '}' and properly nested
8012
- var {
8013
- tokens
8014
- } = parser.gullet.consumeArg();
7914
+ var _parser$gullet$consum = parser.gullet.consumeArg(),
7915
+ tokens = _parser$gullet$consum.tokens;
8015
7916
  if (insert) {
8016
7917
  tokens.unshift(insert);
8017
7918
  }
@@ -8039,16 +7940,12 @@ defineFunction({
8039
7940
  type: "internal",
8040
7941
  names: ["\\let", "\\\\globallet" // can’t be entered directly
8041
7942
  ],
8042
- props: {
8043
- numArgs: 0,
8044
- allowedInText: true,
8045
- primitive: true
8046
- },
7943
+ numArgs: 0,
7944
+ allowedInText: true,
7945
+ primitive: true,
8047
7946
  handler(_ref3) {
8048
- var {
8049
- parser,
8050
- funcName
8051
- } = _ref3;
7947
+ var parser = _ref3.parser,
7948
+ funcName = _ref3.funcName;
8052
7949
  var name = checkControlSequence(parser.gullet.popToken());
8053
7950
  parser.gullet.consumeSpaces();
8054
7951
  var tok = getRHS(parser);
@@ -8064,16 +7961,12 @@ defineFunction({
8064
7961
  type: "internal",
8065
7962
  names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
8066
7963
  ],
8067
- props: {
8068
- numArgs: 0,
8069
- allowedInText: true,
8070
- primitive: true
8071
- },
7964
+ numArgs: 0,
7965
+ allowedInText: true,
7966
+ primitive: true,
8072
7967
  handler(_ref4) {
8073
- var {
8074
- parser,
8075
- funcName
8076
- } = _ref4;
7968
+ var parser = _ref4.parser,
7969
+ funcName = _ref4.funcName;
8077
7970
  var name = checkControlSequence(parser.gullet.popToken());
8078
7971
  var middle = parser.gullet.popToken();
8079
7972
  var tok = parser.gullet.popToken();
@@ -8808,10 +8701,8 @@ function checkDelimiter(delim, context) {
8808
8701
  defineFunction({
8809
8702
  type: "delimsizing",
8810
8703
  names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
8811
- props: {
8812
- numArgs: 1,
8813
- argTypes: ["primitive"]
8814
- },
8704
+ numArgs: 1,
8705
+ argTypes: ["primitive"],
8815
8706
  handler: (context, args) => {
8816
8707
  var delim = checkDelimiter(args[0], context);
8817
8708
  return {
@@ -8860,10 +8751,8 @@ function assertParsed(group) {
8860
8751
  defineFunction({
8861
8752
  type: "leftright-right",
8862
8753
  names: ["\\right"],
8863
- props: {
8864
- numArgs: 1,
8865
- primitive: true
8866
- },
8754
+ numArgs: 1,
8755
+ primitive: true,
8867
8756
  handler: (context, args) => {
8868
8757
  // \left case below triggers parsing of \right in
8869
8758
  // `const right = parser.parseFunction();`
@@ -8876,17 +8765,15 @@ defineFunction({
8876
8765
  type: "leftright-right",
8877
8766
  mode: context.parser.mode,
8878
8767
  delim: checkDelimiter(args[0], context).text,
8879
- color: color // undefined if not set via \color
8768
+ color // undefined if not set via \color
8880
8769
  };
8881
8770
  }
8882
8771
  });
8883
8772
  defineFunction({
8884
8773
  type: "leftright",
8885
8774
  names: ["\\left"],
8886
- props: {
8887
- numArgs: 1,
8888
- primitive: true
8889
- },
8775
+ numArgs: 1,
8776
+ primitive: true,
8890
8777
  handler: (context, args) => {
8891
8778
  var delim = checkDelimiter(args[0], context);
8892
8779
  var parser = context.parser;
@@ -8985,10 +8872,8 @@ defineFunction({
8985
8872
  defineFunction({
8986
8873
  type: "middle",
8987
8874
  names: ["\\middle"],
8988
- props: {
8989
- numArgs: 1,
8990
- primitive: true
8991
- },
8875
+ numArgs: 1,
8876
+ primitive: true,
8992
8877
  handler: (context, args) => {
8993
8878
  var delim = checkDelimiter(args[0], context);
8994
8879
  if (!context.parser.leftrightDepth) {
@@ -9049,7 +8934,7 @@ var htmlBuilder$7 = (group, options) => {
9049
8934
  // subjects that should get the "tall" treatment.
9050
8935
  var isSingleChar = isCharacterBox(group.body);
9051
8936
  if (label === "sout") {
9052
- img = makeSpan(["stretchy", "sout"]);
8937
+ img = makeSpan(["katex-stretchy", "katex-sout"]);
9053
8938
  img.height = options.fontMetrics().defaultRuleThickness / scale;
9054
8939
  imgShift = -0.5 * options.fontMetrics().xHeight;
9055
8940
  } else if (label === "phase") {
@@ -9224,16 +9109,12 @@ var mathmlBuilder$6 = (group, options) => {
9224
9109
  defineFunction({
9225
9110
  type: "enclose",
9226
9111
  names: ["\\colorbox"],
9227
- props: {
9228
- numArgs: 2,
9229
- allowedInText: true,
9230
- argTypes: ["color", "hbox"]
9231
- },
9112
+ numArgs: 2,
9113
+ allowedInText: true,
9114
+ argTypes: ["color", "hbox"],
9232
9115
  handler(_ref, args, optArgs) {
9233
- var {
9234
- parser,
9235
- funcName
9236
- } = _ref;
9116
+ var parser = _ref.parser,
9117
+ funcName = _ref.funcName;
9237
9118
  var color = assertNodeType(args[0], "color-token").color;
9238
9119
  var body = args[1];
9239
9120
  return {
@@ -9250,16 +9131,12 @@ defineFunction({
9250
9131
  defineFunction({
9251
9132
  type: "enclose",
9252
9133
  names: ["\\fcolorbox"],
9253
- props: {
9254
- numArgs: 3,
9255
- allowedInText: true,
9256
- argTypes: ["color", "color", "hbox"]
9257
- },
9134
+ numArgs: 3,
9135
+ allowedInText: true,
9136
+ argTypes: ["color", "color", "hbox"],
9258
9137
  handler(_ref2, args, optArgs) {
9259
- var {
9260
- parser,
9261
- funcName
9262
- } = _ref2;
9138
+ var parser = _ref2.parser,
9139
+ funcName = _ref2.funcName;
9263
9140
  var borderColor = assertNodeType(args[0], "color-token").color;
9264
9141
  var backgroundColor = assertNodeType(args[1], "color-token").color;
9265
9142
  var body = args[2];
@@ -9271,22 +9148,16 @@ defineFunction({
9271
9148
  borderColor,
9272
9149
  body
9273
9150
  };
9274
- },
9275
- htmlBuilder: htmlBuilder$7,
9276
- mathmlBuilder: mathmlBuilder$6
9151
+ }
9277
9152
  });
9278
9153
  defineFunction({
9279
9154
  type: "enclose",
9280
9155
  names: ["\\fbox"],
9281
- props: {
9282
- numArgs: 1,
9283
- argTypes: ["hbox"],
9284
- allowedInText: true
9285
- },
9156
+ numArgs: 1,
9157
+ argTypes: ["hbox"],
9158
+ allowedInText: true,
9286
9159
  handler(_ref3, args) {
9287
- var {
9288
- parser
9289
- } = _ref3;
9160
+ var parser = _ref3.parser;
9290
9161
  return {
9291
9162
  type: "enclose",
9292
9163
  mode: parser.mode,
@@ -9298,14 +9169,10 @@ defineFunction({
9298
9169
  defineFunction({
9299
9170
  type: "enclose",
9300
9171
  names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
9301
- props: {
9302
- numArgs: 1
9303
- },
9172
+ numArgs: 1,
9304
9173
  handler(_ref4, args) {
9305
- var {
9306
- parser,
9307
- funcName
9308
- } = _ref4;
9174
+ var parser = _ref4.parser,
9175
+ funcName = _ref4.funcName;
9309
9176
  var body = args[0];
9310
9177
  return {
9311
9178
  type: "enclose",
@@ -9313,22 +9180,16 @@ defineFunction({
9313
9180
  label: funcName,
9314
9181
  body
9315
9182
  };
9316
- },
9317
- htmlBuilder: htmlBuilder$7,
9318
- mathmlBuilder: mathmlBuilder$6
9183
+ }
9319
9184
  });
9320
9185
  defineFunction({
9321
9186
  type: "enclose",
9322
9187
  names: ["\\sout"],
9323
- props: {
9324
- numArgs: 1,
9325
- allowedInText: true
9326
- },
9188
+ numArgs: 1,
9189
+ allowedInText: true,
9327
9190
  handler(_ref5, args) {
9328
- var {
9329
- parser,
9330
- funcName
9331
- } = _ref5;
9191
+ var parser = _ref5.parser,
9192
+ funcName = _ref5.funcName;
9332
9193
  if (parser.mode === "math") {
9333
9194
  parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode");
9334
9195
  }
@@ -9339,22 +9200,16 @@ defineFunction({
9339
9200
  label: funcName,
9340
9201
  body
9341
9202
  };
9342
- },
9343
- htmlBuilder: htmlBuilder$7,
9344
- mathmlBuilder: mathmlBuilder$6
9203
+ }
9345
9204
  });
9346
9205
  defineFunction({
9347
9206
  type: "enclose",
9348
9207
  names: ["\\angl"],
9349
- props: {
9350
- numArgs: 1,
9351
- argTypes: ["hbox"],
9352
- allowedInText: false
9353
- },
9208
+ numArgs: 1,
9209
+ argTypes: ["hbox"],
9210
+ allowedInText: false,
9354
9211
  handler(_ref6, args) {
9355
- var {
9356
- parser
9357
- } = _ref6;
9212
+ var parser = _ref6.parser;
9358
9213
  return {
9359
9214
  type: "enclose",
9360
9215
  mode: parser.mode,
@@ -9371,14 +9226,12 @@ defineFunction({
9371
9226
  */
9372
9227
  var _environments = {};
9373
9228
  function defineEnvironment(_ref) {
9374
- var {
9375
- type,
9376
- names,
9377
- props,
9378
- handler,
9379
- htmlBuilder,
9380
- mathmlBuilder
9381
- } = _ref;
9229
+ var type = _ref.type,
9230
+ names = _ref.names,
9231
+ props = _ref.props,
9232
+ handler = _ref.handler,
9233
+ htmlBuilder = _ref.htmlBuilder,
9234
+ mathmlBuilder = _ref.mathmlBuilder;
9382
9235
  // Set default values of environments.
9383
9236
  var data = {
9384
9237
  type,
@@ -9531,18 +9384,16 @@ function getAutoTag(name) {
9531
9384
  * ("text", "display", etc.), then each cell is cast into that style.
9532
9385
  */
9533
9386
  function parseArray(parser, _ref, style) {
9534
- var {
9535
- hskipBeforeAndAfter,
9536
- addJot,
9537
- cols,
9538
- arraystretch,
9539
- colSeparationType,
9540
- autoTag,
9541
- singleRow,
9542
- emptySingleRow,
9543
- maxNumCols,
9544
- leqno
9545
- } = _ref;
9387
+ var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter,
9388
+ addJot = _ref.addJot,
9389
+ cols = _ref.cols,
9390
+ arraystretch = _ref.arraystretch,
9391
+ colSeparationType = _ref.colSeparationType,
9392
+ autoTag = _ref.autoTag,
9393
+ singleRow = _ref.singleRow,
9394
+ emptySingleRow = _ref.emptySingleRow,
9395
+ maxNumCols = _ref.maxNumCols,
9396
+ leqno = _ref.leqno;
9546
9397
  parser.gullet.beginGroup();
9547
9398
  if (!singleRow) {
9548
9399
  // \cr is equivalent to \\ without the optional size argument (see below)
@@ -9901,8 +9752,8 @@ var htmlBuilder$6 = function htmlBuilder(group, options) {
9901
9752
  var tableBody = makeSpan(["mtable"], cols);
9902
9753
  // Add \hline(s), if any.
9903
9754
  if (hlines.length > 0) {
9904
- var line = makeLineSpan("hline", options, ruleThickness);
9905
- var dashes = makeLineSpan("hdashline", options, ruleThickness);
9755
+ var line = makeLineSpan("katex-hline", options, ruleThickness);
9756
+ var dashes = makeLineSpan("katex-hdashline", options, ruleThickness);
9906
9757
  var vListElems = [{
9907
9758
  type: "elem",
9908
9759
  elem: tableBody,
@@ -9937,7 +9788,7 @@ var htmlBuilder$6 = function htmlBuilder(group, options) {
9937
9788
  positionType: "individualShift",
9938
9789
  children: tagSpans
9939
9790
  });
9940
- var tagCol = makeSpan(["tag"], [eqnNumCol], options);
9791
+ var tagCol = makeSpan(["katex-tag"], [eqnNumCol], options);
9941
9792
  return makeFragment([tableBody, tagCol]);
9942
9793
  }
9943
9794
  };
@@ -10069,14 +9920,13 @@ var alignedHandler = function alignedHandler(context, args) {
10069
9920
  validateAmsEnvironmentContext(context);
10070
9921
  }
10071
9922
  var cols = [];
10072
- var separationType = context.envName.includes("at") ? "alignat" : "align";
10073
9923
  var isSplit = context.envName === "split";
10074
9924
  var res = parseArray(context.parser, {
10075
9925
  cols,
10076
9926
  addJot: true,
10077
9927
  autoTag: isSplit ? undefined : getAutoTag(context.envName),
10078
9928
  emptySingleRow: true,
10079
- colSeparationType: separationType,
9929
+ colSeparationType: context.envName.includes("at") ? "alignat" : "align",
10080
9930
  maxNumCols: isSplit ? 2 : undefined,
10081
9931
  leqno: context.parser.settings.leqno
10082
9932
  }, "display");
@@ -10462,11 +10312,9 @@ defineFunction({
10462
10312
  type: "text",
10463
10313
  // Doesn't matter what this is.
10464
10314
  names: ["\\hline", "\\hdashline"],
10465
- props: {
10466
- numArgs: 0,
10467
- allowedInText: true,
10468
- allowedInMath: true
10469
- },
10315
+ numArgs: 0,
10316
+ allowedInText: true,
10317
+ allowedInMath: true,
10470
10318
  handler(context, args) {
10471
10319
  throw new ParseError(context.funcName + " valid only within array environment");
10472
10320
  }
@@ -10479,15 +10327,11 @@ var environments = _environments;
10479
10327
  defineFunction({
10480
10328
  type: "environment",
10481
10329
  names: ["\\begin", "\\end"],
10482
- props: {
10483
- numArgs: 1,
10484
- argTypes: ["text"]
10485
- },
10330
+ numArgs: 1,
10331
+ argTypes: ["text"],
10486
10332
  handler(_ref, args) {
10487
- var {
10488
- parser,
10489
- funcName
10490
- } = _ref;
10333
+ var parser = _ref.parser,
10334
+ funcName = _ref.funcName;
10491
10335
  var nameGroup = args[0];
10492
10336
  if (nameGroup.type !== "ordgroup") {
10493
10337
  throw new ParseError("Invalid environment name", nameGroup);
@@ -10498,16 +10342,15 @@ defineFunction({
10498
10342
  }
10499
10343
  if (funcName === "\\begin") {
10500
10344
  // begin...end is similar to left...right
10501
- if (!environments.hasOwnProperty(envName)) {
10345
+ if (!Object.prototype.hasOwnProperty.call(environments, envName)) {
10502
10346
  throw new ParseError("No such environment: " + envName, nameGroup);
10503
10347
  }
10504
10348
  // Build the environment object. Arguments and other information will
10505
10349
  // be made available to the begin and end methods using properties.
10506
10350
  var env = environments[envName];
10507
- var {
10508
- args: _args,
10509
- optArgs
10510
- } = parser.parseArguments("\\begin{" + envName + "}", env);
10351
+ var _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env),
10352
+ _args = _parser$parseArgument.args,
10353
+ optArgs = _parser$parseArgument.optArgs;
10511
10354
  var context = {
10512
10355
  mode: parser.mode,
10513
10356
  envName,
@@ -10560,20 +10403,13 @@ defineFunction({
10560
10403
  "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
10561
10404
  // aliases, except \bm defined below
10562
10405
  "\\Bbb", "\\bold", "\\frak"],
10563
- props: {
10564
- numArgs: 1,
10565
- allowedInArgument: true
10566
- },
10406
+ numArgs: 1,
10407
+ allowedInArgument: true,
10567
10408
  handler: (_ref, args) => {
10568
- var {
10569
- parser,
10570
- funcName
10571
- } = _ref;
10409
+ var parser = _ref.parser,
10410
+ funcName = _ref.funcName;
10572
10411
  var body = normalizeArgument(args[0]);
10573
- var func = funcName;
10574
- if (func in fontAliases) {
10575
- func = fontAliases[func];
10576
- }
10412
+ var func = funcName in fontAliases ? fontAliases[funcName] : funcName;
10577
10413
  return {
10578
10414
  type: "font",
10579
10415
  mode: parser.mode,
@@ -10587,13 +10423,9 @@ defineFunction({
10587
10423
  defineFunction({
10588
10424
  type: "mclass",
10589
10425
  names: ["\\boldsymbol", "\\bm"],
10590
- props: {
10591
- numArgs: 1
10592
- },
10426
+ numArgs: 1,
10593
10427
  handler: (_ref2, args) => {
10594
- var {
10595
- parser
10596
- } = _ref2;
10428
+ var parser = _ref2.parser;
10597
10429
  var body = args[0];
10598
10430
  // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
10599
10431
  // argument's bin|rel|ord status
@@ -10615,19 +10447,13 @@ defineFunction({
10615
10447
  defineFunction({
10616
10448
  type: "font",
10617
10449
  names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
10618
- props: {
10619
- numArgs: 0,
10620
- allowedInText: true
10621
- },
10450
+ numArgs: 0,
10451
+ allowedInText: true,
10622
10452
  handler: (_ref3, args) => {
10623
- var {
10624
- parser,
10625
- funcName,
10626
- breakOnTokenText
10627
- } = _ref3;
10628
- var {
10629
- mode
10630
- } = parser;
10453
+ var parser = _ref3.parser,
10454
+ funcName = _ref3.funcName,
10455
+ breakOnTokenText = _ref3.breakOnTokenText;
10456
+ var mode = parser.mode;
10631
10457
  var body = parser.parseExpression(true, breakOnTokenText);
10632
10458
  return {
10633
10459
  type: "font",
@@ -10639,9 +10465,7 @@ defineFunction({
10639
10465
  body
10640
10466
  }
10641
10467
  };
10642
- },
10643
- htmlBuilder: htmlBuilder$5,
10644
- mathmlBuilder: mathmlBuilder$4
10468
+ }
10645
10469
  });
10646
10470
 
10647
10471
  var htmlBuilder$4 = (group, options) => {
@@ -10822,15 +10646,11 @@ defineFunction({
10822
10646
  // can’t be entered directly
10823
10647
  "\\\\bracefrac", "\\\\brackfrac" // ditto
10824
10648
  ],
10825
- props: {
10826
- numArgs: 2,
10827
- allowedInArgument: true
10828
- },
10649
+ numArgs: 2,
10650
+ allowedInArgument: true,
10829
10651
  handler: (_ref, args) => {
10830
- var {
10831
- parser,
10832
- funcName
10833
- } = _ref;
10652
+ var parser = _ref.parser,
10653
+ funcName = _ref.funcName;
10834
10654
  var numer = args[0];
10835
10655
  var denom = args[1];
10836
10656
  var hasBarLine;
@@ -10893,16 +10713,12 @@ defineFunction({
10893
10713
  defineFunction({
10894
10714
  type: "infix",
10895
10715
  names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
10896
- props: {
10897
- numArgs: 0,
10898
- infix: true
10899
- },
10716
+ numArgs: 0,
10717
+ infix: true,
10900
10718
  handler(_ref2) {
10901
- var {
10902
- parser,
10903
- funcName,
10904
- token
10905
- } = _ref2;
10719
+ var parser = _ref2.parser,
10720
+ funcName = _ref2.funcName,
10721
+ token = _ref2.token;
10906
10722
  var replaceWith;
10907
10723
  switch (funcName) {
10908
10724
  case "\\over":
@@ -10943,15 +10759,11 @@ var delimFromValue = function delimFromValue(delimString) {
10943
10759
  defineFunction({
10944
10760
  type: "genfrac",
10945
10761
  names: ["\\genfrac"],
10946
- props: {
10947
- numArgs: 6,
10948
- allowedInArgument: true,
10949
- argTypes: ["math", "math", "size", "text", "math", "math"]
10950
- },
10762
+ numArgs: 6,
10763
+ allowedInArgument: true,
10764
+ argTypes: ["math", "math", "size", "text", "math", "math"],
10951
10765
  handler(_ref3, args) {
10952
- var {
10953
- parser
10954
- } = _ref3;
10766
+ var parser = _ref3.parser;
10955
10767
  var numer = args[4];
10956
10768
  var denom = args[5];
10957
10769
  // Look into the parse nodes to get the desired delimiters.
@@ -11000,17 +10812,13 @@ defineFunction({
11000
10812
  defineFunction({
11001
10813
  type: "infix",
11002
10814
  names: ["\\above"],
11003
- props: {
11004
- numArgs: 1,
11005
- argTypes: ["size"],
11006
- infix: true
11007
- },
10815
+ numArgs: 1,
10816
+ argTypes: ["size"],
10817
+ infix: true,
11008
10818
  handler(_ref4, args) {
11009
- var {
11010
- parser,
11011
- funcName,
11012
- token
11013
- } = _ref4;
10819
+ var parser = _ref4.parser;
10820
+ _ref4.funcName;
10821
+ var token = _ref4.token;
11014
10822
  return {
11015
10823
  type: "infix",
11016
10824
  mode: parser.mode,
@@ -11023,15 +10831,11 @@ defineFunction({
11023
10831
  defineFunction({
11024
10832
  type: "genfrac",
11025
10833
  names: ["\\\\abovefrac"],
11026
- props: {
11027
- numArgs: 3,
11028
- argTypes: ["math", "size", "math"]
11029
- },
10834
+ numArgs: 3,
10835
+ argTypes: ["math", "size", "math"],
11030
10836
  handler: (_ref5, args) => {
11031
- var {
11032
- parser,
11033
- funcName
11034
- } = _ref5;
10837
+ var parser = _ref5.parser;
10838
+ _ref5.funcName;
11035
10839
  var numer = args[0];
11036
10840
  var barSize = assertNodeType(args[1], "infix").size;
11037
10841
  if (!barSize) {
@@ -11158,14 +10962,10 @@ var mathmlBuilder$2 = (group, options) => {
11158
10962
  defineFunction({
11159
10963
  type: "horizBrace",
11160
10964
  names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
11161
- props: {
11162
- numArgs: 1
11163
- },
10965
+ numArgs: 1,
11164
10966
  handler(_ref, args) {
11165
- var {
11166
- parser,
11167
- funcName
11168
- } = _ref;
10967
+ var parser = _ref.parser,
10968
+ funcName = _ref.funcName;
11169
10969
  return {
11170
10970
  type: "horizBrace",
11171
10971
  mode: parser.mode,
@@ -11181,15 +10981,11 @@ defineFunction({
11181
10981
  defineFunction({
11182
10982
  type: "href",
11183
10983
  names: ["\\href"],
11184
- props: {
11185
- numArgs: 2,
11186
- argTypes: ["url", "original"],
11187
- allowedInText: true
11188
- },
10984
+ numArgs: 2,
10985
+ argTypes: ["url", "original"],
10986
+ allowedInText: true,
11189
10987
  handler: (_ref, args) => {
11190
- var {
11191
- parser
11192
- } = _ref;
10988
+ var parser = _ref.parser;
11193
10989
  var body = args[1];
11194
10990
  var href = assertNodeType(args[0], "url").url;
11195
10991
  if (!parser.settings.isTrusted({
@@ -11221,15 +11017,11 @@ defineFunction({
11221
11017
  defineFunction({
11222
11018
  type: "href",
11223
11019
  names: ["\\url"],
11224
- props: {
11225
- numArgs: 1,
11226
- argTypes: ["url"],
11227
- allowedInText: true
11228
- },
11020
+ numArgs: 1,
11021
+ argTypes: ["url"],
11022
+ allowedInText: true,
11229
11023
  handler: (_ref2, args) => {
11230
- var {
11231
- parser
11232
- } = _ref2;
11024
+ var parser = _ref2.parser;
11233
11025
  var href = assertNodeType(args[0], "url").url;
11234
11026
  if (!parser.settings.isTrusted({
11235
11027
  command: "\\url",
@@ -11271,16 +11063,12 @@ defineFunction({
11271
11063
  defineFunction({
11272
11064
  type: "hbox",
11273
11065
  names: ["\\hbox"],
11274
- props: {
11275
- numArgs: 1,
11276
- argTypes: ["text"],
11277
- allowedInText: true,
11278
- primitive: true
11279
- },
11066
+ numArgs: 1,
11067
+ argTypes: ["text"],
11068
+ allowedInText: true,
11069
+ primitive: true,
11280
11070
  handler(_ref, args) {
11281
- var {
11282
- parser
11283
- } = _ref;
11071
+ var parser = _ref.parser;
11284
11072
  return {
11285
11073
  type: "hbox",
11286
11074
  mode: parser.mode,
@@ -11299,17 +11087,13 @@ defineFunction({
11299
11087
  defineFunction({
11300
11088
  type: "html",
11301
11089
  names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
11302
- props: {
11303
- numArgs: 2,
11304
- argTypes: ["raw", "original"],
11305
- allowedInText: true
11306
- },
11090
+ numArgs: 2,
11091
+ argTypes: ["raw", "original"],
11092
+ allowedInText: true,
11307
11093
  handler: (_ref, args) => {
11308
- var {
11309
- parser,
11310
- funcName,
11311
- token
11312
- } = _ref;
11094
+ var parser = _ref.parser,
11095
+ funcName = _ref.funcName;
11096
+ _ref.token;
11313
11097
  var value = assertNodeType(args[0], "raw").string;
11314
11098
  var body = args[1];
11315
11099
  if (parser.settings.strict) {
@@ -11378,9 +11162,11 @@ defineFunction({
11378
11162
  classes.push(...group.attributes.class.trim().split(/\s+/));
11379
11163
  }
11380
11164
  var span = makeSpan(classes, elements, options);
11381
- for (var attr in group.attributes) {
11382
- if (attr !== "class" && group.attributes.hasOwnProperty(attr)) {
11383
- span.setAttribute(attr, group.attributes[attr]);
11165
+ for (var _ref3 of Object.entries(group.attributes)) {
11166
+ var attr = _ref3[0];
11167
+ var value = _ref3[1];
11168
+ if (attr !== "class") {
11169
+ span.setAttribute(attr, value);
11384
11170
  }
11385
11171
  }
11386
11172
  return span;
@@ -11393,15 +11179,11 @@ defineFunction({
11393
11179
  defineFunction({
11394
11180
  type: "htmlmathml",
11395
11181
  names: ["\\html@mathml"],
11396
- props: {
11397
- numArgs: 2,
11398
- allowedInArgument: true,
11399
- allowedInText: true
11400
- },
11182
+ numArgs: 2,
11183
+ allowedInArgument: true,
11184
+ allowedInText: true,
11401
11185
  handler: (_ref, args) => {
11402
- var {
11403
- parser
11404
- } = _ref;
11186
+ var parser = _ref.parser;
11405
11187
  return {
11406
11188
  type: "htmlmathml",
11407
11189
  mode: parser.mode,
@@ -11445,16 +11227,12 @@ var sizeData = function sizeData(str) {
11445
11227
  defineFunction({
11446
11228
  type: "includegraphics",
11447
11229
  names: ["\\includegraphics"],
11448
- props: {
11449
- numArgs: 1,
11450
- numOptionalArgs: 1,
11451
- argTypes: ["raw", "url"],
11452
- allowedInText: false
11453
- },
11230
+ numArgs: 1,
11231
+ numOptionalArgs: 1,
11232
+ argTypes: ["raw", "url"],
11233
+ allowedInText: false,
11454
11234
  handler: (_ref, args, optArgs) => {
11455
- var {
11456
- parser
11457
- } = _ref;
11235
+ var parser = _ref.parser;
11458
11236
  var width = {
11459
11237
  number: 0,
11460
11238
  unit: "em"
@@ -11566,17 +11344,13 @@ defineFunction({
11566
11344
  defineFunction({
11567
11345
  type: "kern",
11568
11346
  names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
11569
- props: {
11570
- numArgs: 1,
11571
- argTypes: ["size"],
11572
- primitive: true,
11573
- allowedInText: true
11574
- },
11347
+ numArgs: 1,
11348
+ argTypes: ["size"],
11349
+ primitive: true,
11350
+ allowedInText: true,
11575
11351
  handler(_ref, args) {
11576
- var {
11577
- parser,
11578
- funcName
11579
- } = _ref;
11352
+ var parser = _ref.parser,
11353
+ funcName = _ref.funcName;
11580
11354
  var size = assertNodeType(args[0], "size");
11581
11355
  if (parser.settings.strict) {
11582
11356
  var mathFunction = funcName[1] === 'm'; // \mkern, \mskip
@@ -11614,15 +11388,11 @@ defineFunction({
11614
11388
  defineFunction({
11615
11389
  type: "lap",
11616
11390
  names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
11617
- props: {
11618
- numArgs: 1,
11619
- allowedInText: true
11620
- },
11391
+ numArgs: 1,
11392
+ allowedInText: true,
11621
11393
  handler: (_ref, args) => {
11622
- var {
11623
- parser,
11624
- funcName
11625
- } = _ref;
11394
+ var parser = _ref.parser,
11395
+ funcName = _ref.funcName;
11626
11396
  var body = args[0];
11627
11397
  return {
11628
11398
  type: "lap",
@@ -11637,19 +11407,19 @@ defineFunction({
11637
11407
  if (group.alignment === "clap") {
11638
11408
  // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
11639
11409
  inner = makeSpan([], [buildGroup$1(group.body, options)]);
11640
- // wrap, since CSS will center a .clap > .inner > span
11641
- inner = makeSpan(["inner"], [inner], options);
11410
+ // wrap, since CSS will center a .clap > .katex-inner > span
11411
+ inner = makeSpan(["katex-inner"], [inner], options);
11642
11412
  } else {
11643
- inner = makeSpan(["inner"], [buildGroup$1(group.body, options)]);
11413
+ inner = makeSpan(["katex-inner"], [buildGroup$1(group.body, options)]);
11644
11414
  }
11645
- var fix = makeSpan(["fix"], []);
11415
+ var fix = makeSpan(["katex-fix"], []);
11646
11416
  var node = makeSpan([group.alignment], [inner, fix], options);
11647
11417
  // At this point, we have correctly set horizontal alignment of the
11648
11418
  // two items involved in the lap.
11649
11419
  // Next, use a strut to set the height of the HTML bounding box.
11650
11420
  // Otherwise, a tall argument may be misplaced.
11651
11421
  // This code resolved issue #1153
11652
- var strut = makeSpan(["strut"]);
11422
+ var strut = makeSpan(["katex-strut"]);
11653
11423
  strut.style.height = makeEm(node.height + node.depth);
11654
11424
  if (node.depth) {
11655
11425
  strut.style.verticalAlign = makeEm(-node.depth);
@@ -11657,8 +11427,8 @@ defineFunction({
11657
11427
  node.children.unshift(strut);
11658
11428
  // Next, prevent vertical misplacement when next to something tall.
11659
11429
  // This code resolves issue #1234
11660
- node = makeSpan(["thinbox"], [node], options);
11661
- return makeSpan(["mord", "vbox"], [node], options);
11430
+ node = makeSpan(["katex-thinbox"], [node], options);
11431
+ return makeSpan(["mord", "katex-vbox"], [node], options);
11662
11432
  },
11663
11433
  mathmlBuilder: (group, options) => {
11664
11434
  // mathllap, mathrlap, mathclap
@@ -11676,16 +11446,12 @@ defineFunction({
11676
11446
  defineFunction({
11677
11447
  type: "styling",
11678
11448
  names: ["\\(", "$"],
11679
- props: {
11680
- numArgs: 0,
11681
- allowedInText: true,
11682
- allowedInMath: false
11683
- },
11449
+ numArgs: 0,
11450
+ allowedInText: true,
11451
+ allowedInMath: false,
11684
11452
  handler(_ref, args) {
11685
- var {
11686
- funcName,
11687
- parser
11688
- } = _ref;
11453
+ var funcName = _ref.funcName,
11454
+ parser = _ref.parser;
11689
11455
  var outerMode = parser.mode;
11690
11456
  parser.switchMode("math");
11691
11457
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -11706,11 +11472,9 @@ defineFunction({
11706
11472
  type: "text",
11707
11473
  // Doesn't matter what this is.
11708
11474
  names: ["\\)", "\\]"],
11709
- props: {
11710
- numArgs: 0,
11711
- allowedInText: true,
11712
- allowedInMath: false
11713
- },
11475
+ numArgs: 0,
11476
+ allowedInText: true,
11477
+ allowedInMath: false,
11714
11478
  handler(context, args) {
11715
11479
  throw new ParseError("Mismatched " + context.funcName);
11716
11480
  }
@@ -11733,14 +11497,10 @@ var chooseMathStyle = (group, options) => {
11733
11497
  defineFunction({
11734
11498
  type: "mathchoice",
11735
11499
  names: ["\\mathchoice"],
11736
- props: {
11737
- numArgs: 4,
11738
- primitive: true
11739
- },
11500
+ numArgs: 4,
11501
+ primitive: true,
11740
11502
  handler: (_ref, args) => {
11741
- var {
11742
- parser
11743
- } = _ref;
11503
+ var parser = _ref.parser;
11744
11504
  return {
11745
11505
  type: "mathchoice",
11746
11506
  mode: parser.mode,
@@ -12031,14 +11791,10 @@ var singleCharBigOps = {
12031
11791
  defineFunction({
12032
11792
  type: "op",
12033
11793
  names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"],
12034
- props: {
12035
- numArgs: 0
12036
- },
11794
+ numArgs: 0,
12037
11795
  handler: (_ref, args) => {
12038
- var {
12039
- parser,
12040
- funcName
12041
- } = _ref;
11796
+ var parser = _ref.parser,
11797
+ funcName = _ref.funcName;
12042
11798
  var fName = funcName;
12043
11799
  if (fName.length === 1) {
12044
11800
  fName = singleCharBigOps[fName];
@@ -12055,19 +11811,13 @@ defineFunction({
12055
11811
  htmlBuilder: htmlBuilder$2,
12056
11812
  mathmlBuilder: mathmlBuilder$1
12057
11813
  });
12058
- // Note: calling defineFunction with a type that's already been defined only
12059
- // works because the same htmlBuilder and mathmlBuilder are being used.
12060
11814
  defineFunction({
12061
11815
  type: "op",
12062
11816
  names: ["\\mathop"],
12063
- props: {
12064
- numArgs: 1,
12065
- primitive: true
12066
- },
11817
+ numArgs: 1,
11818
+ primitive: true,
12067
11819
  handler: (_ref2, args) => {
12068
- var {
12069
- parser
12070
- } = _ref2;
11820
+ var parser = _ref2.parser;
12071
11821
  var body = args[0];
12072
11822
  return {
12073
11823
  type: "op",
@@ -12077,9 +11827,7 @@ defineFunction({
12077
11827
  symbol: false,
12078
11828
  body: ordargument(body)
12079
11829
  };
12080
- },
12081
- htmlBuilder: htmlBuilder$2,
12082
- mathmlBuilder: mathmlBuilder$1
11830
+ }
12083
11831
  });
12084
11832
  // There are 2 flags for operators; whether they produce limits in
12085
11833
  // displaystyle, and whether they are symbols and should grow in
@@ -12096,14 +11844,10 @@ var singleCharIntegrals = {
12096
11844
  defineFunction({
12097
11845
  type: "op",
12098
11846
  names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"],
12099
- props: {
12100
- numArgs: 0
12101
- },
11847
+ numArgs: 0,
12102
11848
  handler(_ref3) {
12103
- var {
12104
- parser,
12105
- funcName
12106
- } = _ref3;
11849
+ var parser = _ref3.parser,
11850
+ funcName = _ref3.funcName;
12107
11851
  return {
12108
11852
  type: "op",
12109
11853
  mode: parser.mode,
@@ -12112,22 +11856,16 @@ defineFunction({
12112
11856
  symbol: false,
12113
11857
  name: funcName
12114
11858
  };
12115
- },
12116
- htmlBuilder: htmlBuilder$2,
12117
- mathmlBuilder: mathmlBuilder$1
11859
+ }
12118
11860
  });
12119
11861
  // Limits, not symbols
12120
11862
  defineFunction({
12121
11863
  type: "op",
12122
11864
  names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
12123
- props: {
12124
- numArgs: 0
12125
- },
11865
+ numArgs: 0,
12126
11866
  handler(_ref4) {
12127
- var {
12128
- parser,
12129
- funcName
12130
- } = _ref4;
11867
+ var parser = _ref4.parser,
11868
+ funcName = _ref4.funcName;
12131
11869
  return {
12132
11870
  type: "op",
12133
11871
  mode: parser.mode,
@@ -12136,23 +11874,17 @@ defineFunction({
12136
11874
  symbol: false,
12137
11875
  name: funcName
12138
11876
  };
12139
- },
12140
- htmlBuilder: htmlBuilder$2,
12141
- mathmlBuilder: mathmlBuilder$1
11877
+ }
12142
11878
  });
12143
11879
  // No limits, symbols
12144
11880
  defineFunction({
12145
11881
  type: "op",
12146
11882
  names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"],
12147
- props: {
12148
- numArgs: 0,
12149
- allowedInArgument: true
12150
- },
11883
+ numArgs: 0,
11884
+ allowedInArgument: true,
12151
11885
  handler(_ref5) {
12152
- var {
12153
- parser,
12154
- funcName
12155
- } = _ref5;
11886
+ var parser = _ref5.parser,
11887
+ funcName = _ref5.funcName;
12156
11888
  var fName = funcName;
12157
11889
  if (fName.length === 1) {
12158
11890
  fName = singleCharIntegrals[fName];
@@ -12165,9 +11897,7 @@ defineFunction({
12165
11897
  symbol: true,
12166
11898
  name: fName
12167
11899
  };
12168
- },
12169
- htmlBuilder: htmlBuilder$2,
12170
- mathmlBuilder: mathmlBuilder$1
11900
+ }
12171
11901
  });
12172
11902
 
12173
11903
  // NOTE: Unlike most `htmlBuilder`s, this one handles not only
@@ -12277,14 +12007,10 @@ var mathmlBuilder = (group, options) => {
12277
12007
  defineFunction({
12278
12008
  type: "operatorname",
12279
12009
  names: ["\\operatorname@", "\\operatornamewithlimits"],
12280
- props: {
12281
- numArgs: 1
12282
- },
12010
+ numArgs: 1,
12283
12011
  handler: (_ref, args) => {
12284
- var {
12285
- parser,
12286
- funcName
12287
- } = _ref;
12012
+ var parser = _ref.parser,
12013
+ funcName = _ref.funcName;
12288
12014
  var body = args[0];
12289
12015
  return {
12290
12016
  type: "operatorname",
@@ -12316,13 +12042,9 @@ defineFunctionBuilders({
12316
12042
  defineFunction({
12317
12043
  type: "overline",
12318
12044
  names: ["\\overline"],
12319
- props: {
12320
- numArgs: 1
12321
- },
12045
+ numArgs: 1,
12322
12046
  handler(_ref, args) {
12323
- var {
12324
- parser
12325
- } = _ref;
12047
+ var parser = _ref.parser;
12326
12048
  var body = args[0];
12327
12049
  return {
12328
12050
  type: "overline",
@@ -12354,7 +12076,7 @@ defineFunction({
12354
12076
  size: defaultRuleThickness
12355
12077
  }]
12356
12078
  });
12357
- return makeSpan(["mord", "overline"], [vlist], options);
12079
+ return makeSpan(["mord", "katex-overline"], [vlist], options);
12358
12080
  },
12359
12081
  mathmlBuilder(group, options) {
12360
12082
  var operator = new MathNode("mo", [new TextNode("\u203e")]);
@@ -12368,14 +12090,10 @@ defineFunction({
12368
12090
  defineFunction({
12369
12091
  type: "phantom",
12370
12092
  names: ["\\phantom"],
12371
- props: {
12372
- numArgs: 1,
12373
- allowedInText: true
12374
- },
12093
+ numArgs: 1,
12094
+ allowedInText: true,
12375
12095
  handler: (_ref, args) => {
12376
- var {
12377
- parser
12378
- } = _ref;
12096
+ var parser = _ref.parser;
12379
12097
  var body = args[0];
12380
12098
  return {
12381
12099
  type: "phantom",
@@ -12398,14 +12116,10 @@ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
12398
12116
  defineFunction({
12399
12117
  type: "vphantom",
12400
12118
  names: ["\\vphantom"],
12401
- props: {
12402
- numArgs: 1,
12403
- allowedInText: true
12404
- },
12119
+ numArgs: 1,
12120
+ allowedInText: true,
12405
12121
  handler: (_ref2, args) => {
12406
- var {
12407
- parser
12408
- } = _ref2;
12122
+ var parser = _ref2.parser;
12409
12123
  var body = args[0];
12410
12124
  return {
12411
12125
  type: "vphantom",
@@ -12414,8 +12128,8 @@ defineFunction({
12414
12128
  };
12415
12129
  },
12416
12130
  htmlBuilder: (group, options) => {
12417
- var inner = makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]);
12418
- var fix = makeSpan(["fix"], []);
12131
+ var inner = makeSpan(["katex-inner"], [buildGroup$1(group.body, options.withPhantom())]);
12132
+ var fix = makeSpan(["katex-fix"], []);
12419
12133
  return makeSpan(["mord", "rlap"], [inner, fix], options);
12420
12134
  },
12421
12135
  mathmlBuilder: (group, options) => {
@@ -12431,15 +12145,11 @@ defineFunction({
12431
12145
  defineFunction({
12432
12146
  type: "raisebox",
12433
12147
  names: ["\\raisebox"],
12434
- props: {
12435
- numArgs: 2,
12436
- argTypes: ["size", "hbox"],
12437
- allowedInText: true
12438
- },
12148
+ numArgs: 2,
12149
+ argTypes: ["size", "hbox"],
12150
+ allowedInText: true,
12439
12151
  handler(_ref, args) {
12440
- var {
12441
- parser
12442
- } = _ref;
12152
+ var parser = _ref.parser;
12443
12153
  var amount = assertNodeType(args[0], "size").value;
12444
12154
  var body = args[1];
12445
12155
  return {
@@ -12472,15 +12182,11 @@ defineFunction({
12472
12182
  defineFunction({
12473
12183
  type: "internal",
12474
12184
  names: ["\\relax"],
12475
- props: {
12476
- numArgs: 0,
12477
- allowedInText: true,
12478
- allowedInArgument: true
12479
- },
12185
+ numArgs: 0,
12186
+ allowedInText: true,
12187
+ allowedInArgument: true,
12480
12188
  handler(_ref) {
12481
- var {
12482
- parser
12483
- } = _ref;
12189
+ var parser = _ref.parser;
12484
12190
  return {
12485
12191
  type: "internal",
12486
12192
  mode: parser.mode
@@ -12491,17 +12197,13 @@ defineFunction({
12491
12197
  defineFunction({
12492
12198
  type: "rule",
12493
12199
  names: ["\\rule"],
12494
- props: {
12495
- numArgs: 2,
12496
- numOptionalArgs: 1,
12497
- allowedInText: true,
12498
- allowedInMath: true,
12499
- argTypes: ["size", "size", "size"]
12500
- },
12200
+ numArgs: 2,
12201
+ numOptionalArgs: 1,
12202
+ allowedInText: true,
12203
+ allowedInMath: true,
12204
+ argTypes: ["size", "size", "size"],
12501
12205
  handler(_ref, args, optArgs) {
12502
- var {
12503
- parser
12504
- } = _ref;
12206
+ var parser = _ref.parser;
12505
12207
  var shift = optArgs[0];
12506
12208
  var width = assertNodeType(args[0], "size");
12507
12209
  var height = assertNodeType(args[1], "size");
@@ -12515,7 +12217,7 @@ defineFunction({
12515
12217
  },
12516
12218
  htmlBuilder(group, options) {
12517
12219
  // Make an empty span for the rule
12518
- var rule = makeSpan(["mord", "rule"], [], options);
12220
+ var rule = makeSpan(["mord", "katex-rule"], [], options);
12519
12221
  // Calculate the shift, width, and height of the rule, and account for units
12520
12222
  var width = calculateSize(group.width, options);
12521
12223
  var height = calculateSize(group.height, options);
@@ -12561,7 +12263,7 @@ function sizingGroup(value, options, baseOptions) {
12561
12263
  // Add size-resetting classes to the inner list and set maxFontSize
12562
12264
  // manually. Handle nested size changes.
12563
12265
  for (var i = 0; i < inner.length; i++) {
12564
- var pos = inner[i].classes.indexOf("sizing");
12266
+ var pos = inner[i].classes.indexOf("katex-sizing");
12565
12267
  if (pos < 0) {
12566
12268
  Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
12567
12269
  } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
@@ -12586,16 +12288,12 @@ var htmlBuilder = (group, options) => {
12586
12288
  defineFunction({
12587
12289
  type: "sizing",
12588
12290
  names: sizeFuncs,
12589
- props: {
12590
- numArgs: 0,
12591
- allowedInText: true
12592
- },
12291
+ numArgs: 0,
12292
+ allowedInText: true,
12593
12293
  handler: (_ref, args) => {
12594
- var {
12595
- breakOnTokenText,
12596
- funcName,
12597
- parser
12598
- } = _ref;
12294
+ var breakOnTokenText = _ref.breakOnTokenText,
12295
+ funcName = _ref.funcName,
12296
+ parser = _ref.parser;
12599
12297
  var body = parser.parseExpression(false, breakOnTokenText);
12600
12298
  return {
12601
12299
  type: "sizing",
@@ -12624,15 +12322,11 @@ defineFunction({
12624
12322
  defineFunction({
12625
12323
  type: "smash",
12626
12324
  names: ["\\smash"],
12627
- props: {
12628
- numArgs: 1,
12629
- numOptionalArgs: 1,
12630
- allowedInText: true
12631
- },
12325
+ numArgs: 1,
12326
+ numOptionalArgs: 1,
12327
+ allowedInText: true,
12632
12328
  handler: (_ref, args, optArgs) => {
12633
- var {
12634
- parser
12635
- } = _ref;
12329
+ var parser = _ref.parser;
12636
12330
  var smashHeight = false;
12637
12331
  var smashDepth = false;
12638
12332
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -12680,7 +12374,7 @@ defineFunction({
12680
12374
  }
12681
12375
  if (group.smashHeight && group.smashDepth) {
12682
12376
  // Symmetric \smash can stay in inline layout.
12683
- return makeSpan(["mord", "smash"], [node], options);
12377
+ return makeSpan(["mord", "katex-smash"], [node], options);
12684
12378
  }
12685
12379
  // In order to influence makeVList for asymmetric smashing, we have to
12686
12380
  // reset the children.
@@ -12723,14 +12417,10 @@ defineFunction({
12723
12417
  defineFunction({
12724
12418
  type: "sqrt",
12725
12419
  names: ["\\sqrt"],
12726
- props: {
12727
- numArgs: 1,
12728
- numOptionalArgs: 1
12729
- },
12420
+ numArgs: 1,
12421
+ numOptionalArgs: 1,
12730
12422
  handler(_ref, args, optArgs) {
12731
- var {
12732
- parser
12733
- } = _ref;
12423
+ var parser = _ref.parser;
12734
12424
  var index = optArgs[0];
12735
12425
  var body = args[0];
12736
12426
  return {
@@ -12763,11 +12453,10 @@ defineFunction({
12763
12453
  var lineClearance = theta + phi / 4;
12764
12454
  var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta;
12765
12455
  // Create a sqrt SVG of the required minimum size
12766
- var {
12767
- span: img,
12768
- ruleWidth,
12769
- advanceWidth
12770
- } = makeSqrtImage(minDelimiterHeight, options);
12456
+ var _makeSqrtImage = makeSqrtImage(minDelimiterHeight, options),
12457
+ img = _makeSqrtImage.span,
12458
+ ruleWidth = _makeSqrtImage.ruleWidth,
12459
+ advanceWidth = _makeSqrtImage.advanceWidth;
12771
12460
  var delimDepth = img.height - ruleWidth;
12772
12461
  // Adjust the clearance based on the delimiter size
12773
12462
  if (delimDepth > inner.height + inner.depth + lineClearance) {
@@ -12815,15 +12504,13 @@ defineFunction({
12815
12504
  });
12816
12505
  // Add a class surrounding it so we can add on the appropriate
12817
12506
  // kerning
12818
- var rootVListWrap = makeSpan(["root"], [rootVList]);
12507
+ var rootVListWrap = makeSpan(["katex-root"], [rootVList]);
12819
12508
  return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
12820
12509
  }
12821
12510
  },
12822
12511
  mathmlBuilder(group, options) {
12823
- var {
12824
- body,
12825
- index
12826
- } = group;
12512
+ var body = group.body,
12513
+ index = group.index;
12827
12514
  return index ? new MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new MathNode("msqrt", [buildGroup(body, options)]);
12828
12515
  }
12829
12516
  });
@@ -12840,17 +12527,13 @@ function isStyleStr(s) {
12840
12527
  defineFunction({
12841
12528
  type: "styling",
12842
12529
  names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
12843
- props: {
12844
- numArgs: 0,
12845
- allowedInText: true,
12846
- primitive: true
12847
- },
12530
+ numArgs: 0,
12531
+ allowedInText: true,
12532
+ primitive: true,
12848
12533
  handler(_ref, args) {
12849
- var {
12850
- breakOnTokenText,
12851
- funcName,
12852
- parser
12853
- } = _ref;
12534
+ var breakOnTokenText = _ref.breakOnTokenText,
12535
+ funcName = _ref.funcName,
12536
+ parser = _ref.parser;
12854
12537
  // parse out the implicit body
12855
12538
  var body = parser.parseExpression(true, breakOnTokenText);
12856
12539
  // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g.
@@ -12940,11 +12623,9 @@ defineFunctionBuilders({
12940
12623
  if (builderDelegate) {
12941
12624
  return builderDelegate(group, options);
12942
12625
  }
12943
- var {
12944
- base: valueBase,
12945
- sup: valueSup,
12946
- sub: valueSub
12947
- } = group;
12626
+ var valueBase = group.base,
12627
+ valueSup = group.sup,
12628
+ valueSub = group.sub;
12948
12629
  var base = buildGroup$1(valueBase, options);
12949
12630
  var supm;
12950
12631
  var subm;
@@ -13148,7 +12829,7 @@ var defaultVariant = {
13148
12829
  defineFunctionBuilders({
13149
12830
  type: "mathord",
13150
12831
  htmlBuilder(group, options) {
13151
- return makeOrd(group, options, "mathord");
12832
+ return makeOrd(group, options);
13152
12833
  },
13153
12834
  mathmlBuilder(group, options) {
13154
12835
  var node = new MathNode("mi", [makeText(group.text, group.mode, options)]);
@@ -13162,7 +12843,7 @@ defineFunctionBuilders({
13162
12843
  defineFunctionBuilders({
13163
12844
  type: "textord",
13164
12845
  htmlBuilder(group, options) {
13165
- return makeOrd(group, options, "textord");
12846
+ return makeOrd(group, options);
13166
12847
  },
13167
12848
  mathmlBuilder(group, options) {
13168
12849
  var text = makeText(group.text, group.mode, options);
@@ -13185,55 +12866,48 @@ defineFunctionBuilders({
13185
12866
  });
13186
12867
 
13187
12868
  // A map of CSS-based spacing functions to their CSS class.
13188
- var cssSpace = {
13189
- "\\nobreak": "nobreak",
13190
- "\\allowbreak": "allowbreak"
13191
- };
12869
+ var cssSpace = new Map([["\\nobreak", "nobreak"], ["\\allowbreak", "allowbreak"]]);
13192
12870
  // A lookup table to determine whether a spacing function/symbol should be
13193
12871
  // treated like a regular space character. If a symbol or command is a key
13194
12872
  // in this table, then it should be a regular space character. Furthermore,
13195
12873
  // the associated value may have a `className` specifying an extra CSS class
13196
12874
  // to add to the created `span`.
13197
- var regularSpace = {
13198
- " ": {},
13199
- "\\ ": {},
13200
- "~": {
13201
- className: "nobreak"
13202
- },
13203
- "\\space": {},
13204
- "\\nobreakspace": {
13205
- className: "nobreak"
13206
- }
13207
- };
12875
+ var regularSpace = new Map([[" ", {}], ["\\ ", {}], ["~", {
12876
+ className: "nobreak"
12877
+ }], ["\\space", {}], ["\\nobreakspace", {
12878
+ className: "nobreak"
12879
+ }]]);
13208
12880
  // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
13209
12881
  // src/symbols.js.
13210
12882
  defineFunctionBuilders({
13211
12883
  type: "spacing",
13212
12884
  htmlBuilder(group, options) {
13213
- if (regularSpace.hasOwnProperty(group.text)) {
13214
- var className = regularSpace[group.text].className || "";
12885
+ var regularSpaceItem = regularSpace.get(group.text);
12886
+ var cssSpaceClass = cssSpace.get(group.text);
12887
+ if (regularSpaceItem) {
12888
+ var className = regularSpaceItem.className || "";
13215
12889
  // Spaces are generated by adding an actual space. Each of these
13216
12890
  // things has an entry in the symbols table, so these will be turned
13217
12891
  // into appropriate outputs.
13218
12892
  if (group.mode === "text") {
13219
- var ord = makeOrd(group, options, "textord");
12893
+ var ord = makeOrd(group, options);
13220
12894
  ord.classes.push(className);
13221
12895
  return ord;
13222
12896
  } else {
13223
12897
  return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options);
13224
12898
  }
13225
- } else if (cssSpace.hasOwnProperty(group.text)) {
12899
+ } else if (cssSpaceClass) {
13226
12900
  // Spaces based on just a CSS class.
13227
- return makeSpan(["mspace", cssSpace[group.text]], [], options);
12901
+ return makeSpan(["mspace", cssSpaceClass], [], options);
13228
12902
  } else {
13229
12903
  throw new ParseError("Unknown type of space \"" + group.text + "\"");
13230
12904
  }
13231
12905
  },
13232
12906
  mathmlBuilder(group, options) {
13233
12907
  var node;
13234
- if (regularSpace.hasOwnProperty(group.text)) {
12908
+ if (regularSpace.has(group.text)) {
13235
12909
  node = new MathNode("mtext", [new TextNode("\u00a0")]);
13236
- } else if (cssSpace.hasOwnProperty(group.text)) {
12910
+ } else if (cssSpace.has(group.text)) {
13237
12911
  // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
13238
12912
  return new MathNode("mspace");
13239
12913
  } else {
@@ -13303,17 +12977,13 @@ defineFunction({
13303
12977
  "\\textbf", "\\textmd",
13304
12978
  // Font Shapes
13305
12979
  "\\textit", "\\textup", "\\emph"],
13306
- props: {
13307
- numArgs: 1,
13308
- argTypes: ["text"],
13309
- allowedInArgument: true,
13310
- allowedInText: true
13311
- },
12980
+ numArgs: 1,
12981
+ argTypes: ["text"],
12982
+ allowedInArgument: true,
12983
+ allowedInText: true,
13312
12984
  handler(_ref, args) {
13313
- var {
13314
- parser,
13315
- funcName
13316
- } = _ref;
12985
+ var parser = _ref.parser,
12986
+ funcName = _ref.funcName;
13317
12987
  var body = args[0];
13318
12988
  return {
13319
12989
  type: "text",
@@ -13336,14 +13006,10 @@ defineFunction({
13336
13006
  defineFunction({
13337
13007
  type: "underline",
13338
13008
  names: ["\\underline"],
13339
- props: {
13340
- numArgs: 1,
13341
- allowedInText: true
13342
- },
13009
+ numArgs: 1,
13010
+ allowedInText: true,
13343
13011
  handler(_ref, args) {
13344
- var {
13345
- parser
13346
- } = _ref;
13012
+ var parser = _ref.parser;
13347
13013
  return {
13348
13014
  type: "underline",
13349
13015
  mode: parser.mode,
@@ -13375,7 +13041,7 @@ defineFunction({
13375
13041
  elem: innerGroup
13376
13042
  }]
13377
13043
  });
13378
- return makeSpan(["mord", "underline"], [vlist], options);
13044
+ return makeSpan(["mord", "katex-underline"], [vlist], options);
13379
13045
  },
13380
13046
  mathmlBuilder(group, options) {
13381
13047
  var operator = new MathNode("mo", [new TextNode("\u203e")]);
@@ -13390,16 +13056,12 @@ defineFunction({
13390
13056
  defineFunction({
13391
13057
  type: "vcenter",
13392
13058
  names: ["\\vcenter"],
13393
- props: {
13394
- numArgs: 1,
13395
- argTypes: ["original"],
13396
- // In LaTeX, \vcenter can act only on a box.
13397
- allowedInText: false
13398
- },
13059
+ numArgs: 1,
13060
+ argTypes: ["original"],
13061
+ // In LaTeX, \vcenter can act only on a box.
13062
+ allowedInText: false,
13399
13063
  handler(_ref, args) {
13400
- var {
13401
- parser
13402
- } = _ref;
13064
+ var parser = _ref.parser;
13403
13065
  return {
13404
13066
  type: "vcenter",
13405
13067
  mode: parser.mode,
@@ -13432,10 +13094,8 @@ defineFunction({
13432
13094
  defineFunction({
13433
13095
  type: "verb",
13434
13096
  names: ["\\verb"],
13435
- props: {
13436
- numArgs: 0,
13437
- allowedInText: true
13438
- },
13097
+ numArgs: 0,
13098
+ allowedInText: true,
13439
13099
  handler(context, args, optArgs) {
13440
13100
  // \verb and \verb* are dealt with directly in Parser.js.
13441
13101
  // If we end up here, it's because of a failure to match the two delimiters
@@ -13624,13 +13284,11 @@ class Namespace {
13624
13284
  throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
13625
13285
  }
13626
13286
  var undefs = this.undefStack.pop();
13627
- for (var undef in undefs) {
13628
- if (undefs.hasOwnProperty(undef)) {
13629
- if (undefs[undef] == null) {
13630
- delete this.current[undef];
13631
- } else {
13632
- this.current[undef] = undefs[undef];
13633
- }
13287
+ for (var key of Object.keys(undefs)) {
13288
+ if (undefs[key] === undefined) {
13289
+ delete this.current[key];
13290
+ } else {
13291
+ this.current[key] = undefs[key];
13634
13292
  }
13635
13293
  }
13636
13294
  }
@@ -13648,7 +13306,7 @@ class Namespace {
13648
13306
  * `get(name) != null`.
13649
13307
  */
13650
13308
  has(name) {
13651
- return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name);
13309
+ return Object.prototype.hasOwnProperty.call(this.current, name) || Object.prototype.hasOwnProperty.call(this.builtins, name);
13652
13310
  }
13653
13311
  /**
13654
13312
  * Get the current value of a name, or `undefined` if there is no value.
@@ -13659,7 +13317,7 @@ class Namespace {
13659
13317
  * `if (namespace.has(...))`.
13660
13318
  */
13661
13319
  get(name) {
13662
- if (this.current.hasOwnProperty(name)) {
13320
+ if (Object.prototype.hasOwnProperty.call(this.current, name)) {
13663
13321
  return this.current[name];
13664
13322
  } else {
13665
13323
  return this.builtins[name];
@@ -13692,7 +13350,7 @@ class Namespace {
13692
13350
  // unless an undo is already in place, in which case that older
13693
13351
  // value is the correct one.
13694
13352
  var top = this.undefStack[this.undefStack.length - 1];
13695
- if (top && !top.hasOwnProperty(name)) {
13353
+ if (top && !Object.prototype.hasOwnProperty.call(top, name)) {
13696
13354
  top[name] = this.current[name];
13697
13355
  }
13698
13356
  }
@@ -14707,16 +14365,14 @@ class MacroExpander {
14707
14365
  return null;
14708
14366
  }
14709
14367
  start = this.popToken(); // don't include [ in tokens
14710
- ({
14711
- tokens,
14712
- end
14713
- } = this.consumeArg(["]"]));
14368
+ var _this$consumeArg = this.consumeArg(["]"]);
14369
+ tokens = _this$consumeArg.tokens;
14370
+ end = _this$consumeArg.end;
14714
14371
  } else {
14715
- ({
14716
- tokens,
14717
- start,
14718
- end
14719
- } = this.consumeArg());
14372
+ var _this$consumeArg2 = this.consumeArg();
14373
+ tokens = _this$consumeArg2.tokens;
14374
+ start = _this$consumeArg2.start;
14375
+ end = _this$consumeArg2.end;
14720
14376
  }
14721
14377
  // indicate the end of an argument
14722
14378
  this.pushToken(new Token("EOF", end.loc));
@@ -15014,14 +14670,17 @@ class MacroExpander {
15014
14670
  * `implicitCommands`.
15015
14671
  */
15016
14672
  isDefined(name) {
15017
- return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name);
14673
+ return this.macros.has(name) || Object.prototype.hasOwnProperty.call(functions, name) || Object.prototype.hasOwnProperty.call(symbols.math, name) || Object.prototype.hasOwnProperty.call(symbols.text, name) || Object.prototype.hasOwnProperty.call(implicitCommands, name);
15018
14674
  }
15019
14675
  /**
15020
14676
  * Determine whether a command is expandable.
15021
14677
  */
15022
14678
  isExpandable(name) {
15023
14679
  var macro = this.macros.get(name);
15024
- return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive;
14680
+ if (macro != null) {
14681
+ return typeof macro === "string" || typeof macro === "function" || !macro.unexpandable;
14682
+ }
14683
+ return Object.prototype.hasOwnProperty.call(functions, name) && !functions[name].primitive;
15025
14684
  }
15026
14685
  }
15027
14686
 
@@ -15812,7 +15471,7 @@ class Parser {
15812
15471
  // \left(x\right)^2 work correctly.
15813
15472
  var base = this.parseGroup("atom", breakOnTokenText);
15814
15473
  // Internal nodes (e.g. \relax) cannot support super/subscripts.
15815
- // Instead we will pick up super/subscripts with blank base next round.
15474
+ // Instead, we will pick up super/subscripts with blank base next round.
15816
15475
  if ((base == null ? void 0 : base.type) === "internal") {
15817
15476
  return base;
15818
15477
  }
@@ -15820,7 +15479,6 @@ class Parser {
15820
15479
  if (this.mode === "text") {
15821
15480
  return base;
15822
15481
  }
15823
- // Note that base may be empty (i.e. null) at this point.
15824
15482
  var superscript;
15825
15483
  var subscript;
15826
15484
  while (true) {
@@ -15831,8 +15489,7 @@ class Parser {
15831
15489
  if (lex.text === "\\limits" || lex.text === "\\nolimits") {
15832
15490
  // We got a limit control
15833
15491
  if (base && base.type === "op") {
15834
- var limits = lex.text === "\\limits";
15835
- base.limits = limits;
15492
+ base.limits = lex.text === "\\limits";
15836
15493
  base.alwaysHandleSupSub = true;
15837
15494
  } else if (base && base.type === "operatorname") {
15838
15495
  if (base.alwaysHandleSupSub) {
@@ -15927,15 +15584,28 @@ class Parser {
15927
15584
  }
15928
15585
  // Base must be set if superscript or subscript are set per logic above,
15929
15586
  // but need to check here for type check to pass.
15930
- if (superscript || subscript) {
15931
- // If we got either a superscript or subscript, create a supsub
15587
+ if (superscript && subscript) {
15932
15588
  return {
15933
15589
  type: "supsub",
15934
15590
  mode: this.mode,
15935
- base: base,
15591
+ base,
15936
15592
  sup: superscript,
15937
15593
  sub: subscript
15938
15594
  };
15595
+ } else if (superscript) {
15596
+ return {
15597
+ type: "supsub",
15598
+ mode: this.mode,
15599
+ base,
15600
+ sup: superscript
15601
+ };
15602
+ } else if (subscript) {
15603
+ return {
15604
+ type: "supsub",
15605
+ mode: this.mode,
15606
+ base,
15607
+ sub: subscript
15608
+ };
15939
15609
  } else {
15940
15610
  // Otherwise return the original body
15941
15611
  return base;
@@ -15954,15 +15624,16 @@ class Parser {
15954
15624
  this.consume(); // consume command token
15955
15625
  if (name && name !== "atom" && !funcData.allowedInArgument) {
15956
15626
  throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
15627
+ // Treat undefined allowedInText as false.
15957
15628
  } else if (this.mode === "text" && !funcData.allowedInText) {
15958
15629
  throw new ParseError("Can't use function '" + func + "' in text mode", token);
15630
+ // Treat undefined allowedInMath as true.
15959
15631
  } else if (this.mode === "math" && funcData.allowedInMath === false) {
15960
15632
  throw new ParseError("Can't use function '" + func + "' in math mode", token);
15961
15633
  }
15962
- var {
15963
- args,
15964
- optArgs
15965
- } = this.parseArguments(func, funcData);
15634
+ var _this$parseArguments = this.parseArguments(func, funcData),
15635
+ args = _this$parseArguments.args,
15636
+ optArgs = _this$parseArguments.optArgs;
15966
15637
  return this.callFunction(func, args, optArgs, token, breakOnTokenText);
15967
15638
  }
15968
15639
  /**
@@ -15988,7 +15659,9 @@ class Parser {
15988
15659
  parseArguments(func,
15989
15660
  // Should look like "\name" or "\begin{name}".
15990
15661
  funcData) {
15991
- var totalArgs = funcData.numArgs + funcData.numOptionalArgs;
15662
+ var _funcData$numOptional;
15663
+ var numOptionalArgs = (_funcData$numOptional = funcData.numOptionalArgs) != null ? _funcData$numOptional : 0;
15664
+ var totalArgs = funcData.numArgs + numOptionalArgs;
15992
15665
  if (totalArgs === 0) {
15993
15666
  return {
15994
15667
  args: [],
@@ -15998,8 +15671,9 @@ class Parser {
15998
15671
  var args = [];
15999
15672
  var optArgs = [];
16000
15673
  for (var i = 0; i < totalArgs; i++) {
16001
- var argType = funcData.argTypes && funcData.argTypes[i];
16002
- var isOptional = i < funcData.numOptionalArgs;
15674
+ var _funcData$argTypes;
15675
+ var argType = (_funcData$argTypes = funcData.argTypes) == null ? void 0 : _funcData$argTypes[i];
15676
+ var isOptional = i < numOptionalArgs;
16003
15677
  if ("primitive" in funcData && funcData.primitive && argType == null ||
16004
15678
  // \sqrt expands into primitive if optional argument doesn't exist
16005
15679
  funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
@@ -16051,7 +15725,7 @@ class Parser {
16051
15725
  }
16052
15726
  case "raw":
16053
15727
  {
16054
- var token = this.parseStringGroup("raw", optional);
15728
+ var token = this.parseStringGroup(optional);
16055
15729
  return token != null ? {
16056
15730
  type: "raw",
16057
15731
  mode: "text",
@@ -16070,7 +15744,6 @@ class Parser {
16070
15744
  return _group2;
16071
15745
  }
16072
15746
  case "original":
16073
- case null:
16074
15747
  case undefined:
16075
15748
  return this.parseArgumentGroup(optional);
16076
15749
  default:
@@ -16089,9 +15762,7 @@ class Parser {
16089
15762
  * Parses a group, essentially returning the string formed by the
16090
15763
  * brace-enclosed tokens plus some position information.
16091
15764
  */
16092
- parseStringGroup(modeName,
16093
- // Used to describe the mode in error messages.
16094
- optional) {
15765
+ parseStringGroup(optional) {
16095
15766
  var argToken = this.gullet.scanArgument(optional);
16096
15767
  if (argToken == null) {
16097
15768
  return null;
@@ -16130,7 +15801,7 @@ class Parser {
16130
15801
  * Parses a color description.
16131
15802
  */
16132
15803
  parseColorGroup(optional) {
16133
- var res = this.parseStringGroup("color", optional);
15804
+ var res = this.parseStringGroup(optional);
16134
15805
  if (res == null) {
16135
15806
  return null;
16136
15807
  }
@@ -16162,7 +15833,7 @@ class Parser {
16162
15833
  if (!optional && this.gullet.future().text !== "{") {
16163
15834
  res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
16164
15835
  } else {
16165
- res = this.parseStringGroup("size", optional);
15836
+ res = this.parseStringGroup(optional);
16166
15837
  }
16167
15838
  if (!res) {
16168
15839
  return null;
@@ -16200,7 +15871,7 @@ class Parser {
16200
15871
  parseUrlGroup(optional) {
16201
15872
  this.gullet.lexer.setCatcode("%", 13); // active character
16202
15873
  this.gullet.lexer.setCatcode("~", 12); // other character
16203
- var res = this.parseStringGroup("url", optional);
15874
+ var res = this.parseStringGroup(optional);
16204
15875
  this.gullet.lexer.setCatcode("%", 14); // comment character
16205
15876
  this.gullet.lexer.setCatcode("~", 13); // active character
16206
15877
  if (res == null) {
@@ -16284,7 +15955,7 @@ class Parser {
16284
15955
  // If there exists a function with this name, parse the function.
16285
15956
  // Otherwise, just return a nucleus
16286
15957
  result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
16287
- if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) {
15958
+ if (result == null && text[0] === "\\" && !Object.prototype.hasOwnProperty.call(implicitCommands, text)) {
16288
15959
  if (this.settings.throwOnError) {
16289
15960
  throw new ParseError("Undefined control sequence: " + text, firstToken);
16290
15961
  }
@@ -16374,7 +16045,7 @@ class Parser {
16374
16045
  }
16375
16046
  // At this point, we should have a symbol, possibly with accents.
16376
16047
  // First expand any accented base symbol according to unicodeSymbols.
16377
- if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) {
16048
+ if (Object.prototype.hasOwnProperty.call(unicodeSymbols, text[0]) && !symbols[this.mode][text[0]]) {
16378
16049
  // This behavior is not strict (XeTeX-compatible) in math mode.
16379
16050
  if (this.settings.strict && this.mode === "math") {
16380
16051
  this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
@@ -16470,10 +16141,6 @@ class Parser {
16470
16141
  }
16471
16142
  Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]);
16472
16143
 
16473
- /**
16474
- * Provides a single function for parsing an expression using a Parser
16475
- * TODO(emily): Remove this
16476
- */
16477
16144
  /**
16478
16145
  * Parses an expression using a Parser, then returns the parsed result.
16479
16146
  */
@@ -16578,7 +16245,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
16578
16245
  return renderError(error, expression, settings);
16579
16246
  }
16580
16247
  };
16581
- var version = "0.16.47";
16248
+ var version = "0.18.0";
16582
16249
  var __domTree = {
16583
16250
  Span,
16584
16251
  Anchor,