katex 0.15.6 → 0.16.2

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 (44) hide show
  1. package/README.md +3 -3
  2. package/contrib/auto-render/auto-render.js +20 -1
  3. package/contrib/auto-render/test/auto-render-spec.js +88 -17
  4. package/contrib/copy-tex/README.md +9 -19
  5. package/contrib/copy-tex/copy-tex.js +39 -12
  6. package/contrib/copy-tex/katex2tex.js +16 -7
  7. package/contrib/mathtex-script-type/README.md +5 -5
  8. package/contrib/mhchem/README.md +1 -1
  9. package/contrib/render-a11y-string/render-a11y-string.js +5 -0
  10. package/dist/README.md +3 -3
  11. package/dist/contrib/auto-render.js +23 -1
  12. package/dist/contrib/auto-render.min.js +1 -1
  13. package/dist/contrib/auto-render.mjs +23 -1
  14. package/dist/contrib/copy-tex.js +38 -24
  15. package/dist/contrib/copy-tex.min.js +1 -1
  16. package/dist/contrib/copy-tex.mjs +35 -16
  17. package/dist/contrib/render-a11y-string.js +6 -0
  18. package/dist/contrib/render-a11y-string.min.js +1 -1
  19. package/dist/contrib/render-a11y-string.mjs +6 -0
  20. package/dist/katex.css +1 -1
  21. package/dist/katex.js +322 -199
  22. package/dist/katex.min.css +1 -1
  23. package/dist/katex.min.js +1 -1
  24. package/dist/katex.mjs +363 -241
  25. package/package.json +3 -3
  26. package/src/Parser.js +1 -1
  27. package/src/buildCommon.js +1 -1
  28. package/src/buildMathML.js +2 -2
  29. package/src/delimiter.js +68 -25
  30. package/src/domTree.js +1 -0
  31. package/src/environments/array.js +1 -1
  32. package/src/functions/enclose.js +1 -1
  33. package/src/functions/mclass.js +1 -1
  34. package/src/functions/op.js +1 -1
  35. package/src/functions/pmb.js +44 -0
  36. package/src/functions.js +1 -0
  37. package/src/macros.js +1 -9
  38. package/src/parseNode.js +7 -0
  39. package/src/stretchy.js +1 -1
  40. package/src/svgGeometry.js +56 -0
  41. package/contrib/copy-tex/copy-tex.css +0 -10
  42. package/contrib/copy-tex/copy-tex.webpack.js +0 -6
  43. package/dist/contrib/copy-tex.css +0 -13
  44. package/dist/contrib/copy-tex.min.css +0 -1
package/dist/katex.js CHANGED
@@ -932,6 +932,43 @@ var path = {
932
932
  shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",
933
933
  shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"
934
934
  };
935
+ var tallDelim = function tallDelim(label, midHeight) {
936
+ switch (label) {
937
+ case "lbrack":
938
+ return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z";
939
+
940
+ case "rbrack":
941
+ return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z";
942
+
943
+ case "vert":
944
+ return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z";
945
+
946
+ case "doublevert":
947
+ return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z";
948
+
949
+ case "lfloor":
950
+ return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
951
+
952
+ case "rfloor":
953
+ return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z";
954
+
955
+ case "lceil":
956
+ return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z";
957
+
958
+ case "rceil":
959
+ return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z";
960
+
961
+ case "lparen":
962
+ return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";
963
+
964
+ case "rparen":
965
+ return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";
966
+
967
+ default:
968
+ // We should not ever get here.
969
+ throw new Error("Unknown stretchy delimiter.");
970
+ }
971
+ };
935
972
  ;// CONCATENATED MODULE: ./src/tree.js
936
973
 
937
974
 
@@ -5484,7 +5521,7 @@ var makeOrd = function makeOrd(group, options, type) {
5484
5521
 
5485
5522
  if (lookupSymbol(text, fontName, mode).metrics) {
5486
5523
  return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
5487
- } else if (ligatures.hasOwnProperty(text) && fontName.substr(0, 10) === "Typewriter") {
5524
+ } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") {
5488
5525
  // Deconstruct ligatures in monospace fonts (\texttt, \tt).
5489
5526
  var parts = [];
5490
5527
 
@@ -6851,7 +6888,7 @@ var SpaceNode = /*#__PURE__*/function () {
6851
6888
  * optional replacement from symbols.js.
6852
6889
  */
6853
6890
  var makeText = function makeText(text, mode, options) {
6854
- if (src_symbols[mode][text] && src_symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.substr(4, 2) === "tt" || options.font && options.font.substr(4, 2) === "tt"))) {
6891
+ if (src_symbols[mode][text] && src_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"))) {
6855
6892
  text = src_symbols[mode][text].replace;
6856
6893
  }
6857
6894
 
@@ -7307,7 +7344,7 @@ var svgSpan = function svgSpan(group, options) {
7307
7344
  function buildSvgSpan_() {
7308
7345
  var viewBoxWidth = 400000; // default
7309
7346
 
7310
- var label = group.label.substr(1);
7347
+ var label = group.label.slice(1);
7311
7348
 
7312
7349
  if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) {
7313
7350
  // Each type in the `if` statement corresponds to one of the ParseNode
@@ -7976,6 +8013,211 @@ defineFunction({
7976
8013
  return node;
7977
8014
  }
7978
8015
  });
8016
+ ;// CONCATENATED MODULE: ./src/functions/mclass.js
8017
+
8018
+
8019
+
8020
+
8021
+
8022
+
8023
+ var mclass_makeSpan = buildCommon.makeSpan;
8024
+
8025
+ function mclass_htmlBuilder(group, options) {
8026
+ var elements = buildExpression(group.body, options, true);
8027
+ return mclass_makeSpan([group.mclass], elements, options);
8028
+ }
8029
+
8030
+ function mclass_mathmlBuilder(group, options) {
8031
+ var node;
8032
+ var inner = buildMathML_buildExpression(group.body, options);
8033
+
8034
+ if (group.mclass === "minner") {
8035
+ node = new mathMLTree.MathNode("mpadded", inner);
8036
+ } else if (group.mclass === "mord") {
8037
+ if (group.isCharacterBox) {
8038
+ node = inner[0];
8039
+ node.type = "mi";
8040
+ } else {
8041
+ node = new mathMLTree.MathNode("mi", inner);
8042
+ }
8043
+ } else {
8044
+ if (group.isCharacterBox) {
8045
+ node = inner[0];
8046
+ node.type = "mo";
8047
+ } else {
8048
+ node = new mathMLTree.MathNode("mo", inner);
8049
+ } // Set spacing based on what is the most likely adjacent atom type.
8050
+ // See TeXbook p170.
8051
+
8052
+
8053
+ if (group.mclass === "mbin") {
8054
+ node.attributes.lspace = "0.22em"; // medium space
8055
+
8056
+ node.attributes.rspace = "0.22em";
8057
+ } else if (group.mclass === "mpunct") {
8058
+ node.attributes.lspace = "0em";
8059
+ node.attributes.rspace = "0.17em"; // thinspace
8060
+ } else if (group.mclass === "mopen" || group.mclass === "mclose") {
8061
+ node.attributes.lspace = "0em";
8062
+ node.attributes.rspace = "0em";
8063
+ } else if (group.mclass === "minner") {
8064
+ node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
8065
+
8066
+ node.attributes.width = "+0.1111em";
8067
+ } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
8068
+ // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
8069
+
8070
+ }
8071
+
8072
+ return node;
8073
+ } // Math class commands except \mathop
8074
+
8075
+
8076
+ defineFunction({
8077
+ type: "mclass",
8078
+ names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
8079
+ props: {
8080
+ numArgs: 1,
8081
+ primitive: true
8082
+ },
8083
+ handler: function handler(_ref, args) {
8084
+ var parser = _ref.parser,
8085
+ funcName = _ref.funcName;
8086
+ var body = args[0];
8087
+ return {
8088
+ type: "mclass",
8089
+ mode: parser.mode,
8090
+ mclass: "m" + funcName.slice(5),
8091
+ // TODO(kevinb): don't prefix with 'm'
8092
+ body: ordargument(body),
8093
+ isCharacterBox: utils.isCharacterBox(body)
8094
+ };
8095
+ },
8096
+ htmlBuilder: mclass_htmlBuilder,
8097
+ mathmlBuilder: mclass_mathmlBuilder
8098
+ });
8099
+ var binrelClass = function binrelClass(arg) {
8100
+ // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
8101
+ // (by rendering separately and with {}s before and after, and measuring
8102
+ // the change in spacing). We'll do roughly the same by detecting the
8103
+ // atom type directly.
8104
+ var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg;
8105
+
8106
+ if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
8107
+ return "m" + atom.family;
8108
+ } else {
8109
+ return "mord";
8110
+ }
8111
+ }; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord.
8112
+ // This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX.
8113
+
8114
+ defineFunction({
8115
+ type: "mclass",
8116
+ names: ["\\@binrel"],
8117
+ props: {
8118
+ numArgs: 2
8119
+ },
8120
+ handler: function handler(_ref2, args) {
8121
+ var parser = _ref2.parser;
8122
+ return {
8123
+ type: "mclass",
8124
+ mode: parser.mode,
8125
+ mclass: binrelClass(args[0]),
8126
+ body: ordargument(args[1]),
8127
+ isCharacterBox: utils.isCharacterBox(args[1])
8128
+ };
8129
+ }
8130
+ }); // Build a relation or stacked op by placing one symbol on top of another
8131
+
8132
+ defineFunction({
8133
+ type: "mclass",
8134
+ names: ["\\stackrel", "\\overset", "\\underset"],
8135
+ props: {
8136
+ numArgs: 2
8137
+ },
8138
+ handler: function handler(_ref3, args) {
8139
+ var parser = _ref3.parser,
8140
+ funcName = _ref3.funcName;
8141
+ var baseArg = args[1];
8142
+ var shiftedArg = args[0];
8143
+ var mclass;
8144
+
8145
+ if (funcName !== "\\stackrel") {
8146
+ // LaTeX applies \binrel spacing to \overset and \underset.
8147
+ mclass = binrelClass(baseArg);
8148
+ } else {
8149
+ mclass = "mrel"; // for \stackrel
8150
+ }
8151
+
8152
+ var baseOp = {
8153
+ type: "op",
8154
+ mode: baseArg.mode,
8155
+ limits: true,
8156
+ alwaysHandleSupSub: true,
8157
+ parentIsSupSub: false,
8158
+ symbol: false,
8159
+ suppressBaseShift: funcName !== "\\stackrel",
8160
+ body: ordargument(baseArg)
8161
+ };
8162
+ var supsub = {
8163
+ type: "supsub",
8164
+ mode: shiftedArg.mode,
8165
+ base: baseOp,
8166
+ sup: funcName === "\\underset" ? null : shiftedArg,
8167
+ sub: funcName === "\\underset" ? shiftedArg : null
8168
+ };
8169
+ return {
8170
+ type: "mclass",
8171
+ mode: parser.mode,
8172
+ mclass: mclass,
8173
+ body: [supsub],
8174
+ isCharacterBox: utils.isCharacterBox(supsub)
8175
+ };
8176
+ },
8177
+ htmlBuilder: mclass_htmlBuilder,
8178
+ mathmlBuilder: mclass_mathmlBuilder
8179
+ });
8180
+ ;// CONCATENATED MODULE: ./src/functions/pmb.js
8181
+
8182
+
8183
+
8184
+
8185
+
8186
+
8187
+ // \pmb is a simulation of bold font.
8188
+ // The version of \pmb in ambsy.sty works by typesetting three copies
8189
+ // with small offsets. We use CSS text-shadow.
8190
+ // It's a hack. Not as good as a real bold font. Better than nothing.
8191
+ defineFunction({
8192
+ type: "pmb",
8193
+ names: ["\\pmb"],
8194
+ props: {
8195
+ numArgs: 1,
8196
+ allowedInText: true
8197
+ },
8198
+ handler: function handler(_ref, args) {
8199
+ var parser = _ref.parser;
8200
+ return {
8201
+ type: "pmb",
8202
+ mode: parser.mode,
8203
+ mclass: binrelClass(args[0]),
8204
+ body: ordargument(args[0])
8205
+ };
8206
+ },
8207
+ htmlBuilder: function htmlBuilder(group, options) {
8208
+ var elements = buildExpression(group.body, options, true);
8209
+ var node = buildCommon.makeSpan([group.mclass], elements, options);
8210
+ node.style.textShadow = "0.02em 0.01em 0.04px";
8211
+ return node;
8212
+ },
8213
+ mathmlBuilder: function mathmlBuilder(group, style) {
8214
+ var inner = buildMathML_buildExpression(group.body, style); // Wrap with an <mstyle> element.
8215
+
8216
+ var node = new mathMLTree.MathNode("mstyle", inner);
8217
+ node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
8218
+ return node;
8219
+ }
8220
+ });
7979
8221
  ;// CONCATENATED MODULE: ./src/environments/cd.js
7980
8222
 
7981
8223
 
@@ -8885,6 +9127,8 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
8885
9127
  var middle;
8886
9128
  var repeat;
8887
9129
  var bottom;
9130
+ var svgLabel = "";
9131
+ var viewBoxWidth = 0;
8888
9132
  top = repeat = bottom = delim;
8889
9133
  middle = null; // Also keep track of what font the delimiters are in
8890
9134
 
@@ -8910,44 +9154,64 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
8910
9154
  bottom = "\\Downarrow";
8911
9155
  } else if (utils.contains(verts, delim)) {
8912
9156
  repeat = "\u2223";
9157
+ svgLabel = "vert";
9158
+ viewBoxWidth = 333;
8913
9159
  } else if (utils.contains(doubleVerts, delim)) {
8914
9160
  repeat = "\u2225";
9161
+ svgLabel = "doublevert";
9162
+ viewBoxWidth = 556;
8915
9163
  } else if (delim === "[" || delim === "\\lbrack") {
8916
9164
  top = "\u23A1";
8917
9165
  repeat = "\u23A2";
8918
9166
  bottom = "\u23A3";
8919
9167
  font = "Size4-Regular";
9168
+ svgLabel = "lbrack";
9169
+ viewBoxWidth = 667;
8920
9170
  } else if (delim === "]" || delim === "\\rbrack") {
8921
9171
  top = "\u23A4";
8922
9172
  repeat = "\u23A5";
8923
9173
  bottom = "\u23A6";
8924
9174
  font = "Size4-Regular";
9175
+ svgLabel = "rbrack";
9176
+ viewBoxWidth = 667;
8925
9177
  } else if (delim === "\\lfloor" || delim === "\u230A") {
8926
9178
  repeat = top = "\u23A2";
8927
9179
  bottom = "\u23A3";
8928
9180
  font = "Size4-Regular";
9181
+ svgLabel = "lfloor";
9182
+ viewBoxWidth = 667;
8929
9183
  } else if (delim === "\\lceil" || delim === "\u2308") {
8930
9184
  top = "\u23A1";
8931
9185
  repeat = bottom = "\u23A2";
8932
9186
  font = "Size4-Regular";
9187
+ svgLabel = "lceil";
9188
+ viewBoxWidth = 667;
8933
9189
  } else if (delim === "\\rfloor" || delim === "\u230B") {
8934
9190
  repeat = top = "\u23A5";
8935
9191
  bottom = "\u23A6";
8936
9192
  font = "Size4-Regular";
9193
+ svgLabel = "rfloor";
9194
+ viewBoxWidth = 667;
8937
9195
  } else if (delim === "\\rceil" || delim === "\u2309") {
8938
9196
  top = "\u23A4";
8939
9197
  repeat = bottom = "\u23A5";
8940
9198
  font = "Size4-Regular";
9199
+ svgLabel = "rceil";
9200
+ viewBoxWidth = 667;
8941
9201
  } else if (delim === "(" || delim === "\\lparen") {
8942
9202
  top = "\u239B";
8943
9203
  repeat = "\u239C";
8944
9204
  bottom = "\u239D";
8945
9205
  font = "Size4-Regular";
9206
+ svgLabel = "lparen";
9207
+ viewBoxWidth = 875;
8946
9208
  } else if (delim === ")" || delim === "\\rparen") {
8947
9209
  top = "\u239E";
8948
9210
  repeat = "\u239F";
8949
9211
  bottom = "\u23A0";
8950
9212
  font = "Size4-Regular";
9213
+ svgLabel = "rparen";
9214
+ viewBoxWidth = 875;
8951
9215
  } else if (delim === "\\{" || delim === "\\lbrace") {
8952
9216
  top = "\u23A7";
8953
9217
  middle = "\u23A8";
@@ -9019,32 +9283,59 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt
9019
9283
  var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist
9020
9284
  // Keep a list of the pieces of the stacked delimiter
9021
9285
 
9022
- var stack = []; // Add the bottom symbol
9286
+ var stack = [];
9287
+
9288
+ if (svgLabel.length > 0) {
9289
+ // Instead of stacking glyphs, create a single SVG.
9290
+ // This evades browser problems with imprecise positioning of spans.
9291
+ var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal;
9292
+ var viewBoxHeight = Math.round(realHeightTotal * 1000);
9293
+ var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000));
9294
+ var path = new PathNode(svgLabel, pathStr);
9295
+ var width = (viewBoxWidth / 1000).toFixed(3) + "em";
9296
+ var height = (viewBoxHeight / 1000).toFixed(3) + "em";
9297
+ var svg = new SvgNode([path], {
9298
+ "width": width,
9299
+ "height": height,
9300
+ "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight
9301
+ });
9302
+ var wrapper = buildCommon.makeSvgSpan([], [svg], options);
9303
+ wrapper.height = viewBoxHeight / 1000;
9304
+ wrapper.style.width = width;
9305
+ wrapper.style.height = height;
9306
+ stack.push({
9307
+ type: "elem",
9308
+ elem: wrapper
9309
+ });
9310
+ } else {
9311
+ // Stack glyphs
9312
+ // Start by adding the bottom symbol
9313
+ stack.push(makeGlyphSpan(bottom, font, mode));
9314
+ stack.push(lap); // overlap
9315
+
9316
+ if (middle === null) {
9317
+ // The middle section will be an SVG. Make it an extra 0.016em tall.
9318
+ // We'll overlap by 0.008em at top and bottom.
9319
+ var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
9320
+ stack.push(makeInner(repeat, innerHeight, options));
9321
+ } else {
9322
+ // When there is a middle bit, we need the middle part and two repeated
9323
+ // sections
9324
+ var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
9023
9325
 
9024
- stack.push(makeGlyphSpan(bottom, font, mode));
9025
- stack.push(lap); // overlap
9326
+ stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
9026
9327
 
9027
- if (middle === null) {
9028
- // The middle section will be an SVG. Make it an extra 0.016em tall.
9029
- // We'll overlap by 0.008em at top and bottom.
9030
- var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms;
9031
- stack.push(makeInner(repeat, innerHeight, options));
9032
- } else {
9033
- // When there is a middle bit, we need the middle part and two repeated
9034
- // sections
9035
- var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms;
9328
+ stack.push(lap);
9329
+ stack.push(makeGlyphSpan(middle, font, mode));
9330
+ stack.push(lap);
9331
+ stack.push(makeInner(repeat, _innerHeight, options));
9332
+ } // Add the top symbol
9036
9333
 
9037
- stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace.
9038
9334
 
9039
9335
  stack.push(lap);
9040
- stack.push(makeGlyphSpan(middle, font, mode));
9041
- stack.push(lap);
9042
- stack.push(makeInner(repeat, _innerHeight, options));
9043
- } // Add the top symbol
9044
-
9336
+ stack.push(makeGlyphSpan(top, font, mode));
9337
+ } // Finally, build the vlist
9045
9338
 
9046
- stack.push(lap);
9047
- stack.push(makeGlyphSpan(top, font, mode)); // Finally, build the vlist
9048
9339
 
9049
9340
  var newOptions = options.havingBaseStyle(src_Style.TEXT);
9050
9341
  var inner = buildCommon.makeVList({
@@ -9753,7 +10044,7 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
9753
10044
  // Some groups can return document fragments. Handle those by wrapping
9754
10045
  // them in a span.
9755
10046
  var inner = buildCommon.wrapFragment(buildGroup(group.body, options), options);
9756
- var label = group.label.substr(1);
10047
+ var label = group.label.slice(1);
9757
10048
  var scale = options.sizeMultiplier;
9758
10049
  var img;
9759
10050
  var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different
@@ -10436,7 +10727,7 @@ function parseArray(parser, _ref, style) {
10436
10727
 
10437
10728
 
10438
10729
  function dCellStyle(envName) {
10439
- if (envName.substr(0, 1) === "d") {
10730
+ if (envName.slice(0, 1) === "d") {
10440
10731
  return "display";
10441
10732
  } else {
10442
10733
  return "text";
@@ -11400,170 +11691,6 @@ defineFunction({
11400
11691
  };
11401
11692
  }
11402
11693
  });
11403
- ;// CONCATENATED MODULE: ./src/functions/mclass.js
11404
-
11405
-
11406
-
11407
-
11408
-
11409
-
11410
- var mclass_makeSpan = buildCommon.makeSpan;
11411
-
11412
- function mclass_htmlBuilder(group, options) {
11413
- var elements = buildExpression(group.body, options, true);
11414
- return mclass_makeSpan([group.mclass], elements, options);
11415
- }
11416
-
11417
- function mclass_mathmlBuilder(group, options) {
11418
- var node;
11419
- var inner = buildMathML_buildExpression(group.body, options);
11420
-
11421
- if (group.mclass === "minner") {
11422
- node = new mathMLTree.MathNode("mpadded", inner);
11423
- } else if (group.mclass === "mord") {
11424
- if (group.isCharacterBox) {
11425
- node = inner[0];
11426
- node.type = "mi";
11427
- } else {
11428
- node = new mathMLTree.MathNode("mi", inner);
11429
- }
11430
- } else {
11431
- if (group.isCharacterBox) {
11432
- node = inner[0];
11433
- node.type = "mo";
11434
- } else {
11435
- node = new mathMLTree.MathNode("mo", inner);
11436
- } // Set spacing based on what is the most likely adjacent atom type.
11437
- // See TeXbook p170.
11438
-
11439
-
11440
- if (group.mclass === "mbin") {
11441
- node.attributes.lspace = "0.22em"; // medium space
11442
-
11443
- node.attributes.rspace = "0.22em";
11444
- } else if (group.mclass === "mpunct") {
11445
- node.attributes.lspace = "0em";
11446
- node.attributes.rspace = "0.17em"; // thinspace
11447
- } else if (group.mclass === "mopen" || group.mclass === "mclose") {
11448
- node.attributes.lspace = "0em";
11449
- node.attributes.rspace = "0em";
11450
- } else if (group.mclass === "minner") {
11451
- node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
11452
-
11453
- node.attributes.width = "+0.1111em";
11454
- } // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
11455
- // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
11456
-
11457
- }
11458
-
11459
- return node;
11460
- } // Math class commands except \mathop
11461
-
11462
-
11463
- defineFunction({
11464
- type: "mclass",
11465
- names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
11466
- props: {
11467
- numArgs: 1,
11468
- primitive: true
11469
- },
11470
- handler: function handler(_ref, args) {
11471
- var parser = _ref.parser,
11472
- funcName = _ref.funcName;
11473
- var body = args[0];
11474
- return {
11475
- type: "mclass",
11476
- mode: parser.mode,
11477
- mclass: "m" + funcName.substr(5),
11478
- // TODO(kevinb): don't prefix with 'm'
11479
- body: ordargument(body),
11480
- isCharacterBox: utils.isCharacterBox(body)
11481
- };
11482
- },
11483
- htmlBuilder: mclass_htmlBuilder,
11484
- mathmlBuilder: mclass_mathmlBuilder
11485
- });
11486
- var binrelClass = function binrelClass(arg) {
11487
- // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
11488
- // (by rendering separately and with {}s before and after, and measuring
11489
- // the change in spacing). We'll do roughly the same by detecting the
11490
- // atom type directly.
11491
- var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg;
11492
-
11493
- if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
11494
- return "m" + atom.family;
11495
- } else {
11496
- return "mord";
11497
- }
11498
- }; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord.
11499
- // This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX.
11500
-
11501
- defineFunction({
11502
- type: "mclass",
11503
- names: ["\\@binrel"],
11504
- props: {
11505
- numArgs: 2
11506
- },
11507
- handler: function handler(_ref2, args) {
11508
- var parser = _ref2.parser;
11509
- return {
11510
- type: "mclass",
11511
- mode: parser.mode,
11512
- mclass: binrelClass(args[0]),
11513
- body: ordargument(args[1]),
11514
- isCharacterBox: utils.isCharacterBox(args[1])
11515
- };
11516
- }
11517
- }); // Build a relation or stacked op by placing one symbol on top of another
11518
-
11519
- defineFunction({
11520
- type: "mclass",
11521
- names: ["\\stackrel", "\\overset", "\\underset"],
11522
- props: {
11523
- numArgs: 2
11524
- },
11525
- handler: function handler(_ref3, args) {
11526
- var parser = _ref3.parser,
11527
- funcName = _ref3.funcName;
11528
- var baseArg = args[1];
11529
- var shiftedArg = args[0];
11530
- var mclass;
11531
-
11532
- if (funcName !== "\\stackrel") {
11533
- // LaTeX applies \binrel spacing to \overset and \underset.
11534
- mclass = binrelClass(baseArg);
11535
- } else {
11536
- mclass = "mrel"; // for \stackrel
11537
- }
11538
-
11539
- var baseOp = {
11540
- type: "op",
11541
- mode: baseArg.mode,
11542
- limits: true,
11543
- alwaysHandleSupSub: true,
11544
- parentIsSupSub: false,
11545
- symbol: false,
11546
- suppressBaseShift: funcName !== "\\stackrel",
11547
- body: ordargument(baseArg)
11548
- };
11549
- var supsub = {
11550
- type: "supsub",
11551
- mode: shiftedArg.mode,
11552
- base: baseOp,
11553
- sup: funcName === "\\underset" ? null : shiftedArg,
11554
- sub: funcName === "\\underset" ? shiftedArg : null
11555
- };
11556
- return {
11557
- type: "mclass",
11558
- mode: parser.mode,
11559
- mclass: mclass,
11560
- body: [supsub],
11561
- isCharacterBox: utils.isCharacterBox(supsub)
11562
- };
11563
- },
11564
- htmlBuilder: mclass_htmlBuilder,
11565
- mathmlBuilder: mclass_mathmlBuilder
11566
- });
11567
11694
  ;// CONCATENATED MODULE: ./src/functions/font.js
11568
11695
  // TODO(kevinb): implement \\sl and \\sc
11569
11696
 
@@ -13188,7 +13315,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
13188
13315
  if (group.name === "\\oiint" || group.name === "\\oiiint") {
13189
13316
  // No font glyphs yet, so use a glyph w/o the oval.
13190
13317
  // TODO: When font glyphs are available, delete this code.
13191
- stash = group.name.substr(1);
13318
+ stash = group.name.slice(1);
13192
13319
  group.name = stash === "oiint" ? "\\iint" : "\\iiint";
13193
13320
  }
13194
13321
 
@@ -14996,6 +15123,7 @@ var functions = _functions;
14996
15123
 
14997
15124
 
14998
15125
 
15126
+
14999
15127
 
15000
15128
 
15001
15129
  ;// CONCATENATED MODULE: ./src/Lexer.js
@@ -15743,7 +15871,7 @@ defineMacro("\\dots", function (context) {
15743
15871
 
15744
15872
  if (next in dotsByToken) {
15745
15873
  thedots = dotsByToken[next];
15746
- } else if (next.substr(0, 4) === '\\not') {
15874
+ } else if (next.slice(0, 4) === '\\not') {
15747
15875
  thedots = '\\dotsb';
15748
15876
  } else if (next in src_symbols.math) {
15749
15877
  if (utils.contains(['bin', 'rel'], src_symbols.math[next].group)) {
@@ -15880,12 +16008,7 @@ defineMacro("\\tag@literal", function (context) {
15880
16008
  defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");
15881
16009
  defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");
15882
16010
  defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}");
15883
- defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); // \pmb -- A simulation of bold.
15884
- // The version in ambsy.sty works by typesetting three copies of the argument
15885
- // with small offsets. We use two copies. We omit the vertical offset because
15886
- // of rendering problems that makeVList encounters in Safari.
15887
-
15888
- defineMacro("\\pmb", "\\html@mathml{" + "\\@binrel{#1}{\\mathrlap{#1}\\kern0.5px#1}}" + "{\\mathbf{#1}}"); //////////////////////////////////////////////////////////////////////
16011
+ defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); //////////////////////////////////////////////////////////////////////
15889
16012
  // LaTeX source2e
15890
16013
  // \expandafter\let\expandafter\@normalcr
15891
16014
  // \csname\expandafter\@gobble\string\\ \endcsname
@@ -18293,7 +18416,7 @@ var Parser = /*#__PURE__*/function () {
18293
18416
  this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
18294
18417
  }
18295
18418
 
18296
- text = unicodeSymbols[text[0]] + text.substr(1);
18419
+ text = unicodeSymbols[text[0]] + text.slice(1);
18297
18420
  } // Strip off any combining characters
18298
18421
 
18299
18422
 
@@ -18564,7 +18687,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
18564
18687
  /**
18565
18688
  * Current KaTeX version
18566
18689
  */
18567
- version: "0.15.6",
18690
+ version: "0.16.2",
18568
18691
 
18569
18692
  /**
18570
18693
  * Renders the given LaTeX into an HTML+MathML combination, and adds