katex 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/cli.js +6 -9
- package/contrib/auto-render/index.html +1 -1
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/copy-tex/index.html +1 -1
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/render-a11y-string.js +15 -40
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +13 -33
- package/dist/katex-swap.css +159 -164
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +159 -164
- package/dist/katex.js +277 -421
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +279 -423
- package/package.json +14 -16
- package/src/MacroExpander.ts +10 -7
- package/src/Namespace.ts +16 -20
- package/src/Options.ts +2 -2
- package/src/Parser.ts +2 -2
- package/src/atoms.ts +22 -22
- package/src/buildCommon.ts +2 -2
- package/src/buildHTML.ts +8 -8
- package/src/buildMathML.ts +3 -3
- package/src/environments/array.ts +3 -3
- package/src/fontMetrics.ts +2 -4
- package/src/functions/accent.ts +2 -2
- package/src/functions/cr.ts +1 -1
- package/src/functions/enclose.ts +1 -1
- package/src/functions/environment.ts +1 -1
- package/src/functions/html.ts +21 -4
- package/src/functions/lap.ts +7 -7
- package/src/functions/overline.ts +1 -1
- package/src/functions/phantom.ts +2 -2
- package/src/functions/rule.ts +1 -1
- package/src/functions/sizing.ts +1 -1
- package/src/functions/smash.ts +1 -1
- package/src/functions/sqrt.ts +1 -1
- package/src/functions/symbolsSpacing.ts +20 -21
- package/src/functions/underline.ts +1 -1
- package/src/macros.ts +3 -3
- package/src/mathMLTree.ts +6 -10
- package/src/parseNode.ts +4 -4
- package/src/stretchy.ts +2 -2
- package/src/styles/katex.scss +31 -37
- package/src/wide-character.ts +2 -2
package/dist/katex.js
CHANGED
|
@@ -3905,10 +3905,8 @@ function getGlobalMetrics(size) {
|
|
|
3905
3905
|
const metrics = fontMetricsBySizeIndex[sizeIndex] = {
|
|
3906
3906
|
cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
|
|
3907
3907
|
};
|
|
3908
|
-
for (const key
|
|
3909
|
-
|
|
3910
|
-
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3911
|
-
}
|
|
3908
|
+
for (const key of Object.keys(sigmasAndXis)) {
|
|
3909
|
+
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3912
3910
|
}
|
|
3913
3911
|
}
|
|
3914
3912
|
return fontMetricsBySizeIndex[sizeIndex];
|
|
@@ -5034,12 +5032,10 @@ const makeOrd = function (group, options) {
|
|
|
5034
5032
|
const mode = group.mode;
|
|
5035
5033
|
const text = group.text;
|
|
5036
5034
|
const classes = ["mord"];
|
|
5037
|
-
const
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
fontShape
|
|
5042
|
-
} = options;
|
|
5035
|
+
const font = options.font,
|
|
5036
|
+
fontFamily = options.fontFamily,
|
|
5037
|
+
fontWeight = options.fontWeight,
|
|
5038
|
+
fontShape = options.fontShape;
|
|
5043
5039
|
|
|
5044
5040
|
// Math mode or Old font (i.e. \rm)
|
|
5045
5041
|
const useFont = mode === "math" || mode === "text" && !!font;
|
|
@@ -5070,7 +5066,7 @@ const makeOrd = function (group, options) {
|
|
|
5070
5066
|
}
|
|
5071
5067
|
if (lookupSymbol(text, fontName, mode).metrics) {
|
|
5072
5068
|
return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
|
|
5073
|
-
} else if (
|
|
5069
|
+
} else if (Object.prototype.hasOwnProperty.call(ligatures, text) && fontName.slice(0, 10) === "Typewriter") {
|
|
5074
5070
|
// Deconstruct ligatures in monospace fonts (\texttt, \tt).
|
|
5075
5071
|
const parts = [];
|
|
5076
5072
|
for (let i = 0; i < text.length; i++) {
|
|
@@ -5305,10 +5301,9 @@ const getVListChildrenAndDepth = function (params) {
|
|
|
5305
5301
|
* See VListParam documentation above.
|
|
5306
5302
|
*/
|
|
5307
5303
|
const makeVList = function (params, options) {
|
|
5308
|
-
const
|
|
5309
|
-
children,
|
|
5310
|
-
depth
|
|
5311
|
-
} = getVListChildrenAndDepth(params);
|
|
5304
|
+
const _getVListChildrenAndD = getVListChildrenAndDepth(params),
|
|
5305
|
+
children = _getVListChildrenAndD.children,
|
|
5306
|
+
depth = _getVListChildrenAndD.depth;
|
|
5312
5307
|
|
|
5313
5308
|
// Create a strut that is taller than any list item. The strut is added to
|
|
5314
5309
|
// each item, where it will determine the item's baseline. Since it has
|
|
@@ -5509,7 +5504,10 @@ const svgData = {
|
|
|
5509
5504
|
};
|
|
5510
5505
|
const staticSvg = function (value, options) {
|
|
5511
5506
|
// Create a span with inline SVG for the element.
|
|
5512
|
-
const
|
|
5507
|
+
const _svgData$value = svgData[value],
|
|
5508
|
+
pathName = _svgData$value[0],
|
|
5509
|
+
width = _svgData$value[1],
|
|
5510
|
+
height = _svgData$value[2];
|
|
5513
5511
|
const path = new PathNode(pathName);
|
|
5514
5512
|
const svgNode = new SvgNode([path], {
|
|
5515
5513
|
"width": makeEm(width),
|
|
@@ -5519,7 +5517,7 @@ const staticSvg = function (value, options) {
|
|
|
5519
5517
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
5520
5518
|
"preserveAspectRatio": "xMinYMin"
|
|
5521
5519
|
});
|
|
5522
|
-
const span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
5520
|
+
const span = makeSvgSpan(["katex-overlay"], [svgNode], options);
|
|
5523
5521
|
span.height = height;
|
|
5524
5522
|
span.style.height = makeEm(height);
|
|
5525
5523
|
span.style.width = makeEm(width);
|
|
@@ -5674,12 +5672,10 @@ const _htmlGroupBuilders = {};
|
|
|
5674
5672
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5675
5673
|
const _mathmlGroupBuilders = {};
|
|
5676
5674
|
function defineFunction(data) {
|
|
5677
|
-
const
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
mathmlBuilder
|
|
5682
|
-
} = data;
|
|
5675
|
+
const type = data.type,
|
|
5676
|
+
names = data.names,
|
|
5677
|
+
htmlBuilder = data.htmlBuilder,
|
|
5678
|
+
mathmlBuilder = data.mathmlBuilder;
|
|
5683
5679
|
for (let i = 0; i < names.length; ++i) {
|
|
5684
5680
|
// To avoid destructuring and rebuilding an object,
|
|
5685
5681
|
// we store the entire FunctionDefSpec object,
|
|
@@ -5702,11 +5698,9 @@ function defineFunction(data) {
|
|
|
5702
5698
|
* stand-alone handler provided to `defineFunction`).
|
|
5703
5699
|
*/
|
|
5704
5700
|
function defineFunctionBuilders(_ref) {
|
|
5705
|
-
let
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
mathmlBuilder
|
|
5709
|
-
} = _ref;
|
|
5701
|
+
let type = _ref.type,
|
|
5702
|
+
htmlBuilder = _ref.htmlBuilder,
|
|
5703
|
+
mathmlBuilder = _ref.mathmlBuilder;
|
|
5710
5704
|
if (htmlBuilder) {
|
|
5711
5705
|
_htmlGroupBuilders[type] = htmlBuilder;
|
|
5712
5706
|
}
|
|
@@ -5882,7 +5876,7 @@ const traverseNonSpaceNodes = function (nodes, callback, prev, next, isRoot) {
|
|
|
5882
5876
|
}
|
|
5883
5877
|
if (nonspace) {
|
|
5884
5878
|
prev.node = node;
|
|
5885
|
-
} else if (isRoot && node.hasClass("newline")) {
|
|
5879
|
+
} else if (isRoot && node.hasClass("katex-newline")) {
|
|
5886
5880
|
prev.node = makeSpan(["leftmost"]); // treat like beginning of line
|
|
5887
5881
|
}
|
|
5888
5882
|
prev.insertAfter = (index => n => {
|
|
@@ -5968,18 +5962,18 @@ const buildGroup = function (group, options, baseOptions) {
|
|
|
5968
5962
|
|
|
5969
5963
|
/**
|
|
5970
5964
|
* Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
|
|
5971
|
-
* into an unbreakable HTML node of class .base, with proper struts to
|
|
5965
|
+
* into an unbreakable HTML node of class .katex-base, with proper struts to
|
|
5972
5966
|
* guarantee correct vertical extent. `buildHTML` calls this repeatedly to
|
|
5973
5967
|
* make up the entire expression as a sequence of unbreakable units.
|
|
5974
5968
|
*/
|
|
5975
5969
|
function buildHTMLUnbreakable(children, options) {
|
|
5976
5970
|
// Compute height and depth of this chunk.
|
|
5977
|
-
const body = makeSpan(["base"], children, options);
|
|
5971
|
+
const body = makeSpan(["katex-base"], children, options);
|
|
5978
5972
|
|
|
5979
5973
|
// Add strut, which ensures that the top of the HTML element falls at
|
|
5980
5974
|
// the height of the expression, and the bottom of the HTML element
|
|
5981
5975
|
// falls at the depth of the expression.
|
|
5982
|
-
const strut = makeSpan(["strut"]);
|
|
5976
|
+
const strut = makeSpan(["katex-strut"]);
|
|
5983
5977
|
strut.style.height = makeEm(body.height + body.depth);
|
|
5984
5978
|
if (body.depth) {
|
|
5985
5979
|
strut.style.verticalAlign = makeEm(-body.depth);
|
|
@@ -6003,7 +5997,7 @@ function buildHTML(tree, options) {
|
|
|
6003
5997
|
// Build the expression contained in the tree
|
|
6004
5998
|
const expression = buildExpression(tree, options, "root");
|
|
6005
5999
|
let eqnNum;
|
|
6006
|
-
if (expression.length === 2 && expression[1].hasClass("tag")) {
|
|
6000
|
+
if (expression.length === 2 && expression[1].hasClass("katex-tag")) {
|
|
6007
6001
|
// An environment with automatic equation numbers, e.g. {gather}.
|
|
6008
6002
|
eqnNum = expression.pop();
|
|
6009
6003
|
}
|
|
@@ -6023,7 +6017,7 @@ function buildHTML(tree, options) {
|
|
|
6023
6017
|
// Put any post-operator glue on same line as operator.
|
|
6024
6018
|
// Watch for \nobreak along the way, and stop at \newline.
|
|
6025
6019
|
let nobreak = false;
|
|
6026
|
-
while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) {
|
|
6020
|
+
while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("katex-newline")) {
|
|
6027
6021
|
i++;
|
|
6028
6022
|
parts.push(expression[i]);
|
|
6029
6023
|
if (expression[i].hasClass("nobreak")) {
|
|
@@ -6035,7 +6029,7 @@ function buildHTML(tree, options) {
|
|
|
6035
6029
|
children.push(buildHTMLUnbreakable(parts, options));
|
|
6036
6030
|
parts = [];
|
|
6037
6031
|
}
|
|
6038
|
-
} else if (expression[i].hasClass("newline")) {
|
|
6032
|
+
} else if (expression[i].hasClass("katex-newline")) {
|
|
6039
6033
|
// Write the line except the newline
|
|
6040
6034
|
parts.pop();
|
|
6041
6035
|
if (parts.length > 0) {
|
|
@@ -6054,7 +6048,7 @@ function buildHTML(tree, options) {
|
|
|
6054
6048
|
let tagChild;
|
|
6055
6049
|
if (tag) {
|
|
6056
6050
|
tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true), options);
|
|
6057
|
-
tagChild.classes = ["tag"];
|
|
6051
|
+
tagChild.classes = ["katex-tag"];
|
|
6058
6052
|
children.push(tagChild);
|
|
6059
6053
|
} else if (eqnNum) {
|
|
6060
6054
|
children.push(eqnNum);
|
|
@@ -6135,10 +6129,10 @@ class MathNode {
|
|
|
6135
6129
|
*/
|
|
6136
6130
|
toNode() {
|
|
6137
6131
|
const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
|
|
6138
|
-
for (const
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6132
|
+
for (const _ref of Object.entries(this.attributes)) {
|
|
6133
|
+
const attr = _ref[0];
|
|
6134
|
+
const value = _ref[1];
|
|
6135
|
+
node.setAttribute(attr, value);
|
|
6142
6136
|
}
|
|
6143
6137
|
if (this.classes.length > 0) {
|
|
6144
6138
|
node.className = createClass(this.classes);
|
|
@@ -6166,12 +6160,12 @@ class MathNode {
|
|
|
6166
6160
|
let markup = "<" + this.type;
|
|
6167
6161
|
|
|
6168
6162
|
// Add the attributes
|
|
6169
|
-
for (const
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6163
|
+
for (const _ref2 of Object.entries(this.attributes)) {
|
|
6164
|
+
const attr = _ref2[0];
|
|
6165
|
+
const value = _ref2[1];
|
|
6166
|
+
markup += " " + attr + "=\"";
|
|
6167
|
+
markup += utils_escape(value);
|
|
6168
|
+
markup += "\"";
|
|
6175
6169
|
}
|
|
6176
6170
|
if (this.classes.length > 0) {
|
|
6177
6171
|
markup += " class =\"" + utils_escape(createClass(this.classes)) + "\"";
|
|
@@ -6318,7 +6312,8 @@ const rowLikeTypes = new Set(["mrow", "mtable"]);
|
|
|
6318
6312
|
* optional replacement from symbols.js.
|
|
6319
6313
|
*/
|
|
6320
6314
|
const makeText = function (text, mode, options) {
|
|
6321
|
-
|
|
6315
|
+
var _options$fontFamily, _options$font;
|
|
6316
|
+
if (src_symbols[mode][text] && src_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"))) {
|
|
6322
6317
|
text = src_symbols[mode][text].replace;
|
|
6323
6318
|
}
|
|
6324
6319
|
return new TextNode(text);
|
|
@@ -6807,7 +6802,7 @@ class Options {
|
|
|
6807
6802
|
*/
|
|
6808
6803
|
sizingClasses(oldOptions) {
|
|
6809
6804
|
if (oldOptions.size !== this.size) {
|
|
6810
|
-
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
6805
|
+
return ["katex-sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
6811
6806
|
} else {
|
|
6812
6807
|
return [];
|
|
6813
6808
|
}
|
|
@@ -6819,7 +6814,7 @@ class Options {
|
|
|
6819
6814
|
*/
|
|
6820
6815
|
baseSizingClasses() {
|
|
6821
6816
|
if (this.size !== Options.BASESIZE) {
|
|
6822
|
-
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
6817
|
+
return ["katex-sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
6823
6818
|
} else {
|
|
6824
6819
|
return [];
|
|
6825
6820
|
}
|
|
@@ -7105,7 +7100,9 @@ const stretchySvg = function (group, options) {
|
|
|
7105
7100
|
if (!data) {
|
|
7106
7101
|
throw new Error("No SVG data for \"" + label + "\".");
|
|
7107
7102
|
}
|
|
7108
|
-
const
|
|
7103
|
+
const paths = data[0],
|
|
7104
|
+
minWidth = data[1],
|
|
7105
|
+
viewBoxHeight = data[2];
|
|
7109
7106
|
const height = viewBoxHeight / 1000;
|
|
7110
7107
|
const numSvgChildren = paths.length;
|
|
7111
7108
|
let widthClasses;
|
|
@@ -7146,17 +7143,16 @@ const stretchySvg = function (group, options) {
|
|
|
7146
7143
|
}
|
|
7147
7144
|
}
|
|
7148
7145
|
return {
|
|
7149
|
-
span: makeSpan(["stretchy"], spans, options),
|
|
7146
|
+
span: makeSpan(["katex-stretchy"], spans, options),
|
|
7150
7147
|
minWidth,
|
|
7151
7148
|
height
|
|
7152
7149
|
};
|
|
7153
7150
|
}
|
|
7154
7151
|
} // buildSvgSpan_()
|
|
7155
|
-
const
|
|
7156
|
-
span,
|
|
7157
|
-
minWidth,
|
|
7158
|
-
height
|
|
7159
|
-
} = buildSvgSpan_();
|
|
7152
|
+
const _buildSvgSpan_ = buildSvgSpan_(),
|
|
7153
|
+
span = _buildSvgSpan_.span,
|
|
7154
|
+
minWidth = _buildSvgSpan_.minWidth,
|
|
7155
|
+
height = _buildSvgSpan_.height;
|
|
7160
7156
|
|
|
7161
7157
|
// Note that we are returning span.depth = 0.
|
|
7162
7158
|
// Any adjustments relative to the baseline must be done in buildHTML.
|
|
@@ -7172,7 +7168,7 @@ const stretchyEnclose = function (inner, label, topPad, bottomPad, options) {
|
|
|
7172
7168
|
let img;
|
|
7173
7169
|
const totalHeight = inner.height + inner.depth + topPad + bottomPad;
|
|
7174
7170
|
if (/fbox|color|angl/.test(label)) {
|
|
7175
|
-
img = makeSpan(["stretchy", label], [], options);
|
|
7171
|
+
img = makeSpan(["katex-stretchy", label], [], options);
|
|
7176
7172
|
if (label === "fbox") {
|
|
7177
7173
|
const color = options.color && options.getColor();
|
|
7178
7174
|
if (color) {
|
|
@@ -7220,27 +7216,12 @@ const stretchyEnclose = function (inner, label, topPad, bottomPad, options) {
|
|
|
7220
7216
|
* pull in `isAtom` without dragging in the ~870-line symbol tables.
|
|
7221
7217
|
*/
|
|
7222
7218
|
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
const ATOMS = {
|
|
7228
|
-
"bin": 1,
|
|
7229
|
-
"close": 1,
|
|
7230
|
-
"inner": 1,
|
|
7231
|
-
"open": 1,
|
|
7232
|
-
"punct": 1,
|
|
7233
|
-
"rel": 1
|
|
7234
|
-
};
|
|
7235
|
-
const NON_ATOMS = {
|
|
7236
|
-
"accent-token": 1,
|
|
7237
|
-
"mathord": 1,
|
|
7238
|
-
"op-token": 1,
|
|
7239
|
-
"spacing": 1,
|
|
7240
|
-
"textord": 1
|
|
7241
|
-
};
|
|
7219
|
+
const atomList = ["bin", "close", "inner", "open", "punct", "rel"];
|
|
7220
|
+
const nonAtomList = ["accent-token", "mathord", "op-token", "spacing", "textord"];
|
|
7221
|
+
const Atoms = new Set(atomList);
|
|
7222
|
+
const NonAtoms = new Set(nonAtomList);
|
|
7242
7223
|
function isAtom(value) {
|
|
7243
|
-
return value
|
|
7224
|
+
return Atoms.has(value);
|
|
7244
7225
|
}
|
|
7245
7226
|
;// ./src/parseNode.ts
|
|
7246
7227
|
|
|
@@ -7272,7 +7253,7 @@ function assertSymbolNodeType(node) {
|
|
|
7272
7253
|
* returns null.
|
|
7273
7254
|
*/
|
|
7274
7255
|
function checkSymbolNodeType(node) {
|
|
7275
|
-
if (node
|
|
7256
|
+
if (node.type === "atom" || NonAtoms.has(node.type)) {
|
|
7276
7257
|
return node;
|
|
7277
7258
|
}
|
|
7278
7259
|
return null;
|
|
@@ -7396,7 +7377,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7396
7377
|
// Shift the accent over by the skew.
|
|
7397
7378
|
let left = skew;
|
|
7398
7379
|
|
|
7399
|
-
// CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
|
|
7380
|
+
// CSS defines `.katex .katex-accent .accent-body:not(.accent-full) { width: 0 }`
|
|
7400
7381
|
// so that the accent doesn't contribute to the bounding box.
|
|
7401
7382
|
// We need to shift the character by its width (effectively half
|
|
7402
7383
|
// its width) to compensate.
|
|
@@ -7441,7 +7422,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7441
7422
|
}]
|
|
7442
7423
|
}, options);
|
|
7443
7424
|
}
|
|
7444
|
-
const accentWrap = makeSpan(["mord", "accent"], [accentBody], options);
|
|
7425
|
+
const accentWrap = makeSpan(["mord", "katex-accent"], [accentBody], options);
|
|
7445
7426
|
if (supSubGroup) {
|
|
7446
7427
|
// Here, we replace the "base" child of the supsub with our newly
|
|
7447
7428
|
// generated accent.
|
|
@@ -7527,10 +7508,8 @@ defineFunction({
|
|
|
7527
7508
|
names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
|
|
7528
7509
|
numArgs: 1,
|
|
7529
7510
|
handler: (_ref, args) => {
|
|
7530
|
-
let
|
|
7531
|
-
|
|
7532
|
-
funcName
|
|
7533
|
-
} = _ref;
|
|
7511
|
+
let parser = _ref.parser,
|
|
7512
|
+
funcName = _ref.funcName;
|
|
7534
7513
|
const base = args[0];
|
|
7535
7514
|
return {
|
|
7536
7515
|
type: "accentUnder",
|
|
@@ -7597,10 +7576,8 @@ defineFunction({
|
|
|
7597
7576
|
numArgs: 1,
|
|
7598
7577
|
numOptionalArgs: 1,
|
|
7599
7578
|
handler(_ref, args, optArgs) {
|
|
7600
|
-
let
|
|
7601
|
-
|
|
7602
|
-
funcName
|
|
7603
|
-
} = _ref;
|
|
7579
|
+
let parser = _ref.parser,
|
|
7580
|
+
funcName = _ref.funcName;
|
|
7604
7581
|
return {
|
|
7605
7582
|
type: "xArrow",
|
|
7606
7583
|
mode: parser.mode,
|
|
@@ -7757,10 +7734,8 @@ defineFunction({
|
|
|
7757
7734
|
numArgs: 1,
|
|
7758
7735
|
primitive: true,
|
|
7759
7736
|
handler(_ref, args) {
|
|
7760
|
-
let
|
|
7761
|
-
|
|
7762
|
-
funcName
|
|
7763
|
-
} = _ref;
|
|
7737
|
+
let parser = _ref.parser,
|
|
7738
|
+
funcName = _ref.funcName;
|
|
7764
7739
|
const body = args[0];
|
|
7765
7740
|
return {
|
|
7766
7741
|
type: "mclass",
|
|
@@ -7793,9 +7768,7 @@ defineFunction({
|
|
|
7793
7768
|
names: ["\\@binrel"],
|
|
7794
7769
|
numArgs: 2,
|
|
7795
7770
|
handler(_ref2, args) {
|
|
7796
|
-
let
|
|
7797
|
-
parser
|
|
7798
|
-
} = _ref2;
|
|
7771
|
+
let parser = _ref2.parser;
|
|
7799
7772
|
return {
|
|
7800
7773
|
type: "mclass",
|
|
7801
7774
|
mode: parser.mode,
|
|
@@ -7812,10 +7785,8 @@ defineFunction({
|
|
|
7812
7785
|
names: ["\\stackrel", "\\overset", "\\underset"],
|
|
7813
7786
|
numArgs: 2,
|
|
7814
7787
|
handler(_ref3, args) {
|
|
7815
|
-
let
|
|
7816
|
-
|
|
7817
|
-
funcName
|
|
7818
|
-
} = _ref3;
|
|
7788
|
+
let parser = _ref3.parser,
|
|
7789
|
+
funcName = _ref3.funcName;
|
|
7819
7790
|
const baseArg = args[1];
|
|
7820
7791
|
const shiftedArg = args[0];
|
|
7821
7792
|
let mclass;
|
|
@@ -7873,9 +7844,7 @@ defineFunction({
|
|
|
7873
7844
|
numArgs: 1,
|
|
7874
7845
|
allowedInText: true,
|
|
7875
7846
|
handler(_ref, args) {
|
|
7876
|
-
let
|
|
7877
|
-
parser
|
|
7878
|
-
} = _ref;
|
|
7847
|
+
let parser = _ref.parser;
|
|
7879
7848
|
return {
|
|
7880
7849
|
type: "pmb",
|
|
7881
7850
|
mode: parser.mode,
|
|
@@ -8141,10 +8110,8 @@ defineFunction({
|
|
|
8141
8110
|
names: ["\\\\cdleft", "\\\\cdright"],
|
|
8142
8111
|
numArgs: 1,
|
|
8143
8112
|
handler(_ref, args) {
|
|
8144
|
-
let
|
|
8145
|
-
|
|
8146
|
-
funcName
|
|
8147
|
-
} = _ref;
|
|
8113
|
+
let parser = _ref.parser,
|
|
8114
|
+
funcName = _ref.funcName;
|
|
8148
8115
|
return {
|
|
8149
8116
|
type: "cdlabel",
|
|
8150
8117
|
mode: parser.mode,
|
|
@@ -8184,9 +8151,7 @@ defineFunction({
|
|
|
8184
8151
|
names: ["\\\\cdparent"],
|
|
8185
8152
|
numArgs: 1,
|
|
8186
8153
|
handler(_ref2, args) {
|
|
8187
|
-
let
|
|
8188
|
-
parser
|
|
8189
|
-
} = _ref2;
|
|
8154
|
+
let parser = _ref2.parser;
|
|
8190
8155
|
return {
|
|
8191
8156
|
type: "cdlabelparent",
|
|
8192
8157
|
mode: parser.mode,
|
|
@@ -8219,9 +8184,7 @@ defineFunction({
|
|
|
8219
8184
|
numArgs: 1,
|
|
8220
8185
|
allowedInText: true,
|
|
8221
8186
|
handler(_ref, args) {
|
|
8222
|
-
let
|
|
8223
|
-
parser
|
|
8224
|
-
} = _ref;
|
|
8187
|
+
let parser = _ref.parser;
|
|
8225
8188
|
const arg = assertNodeType(args[0], "ordgroup");
|
|
8226
8189
|
const group = arg.body;
|
|
8227
8190
|
let number = "";
|
|
@@ -8280,9 +8243,7 @@ defineFunction({
|
|
|
8280
8243
|
allowedInText: true,
|
|
8281
8244
|
argTypes: ["color", "original"],
|
|
8282
8245
|
handler(_ref, args) {
|
|
8283
|
-
let
|
|
8284
|
-
parser
|
|
8285
|
-
} = _ref;
|
|
8246
|
+
let parser = _ref.parser;
|
|
8286
8247
|
const color = assertNodeType(args[0], "color-token").color;
|
|
8287
8248
|
const body = args[1];
|
|
8288
8249
|
return {
|
|
@@ -8302,10 +8263,8 @@ defineFunction({
|
|
|
8302
8263
|
allowedInText: true,
|
|
8303
8264
|
argTypes: ["color"],
|
|
8304
8265
|
handler(_ref2, args) {
|
|
8305
|
-
let
|
|
8306
|
-
|
|
8307
|
-
breakOnTokenText
|
|
8308
|
-
} = _ref2;
|
|
8266
|
+
let parser = _ref2.parser,
|
|
8267
|
+
breakOnTokenText = _ref2.breakOnTokenText;
|
|
8309
8268
|
const color = assertNodeType(args[0], "color-token").color;
|
|
8310
8269
|
|
|
8311
8270
|
// Set macro \current@color in current namespace to store the current
|
|
@@ -8341,9 +8300,7 @@ defineFunction({
|
|
|
8341
8300
|
numOptionalArgs: 0,
|
|
8342
8301
|
allowedInText: true,
|
|
8343
8302
|
handler(_ref, args, optArgs) {
|
|
8344
|
-
let
|
|
8345
|
-
parser
|
|
8346
|
-
} = _ref;
|
|
8303
|
+
let parser = _ref.parser;
|
|
8347
8304
|
const size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null;
|
|
8348
8305
|
const newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
|
|
8349
8306
|
return {
|
|
@@ -8359,7 +8316,7 @@ defineFunction({
|
|
|
8359
8316
|
htmlBuilder(group, options) {
|
|
8360
8317
|
const span = makeSpan(["mspace"], [], options);
|
|
8361
8318
|
if (group.newLine) {
|
|
8362
|
-
span.classes.push("newline");
|
|
8319
|
+
span.classes.push("katex-newline");
|
|
8363
8320
|
if (group.size) {
|
|
8364
8321
|
span.style.marginTop = makeEm(calculateSize(group.size, options));
|
|
8365
8322
|
}
|
|
@@ -8438,10 +8395,8 @@ defineFunction({
|
|
|
8438
8395
|
numArgs: 0,
|
|
8439
8396
|
allowedInText: true,
|
|
8440
8397
|
handler(_ref) {
|
|
8441
|
-
let
|
|
8442
|
-
|
|
8443
|
-
funcName
|
|
8444
|
-
} = _ref;
|
|
8398
|
+
let parser = _ref.parser,
|
|
8399
|
+
funcName = _ref.funcName;
|
|
8445
8400
|
parser.consumeSpaces();
|
|
8446
8401
|
const token = parser.fetch();
|
|
8447
8402
|
if (globalMap[token.text]) {
|
|
@@ -8466,10 +8421,8 @@ defineFunction({
|
|
|
8466
8421
|
allowedInText: true,
|
|
8467
8422
|
primitive: true,
|
|
8468
8423
|
handler(_ref2) {
|
|
8469
|
-
let
|
|
8470
|
-
|
|
8471
|
-
funcName
|
|
8472
|
-
} = _ref2;
|
|
8424
|
+
let parser = _ref2.parser,
|
|
8425
|
+
funcName = _ref2.funcName;
|
|
8473
8426
|
let tok = parser.gullet.popToken();
|
|
8474
8427
|
const name = tok.text;
|
|
8475
8428
|
if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
|
|
@@ -8510,9 +8463,8 @@ defineFunction({
|
|
|
8510
8463
|
}
|
|
8511
8464
|
}
|
|
8512
8465
|
// replacement text, enclosed in '{' and '}' and properly nested
|
|
8513
|
-
let
|
|
8514
|
-
tokens
|
|
8515
|
-
} = parser.gullet.consumeArg();
|
|
8466
|
+
let _parser$gullet$consum = parser.gullet.consumeArg(),
|
|
8467
|
+
tokens = _parser$gullet$consum.tokens;
|
|
8516
8468
|
if (insert) {
|
|
8517
8469
|
tokens.unshift(insert);
|
|
8518
8470
|
}
|
|
@@ -8545,10 +8497,8 @@ defineFunction({
|
|
|
8545
8497
|
allowedInText: true,
|
|
8546
8498
|
primitive: true,
|
|
8547
8499
|
handler(_ref3) {
|
|
8548
|
-
let
|
|
8549
|
-
|
|
8550
|
-
funcName
|
|
8551
|
-
} = _ref3;
|
|
8500
|
+
let parser = _ref3.parser,
|
|
8501
|
+
funcName = _ref3.funcName;
|
|
8552
8502
|
const name = checkControlSequence(parser.gullet.popToken());
|
|
8553
8503
|
parser.gullet.consumeSpaces();
|
|
8554
8504
|
const tok = getRHS(parser);
|
|
@@ -8569,10 +8519,8 @@ defineFunction({
|
|
|
8569
8519
|
allowedInText: true,
|
|
8570
8520
|
primitive: true,
|
|
8571
8521
|
handler(_ref4) {
|
|
8572
|
-
let
|
|
8573
|
-
|
|
8574
|
-
funcName
|
|
8575
|
-
} = _ref4;
|
|
8522
|
+
let parser = _ref4.parser,
|
|
8523
|
+
funcName = _ref4.funcName;
|
|
8576
8524
|
const name = checkControlSequence(parser.gullet.popToken());
|
|
8577
8525
|
const middle = parser.gullet.popToken();
|
|
8578
8526
|
const tok = parser.gullet.popToken();
|
|
@@ -9641,7 +9589,7 @@ const enclose_htmlBuilder = (group, options) => {
|
|
|
9641
9589
|
// subjects that should get the "tall" treatment.
|
|
9642
9590
|
const isSingleChar = isCharacterBox(group.body);
|
|
9643
9591
|
if (label === "sout") {
|
|
9644
|
-
img = makeSpan(["stretchy", "sout"]);
|
|
9592
|
+
img = makeSpan(["katex-stretchy", "katex-sout"]);
|
|
9645
9593
|
img.height = options.fontMetrics().defaultRuleThickness / scale;
|
|
9646
9594
|
imgShift = -0.5 * options.fontMetrics().xHeight;
|
|
9647
9595
|
} else if (label === "phase") {
|
|
@@ -9825,10 +9773,8 @@ defineFunction({
|
|
|
9825
9773
|
allowedInText: true,
|
|
9826
9774
|
argTypes: ["color", "hbox"],
|
|
9827
9775
|
handler(_ref, args, optArgs) {
|
|
9828
|
-
let
|
|
9829
|
-
|
|
9830
|
-
funcName
|
|
9831
|
-
} = _ref;
|
|
9776
|
+
let parser = _ref.parser,
|
|
9777
|
+
funcName = _ref.funcName;
|
|
9832
9778
|
const color = assertNodeType(args[0], "color-token").color;
|
|
9833
9779
|
const body = args[1];
|
|
9834
9780
|
return {
|
|
@@ -9849,10 +9795,8 @@ defineFunction({
|
|
|
9849
9795
|
allowedInText: true,
|
|
9850
9796
|
argTypes: ["color", "color", "hbox"],
|
|
9851
9797
|
handler(_ref2, args, optArgs) {
|
|
9852
|
-
let
|
|
9853
|
-
|
|
9854
|
-
funcName
|
|
9855
|
-
} = _ref2;
|
|
9798
|
+
let parser = _ref2.parser,
|
|
9799
|
+
funcName = _ref2.funcName;
|
|
9856
9800
|
const borderColor = assertNodeType(args[0], "color-token").color;
|
|
9857
9801
|
const backgroundColor = assertNodeType(args[1], "color-token").color;
|
|
9858
9802
|
const body = args[2];
|
|
@@ -9873,9 +9817,7 @@ defineFunction({
|
|
|
9873
9817
|
argTypes: ["hbox"],
|
|
9874
9818
|
allowedInText: true,
|
|
9875
9819
|
handler(_ref3, args) {
|
|
9876
|
-
let
|
|
9877
|
-
parser
|
|
9878
|
-
} = _ref3;
|
|
9820
|
+
let parser = _ref3.parser;
|
|
9879
9821
|
return {
|
|
9880
9822
|
type: "enclose",
|
|
9881
9823
|
mode: parser.mode,
|
|
@@ -9889,10 +9831,8 @@ defineFunction({
|
|
|
9889
9831
|
names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
|
|
9890
9832
|
numArgs: 1,
|
|
9891
9833
|
handler(_ref4, args) {
|
|
9892
|
-
let
|
|
9893
|
-
|
|
9894
|
-
funcName
|
|
9895
|
-
} = _ref4;
|
|
9834
|
+
let parser = _ref4.parser,
|
|
9835
|
+
funcName = _ref4.funcName;
|
|
9896
9836
|
const body = args[0];
|
|
9897
9837
|
return {
|
|
9898
9838
|
type: "enclose",
|
|
@@ -9908,10 +9848,8 @@ defineFunction({
|
|
|
9908
9848
|
numArgs: 1,
|
|
9909
9849
|
allowedInText: true,
|
|
9910
9850
|
handler(_ref5, args) {
|
|
9911
|
-
let
|
|
9912
|
-
|
|
9913
|
-
funcName
|
|
9914
|
-
} = _ref5;
|
|
9851
|
+
let parser = _ref5.parser,
|
|
9852
|
+
funcName = _ref5.funcName;
|
|
9915
9853
|
if (parser.mode === "math") {
|
|
9916
9854
|
parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode");
|
|
9917
9855
|
}
|
|
@@ -9931,9 +9869,7 @@ defineFunction({
|
|
|
9931
9869
|
argTypes: ["hbox"],
|
|
9932
9870
|
allowedInText: false,
|
|
9933
9871
|
handler(_ref6, args) {
|
|
9934
|
-
let
|
|
9935
|
-
parser
|
|
9936
|
-
} = _ref6;
|
|
9872
|
+
let parser = _ref6.parser;
|
|
9937
9873
|
return {
|
|
9938
9874
|
type: "enclose",
|
|
9939
9875
|
mode: parser.mode,
|
|
@@ -9981,14 +9917,12 @@ defineFunction({
|
|
|
9981
9917
|
*/
|
|
9982
9918
|
const _environments = {};
|
|
9983
9919
|
function defineEnvironment(_ref) {
|
|
9984
|
-
let
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
mathmlBuilder
|
|
9991
|
-
} = _ref;
|
|
9920
|
+
let type = _ref.type,
|
|
9921
|
+
names = _ref.names,
|
|
9922
|
+
props = _ref.props,
|
|
9923
|
+
handler = _ref.handler,
|
|
9924
|
+
htmlBuilder = _ref.htmlBuilder,
|
|
9925
|
+
mathmlBuilder = _ref.mathmlBuilder;
|
|
9992
9926
|
// Set default values of environments.
|
|
9993
9927
|
const data = {
|
|
9994
9928
|
type,
|
|
@@ -10182,18 +10116,16 @@ function getAutoTag(name) {
|
|
|
10182
10116
|
* ("text", "display", etc.), then each cell is cast into that style.
|
|
10183
10117
|
*/
|
|
10184
10118
|
function parseArray(parser, _ref, style) {
|
|
10185
|
-
let
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
|
|
10195
|
-
leqno
|
|
10196
|
-
} = _ref;
|
|
10119
|
+
let hskipBeforeAndAfter = _ref.hskipBeforeAndAfter,
|
|
10120
|
+
addJot = _ref.addJot,
|
|
10121
|
+
cols = _ref.cols,
|
|
10122
|
+
arraystretch = _ref.arraystretch,
|
|
10123
|
+
colSeparationType = _ref.colSeparationType,
|
|
10124
|
+
autoTag = _ref.autoTag,
|
|
10125
|
+
singleRow = _ref.singleRow,
|
|
10126
|
+
emptySingleRow = _ref.emptySingleRow,
|
|
10127
|
+
maxNumCols = _ref.maxNumCols,
|
|
10128
|
+
leqno = _ref.leqno;
|
|
10197
10129
|
parser.gullet.beginGroup();
|
|
10198
10130
|
if (!singleRow) {
|
|
10199
10131
|
// \cr is equivalent to \\ without the optional size argument (see below)
|
|
@@ -10567,8 +10499,8 @@ const array_htmlBuilder = function (group, options) {
|
|
|
10567
10499
|
|
|
10568
10500
|
// Add \hline(s), if any.
|
|
10569
10501
|
if (hlines.length > 0) {
|
|
10570
|
-
const line = makeLineSpan("hline", options, ruleThickness);
|
|
10571
|
-
const dashes = makeLineSpan("hdashline", options, ruleThickness);
|
|
10502
|
+
const line = makeLineSpan("katex-hline", options, ruleThickness);
|
|
10503
|
+
const dashes = makeLineSpan("katex-hdashline", options, ruleThickness);
|
|
10572
10504
|
const vListElems = [{
|
|
10573
10505
|
type: "elem",
|
|
10574
10506
|
elem: tableBody,
|
|
@@ -10603,7 +10535,7 @@ const array_htmlBuilder = function (group, options) {
|
|
|
10603
10535
|
positionType: "individualShift",
|
|
10604
10536
|
children: tagSpans
|
|
10605
10537
|
}, options);
|
|
10606
|
-
const tagCol = makeSpan(["tag"], [eqnNumCol], options);
|
|
10538
|
+
const tagCol = makeSpan(["katex-tag"], [eqnNumCol], options);
|
|
10607
10539
|
return makeFragment([tableBody, tagCol]);
|
|
10608
10540
|
}
|
|
10609
10541
|
};
|
|
@@ -11171,10 +11103,8 @@ defineFunction({
|
|
|
11171
11103
|
numArgs: 1,
|
|
11172
11104
|
argTypes: ["text"],
|
|
11173
11105
|
handler(_ref, args) {
|
|
11174
|
-
let
|
|
11175
|
-
|
|
11176
|
-
funcName
|
|
11177
|
-
} = _ref;
|
|
11106
|
+
let parser = _ref.parser,
|
|
11107
|
+
funcName = _ref.funcName;
|
|
11178
11108
|
const nameGroup = args[0];
|
|
11179
11109
|
if (nameGroup.type !== "ordgroup") {
|
|
11180
11110
|
throw new src_ParseError("Invalid environment name", nameGroup);
|
|
@@ -11185,16 +11115,15 @@ defineFunction({
|
|
|
11185
11115
|
}
|
|
11186
11116
|
if (funcName === "\\begin") {
|
|
11187
11117
|
// begin...end is similar to left...right
|
|
11188
|
-
if (!
|
|
11118
|
+
if (!Object.prototype.hasOwnProperty.call(src_environments, envName)) {
|
|
11189
11119
|
throw new src_ParseError("No such environment: " + envName, nameGroup);
|
|
11190
11120
|
}
|
|
11191
11121
|
// Build the environment object. Arguments and other information will
|
|
11192
11122
|
// be made available to the begin and end methods using properties.
|
|
11193
11123
|
const env = src_environments[envName];
|
|
11194
|
-
const {
|
|
11195
|
-
args,
|
|
11196
|
-
optArgs
|
|
11197
|
-
} = parser.parseArguments("\\begin{" + envName + "}", env);
|
|
11124
|
+
const _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env),
|
|
11125
|
+
args = _parser$parseArgument.args,
|
|
11126
|
+
optArgs = _parser$parseArgument.optArgs;
|
|
11198
11127
|
const context = {
|
|
11199
11128
|
mode: parser.mode,
|
|
11200
11129
|
envName,
|
|
@@ -11256,10 +11185,8 @@ defineFunction({
|
|
|
11256
11185
|
numArgs: 1,
|
|
11257
11186
|
allowedInArgument: true,
|
|
11258
11187
|
handler: (_ref, args) => {
|
|
11259
|
-
let
|
|
11260
|
-
|
|
11261
|
-
funcName
|
|
11262
|
-
} = _ref;
|
|
11188
|
+
let parser = _ref.parser,
|
|
11189
|
+
funcName = _ref.funcName;
|
|
11263
11190
|
const body = normalizeArgument(args[0]);
|
|
11264
11191
|
const func = funcName in fontAliases ? fontAliases[funcName] : funcName;
|
|
11265
11192
|
return {
|
|
@@ -11277,9 +11204,7 @@ defineFunction({
|
|
|
11277
11204
|
names: ["\\boldsymbol", "\\bm"],
|
|
11278
11205
|
numArgs: 1,
|
|
11279
11206
|
handler: (_ref2, args) => {
|
|
11280
|
-
let
|
|
11281
|
-
parser
|
|
11282
|
-
} = _ref2;
|
|
11207
|
+
let parser = _ref2.parser;
|
|
11283
11208
|
const body = args[0];
|
|
11284
11209
|
// amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
|
|
11285
11210
|
// argument's bin|rel|ord status
|
|
@@ -11305,14 +11230,10 @@ defineFunction({
|
|
|
11305
11230
|
numArgs: 0,
|
|
11306
11231
|
allowedInText: true,
|
|
11307
11232
|
handler: (_ref3, args) => {
|
|
11308
|
-
let
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
} = _ref3;
|
|
11313
|
-
const {
|
|
11314
|
-
mode
|
|
11315
|
-
} = parser;
|
|
11233
|
+
let parser = _ref3.parser,
|
|
11234
|
+
funcName = _ref3.funcName,
|
|
11235
|
+
breakOnTokenText = _ref3.breakOnTokenText;
|
|
11236
|
+
const mode = parser.mode;
|
|
11316
11237
|
const body = parser.parseExpression(true, breakOnTokenText);
|
|
11317
11238
|
return {
|
|
11318
11239
|
type: "font",
|
|
@@ -11521,10 +11442,8 @@ defineFunction({
|
|
|
11521
11442
|
numArgs: 2,
|
|
11522
11443
|
allowedInArgument: true,
|
|
11523
11444
|
handler: (_ref, args) => {
|
|
11524
|
-
let
|
|
11525
|
-
|
|
11526
|
-
funcName
|
|
11527
|
-
} = _ref;
|
|
11445
|
+
let parser = _ref.parser,
|
|
11446
|
+
funcName = _ref.funcName;
|
|
11528
11447
|
const numer = args[0];
|
|
11529
11448
|
const denom = args[1];
|
|
11530
11449
|
let hasBarLine;
|
|
@@ -11591,11 +11510,9 @@ defineFunction({
|
|
|
11591
11510
|
numArgs: 0,
|
|
11592
11511
|
infix: true,
|
|
11593
11512
|
handler(_ref2) {
|
|
11594
|
-
let
|
|
11595
|
-
|
|
11596
|
-
|
|
11597
|
-
token
|
|
11598
|
-
} = _ref2;
|
|
11513
|
+
let parser = _ref2.parser,
|
|
11514
|
+
funcName = _ref2.funcName,
|
|
11515
|
+
token = _ref2.token;
|
|
11599
11516
|
let replaceWith;
|
|
11600
11517
|
switch (funcName) {
|
|
11601
11518
|
case "\\over":
|
|
@@ -11640,9 +11557,7 @@ defineFunction({
|
|
|
11640
11557
|
allowedInArgument: true,
|
|
11641
11558
|
argTypes: ["math", "math", "size", "text", "math", "math"],
|
|
11642
11559
|
handler(_ref3, args) {
|
|
11643
|
-
let
|
|
11644
|
-
parser
|
|
11645
|
-
} = _ref3;
|
|
11560
|
+
let parser = _ref3.parser;
|
|
11646
11561
|
const numer = args[4];
|
|
11647
11562
|
const denom = args[5];
|
|
11648
11563
|
|
|
@@ -11698,11 +11613,9 @@ defineFunction({
|
|
|
11698
11613
|
argTypes: ["size"],
|
|
11699
11614
|
infix: true,
|
|
11700
11615
|
handler(_ref4, args) {
|
|
11701
|
-
let
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
token
|
|
11705
|
-
} = _ref4;
|
|
11616
|
+
let parser = _ref4.parser,
|
|
11617
|
+
funcName = _ref4.funcName,
|
|
11618
|
+
token = _ref4.token;
|
|
11706
11619
|
return {
|
|
11707
11620
|
type: "infix",
|
|
11708
11621
|
mode: parser.mode,
|
|
@@ -11718,10 +11631,8 @@ defineFunction({
|
|
|
11718
11631
|
numArgs: 3,
|
|
11719
11632
|
argTypes: ["math", "size", "math"],
|
|
11720
11633
|
handler: (_ref5, args) => {
|
|
11721
|
-
let
|
|
11722
|
-
|
|
11723
|
-
funcName
|
|
11724
|
-
} = _ref5;
|
|
11634
|
+
let parser = _ref5.parser,
|
|
11635
|
+
funcName = _ref5.funcName;
|
|
11725
11636
|
const numer = args[0];
|
|
11726
11637
|
const barSize = assertNodeType(args[1], "infix").size;
|
|
11727
11638
|
if (!barSize) {
|
|
@@ -11865,10 +11776,8 @@ defineFunction({
|
|
|
11865
11776
|
names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
|
|
11866
11777
|
numArgs: 1,
|
|
11867
11778
|
handler(_ref, args) {
|
|
11868
|
-
let
|
|
11869
|
-
|
|
11870
|
-
funcName
|
|
11871
|
-
} = _ref;
|
|
11779
|
+
let parser = _ref.parser,
|
|
11780
|
+
funcName = _ref.funcName;
|
|
11872
11781
|
return {
|
|
11873
11782
|
type: "horizBrace",
|
|
11874
11783
|
mode: parser.mode,
|
|
@@ -11894,9 +11803,7 @@ defineFunction({
|
|
|
11894
11803
|
argTypes: ["url", "original"],
|
|
11895
11804
|
allowedInText: true,
|
|
11896
11805
|
handler: (_ref, args) => {
|
|
11897
|
-
let
|
|
11898
|
-
parser
|
|
11899
|
-
} = _ref;
|
|
11806
|
+
let parser = _ref.parser;
|
|
11900
11807
|
const body = args[1];
|
|
11901
11808
|
const href = assertNodeType(args[0], "url").url;
|
|
11902
11809
|
if (!parser.settings.isTrusted({
|
|
@@ -11932,9 +11839,7 @@ defineFunction({
|
|
|
11932
11839
|
argTypes: ["url"],
|
|
11933
11840
|
allowedInText: true,
|
|
11934
11841
|
handler: (_ref2, args) => {
|
|
11935
|
-
let
|
|
11936
|
-
parser
|
|
11937
|
-
} = _ref2;
|
|
11842
|
+
let parser = _ref2.parser;
|
|
11938
11843
|
const href = assertNodeType(args[0], "url").url;
|
|
11939
11844
|
if (!parser.settings.isTrusted({
|
|
11940
11845
|
command: "\\url",
|
|
@@ -11988,9 +11893,7 @@ defineFunction({
|
|
|
11988
11893
|
allowedInText: true,
|
|
11989
11894
|
primitive: true,
|
|
11990
11895
|
handler(_ref, args) {
|
|
11991
|
-
let
|
|
11992
|
-
parser
|
|
11993
|
-
} = _ref;
|
|
11896
|
+
let parser = _ref.parser;
|
|
11994
11897
|
return {
|
|
11995
11898
|
type: "hbox",
|
|
11996
11899
|
mode: parser.mode,
|
|
@@ -12019,11 +11922,9 @@ defineFunction({
|
|
|
12019
11922
|
argTypes: ["raw", "original"],
|
|
12020
11923
|
allowedInText: true,
|
|
12021
11924
|
handler: (_ref, args) => {
|
|
12022
|
-
let
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
token
|
|
12026
|
-
} = _ref;
|
|
11925
|
+
let parser = _ref.parser,
|
|
11926
|
+
funcName = _ref.funcName,
|
|
11927
|
+
token = _ref.token;
|
|
12027
11928
|
const value = assertNodeType(args[0], "raw").string;
|
|
12028
11929
|
const body = args[1];
|
|
12029
11930
|
if (parser.settings.strict) {
|
|
@@ -12055,7 +11956,24 @@ defineFunction({
|
|
|
12055
11956
|
break;
|
|
12056
11957
|
case "\\htmlData":
|
|
12057
11958
|
{
|
|
12058
|
-
|
|
11959
|
+
// `{,}` escapes a literal comma. Braces are used rather than a
|
|
11960
|
+
// backslash because `\,` is a macro (a thin space) that expands
|
|
11961
|
+
// away before this raw argument is ever read.
|
|
11962
|
+
const ESCAPED_COMMA = "{,}";
|
|
11963
|
+
const data = [];
|
|
11964
|
+
let current = "";
|
|
11965
|
+
for (let i = 0; i < value.length; i++) {
|
|
11966
|
+
if (value.startsWith(ESCAPED_COMMA, i)) {
|
|
11967
|
+
current += ",";
|
|
11968
|
+
i += ESCAPED_COMMA.length - 1;
|
|
11969
|
+
} else if (value[i] === ",") {
|
|
11970
|
+
data.push(current);
|
|
11971
|
+
current = "";
|
|
11972
|
+
} else {
|
|
11973
|
+
current += value[i];
|
|
11974
|
+
}
|
|
11975
|
+
}
|
|
11976
|
+
data.push(current);
|
|
12059
11977
|
for (let i = 0; i < data.length; i++) {
|
|
12060
11978
|
const item = data[i];
|
|
12061
11979
|
const firstEquals = item.indexOf("=");
|
|
@@ -12092,9 +12010,11 @@ defineFunction({
|
|
|
12092
12010
|
classes.push(...group.attributes.class.trim().split(/\s+/));
|
|
12093
12011
|
}
|
|
12094
12012
|
const span = makeSpan(classes, elements, options);
|
|
12095
|
-
for (const
|
|
12096
|
-
|
|
12097
|
-
|
|
12013
|
+
for (const _ref2 of Object.entries(group.attributes)) {
|
|
12014
|
+
const attr = _ref2[0];
|
|
12015
|
+
const value = _ref2[1];
|
|
12016
|
+
if (attr !== "class") {
|
|
12017
|
+
span.setAttribute(attr, value);
|
|
12098
12018
|
}
|
|
12099
12019
|
}
|
|
12100
12020
|
return span;
|
|
@@ -12115,9 +12035,7 @@ defineFunction({
|
|
|
12115
12035
|
allowedInArgument: true,
|
|
12116
12036
|
allowedInText: true,
|
|
12117
12037
|
handler: (_ref, args) => {
|
|
12118
|
-
let
|
|
12119
|
-
parser
|
|
12120
|
-
} = _ref;
|
|
12038
|
+
let parser = _ref.parser;
|
|
12121
12039
|
return {
|
|
12122
12040
|
type: "htmlmathml",
|
|
12123
12041
|
mode: parser.mode,
|
|
@@ -12172,9 +12090,7 @@ defineFunction({
|
|
|
12172
12090
|
argTypes: ["raw", "url"],
|
|
12173
12091
|
allowedInText: false,
|
|
12174
12092
|
handler: (_ref, args, optArgs) => {
|
|
12175
|
-
let
|
|
12176
|
-
parser
|
|
12177
|
-
} = _ref;
|
|
12093
|
+
let parser = _ref.parser;
|
|
12178
12094
|
let width = {
|
|
12179
12095
|
number: 0,
|
|
12180
12096
|
unit: "em"
|
|
@@ -12300,10 +12216,8 @@ defineFunction({
|
|
|
12300
12216
|
primitive: true,
|
|
12301
12217
|
allowedInText: true,
|
|
12302
12218
|
handler(_ref, args) {
|
|
12303
|
-
let
|
|
12304
|
-
|
|
12305
|
-
funcName
|
|
12306
|
-
} = _ref;
|
|
12219
|
+
let parser = _ref.parser,
|
|
12220
|
+
funcName = _ref.funcName;
|
|
12307
12221
|
const size = assertNodeType(args[0], "size");
|
|
12308
12222
|
if (parser.settings.strict) {
|
|
12309
12223
|
const mathFunction = funcName[1] === 'm'; // \mkern, \mskip
|
|
@@ -12350,10 +12264,8 @@ defineFunction({
|
|
|
12350
12264
|
numArgs: 1,
|
|
12351
12265
|
allowedInText: true,
|
|
12352
12266
|
handler: (_ref, args) => {
|
|
12353
|
-
let
|
|
12354
|
-
|
|
12355
|
-
funcName
|
|
12356
|
-
} = _ref;
|
|
12267
|
+
let parser = _ref.parser,
|
|
12268
|
+
funcName = _ref.funcName;
|
|
12357
12269
|
const body = args[0];
|
|
12358
12270
|
return {
|
|
12359
12271
|
type: "lap",
|
|
@@ -12368,12 +12280,12 @@ defineFunction({
|
|
|
12368
12280
|
if (group.alignment === "clap") {
|
|
12369
12281
|
// ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
|
|
12370
12282
|
inner = makeSpan([], [buildGroup(group.body, options)]);
|
|
12371
|
-
// wrap, since CSS will center a .clap > .inner > span
|
|
12372
|
-
inner = makeSpan(["inner"], [inner], options);
|
|
12283
|
+
// wrap, since CSS will center a .clap > .katex-inner > span
|
|
12284
|
+
inner = makeSpan(["katex-inner"], [inner], options);
|
|
12373
12285
|
} else {
|
|
12374
|
-
inner = makeSpan(["inner"], [buildGroup(group.body, options)]);
|
|
12286
|
+
inner = makeSpan(["katex-inner"], [buildGroup(group.body, options)]);
|
|
12375
12287
|
}
|
|
12376
|
-
const fix = makeSpan(["fix"], []);
|
|
12288
|
+
const fix = makeSpan(["katex-fix"], []);
|
|
12377
12289
|
let node = makeSpan([group.alignment], [inner, fix], options);
|
|
12378
12290
|
|
|
12379
12291
|
// At this point, we have correctly set horizontal alignment of the
|
|
@@ -12381,7 +12293,7 @@ defineFunction({
|
|
|
12381
12293
|
// Next, use a strut to set the height of the HTML bounding box.
|
|
12382
12294
|
// Otherwise, a tall argument may be misplaced.
|
|
12383
12295
|
// This code resolved issue #1153
|
|
12384
|
-
const strut = makeSpan(["strut"]);
|
|
12296
|
+
const strut = makeSpan(["katex-strut"]);
|
|
12385
12297
|
strut.style.height = makeEm(node.height + node.depth);
|
|
12386
12298
|
if (node.depth) {
|
|
12387
12299
|
strut.style.verticalAlign = makeEm(-node.depth);
|
|
@@ -12390,8 +12302,8 @@ defineFunction({
|
|
|
12390
12302
|
|
|
12391
12303
|
// Next, prevent vertical misplacement when next to something tall.
|
|
12392
12304
|
// This code resolves issue #1234
|
|
12393
|
-
node = makeSpan(["thinbox"], [node], options);
|
|
12394
|
-
return makeSpan(["mord", "vbox"], [node], options);
|
|
12305
|
+
node = makeSpan(["katex-thinbox"], [node], options);
|
|
12306
|
+
return makeSpan(["mord", "katex-vbox"], [node], options);
|
|
12395
12307
|
},
|
|
12396
12308
|
mathmlBuilder: (group, options) => {
|
|
12397
12309
|
// mathllap, mathrlap, mathclap
|
|
@@ -12416,10 +12328,8 @@ defineFunction({
|
|
|
12416
12328
|
allowedInText: true,
|
|
12417
12329
|
allowedInMath: false,
|
|
12418
12330
|
handler(_ref, args) {
|
|
12419
|
-
let
|
|
12420
|
-
|
|
12421
|
-
parser
|
|
12422
|
-
} = _ref;
|
|
12331
|
+
let funcName = _ref.funcName,
|
|
12332
|
+
parser = _ref.parser;
|
|
12423
12333
|
const outerMode = parser.mode;
|
|
12424
12334
|
parser.switchMode("math");
|
|
12425
12335
|
const close = funcName === "\\(" ? "\\)" : "$";
|
|
@@ -12474,9 +12384,7 @@ defineFunction({
|
|
|
12474
12384
|
numArgs: 4,
|
|
12475
12385
|
primitive: true,
|
|
12476
12386
|
handler: (_ref, args) => {
|
|
12477
|
-
let
|
|
12478
|
-
parser
|
|
12479
|
-
} = _ref;
|
|
12387
|
+
let parser = _ref.parser;
|
|
12480
12388
|
return {
|
|
12481
12389
|
type: "mathchoice",
|
|
12482
12390
|
mode: parser.mode,
|
|
@@ -12790,10 +12698,8 @@ defineFunction({
|
|
|
12790
12698
|
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"],
|
|
12791
12699
|
numArgs: 0,
|
|
12792
12700
|
handler: (_ref, args) => {
|
|
12793
|
-
let
|
|
12794
|
-
|
|
12795
|
-
funcName
|
|
12796
|
-
} = _ref;
|
|
12701
|
+
let parser = _ref.parser,
|
|
12702
|
+
funcName = _ref.funcName;
|
|
12797
12703
|
let fName = funcName;
|
|
12798
12704
|
if (fName.length === 1) {
|
|
12799
12705
|
fName = singleCharBigOps[fName];
|
|
@@ -12816,9 +12722,7 @@ defineFunction({
|
|
|
12816
12722
|
numArgs: 1,
|
|
12817
12723
|
primitive: true,
|
|
12818
12724
|
handler: (_ref2, args) => {
|
|
12819
|
-
let
|
|
12820
|
-
parser
|
|
12821
|
-
} = _ref2;
|
|
12725
|
+
let parser = _ref2.parser;
|
|
12822
12726
|
const body = args[0];
|
|
12823
12727
|
return {
|
|
12824
12728
|
type: "op",
|
|
@@ -12849,10 +12753,8 @@ defineFunction({
|
|
|
12849
12753
|
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"],
|
|
12850
12754
|
numArgs: 0,
|
|
12851
12755
|
handler(_ref3) {
|
|
12852
|
-
let
|
|
12853
|
-
|
|
12854
|
-
funcName
|
|
12855
|
-
} = _ref3;
|
|
12756
|
+
let parser = _ref3.parser,
|
|
12757
|
+
funcName = _ref3.funcName;
|
|
12856
12758
|
return {
|
|
12857
12759
|
type: "op",
|
|
12858
12760
|
mode: parser.mode,
|
|
@@ -12870,10 +12772,8 @@ defineFunction({
|
|
|
12870
12772
|
names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
|
|
12871
12773
|
numArgs: 0,
|
|
12872
12774
|
handler(_ref4) {
|
|
12873
|
-
let
|
|
12874
|
-
|
|
12875
|
-
funcName
|
|
12876
|
-
} = _ref4;
|
|
12775
|
+
let parser = _ref4.parser,
|
|
12776
|
+
funcName = _ref4.funcName;
|
|
12877
12777
|
return {
|
|
12878
12778
|
type: "op",
|
|
12879
12779
|
mode: parser.mode,
|
|
@@ -12892,10 +12792,8 @@ defineFunction({
|
|
|
12892
12792
|
numArgs: 0,
|
|
12893
12793
|
allowedInArgument: true,
|
|
12894
12794
|
handler(_ref5) {
|
|
12895
|
-
let
|
|
12896
|
-
|
|
12897
|
-
funcName
|
|
12898
|
-
} = _ref5;
|
|
12795
|
+
let parser = _ref5.parser,
|
|
12796
|
+
funcName = _ref5.funcName;
|
|
12899
12797
|
let fName = funcName;
|
|
12900
12798
|
if (fName.length === 1) {
|
|
12901
12799
|
fName = singleCharIntegrals[fName];
|
|
@@ -13035,10 +12933,8 @@ defineFunction({
|
|
|
13035
12933
|
names: ["\\operatorname@", "\\operatornamewithlimits"],
|
|
13036
12934
|
numArgs: 1,
|
|
13037
12935
|
handler: (_ref, args) => {
|
|
13038
|
-
let
|
|
13039
|
-
|
|
13040
|
-
funcName
|
|
13041
|
-
} = _ref;
|
|
12936
|
+
let parser = _ref.parser,
|
|
12937
|
+
funcName = _ref.funcName;
|
|
13042
12938
|
const body = args[0];
|
|
13043
12939
|
return {
|
|
13044
12940
|
type: "operatorname",
|
|
@@ -13081,9 +12977,7 @@ defineFunction({
|
|
|
13081
12977
|
names: ["\\overline"],
|
|
13082
12978
|
numArgs: 1,
|
|
13083
12979
|
handler(_ref, args) {
|
|
13084
|
-
let
|
|
13085
|
-
parser
|
|
13086
|
-
} = _ref;
|
|
12980
|
+
let parser = _ref.parser;
|
|
13087
12981
|
const body = args[0];
|
|
13088
12982
|
return {
|
|
13089
12983
|
type: "overline",
|
|
@@ -13118,7 +13012,7 @@ defineFunction({
|
|
|
13118
13012
|
size: defaultRuleThickness
|
|
13119
13013
|
}]
|
|
13120
13014
|
}, options);
|
|
13121
|
-
return makeSpan(["mord", "overline"], [vlist], options);
|
|
13015
|
+
return makeSpan(["mord", "katex-overline"], [vlist], options);
|
|
13122
13016
|
},
|
|
13123
13017
|
mathmlBuilder(group, options) {
|
|
13124
13018
|
const operator = new MathNode("mo", [new TextNode("\u203e")]);
|
|
@@ -13141,9 +13035,7 @@ defineFunction({
|
|
|
13141
13035
|
numArgs: 1,
|
|
13142
13036
|
allowedInText: true,
|
|
13143
13037
|
handler: (_ref, args) => {
|
|
13144
|
-
let
|
|
13145
|
-
parser
|
|
13146
|
-
} = _ref;
|
|
13038
|
+
let parser = _ref.parser;
|
|
13147
13039
|
const body = args[0];
|
|
13148
13040
|
return {
|
|
13149
13041
|
type: "phantom",
|
|
@@ -13170,9 +13062,7 @@ defineFunction({
|
|
|
13170
13062
|
numArgs: 1,
|
|
13171
13063
|
allowedInText: true,
|
|
13172
13064
|
handler: (_ref2, args) => {
|
|
13173
|
-
let
|
|
13174
|
-
parser
|
|
13175
|
-
} = _ref2;
|
|
13065
|
+
let parser = _ref2.parser;
|
|
13176
13066
|
const body = args[0];
|
|
13177
13067
|
return {
|
|
13178
13068
|
type: "vphantom",
|
|
@@ -13181,8 +13071,8 @@ defineFunction({
|
|
|
13181
13071
|
};
|
|
13182
13072
|
},
|
|
13183
13073
|
htmlBuilder: (group, options) => {
|
|
13184
|
-
const inner = makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]);
|
|
13185
|
-
const fix = makeSpan(["fix"], []);
|
|
13074
|
+
const inner = makeSpan(["katex-inner"], [buildGroup(group.body, options.withPhantom())]);
|
|
13075
|
+
const fix = makeSpan(["katex-fix"], []);
|
|
13186
13076
|
return makeSpan(["mord", "rlap"], [inner, fix], options);
|
|
13187
13077
|
},
|
|
13188
13078
|
mathmlBuilder: (group, options) => {
|
|
@@ -13210,9 +13100,7 @@ defineFunction({
|
|
|
13210
13100
|
argTypes: ["size", "hbox"],
|
|
13211
13101
|
allowedInText: true,
|
|
13212
13102
|
handler(_ref, args) {
|
|
13213
|
-
let
|
|
13214
|
-
parser
|
|
13215
|
-
} = _ref;
|
|
13103
|
+
let parser = _ref.parser;
|
|
13216
13104
|
const amount = assertNodeType(args[0], "size").value;
|
|
13217
13105
|
const body = args[1];
|
|
13218
13106
|
return {
|
|
@@ -13250,9 +13138,7 @@ defineFunction({
|
|
|
13250
13138
|
allowedInText: true,
|
|
13251
13139
|
allowedInArgument: true,
|
|
13252
13140
|
handler(_ref) {
|
|
13253
|
-
let
|
|
13254
|
-
parser
|
|
13255
|
-
} = _ref;
|
|
13141
|
+
let parser = _ref.parser;
|
|
13256
13142
|
return {
|
|
13257
13143
|
type: "internal",
|
|
13258
13144
|
mode: parser.mode
|
|
@@ -13274,9 +13160,7 @@ defineFunction({
|
|
|
13274
13160
|
allowedInMath: true,
|
|
13275
13161
|
argTypes: ["size", "size", "size"],
|
|
13276
13162
|
handler(_ref, args, optArgs) {
|
|
13277
|
-
let
|
|
13278
|
-
parser
|
|
13279
|
-
} = _ref;
|
|
13163
|
+
let parser = _ref.parser;
|
|
13280
13164
|
const shift = optArgs[0];
|
|
13281
13165
|
const width = assertNodeType(args[0], "size");
|
|
13282
13166
|
const height = assertNodeType(args[1], "size");
|
|
@@ -13290,7 +13174,7 @@ defineFunction({
|
|
|
13290
13174
|
},
|
|
13291
13175
|
htmlBuilder(group, options) {
|
|
13292
13176
|
// Make an empty span for the rule
|
|
13293
|
-
const rule = makeSpan(["mord", "rule"], [], options);
|
|
13177
|
+
const rule = makeSpan(["mord", "katex-rule"], [], options);
|
|
13294
13178
|
|
|
13295
13179
|
// Calculate the shift, width, and height of the rule, and account for units
|
|
13296
13180
|
const width = calculateSize(group.width, options);
|
|
@@ -13346,7 +13230,7 @@ function sizingGroup(value, options, baseOptions) {
|
|
|
13346
13230
|
// Add size-resetting classes to the inner list and set maxFontSize
|
|
13347
13231
|
// manually. Handle nested size changes.
|
|
13348
13232
|
for (let i = 0; i < inner.length; i++) {
|
|
13349
|
-
const pos = inner[i].classes.indexOf("sizing");
|
|
13233
|
+
const pos = inner[i].classes.indexOf("katex-sizing");
|
|
13350
13234
|
if (pos < 0) {
|
|
13351
13235
|
Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
|
|
13352
13236
|
} else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
|
|
@@ -13374,11 +13258,9 @@ defineFunction({
|
|
|
13374
13258
|
numArgs: 0,
|
|
13375
13259
|
allowedInText: true,
|
|
13376
13260
|
handler: (_ref, args) => {
|
|
13377
|
-
let
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
parser
|
|
13381
|
-
} = _ref;
|
|
13261
|
+
let breakOnTokenText = _ref.breakOnTokenText,
|
|
13262
|
+
funcName = _ref.funcName,
|
|
13263
|
+
parser = _ref.parser;
|
|
13382
13264
|
const body = parser.parseExpression(false, breakOnTokenText);
|
|
13383
13265
|
return {
|
|
13384
13266
|
type: "sizing",
|
|
@@ -13418,9 +13300,7 @@ defineFunction({
|
|
|
13418
13300
|
numOptionalArgs: 1,
|
|
13419
13301
|
allowedInText: true,
|
|
13420
13302
|
handler: (_ref, args, optArgs) => {
|
|
13421
|
-
let
|
|
13422
|
-
parser
|
|
13423
|
-
} = _ref;
|
|
13303
|
+
let parser = _ref.parser;
|
|
13424
13304
|
let smashHeight = false;
|
|
13425
13305
|
let smashDepth = false;
|
|
13426
13306
|
const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
|
|
@@ -13468,7 +13348,7 @@ defineFunction({
|
|
|
13468
13348
|
}
|
|
13469
13349
|
if (group.smashHeight && group.smashDepth) {
|
|
13470
13350
|
// Symmetric \smash can stay in inline layout.
|
|
13471
|
-
return makeSpan(["mord", "smash"], [node], options);
|
|
13351
|
+
return makeSpan(["mord", "katex-smash"], [node], options);
|
|
13472
13352
|
}
|
|
13473
13353
|
|
|
13474
13354
|
// In order to influence makeVList for asymmetric smashing, we have to
|
|
@@ -13526,9 +13406,7 @@ defineFunction({
|
|
|
13526
13406
|
numArgs: 1,
|
|
13527
13407
|
numOptionalArgs: 1,
|
|
13528
13408
|
handler(_ref, args, optArgs) {
|
|
13529
|
-
let
|
|
13530
|
-
parser
|
|
13531
|
-
} = _ref;
|
|
13409
|
+
let parser = _ref.parser;
|
|
13532
13410
|
const index = optArgs[0];
|
|
13533
13411
|
const body = args[0];
|
|
13534
13412
|
return {
|
|
@@ -13566,11 +13444,10 @@ defineFunction({
|
|
|
13566
13444
|
const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta;
|
|
13567
13445
|
|
|
13568
13446
|
// Create a sqrt SVG of the required minimum size
|
|
13569
|
-
const
|
|
13570
|
-
span
|
|
13571
|
-
ruleWidth,
|
|
13572
|
-
advanceWidth
|
|
13573
|
-
} = makeSqrtImage(minDelimiterHeight, options);
|
|
13447
|
+
const _makeSqrtImage = makeSqrtImage(minDelimiterHeight, options),
|
|
13448
|
+
img = _makeSqrtImage.span,
|
|
13449
|
+
ruleWidth = _makeSqrtImage.ruleWidth,
|
|
13450
|
+
advanceWidth = _makeSqrtImage.advanceWidth;
|
|
13574
13451
|
const delimDepth = img.height - ruleWidth;
|
|
13575
13452
|
|
|
13576
13453
|
// Adjust the clearance based on the delimiter size
|
|
@@ -13624,15 +13501,13 @@ defineFunction({
|
|
|
13624
13501
|
}, options);
|
|
13625
13502
|
// Add a class surrounding it so we can add on the appropriate
|
|
13626
13503
|
// kerning
|
|
13627
|
-
const rootVListWrap = makeSpan(["root"], [rootVList]);
|
|
13504
|
+
const rootVListWrap = makeSpan(["katex-root"], [rootVList]);
|
|
13628
13505
|
return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
|
|
13629
13506
|
}
|
|
13630
13507
|
},
|
|
13631
13508
|
mathmlBuilder(group, options) {
|
|
13632
|
-
const
|
|
13633
|
-
|
|
13634
|
-
index
|
|
13635
|
-
} = group;
|
|
13509
|
+
const body = group.body,
|
|
13510
|
+
index = group.index;
|
|
13636
13511
|
return index ? new MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new MathNode("msqrt", [buildMathML_buildGroup(body, options)]);
|
|
13637
13512
|
}
|
|
13638
13513
|
});
|
|
@@ -13658,11 +13533,9 @@ defineFunction({
|
|
|
13658
13533
|
allowedInText: true,
|
|
13659
13534
|
primitive: true,
|
|
13660
13535
|
handler(_ref, args) {
|
|
13661
|
-
let
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
parser
|
|
13665
|
-
} = _ref;
|
|
13536
|
+
let breakOnTokenText = _ref.breakOnTokenText,
|
|
13537
|
+
funcName = _ref.funcName,
|
|
13538
|
+
parser = _ref.parser;
|
|
13666
13539
|
// parse out the implicit body
|
|
13667
13540
|
const body = parser.parseExpression(true, breakOnTokenText);
|
|
13668
13541
|
|
|
@@ -13770,11 +13643,9 @@ defineFunctionBuilders({
|
|
|
13770
13643
|
if (builderDelegate) {
|
|
13771
13644
|
return builderDelegate(group, options);
|
|
13772
13645
|
}
|
|
13773
|
-
const
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
sub: valueSub
|
|
13777
|
-
} = group;
|
|
13646
|
+
const valueBase = group.base,
|
|
13647
|
+
valueSup = group.sup,
|
|
13648
|
+
valueSub = group.sub;
|
|
13778
13649
|
const base = buildGroup(valueBase, options);
|
|
13779
13650
|
let supm;
|
|
13780
13651
|
let subm;
|
|
@@ -14036,35 +13907,28 @@ defineFunctionBuilders({
|
|
|
14036
13907
|
|
|
14037
13908
|
|
|
14038
13909
|
// A map of CSS-based spacing functions to their CSS class.
|
|
14039
|
-
const cssSpace =
|
|
14040
|
-
"\\nobreak": "nobreak",
|
|
14041
|
-
"\\allowbreak": "allowbreak"
|
|
14042
|
-
};
|
|
13910
|
+
const cssSpace = new Map([["\\nobreak", "nobreak"], ["\\allowbreak", "allowbreak"]]);
|
|
14043
13911
|
|
|
14044
13912
|
// A lookup table to determine whether a spacing function/symbol should be
|
|
14045
13913
|
// treated like a regular space character. If a symbol or command is a key
|
|
14046
13914
|
// in this table, then it should be a regular space character. Furthermore,
|
|
14047
13915
|
// the associated value may have a `className` specifying an extra CSS class
|
|
14048
13916
|
// to add to the created `span`.
|
|
14049
|
-
const regularSpace = {
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
"
|
|
14053
|
-
|
|
14054
|
-
},
|
|
14055
|
-
"\\space": {},
|
|
14056
|
-
"\\nobreakspace": {
|
|
14057
|
-
className: "nobreak"
|
|
14058
|
-
}
|
|
14059
|
-
};
|
|
13917
|
+
const regularSpace = new Map([[" ", {}], ["\\ ", {}], ["~", {
|
|
13918
|
+
className: "nobreak"
|
|
13919
|
+
}], ["\\space", {}], ["\\nobreakspace", {
|
|
13920
|
+
className: "nobreak"
|
|
13921
|
+
}]]);
|
|
14060
13922
|
|
|
14061
13923
|
// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
|
|
14062
13924
|
// src/symbols.js.
|
|
14063
13925
|
defineFunctionBuilders({
|
|
14064
13926
|
type: "spacing",
|
|
14065
13927
|
htmlBuilder(group, options) {
|
|
14066
|
-
|
|
14067
|
-
|
|
13928
|
+
const regularSpaceItem = regularSpace.get(group.text);
|
|
13929
|
+
const cssSpaceClass = cssSpace.get(group.text);
|
|
13930
|
+
if (regularSpaceItem) {
|
|
13931
|
+
const className = regularSpaceItem.className || "";
|
|
14068
13932
|
// Spaces are generated by adding an actual space. Each of these
|
|
14069
13933
|
// things has an entry in the symbols table, so these will be turned
|
|
14070
13934
|
// into appropriate outputs.
|
|
@@ -14075,18 +13939,18 @@ defineFunctionBuilders({
|
|
|
14075
13939
|
} else {
|
|
14076
13940
|
return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options);
|
|
14077
13941
|
}
|
|
14078
|
-
} else if (
|
|
13942
|
+
} else if (cssSpaceClass) {
|
|
14079
13943
|
// Spaces based on just a CSS class.
|
|
14080
|
-
return makeSpan(["mspace",
|
|
13944
|
+
return makeSpan(["mspace", cssSpaceClass], [], options);
|
|
14081
13945
|
} else {
|
|
14082
13946
|
throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
|
|
14083
13947
|
}
|
|
14084
13948
|
},
|
|
14085
13949
|
mathmlBuilder(group, options) {
|
|
14086
13950
|
let node;
|
|
14087
|
-
if (regularSpace.
|
|
13951
|
+
if (regularSpace.has(group.text)) {
|
|
14088
13952
|
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
14089
|
-
} else if (cssSpace.
|
|
13953
|
+
} else if (cssSpace.has(group.text)) {
|
|
14090
13954
|
// CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
|
|
14091
13955
|
return new MathNode("mspace");
|
|
14092
13956
|
} else {
|
|
@@ -14169,10 +14033,8 @@ defineFunction({
|
|
|
14169
14033
|
allowedInArgument: true,
|
|
14170
14034
|
allowedInText: true,
|
|
14171
14035
|
handler(_ref, args) {
|
|
14172
|
-
let
|
|
14173
|
-
|
|
14174
|
-
funcName
|
|
14175
|
-
} = _ref;
|
|
14036
|
+
let parser = _ref.parser,
|
|
14037
|
+
funcName = _ref.funcName;
|
|
14176
14038
|
const body = args[0];
|
|
14177
14039
|
return {
|
|
14178
14040
|
type: "text",
|
|
@@ -14203,9 +14065,7 @@ defineFunction({
|
|
|
14203
14065
|
numArgs: 1,
|
|
14204
14066
|
allowedInText: true,
|
|
14205
14067
|
handler(_ref, args) {
|
|
14206
|
-
let
|
|
14207
|
-
parser
|
|
14208
|
-
} = _ref;
|
|
14068
|
+
let parser = _ref.parser;
|
|
14209
14069
|
return {
|
|
14210
14070
|
type: "underline",
|
|
14211
14071
|
mode: parser.mode,
|
|
@@ -14239,7 +14099,7 @@ defineFunction({
|
|
|
14239
14099
|
elem: innerGroup
|
|
14240
14100
|
}]
|
|
14241
14101
|
}, options);
|
|
14242
|
-
return makeSpan(["mord", "underline"], [vlist], options);
|
|
14102
|
+
return makeSpan(["mord", "katex-underline"], [vlist], options);
|
|
14243
14103
|
},
|
|
14244
14104
|
mathmlBuilder(group, options) {
|
|
14245
14105
|
const operator = new MathNode("mo", [new TextNode("\u203e")]);
|
|
@@ -14266,9 +14126,7 @@ defineFunction({
|
|
|
14266
14126
|
// In LaTeX, \vcenter can act only on a box.
|
|
14267
14127
|
allowedInText: false,
|
|
14268
14128
|
handler(_ref, args) {
|
|
14269
|
-
let
|
|
14270
|
-
parser
|
|
14271
|
-
} = _ref;
|
|
14129
|
+
let parser = _ref.parser;
|
|
14272
14130
|
return {
|
|
14273
14131
|
type: "vcenter",
|
|
14274
14132
|
mode: parser.mode,
|
|
@@ -14557,13 +14415,11 @@ class Namespace {
|
|
|
14557
14415
|
throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
|
|
14558
14416
|
}
|
|
14559
14417
|
const undefs = this.undefStack.pop();
|
|
14560
|
-
for (const
|
|
14561
|
-
if (undefs
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
this.current[undef] = undefs[undef];
|
|
14566
|
-
}
|
|
14418
|
+
for (const key of Object.keys(undefs)) {
|
|
14419
|
+
if (undefs[key] === undefined) {
|
|
14420
|
+
delete this.current[key];
|
|
14421
|
+
} else {
|
|
14422
|
+
this.current[key] = undefs[key];
|
|
14567
14423
|
}
|
|
14568
14424
|
}
|
|
14569
14425
|
}
|
|
@@ -14583,7 +14439,7 @@ class Namespace {
|
|
|
14583
14439
|
* `get(name) != null`.
|
|
14584
14440
|
*/
|
|
14585
14441
|
has(name) {
|
|
14586
|
-
return
|
|
14442
|
+
return Object.prototype.hasOwnProperty.call(this.current, name) || Object.prototype.hasOwnProperty.call(this.builtins, name);
|
|
14587
14443
|
}
|
|
14588
14444
|
|
|
14589
14445
|
/**
|
|
@@ -14595,7 +14451,7 @@ class Namespace {
|
|
|
14595
14451
|
* `if (namespace.has(...))`.
|
|
14596
14452
|
*/
|
|
14597
14453
|
get(name) {
|
|
14598
|
-
if (
|
|
14454
|
+
if (Object.prototype.hasOwnProperty.call(this.current, name)) {
|
|
14599
14455
|
return this.current[name];
|
|
14600
14456
|
} else {
|
|
14601
14457
|
return this.builtins[name];
|
|
@@ -14629,7 +14485,7 @@ class Namespace {
|
|
|
14629
14485
|
// unless an undo is already in place, in which case that older
|
|
14630
14486
|
// value is the correct one.
|
|
14631
14487
|
const top = this.undefStack[this.undefStack.length - 1];
|
|
14632
|
-
if (top && !
|
|
14488
|
+
if (top && !Object.prototype.hasOwnProperty.call(top, name)) {
|
|
14633
14489
|
top[name] = this.current[name];
|
|
14634
14490
|
}
|
|
14635
14491
|
}
|
|
@@ -15740,16 +15596,14 @@ class MacroExpander {
|
|
|
15740
15596
|
return null;
|
|
15741
15597
|
}
|
|
15742
15598
|
start = this.popToken(); // don't include [ in tokens
|
|
15743
|
-
(
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
} = this.consumeArg(["]"]));
|
|
15599
|
+
var _this$consumeArg = this.consumeArg(["]"]);
|
|
15600
|
+
tokens = _this$consumeArg.tokens;
|
|
15601
|
+
end = _this$consumeArg.end;
|
|
15747
15602
|
} else {
|
|
15748
|
-
(
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
} = this.consumeArg());
|
|
15603
|
+
var _this$consumeArg2 = this.consumeArg();
|
|
15604
|
+
tokens = _this$consumeArg2.tokens;
|
|
15605
|
+
start = _this$consumeArg2.start;
|
|
15606
|
+
end = _this$consumeArg2.end;
|
|
15753
15607
|
}
|
|
15754
15608
|
|
|
15755
15609
|
// indicate the end of an argument
|
|
@@ -16060,7 +15914,7 @@ class MacroExpander {
|
|
|
16060
15914
|
* `implicitCommands`.
|
|
16061
15915
|
*/
|
|
16062
15916
|
isDefined(name) {
|
|
16063
|
-
return this.macros.has(name) ||
|
|
15917
|
+
return this.macros.has(name) || Object.prototype.hasOwnProperty.call(src_functions, name) || Object.prototype.hasOwnProperty.call(src_symbols.math, name) || Object.prototype.hasOwnProperty.call(src_symbols.text, name) || Object.prototype.hasOwnProperty.call(implicitCommands, name);
|
|
16064
15918
|
}
|
|
16065
15919
|
|
|
16066
15920
|
/**
|
|
@@ -16068,7 +15922,10 @@ class MacroExpander {
|
|
|
16068
15922
|
*/
|
|
16069
15923
|
isExpandable(name) {
|
|
16070
15924
|
const macro = this.macros.get(name);
|
|
16071
|
-
|
|
15925
|
+
if (macro != null) {
|
|
15926
|
+
return typeof macro === "string" || typeof macro === "function" || !macro.unexpandable;
|
|
15927
|
+
}
|
|
15928
|
+
return Object.prototype.hasOwnProperty.call(src_functions, name) && !src_functions[name].primitive;
|
|
16072
15929
|
}
|
|
16073
15930
|
}
|
|
16074
15931
|
;// ./src/unicodeSupOrSub.ts
|
|
@@ -17059,10 +16916,9 @@ class Parser {
|
|
|
17059
16916
|
} else if (this.mode === "math" && funcData.allowedInMath === false) {
|
|
17060
16917
|
throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
|
|
17061
16918
|
}
|
|
17062
|
-
const
|
|
17063
|
-
args,
|
|
17064
|
-
optArgs
|
|
17065
|
-
} = this.parseArguments(func, funcData);
|
|
16919
|
+
const _this$parseArguments = this.parseArguments(func, funcData),
|
|
16920
|
+
args = _this$parseArguments.args,
|
|
16921
|
+
optArgs = _this$parseArguments.optArgs;
|
|
17066
16922
|
return this.callFunction(func, args, optArgs, token, breakOnTokenText);
|
|
17067
16923
|
}
|
|
17068
16924
|
|
|
@@ -17396,7 +17252,7 @@ class Parser {
|
|
|
17396
17252
|
// If there exists a function with this name, parse the function.
|
|
17397
17253
|
// Otherwise, just return a nucleus
|
|
17398
17254
|
result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
|
|
17399
|
-
if (result == null && text[0] === "\\" && !
|
|
17255
|
+
if (result == null && text[0] === "\\" && !Object.prototype.hasOwnProperty.call(implicitCommands, text)) {
|
|
17400
17256
|
if (this.settings.throwOnError) {
|
|
17401
17257
|
throw new src_ParseError("Undefined control sequence: " + text, firstToken);
|
|
17402
17258
|
}
|
|
@@ -17489,7 +17345,7 @@ class Parser {
|
|
|
17489
17345
|
}
|
|
17490
17346
|
// At this point, we should have a symbol, possibly with accents.
|
|
17491
17347
|
// First expand any accented base symbol according to unicodeSymbols.
|
|
17492
|
-
if (
|
|
17348
|
+
if (Object.prototype.hasOwnProperty.call(unicodeSymbols, text[0]) && !src_symbols[this.mode][text[0]]) {
|
|
17493
17349
|
// This behavior is not strict (XeTeX-compatible) in math mode.
|
|
17494
17350
|
if (this.settings.strict && this.mode === "math") {
|
|
17495
17351
|
this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
|
|
@@ -17720,7 +17576,7 @@ const renderToHTMLTree = function (expression, options) {
|
|
|
17720
17576
|
return renderError(error, expression, settings);
|
|
17721
17577
|
}
|
|
17722
17578
|
};
|
|
17723
|
-
const version = "0.
|
|
17579
|
+
const version = "0.18.1";
|
|
17724
17580
|
const __domTree = {
|
|
17725
17581
|
Span: Span,
|
|
17726
17582
|
Anchor: Anchor,
|