katex 0.16.47 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -10
- 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/contrib/render-a11y-string/render-a11y-string.ts +1 -1
- package/dist/README.md +5 -10
- 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 +509 -849
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +498 -831
- package/katex.ts +1 -1
- package/package.json +12 -16
- package/src/MacroExpander.ts +11 -8
- package/src/Namespace.ts +17 -21
- package/src/Options.ts +2 -2
- package/src/ParseError.ts +1 -1
- package/src/Parser.ts +44 -50
- package/src/Settings.ts +1 -1
- package/src/SourceLocation.ts +2 -2
- package/src/atoms.ts +22 -22
- package/src/buildCommon.ts +8 -8
- package/src/buildHTML.ts +12 -13
- package/src/buildMathML.ts +4 -4
- package/src/buildTree.ts +1 -1
- package/src/defineEnvironment.ts +1 -2
- package/src/defineFunction.ts +104 -112
- package/src/environments/array.ts +11 -15
- package/src/environments/cd.ts +8 -8
- package/src/fontMetrics.ts +2 -4
- package/src/functions/accent.ts +12 -15
- package/src/functions/accentunder.ts +4 -4
- package/src/functions/arrow.ts +5 -5
- package/src/functions/char.ts +3 -4
- package/src/functions/color.ts +10 -13
- package/src/functions/cr.ts +4 -6
- package/src/functions/def.ts +15 -19
- package/src/functions/delimsizing.ts +23 -23
- package/src/functions/enclose.ts +23 -34
- package/src/functions/environment.ts +5 -6
- package/src/functions/font.ts +15 -27
- package/src/functions/genfrac.ts +19 -23
- package/src/functions/hbox.ts +6 -6
- package/src/functions/horizBrace.ts +4 -4
- package/src/functions/href.ts +10 -11
- package/src/functions/html.ts +8 -8
- package/src/functions/htmlmathml.ts +5 -5
- package/src/functions/includegraphics.ts +7 -7
- package/src/functions/kern.ts +6 -6
- package/src/functions/lap.ts +11 -11
- package/src/functions/math.ts +8 -10
- package/src/functions/mathchoice.ts +5 -5
- package/src/functions/mclass.ts +16 -28
- package/src/functions/op.ts +16 -30
- package/src/functions/operatorname.ts +4 -4
- package/src/functions/overline.ts +4 -4
- package/src/functions/phantom.ts +10 -10
- package/src/functions/pmb.ts +5 -5
- package/src/functions/raisebox.ts +5 -5
- package/src/functions/relax.ts +4 -5
- package/src/functions/rule.ts +8 -8
- package/src/functions/sizing.ts +7 -7
- package/src/functions/smash.ts +6 -6
- package/src/functions/sqrt.ts +5 -5
- package/src/functions/styling.ts +5 -5
- package/src/functions/supsub.ts +1 -1
- package/src/functions/symbolsOrd.ts +3 -3
- package/src/functions/symbolsSpacing.ts +21 -22
- package/src/functions/text.ts +7 -7
- package/src/functions/underline.ts +5 -5
- package/src/functions/utils/assembleSupSub.ts +1 -1
- package/src/functions/vcenter.ts +5 -5
- package/src/functions/verb.ts +5 -5
- package/src/macros.ts +3 -3
- package/src/mathMLTree.ts +6 -10
- package/src/parseNode.ts +6 -480
- package/src/parseTree.ts +1 -6
- package/src/spacingData.ts +2 -1
- package/src/stretchy.ts +3 -3
- package/src/styles/katex.scss +31 -37
- package/src/types/index.ts +12 -0
- package/src/types/nodes.ts +456 -0
- package/src/units.ts +1 -2
- package/src/utils.ts +1 -1
- package/src/wide-character.ts +2 -2
package/dist/katex.js
CHANGED
|
@@ -1008,6 +1008,7 @@ const relativeUnit = {
|
|
|
1008
1008
|
"em": true,
|
|
1009
1009
|
"mu": true
|
|
1010
1010
|
};
|
|
1011
|
+
|
|
1011
1012
|
/**
|
|
1012
1013
|
* Determine whether the specified unit (either a string defining the unit
|
|
1013
1014
|
* or a "size" parse node containing a unit field) is valid.
|
|
@@ -3904,10 +3905,8 @@ function getGlobalMetrics(size) {
|
|
|
3904
3905
|
const metrics = fontMetricsBySizeIndex[sizeIndex] = {
|
|
3905
3906
|
cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
|
|
3906
3907
|
};
|
|
3907
|
-
for (const key
|
|
3908
|
-
|
|
3909
|
-
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3910
|
-
}
|
|
3908
|
+
for (const key of Object.keys(sigmasAndXis)) {
|
|
3909
|
+
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3911
3910
|
}
|
|
3912
3911
|
}
|
|
3913
3912
|
return fontMetricsBySizeIndex[sizeIndex];
|
|
@@ -5027,16 +5026,16 @@ const boldSymbol = function (value, mode, type) {
|
|
|
5027
5026
|
/**
|
|
5028
5027
|
* Makes either a mathord or textord in the correct font and color.
|
|
5029
5028
|
*/
|
|
5030
|
-
const makeOrd = function (group, options
|
|
5029
|
+
const makeOrd = function (group, options) {
|
|
5030
|
+
// Spacing nodes are rendered as textord.
|
|
5031
|
+
const type = group.type === "mathord" ? "mathord" : "textord";
|
|
5031
5032
|
const mode = group.mode;
|
|
5032
5033
|
const text = group.text;
|
|
5033
5034
|
const classes = ["mord"];
|
|
5034
|
-
const
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
fontShape
|
|
5039
|
-
} = options;
|
|
5035
|
+
const font = options.font,
|
|
5036
|
+
fontFamily = options.fontFamily,
|
|
5037
|
+
fontWeight = options.fontWeight,
|
|
5038
|
+
fontShape = options.fontShape;
|
|
5040
5039
|
|
|
5041
5040
|
// Math mode or Old font (i.e. \rm)
|
|
5042
5041
|
const useFont = mode === "math" || mode === "text" && !!font;
|
|
@@ -5067,7 +5066,7 @@ const makeOrd = function (group, options, type) {
|
|
|
5067
5066
|
}
|
|
5068
5067
|
if (lookupSymbol(text, fontName, mode).metrics) {
|
|
5069
5068
|
return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses));
|
|
5070
|
-
} else if (
|
|
5069
|
+
} else if (Object.prototype.hasOwnProperty.call(ligatures, text) && fontName.slice(0, 10) === "Typewriter") {
|
|
5071
5070
|
// Deconstruct ligatures in monospace fonts (\texttt, \tt).
|
|
5072
5071
|
const parts = [];
|
|
5073
5072
|
for (let i = 0; i < text.length; i++) {
|
|
@@ -5302,10 +5301,9 @@ const getVListChildrenAndDepth = function (params) {
|
|
|
5302
5301
|
* See VListParam documentation above.
|
|
5303
5302
|
*/
|
|
5304
5303
|
const makeVList = function (params, options) {
|
|
5305
|
-
const
|
|
5306
|
-
children,
|
|
5307
|
-
depth
|
|
5308
|
-
} = getVListChildrenAndDepth(params);
|
|
5304
|
+
const _getVListChildrenAndD = getVListChildrenAndDepth(params),
|
|
5305
|
+
children = _getVListChildrenAndD.children,
|
|
5306
|
+
depth = _getVListChildrenAndD.depth;
|
|
5309
5307
|
|
|
5310
5308
|
// Create a strut that is taller than any list item. The strut is added to
|
|
5311
5309
|
// each item, where it will determine the item's baseline. Since it has
|
|
@@ -5506,7 +5504,10 @@ const svgData = {
|
|
|
5506
5504
|
};
|
|
5507
5505
|
const staticSvg = function (value, options) {
|
|
5508
5506
|
// Create a span with inline SVG for the element.
|
|
5509
|
-
const
|
|
5507
|
+
const _svgData$value = svgData[value],
|
|
5508
|
+
pathName = _svgData$value[0],
|
|
5509
|
+
width = _svgData$value[1],
|
|
5510
|
+
height = _svgData$value[2];
|
|
5510
5511
|
const path = new PathNode(pathName);
|
|
5511
5512
|
const svgNode = new SvgNode([path], {
|
|
5512
5513
|
"width": makeEm(width),
|
|
@@ -5516,7 +5517,7 @@ const staticSvg = function (value, options) {
|
|
|
5516
5517
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
5517
5518
|
"preserveAspectRatio": "xMinYMin"
|
|
5518
5519
|
});
|
|
5519
|
-
const span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
5520
|
+
const span = makeSvgSpan(["katex-overlay"], [svgNode], options);
|
|
5520
5521
|
span.height = height;
|
|
5521
5522
|
span.style.height = makeEm(height);
|
|
5522
5523
|
span.style.width = makeEm(width);
|
|
@@ -5630,11 +5631,19 @@ const tightSpacings = {
|
|
|
5630
5631
|
// delegates its HTML building to the HtmlBuilder corresponding to these nodes.
|
|
5631
5632
|
|
|
5632
5633
|
/**
|
|
5633
|
-
*
|
|
5634
|
-
*
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5634
|
+
* Parser-facing function spec. Optional properties should use the defaults
|
|
5635
|
+
* documented below.
|
|
5636
|
+
*/
|
|
5637
|
+
|
|
5638
|
+
/**
|
|
5639
|
+
* Builder fields consumed during registration. These are stored separately in
|
|
5640
|
+
* `_htmlGroupBuilders` and `_mathmlGroupBuilders`, and are not used by Parser.
|
|
5641
|
+
*/
|
|
5642
|
+
|
|
5643
|
+
/**
|
|
5644
|
+
* Full registration spec passed to `defineFunction`. It combines the
|
|
5645
|
+
* parser-facing fields with optional builder fields and the names being
|
|
5646
|
+
* registered.
|
|
5638
5647
|
*/
|
|
5639
5648
|
|
|
5640
5649
|
/**
|
|
@@ -5662,29 +5671,15 @@ const _htmlGroupBuilders = {};
|
|
|
5662
5671
|
*/
|
|
5663
5672
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5664
5673
|
const _mathmlGroupBuilders = {};
|
|
5665
|
-
function defineFunction(
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
handler,
|
|
5671
|
-
htmlBuilder,
|
|
5672
|
-
mathmlBuilder
|
|
5673
|
-
} = _ref;
|
|
5674
|
-
// Set default values of functions
|
|
5675
|
-
const data = {
|
|
5676
|
-
type,
|
|
5677
|
-
numArgs: props.numArgs,
|
|
5678
|
-
argTypes: props.argTypes,
|
|
5679
|
-
allowedInArgument: !!props.allowedInArgument,
|
|
5680
|
-
allowedInText: !!props.allowedInText,
|
|
5681
|
-
allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath,
|
|
5682
|
-
numOptionalArgs: props.numOptionalArgs || 0,
|
|
5683
|
-
infix: !!props.infix,
|
|
5684
|
-
primitive: !!props.primitive,
|
|
5685
|
-
handler
|
|
5686
|
-
};
|
|
5674
|
+
function defineFunction(data) {
|
|
5675
|
+
const type = data.type,
|
|
5676
|
+
names = data.names,
|
|
5677
|
+
htmlBuilder = data.htmlBuilder,
|
|
5678
|
+
mathmlBuilder = data.mathmlBuilder;
|
|
5687
5679
|
for (let i = 0; i < names.length; ++i) {
|
|
5680
|
+
// To avoid destructuring and rebuilding an object,
|
|
5681
|
+
// we store the entire FunctionDefSpec object,
|
|
5682
|
+
// even though Parser only needs the FunctionSpec fields.
|
|
5688
5683
|
_functions[names[i]] = data;
|
|
5689
5684
|
}
|
|
5690
5685
|
if (type) {
|
|
@@ -5702,24 +5697,16 @@ function defineFunction(_ref) {
|
|
|
5702
5697
|
* if the function's ParseNode is generated in Parser.js rather than via a
|
|
5703
5698
|
* stand-alone handler provided to `defineFunction`).
|
|
5704
5699
|
*/
|
|
5705
|
-
function defineFunctionBuilders(
|
|
5706
|
-
let
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
numArgs: 0
|
|
5716
|
-
},
|
|
5717
|
-
handler() {
|
|
5718
|
-
throw new Error('Should never be called.');
|
|
5719
|
-
},
|
|
5720
|
-
htmlBuilder,
|
|
5721
|
-
mathmlBuilder
|
|
5722
|
-
});
|
|
5700
|
+
function defineFunctionBuilders(_ref) {
|
|
5701
|
+
let type = _ref.type,
|
|
5702
|
+
htmlBuilder = _ref.htmlBuilder,
|
|
5703
|
+
mathmlBuilder = _ref.mathmlBuilder;
|
|
5704
|
+
if (htmlBuilder) {
|
|
5705
|
+
_htmlGroupBuilders[type] = htmlBuilder;
|
|
5706
|
+
}
|
|
5707
|
+
if (mathmlBuilder) {
|
|
5708
|
+
_mathmlGroupBuilders[type] = mathmlBuilder;
|
|
5709
|
+
}
|
|
5723
5710
|
}
|
|
5724
5711
|
const normalizeArgument = function (arg) {
|
|
5725
5712
|
return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
|
|
@@ -5889,7 +5876,7 @@ const traverseNonSpaceNodes = function (nodes, callback, prev, next, isRoot) {
|
|
|
5889
5876
|
}
|
|
5890
5877
|
if (nonspace) {
|
|
5891
5878
|
prev.node = node;
|
|
5892
|
-
} else if (isRoot && node.hasClass("newline")) {
|
|
5879
|
+
} else if (isRoot && node.hasClass("katex-newline")) {
|
|
5893
5880
|
prev.node = makeSpan(["leftmost"]); // treat like beginning of line
|
|
5894
5881
|
}
|
|
5895
5882
|
prev.insertAfter = (index => n => {
|
|
@@ -5975,18 +5962,18 @@ const buildGroup = function (group, options, baseOptions) {
|
|
|
5975
5962
|
|
|
5976
5963
|
/**
|
|
5977
5964
|
* Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`)
|
|
5978
|
-
* 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
|
|
5979
5966
|
* guarantee correct vertical extent. `buildHTML` calls this repeatedly to
|
|
5980
5967
|
* make up the entire expression as a sequence of unbreakable units.
|
|
5981
5968
|
*/
|
|
5982
5969
|
function buildHTMLUnbreakable(children, options) {
|
|
5983
5970
|
// Compute height and depth of this chunk.
|
|
5984
|
-
const body = makeSpan(["base"], children, options);
|
|
5971
|
+
const body = makeSpan(["katex-base"], children, options);
|
|
5985
5972
|
|
|
5986
5973
|
// Add strut, which ensures that the top of the HTML element falls at
|
|
5987
5974
|
// the height of the expression, and the bottom of the HTML element
|
|
5988
5975
|
// falls at the depth of the expression.
|
|
5989
|
-
const strut = makeSpan(["strut"]);
|
|
5976
|
+
const strut = makeSpan(["katex-strut"]);
|
|
5990
5977
|
strut.style.height = makeEm(body.height + body.depth);
|
|
5991
5978
|
if (body.depth) {
|
|
5992
5979
|
strut.style.verticalAlign = makeEm(-body.depth);
|
|
@@ -6010,7 +5997,7 @@ function buildHTML(tree, options) {
|
|
|
6010
5997
|
// Build the expression contained in the tree
|
|
6011
5998
|
const expression = buildExpression(tree, options, "root");
|
|
6012
5999
|
let eqnNum;
|
|
6013
|
-
if (expression.length === 2 && expression[1].hasClass("tag")) {
|
|
6000
|
+
if (expression.length === 2 && expression[1].hasClass("katex-tag")) {
|
|
6014
6001
|
// An environment with automatic equation numbers, e.g. {gather}.
|
|
6015
6002
|
eqnNum = expression.pop();
|
|
6016
6003
|
}
|
|
@@ -6030,7 +6017,7 @@ function buildHTML(tree, options) {
|
|
|
6030
6017
|
// Put any post-operator glue on same line as operator.
|
|
6031
6018
|
// Watch for \nobreak along the way, and stop at \newline.
|
|
6032
6019
|
let nobreak = false;
|
|
6033
|
-
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")) {
|
|
6034
6021
|
i++;
|
|
6035
6022
|
parts.push(expression[i]);
|
|
6036
6023
|
if (expression[i].hasClass("nobreak")) {
|
|
@@ -6042,7 +6029,7 @@ function buildHTML(tree, options) {
|
|
|
6042
6029
|
children.push(buildHTMLUnbreakable(parts, options));
|
|
6043
6030
|
parts = [];
|
|
6044
6031
|
}
|
|
6045
|
-
} else if (expression[i].hasClass("newline")) {
|
|
6032
|
+
} else if (expression[i].hasClass("katex-newline")) {
|
|
6046
6033
|
// Write the line except the newline
|
|
6047
6034
|
parts.pop();
|
|
6048
6035
|
if (parts.length > 0) {
|
|
@@ -6061,7 +6048,7 @@ function buildHTML(tree, options) {
|
|
|
6061
6048
|
let tagChild;
|
|
6062
6049
|
if (tag) {
|
|
6063
6050
|
tagChild = buildHTMLUnbreakable(buildExpression(tag, options, true), options);
|
|
6064
|
-
tagChild.classes = ["tag"];
|
|
6051
|
+
tagChild.classes = ["katex-tag"];
|
|
6065
6052
|
children.push(tagChild);
|
|
6066
6053
|
} else if (eqnNum) {
|
|
6067
6054
|
children.push(eqnNum);
|
|
@@ -6142,10 +6129,10 @@ class MathNode {
|
|
|
6142
6129
|
*/
|
|
6143
6130
|
toNode() {
|
|
6144
6131
|
const node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type);
|
|
6145
|
-
for (const
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6132
|
+
for (const _ref of Object.entries(this.attributes)) {
|
|
6133
|
+
const attr = _ref[0];
|
|
6134
|
+
const value = _ref[1];
|
|
6135
|
+
node.setAttribute(attr, value);
|
|
6149
6136
|
}
|
|
6150
6137
|
if (this.classes.length > 0) {
|
|
6151
6138
|
node.className = createClass(this.classes);
|
|
@@ -6173,12 +6160,12 @@ class MathNode {
|
|
|
6173
6160
|
let markup = "<" + this.type;
|
|
6174
6161
|
|
|
6175
6162
|
// Add the attributes
|
|
6176
|
-
for (const
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
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 += "\"";
|
|
6182
6169
|
}
|
|
6183
6170
|
if (this.classes.length > 0) {
|
|
6184
6171
|
markup += " class =\"" + utils_escape(createClass(this.classes)) + "\"";
|
|
@@ -6325,7 +6312,8 @@ const rowLikeTypes = new Set(["mrow", "mtable"]);
|
|
|
6325
6312
|
* optional replacement from symbols.js.
|
|
6326
6313
|
*/
|
|
6327
6314
|
const makeText = function (text, mode, options) {
|
|
6328
|
-
|
|
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"))) {
|
|
6329
6317
|
text = src_symbols[mode][text].replace;
|
|
6330
6318
|
}
|
|
6331
6319
|
return new TextNode(text);
|
|
@@ -6814,7 +6802,7 @@ class Options {
|
|
|
6814
6802
|
*/
|
|
6815
6803
|
sizingClasses(oldOptions) {
|
|
6816
6804
|
if (oldOptions.size !== this.size) {
|
|
6817
|
-
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
6805
|
+
return ["katex-sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
6818
6806
|
} else {
|
|
6819
6807
|
return [];
|
|
6820
6808
|
}
|
|
@@ -6826,7 +6814,7 @@ class Options {
|
|
|
6826
6814
|
*/
|
|
6827
6815
|
baseSizingClasses() {
|
|
6828
6816
|
if (this.size !== Options.BASESIZE) {
|
|
6829
|
-
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
6817
|
+
return ["katex-sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
6830
6818
|
} else {
|
|
6831
6819
|
return [];
|
|
6832
6820
|
}
|
|
@@ -7112,7 +7100,9 @@ const stretchySvg = function (group, options) {
|
|
|
7112
7100
|
if (!data) {
|
|
7113
7101
|
throw new Error("No SVG data for \"" + label + "\".");
|
|
7114
7102
|
}
|
|
7115
|
-
const
|
|
7103
|
+
const paths = data[0],
|
|
7104
|
+
minWidth = data[1],
|
|
7105
|
+
viewBoxHeight = data[2];
|
|
7116
7106
|
const height = viewBoxHeight / 1000;
|
|
7117
7107
|
const numSvgChildren = paths.length;
|
|
7118
7108
|
let widthClasses;
|
|
@@ -7153,17 +7143,16 @@ const stretchySvg = function (group, options) {
|
|
|
7153
7143
|
}
|
|
7154
7144
|
}
|
|
7155
7145
|
return {
|
|
7156
|
-
span: makeSpan(["stretchy"], spans, options),
|
|
7146
|
+
span: makeSpan(["katex-stretchy"], spans, options),
|
|
7157
7147
|
minWidth,
|
|
7158
7148
|
height
|
|
7159
7149
|
};
|
|
7160
7150
|
}
|
|
7161
7151
|
} // buildSvgSpan_()
|
|
7162
|
-
const
|
|
7163
|
-
span,
|
|
7164
|
-
minWidth,
|
|
7165
|
-
height
|
|
7166
|
-
} = buildSvgSpan_();
|
|
7152
|
+
const _buildSvgSpan_ = buildSvgSpan_(),
|
|
7153
|
+
span = _buildSvgSpan_.span,
|
|
7154
|
+
minWidth = _buildSvgSpan_.minWidth,
|
|
7155
|
+
height = _buildSvgSpan_.height;
|
|
7167
7156
|
|
|
7168
7157
|
// Note that we are returning span.depth = 0.
|
|
7169
7158
|
// Any adjustments relative to the baseline must be done in buildHTML.
|
|
@@ -7179,7 +7168,7 @@ const stretchyEnclose = function (inner, label, topPad, bottomPad, options) {
|
|
|
7179
7168
|
let img;
|
|
7180
7169
|
const totalHeight = inner.height + inner.depth + topPad + bottomPad;
|
|
7181
7170
|
if (/fbox|color|angl/.test(label)) {
|
|
7182
|
-
img = makeSpan(["stretchy", label], [], options);
|
|
7171
|
+
img = makeSpan(["katex-stretchy", label], [], options);
|
|
7183
7172
|
if (label === "fbox") {
|
|
7184
7173
|
const color = options.color && options.getColor();
|
|
7185
7174
|
if (color) {
|
|
@@ -7227,39 +7216,15 @@ const stretchyEnclose = function (inner, label, topPad, bottomPad, options) {
|
|
|
7227
7216
|
* pull in `isAtom` without dragging in the ~870-line symbol tables.
|
|
7228
7217
|
*/
|
|
7229
7218
|
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
const ATOMS = {
|
|
7235
|
-
"bin": 1,
|
|
7236
|
-
"close": 1,
|
|
7237
|
-
"inner": 1,
|
|
7238
|
-
"open": 1,
|
|
7239
|
-
"punct": 1,
|
|
7240
|
-
"rel": 1
|
|
7241
|
-
};
|
|
7242
|
-
const NON_ATOMS = {
|
|
7243
|
-
"accent-token": 1,
|
|
7244
|
-
"mathord": 1,
|
|
7245
|
-
"op-token": 1,
|
|
7246
|
-
"spacing": 1,
|
|
7247
|
-
"textord": 1
|
|
7248
|
-
};
|
|
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);
|
|
7249
7223
|
function isAtom(value) {
|
|
7250
|
-
return value
|
|
7224
|
+
return Atoms.has(value);
|
|
7251
7225
|
}
|
|
7252
7226
|
;// ./src/parseNode.ts
|
|
7253
7227
|
|
|
7254
|
-
|
|
7255
|
-
// ParseNode's corresponding to Symbol `Group`s in symbols.js.
|
|
7256
|
-
|
|
7257
|
-
// ParseNode from `Parser.formatUnsupportedCmd`
|
|
7258
|
-
|
|
7259
|
-
// Union of all possible `ParseNode<>` types.
|
|
7260
|
-
|
|
7261
|
-
// Map from `NodeType` to the corresponding `ParseNode`.
|
|
7262
|
-
|
|
7263
7228
|
/**
|
|
7264
7229
|
* Asserts that the node is of the given type and returns it with stricter
|
|
7265
7230
|
* typing. Throws if the node's type does not match.
|
|
@@ -7284,11 +7249,11 @@ function assertSymbolNodeType(node) {
|
|
|
7284
7249
|
}
|
|
7285
7250
|
|
|
7286
7251
|
/**
|
|
7287
|
-
* Returns the node more strictly typed
|
|
7252
|
+
* Returns the node more strictly typed if it is of the given type. Otherwise,
|
|
7288
7253
|
* returns null.
|
|
7289
7254
|
*/
|
|
7290
7255
|
function checkSymbolNodeType(node) {
|
|
7291
|
-
if (node
|
|
7256
|
+
if (node.type === "atom" || NonAtoms.has(node.type)) {
|
|
7292
7257
|
return node;
|
|
7293
7258
|
}
|
|
7294
7259
|
return null;
|
|
@@ -7388,7 +7353,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7388
7353
|
type: "textord",
|
|
7389
7354
|
mode: group.mode,
|
|
7390
7355
|
text: group.label
|
|
7391
|
-
}, options
|
|
7356
|
+
}, options);
|
|
7392
7357
|
accent = assertSymbolDomNode(accent);
|
|
7393
7358
|
// Remove the italic correction of the accent, because it only serves to
|
|
7394
7359
|
// shift the accent over to a place we don't want.
|
|
@@ -7412,7 +7377,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7412
7377
|
// Shift the accent over by the skew.
|
|
7413
7378
|
let left = skew;
|
|
7414
7379
|
|
|
7415
|
-
// CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }`
|
|
7380
|
+
// CSS defines `.katex .katex-accent .accent-body:not(.accent-full) { width: 0 }`
|
|
7416
7381
|
// so that the accent doesn't contribute to the bounding box.
|
|
7417
7382
|
// We need to shift the character by its width (effectively half
|
|
7418
7383
|
// its width) to compensate.
|
|
@@ -7457,7 +7422,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7457
7422
|
}]
|
|
7458
7423
|
}, options);
|
|
7459
7424
|
}
|
|
7460
|
-
const accentWrap = makeSpan(["mord", "accent"], [accentBody], options);
|
|
7425
|
+
const accentWrap = makeSpan(["mord", "katex-accent"], [accentBody], options);
|
|
7461
7426
|
if (supSubGroup) {
|
|
7462
7427
|
// Here, we replace the "base" child of the supsub with our newly
|
|
7463
7428
|
// generated accent.
|
|
@@ -7486,9 +7451,7 @@ const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\
|
|
|
7486
7451
|
defineFunction({
|
|
7487
7452
|
type: "accent",
|
|
7488
7453
|
names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"],
|
|
7489
|
-
|
|
7490
|
-
numArgs: 1
|
|
7491
|
-
},
|
|
7454
|
+
numArgs: 1,
|
|
7492
7455
|
handler: (context, args) => {
|
|
7493
7456
|
const base = normalizeArgument(args[0]);
|
|
7494
7457
|
const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
|
|
@@ -7510,13 +7473,11 @@ defineFunction({
|
|
|
7510
7473
|
defineFunction({
|
|
7511
7474
|
type: "accent",
|
|
7512
7475
|
names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
argTypes: ["primitive"]
|
|
7519
|
-
},
|
|
7476
|
+
numArgs: 1,
|
|
7477
|
+
allowedInText: true,
|
|
7478
|
+
allowedInMath: true,
|
|
7479
|
+
// unless in strict mode
|
|
7480
|
+
argTypes: ["primitive"],
|
|
7520
7481
|
handler: (context, args) => {
|
|
7521
7482
|
const base = args[0];
|
|
7522
7483
|
let mode = context.parser.mode;
|
|
@@ -7532,9 +7493,7 @@ defineFunction({
|
|
|
7532
7493
|
isShifty: true,
|
|
7533
7494
|
base: base
|
|
7534
7495
|
};
|
|
7535
|
-
}
|
|
7536
|
-
htmlBuilder,
|
|
7537
|
-
mathmlBuilder
|
|
7496
|
+
}
|
|
7538
7497
|
});
|
|
7539
7498
|
;// ./src/functions/accentunder.ts
|
|
7540
7499
|
// Horizontal overlap functions
|
|
@@ -7547,14 +7506,10 @@ defineFunction({
|
|
|
7547
7506
|
defineFunction({
|
|
7548
7507
|
type: "accentUnder",
|
|
7549
7508
|
names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
|
|
7550
|
-
|
|
7551
|
-
numArgs: 1
|
|
7552
|
-
},
|
|
7509
|
+
numArgs: 1,
|
|
7553
7510
|
handler: (_ref, args) => {
|
|
7554
|
-
let
|
|
7555
|
-
|
|
7556
|
-
funcName
|
|
7557
|
-
} = _ref;
|
|
7511
|
+
let parser = _ref.parser,
|
|
7512
|
+
funcName = _ref.funcName;
|
|
7558
7513
|
const base = args[0];
|
|
7559
7514
|
return {
|
|
7560
7515
|
type: "accentUnder",
|
|
@@ -7618,15 +7573,11 @@ defineFunction({
|
|
|
7618
7573
|
"\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium",
|
|
7619
7574
|
// The next 3 functions are here only to support the {CD} environment.
|
|
7620
7575
|
"\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
numOptionalArgs: 1
|
|
7624
|
-
},
|
|
7576
|
+
numArgs: 1,
|
|
7577
|
+
numOptionalArgs: 1,
|
|
7625
7578
|
handler(_ref, args, optArgs) {
|
|
7626
|
-
let
|
|
7627
|
-
|
|
7628
|
-
funcName
|
|
7629
|
-
} = _ref;
|
|
7579
|
+
let parser = _ref.parser,
|
|
7580
|
+
funcName = _ref.funcName;
|
|
7630
7581
|
return {
|
|
7631
7582
|
type: "xArrow",
|
|
7632
7583
|
mode: parser.mode,
|
|
@@ -7769,9 +7720,6 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
7769
7720
|
} else if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
7770
7721
|
node.attributes.lspace = "0em";
|
|
7771
7722
|
node.attributes.rspace = "0em";
|
|
7772
|
-
} else if (group.mclass === "minner") {
|
|
7773
|
-
node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
|
|
7774
|
-
node.attributes.width = "+0.1111em";
|
|
7775
7723
|
}
|
|
7776
7724
|
// MathML <mo> default space is 5/18 em, so <mrel> needs no action.
|
|
7777
7725
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
|
|
@@ -7783,21 +7731,16 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
7783
7731
|
defineFunction({
|
|
7784
7732
|
type: "mclass",
|
|
7785
7733
|
names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
primitive: true
|
|
7789
|
-
},
|
|
7734
|
+
numArgs: 1,
|
|
7735
|
+
primitive: true,
|
|
7790
7736
|
handler(_ref, args) {
|
|
7791
|
-
let
|
|
7792
|
-
|
|
7793
|
-
funcName
|
|
7794
|
-
} = _ref;
|
|
7737
|
+
let parser = _ref.parser,
|
|
7738
|
+
funcName = _ref.funcName;
|
|
7795
7739
|
const body = args[0];
|
|
7796
7740
|
return {
|
|
7797
7741
|
type: "mclass",
|
|
7798
7742
|
mode: parser.mode,
|
|
7799
7743
|
mclass: "m" + funcName.slice(5),
|
|
7800
|
-
// TODO(kevinb): don't prefix with 'm'
|
|
7801
7744
|
body: ordargument(body),
|
|
7802
7745
|
isCharacterBox: isCharacterBox(body)
|
|
7803
7746
|
};
|
|
@@ -7823,13 +7766,9 @@ const binrelClass = arg => {
|
|
|
7823
7766
|
defineFunction({
|
|
7824
7767
|
type: "mclass",
|
|
7825
7768
|
names: ["\\@binrel"],
|
|
7826
|
-
|
|
7827
|
-
numArgs: 2
|
|
7828
|
-
},
|
|
7769
|
+
numArgs: 2,
|
|
7829
7770
|
handler(_ref2, args) {
|
|
7830
|
-
let
|
|
7831
|
-
parser
|
|
7832
|
-
} = _ref2;
|
|
7771
|
+
let parser = _ref2.parser;
|
|
7833
7772
|
return {
|
|
7834
7773
|
type: "mclass",
|
|
7835
7774
|
mode: parser.mode,
|
|
@@ -7844,14 +7783,10 @@ defineFunction({
|
|
|
7844
7783
|
defineFunction({
|
|
7845
7784
|
type: "mclass",
|
|
7846
7785
|
names: ["\\stackrel", "\\overset", "\\underset"],
|
|
7847
|
-
|
|
7848
|
-
numArgs: 2
|
|
7849
|
-
},
|
|
7786
|
+
numArgs: 2,
|
|
7850
7787
|
handler(_ref3, args) {
|
|
7851
|
-
let
|
|
7852
|
-
|
|
7853
|
-
funcName
|
|
7854
|
-
} = _ref3;
|
|
7788
|
+
let parser = _ref3.parser,
|
|
7789
|
+
funcName = _ref3.funcName;
|
|
7855
7790
|
const baseArg = args[1];
|
|
7856
7791
|
const shiftedArg = args[0];
|
|
7857
7792
|
let mclass;
|
|
@@ -7871,12 +7806,16 @@ defineFunction({
|
|
|
7871
7806
|
suppressBaseShift: funcName !== "\\stackrel",
|
|
7872
7807
|
body: ordargument(baseArg)
|
|
7873
7808
|
};
|
|
7874
|
-
const supsub = {
|
|
7809
|
+
const supsub = funcName === "\\underset" ? {
|
|
7875
7810
|
type: "supsub",
|
|
7876
7811
|
mode: shiftedArg.mode,
|
|
7877
7812
|
base: baseOp,
|
|
7878
|
-
|
|
7879
|
-
|
|
7813
|
+
sub: shiftedArg
|
|
7814
|
+
} : {
|
|
7815
|
+
type: "supsub",
|
|
7816
|
+
mode: shiftedArg.mode,
|
|
7817
|
+
base: baseOp,
|
|
7818
|
+
sup: shiftedArg
|
|
7880
7819
|
};
|
|
7881
7820
|
return {
|
|
7882
7821
|
type: "mclass",
|
|
@@ -7885,9 +7824,7 @@ defineFunction({
|
|
|
7885
7824
|
body: [supsub],
|
|
7886
7825
|
isCharacterBox: isCharacterBox(supsub)
|
|
7887
7826
|
};
|
|
7888
|
-
}
|
|
7889
|
-
htmlBuilder: mclass_htmlBuilder,
|
|
7890
|
-
mathmlBuilder: mclass_mathmlBuilder
|
|
7827
|
+
}
|
|
7891
7828
|
});
|
|
7892
7829
|
;// ./src/functions/pmb.ts
|
|
7893
7830
|
|
|
@@ -7904,14 +7841,10 @@ defineFunction({
|
|
|
7904
7841
|
defineFunction({
|
|
7905
7842
|
type: "pmb",
|
|
7906
7843
|
names: ["\\pmb"],
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
allowedInText: true
|
|
7910
|
-
},
|
|
7844
|
+
numArgs: 1,
|
|
7845
|
+
allowedInText: true,
|
|
7911
7846
|
handler(_ref, args) {
|
|
7912
|
-
let
|
|
7913
|
-
parser
|
|
7914
|
-
} = _ref;
|
|
7847
|
+
let parser = _ref.parser;
|
|
7915
7848
|
return {
|
|
7916
7849
|
type: "pmb",
|
|
7917
7850
|
mode: parser.mode,
|
|
@@ -8175,14 +8108,10 @@ function parseCD(parser) {
|
|
|
8175
8108
|
defineFunction({
|
|
8176
8109
|
type: "cdlabel",
|
|
8177
8110
|
names: ["\\\\cdleft", "\\\\cdright"],
|
|
8178
|
-
|
|
8179
|
-
numArgs: 1
|
|
8180
|
-
},
|
|
8111
|
+
numArgs: 1,
|
|
8181
8112
|
handler(_ref, args) {
|
|
8182
|
-
let
|
|
8183
|
-
|
|
8184
|
-
funcName
|
|
8185
|
-
} = _ref;
|
|
8113
|
+
let parser = _ref.parser,
|
|
8114
|
+
funcName = _ref.funcName;
|
|
8186
8115
|
return {
|
|
8187
8116
|
type: "cdlabel",
|
|
8188
8117
|
mode: parser.mode,
|
|
@@ -8220,13 +8149,9 @@ defineFunction({
|
|
|
8220
8149
|
defineFunction({
|
|
8221
8150
|
type: "cdlabelparent",
|
|
8222
8151
|
names: ["\\\\cdparent"],
|
|
8223
|
-
|
|
8224
|
-
numArgs: 1
|
|
8225
|
-
},
|
|
8152
|
+
numArgs: 1,
|
|
8226
8153
|
handler(_ref2, args) {
|
|
8227
|
-
let
|
|
8228
|
-
parser
|
|
8229
|
-
} = _ref2;
|
|
8154
|
+
let parser = _ref2.parser;
|
|
8230
8155
|
return {
|
|
8231
8156
|
type: "cdlabelparent",
|
|
8232
8157
|
mode: parser.mode,
|
|
@@ -8256,14 +8181,10 @@ defineFunction({
|
|
|
8256
8181
|
defineFunction({
|
|
8257
8182
|
type: "textord",
|
|
8258
8183
|
names: ["\\@char"],
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
allowedInText: true
|
|
8262
|
-
},
|
|
8184
|
+
numArgs: 1,
|
|
8185
|
+
allowedInText: true,
|
|
8263
8186
|
handler(_ref, args) {
|
|
8264
|
-
let
|
|
8265
|
-
parser
|
|
8266
|
-
} = _ref;
|
|
8187
|
+
let parser = _ref.parser;
|
|
8267
8188
|
const arg = assertNodeType(args[0], "ordgroup");
|
|
8268
8189
|
const group = arg.body;
|
|
8269
8190
|
let number = "";
|
|
@@ -8318,15 +8239,11 @@ const color_mathmlBuilder = (group, options) => {
|
|
|
8318
8239
|
defineFunction({
|
|
8319
8240
|
type: "color",
|
|
8320
8241
|
names: ["\\textcolor"],
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
argTypes: ["color", "original"]
|
|
8325
|
-
},
|
|
8242
|
+
numArgs: 2,
|
|
8243
|
+
allowedInText: true,
|
|
8244
|
+
argTypes: ["color", "original"],
|
|
8326
8245
|
handler(_ref, args) {
|
|
8327
|
-
let
|
|
8328
|
-
parser
|
|
8329
|
-
} = _ref;
|
|
8246
|
+
let parser = _ref.parser;
|
|
8330
8247
|
const color = assertNodeType(args[0], "color-token").color;
|
|
8331
8248
|
const body = args[1];
|
|
8332
8249
|
return {
|
|
@@ -8342,16 +8259,12 @@ defineFunction({
|
|
|
8342
8259
|
defineFunction({
|
|
8343
8260
|
type: "color",
|
|
8344
8261
|
names: ["\\color"],
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
argTypes: ["color"]
|
|
8349
|
-
},
|
|
8262
|
+
numArgs: 1,
|
|
8263
|
+
allowedInText: true,
|
|
8264
|
+
argTypes: ["color"],
|
|
8350
8265
|
handler(_ref2, args) {
|
|
8351
|
-
let
|
|
8352
|
-
|
|
8353
|
-
breakOnTokenText
|
|
8354
|
-
} = _ref2;
|
|
8266
|
+
let parser = _ref2.parser,
|
|
8267
|
+
breakOnTokenText = _ref2.breakOnTokenText;
|
|
8355
8268
|
const color = assertNodeType(args[0], "color-token").color;
|
|
8356
8269
|
|
|
8357
8270
|
// Set macro \current@color in current namespace to store the current
|
|
@@ -8368,9 +8281,7 @@ defineFunction({
|
|
|
8368
8281
|
color,
|
|
8369
8282
|
body
|
|
8370
8283
|
};
|
|
8371
|
-
}
|
|
8372
|
-
htmlBuilder: color_htmlBuilder,
|
|
8373
|
-
mathmlBuilder: color_mathmlBuilder
|
|
8284
|
+
}
|
|
8374
8285
|
});
|
|
8375
8286
|
;// ./src/functions/cr.ts
|
|
8376
8287
|
// Row breaks within tabular environments, and line breaks at top level
|
|
@@ -8385,15 +8296,11 @@ defineFunction({
|
|
|
8385
8296
|
defineFunction({
|
|
8386
8297
|
type: "cr",
|
|
8387
8298
|
names: ["\\\\"],
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
allowedInText: true
|
|
8392
|
-
},
|
|
8299
|
+
numArgs: 0,
|
|
8300
|
+
numOptionalArgs: 0,
|
|
8301
|
+
allowedInText: true,
|
|
8393
8302
|
handler(_ref, args, optArgs) {
|
|
8394
|
-
let
|
|
8395
|
-
parser
|
|
8396
|
-
} = _ref;
|
|
8303
|
+
let parser = _ref.parser;
|
|
8397
8304
|
const size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null;
|
|
8398
8305
|
const newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode");
|
|
8399
8306
|
return {
|
|
@@ -8409,7 +8316,7 @@ defineFunction({
|
|
|
8409
8316
|
htmlBuilder(group, options) {
|
|
8410
8317
|
const span = makeSpan(["mspace"], [], options);
|
|
8411
8318
|
if (group.newLine) {
|
|
8412
|
-
span.classes.push("newline");
|
|
8319
|
+
span.classes.push("katex-newline");
|
|
8413
8320
|
if (group.size) {
|
|
8414
8321
|
span.style.marginTop = makeEm(calculateSize(group.size, options));
|
|
8415
8322
|
}
|
|
@@ -8485,15 +8392,11 @@ defineFunction({
|
|
|
8485
8392
|
type: "internal",
|
|
8486
8393
|
names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
|
|
8487
8394
|
],
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
allowedInText: true
|
|
8491
|
-
},
|
|
8395
|
+
numArgs: 0,
|
|
8396
|
+
allowedInText: true,
|
|
8492
8397
|
handler(_ref) {
|
|
8493
|
-
let
|
|
8494
|
-
|
|
8495
|
-
funcName
|
|
8496
|
-
} = _ref;
|
|
8398
|
+
let parser = _ref.parser,
|
|
8399
|
+
funcName = _ref.funcName;
|
|
8497
8400
|
parser.consumeSpaces();
|
|
8498
8401
|
const token = parser.fetch();
|
|
8499
8402
|
if (globalMap[token.text]) {
|
|
@@ -8514,16 +8417,12 @@ defineFunction({
|
|
|
8514
8417
|
defineFunction({
|
|
8515
8418
|
type: "internal",
|
|
8516
8419
|
names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
primitive: true
|
|
8521
|
-
},
|
|
8420
|
+
numArgs: 0,
|
|
8421
|
+
allowedInText: true,
|
|
8422
|
+
primitive: true,
|
|
8522
8423
|
handler(_ref2) {
|
|
8523
|
-
let
|
|
8524
|
-
|
|
8525
|
-
funcName
|
|
8526
|
-
} = _ref2;
|
|
8424
|
+
let parser = _ref2.parser,
|
|
8425
|
+
funcName = _ref2.funcName;
|
|
8527
8426
|
let tok = parser.gullet.popToken();
|
|
8528
8427
|
const name = tok.text;
|
|
8529
8428
|
if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) {
|
|
@@ -8564,9 +8463,8 @@ defineFunction({
|
|
|
8564
8463
|
}
|
|
8565
8464
|
}
|
|
8566
8465
|
// replacement text, enclosed in '{' and '}' and properly nested
|
|
8567
|
-
let
|
|
8568
|
-
tokens
|
|
8569
|
-
} = parser.gullet.consumeArg();
|
|
8466
|
+
let _parser$gullet$consum = parser.gullet.consumeArg(),
|
|
8467
|
+
tokens = _parser$gullet$consum.tokens;
|
|
8570
8468
|
if (insert) {
|
|
8571
8469
|
tokens.unshift(insert);
|
|
8572
8470
|
}
|
|
@@ -8595,16 +8493,12 @@ defineFunction({
|
|
|
8595
8493
|
type: "internal",
|
|
8596
8494
|
names: ["\\let", "\\\\globallet" // can’t be entered directly
|
|
8597
8495
|
],
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
primitive: true
|
|
8602
|
-
},
|
|
8496
|
+
numArgs: 0,
|
|
8497
|
+
allowedInText: true,
|
|
8498
|
+
primitive: true,
|
|
8603
8499
|
handler(_ref3) {
|
|
8604
|
-
let
|
|
8605
|
-
|
|
8606
|
-
funcName
|
|
8607
|
-
} = _ref3;
|
|
8500
|
+
let parser = _ref3.parser,
|
|
8501
|
+
funcName = _ref3.funcName;
|
|
8608
8502
|
const name = checkControlSequence(parser.gullet.popToken());
|
|
8609
8503
|
parser.gullet.consumeSpaces();
|
|
8610
8504
|
const tok = getRHS(parser);
|
|
@@ -8621,16 +8515,12 @@ defineFunction({
|
|
|
8621
8515
|
type: "internal",
|
|
8622
8516
|
names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
|
|
8623
8517
|
],
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
primitive: true
|
|
8628
|
-
},
|
|
8518
|
+
numArgs: 0,
|
|
8519
|
+
allowedInText: true,
|
|
8520
|
+
primitive: true,
|
|
8629
8521
|
handler(_ref4) {
|
|
8630
|
-
let
|
|
8631
|
-
|
|
8632
|
-
funcName
|
|
8633
|
-
} = _ref4;
|
|
8522
|
+
let parser = _ref4.parser,
|
|
8523
|
+
funcName = _ref4.funcName;
|
|
8634
8524
|
const name = checkControlSequence(parser.gullet.popToken());
|
|
8635
8525
|
const middle = parser.gullet.popToken();
|
|
8636
8526
|
const tok = parser.gullet.popToken();
|
|
@@ -9450,10 +9340,8 @@ function checkDelimiter(delim, context) {
|
|
|
9450
9340
|
defineFunction({
|
|
9451
9341
|
type: "delimsizing",
|
|
9452
9342
|
names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
argTypes: ["primitive"]
|
|
9456
|
-
},
|
|
9343
|
+
numArgs: 1,
|
|
9344
|
+
argTypes: ["primitive"],
|
|
9457
9345
|
handler: (context, args) => {
|
|
9458
9346
|
const delim = checkDelimiter(args[0], context);
|
|
9459
9347
|
return {
|
|
@@ -9502,10 +9390,8 @@ function assertParsed(group) {
|
|
|
9502
9390
|
defineFunction({
|
|
9503
9391
|
type: "leftright-right",
|
|
9504
9392
|
names: ["\\right"],
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
primitive: true
|
|
9508
|
-
},
|
|
9393
|
+
numArgs: 1,
|
|
9394
|
+
primitive: true,
|
|
9509
9395
|
handler: (context, args) => {
|
|
9510
9396
|
// \left case below triggers parsing of \right in
|
|
9511
9397
|
// `const right = parser.parseFunction();`
|
|
@@ -9518,17 +9404,15 @@ defineFunction({
|
|
|
9518
9404
|
type: "leftright-right",
|
|
9519
9405
|
mode: context.parser.mode,
|
|
9520
9406
|
delim: checkDelimiter(args[0], context).text,
|
|
9521
|
-
color
|
|
9407
|
+
color // undefined if not set via \color
|
|
9522
9408
|
};
|
|
9523
9409
|
}
|
|
9524
9410
|
});
|
|
9525
9411
|
defineFunction({
|
|
9526
9412
|
type: "leftright",
|
|
9527
9413
|
names: ["\\left"],
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
primitive: true
|
|
9531
|
-
},
|
|
9414
|
+
numArgs: 1,
|
|
9415
|
+
primitive: true,
|
|
9532
9416
|
handler: (context, args) => {
|
|
9533
9417
|
const delim = checkDelimiter(args[0], context);
|
|
9534
9418
|
const parser = context.parser;
|
|
@@ -9630,10 +9514,8 @@ defineFunction({
|
|
|
9630
9514
|
defineFunction({
|
|
9631
9515
|
type: "middle",
|
|
9632
9516
|
names: ["\\middle"],
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
primitive: true
|
|
9636
|
-
},
|
|
9517
|
+
numArgs: 1,
|
|
9518
|
+
primitive: true,
|
|
9637
9519
|
handler: (context, args) => {
|
|
9638
9520
|
const delim = checkDelimiter(args[0], context);
|
|
9639
9521
|
if (!context.parser.leftrightDepth) {
|
|
@@ -9707,7 +9589,7 @@ const enclose_htmlBuilder = (group, options) => {
|
|
|
9707
9589
|
// subjects that should get the "tall" treatment.
|
|
9708
9590
|
const isSingleChar = isCharacterBox(group.body);
|
|
9709
9591
|
if (label === "sout") {
|
|
9710
|
-
img = makeSpan(["stretchy", "sout"]);
|
|
9592
|
+
img = makeSpan(["katex-stretchy", "katex-sout"]);
|
|
9711
9593
|
img.height = options.fontMetrics().defaultRuleThickness / scale;
|
|
9712
9594
|
imgShift = -0.5 * options.fontMetrics().xHeight;
|
|
9713
9595
|
} else if (label === "phase") {
|
|
@@ -9887,16 +9769,12 @@ const enclose_mathmlBuilder = (group, options) => {
|
|
|
9887
9769
|
defineFunction({
|
|
9888
9770
|
type: "enclose",
|
|
9889
9771
|
names: ["\\colorbox"],
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
argTypes: ["color", "hbox"]
|
|
9894
|
-
},
|
|
9772
|
+
numArgs: 2,
|
|
9773
|
+
allowedInText: true,
|
|
9774
|
+
argTypes: ["color", "hbox"],
|
|
9895
9775
|
handler(_ref, args, optArgs) {
|
|
9896
|
-
let
|
|
9897
|
-
|
|
9898
|
-
funcName
|
|
9899
|
-
} = _ref;
|
|
9776
|
+
let parser = _ref.parser,
|
|
9777
|
+
funcName = _ref.funcName;
|
|
9900
9778
|
const color = assertNodeType(args[0], "color-token").color;
|
|
9901
9779
|
const body = args[1];
|
|
9902
9780
|
return {
|
|
@@ -9913,16 +9791,12 @@ defineFunction({
|
|
|
9913
9791
|
defineFunction({
|
|
9914
9792
|
type: "enclose",
|
|
9915
9793
|
names: ["\\fcolorbox"],
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
argTypes: ["color", "color", "hbox"]
|
|
9920
|
-
},
|
|
9794
|
+
numArgs: 3,
|
|
9795
|
+
allowedInText: true,
|
|
9796
|
+
argTypes: ["color", "color", "hbox"],
|
|
9921
9797
|
handler(_ref2, args, optArgs) {
|
|
9922
|
-
let
|
|
9923
|
-
|
|
9924
|
-
funcName
|
|
9925
|
-
} = _ref2;
|
|
9798
|
+
let parser = _ref2.parser,
|
|
9799
|
+
funcName = _ref2.funcName;
|
|
9926
9800
|
const borderColor = assertNodeType(args[0], "color-token").color;
|
|
9927
9801
|
const backgroundColor = assertNodeType(args[1], "color-token").color;
|
|
9928
9802
|
const body = args[2];
|
|
@@ -9934,22 +9808,16 @@ defineFunction({
|
|
|
9934
9808
|
borderColor,
|
|
9935
9809
|
body
|
|
9936
9810
|
};
|
|
9937
|
-
}
|
|
9938
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
9939
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9811
|
+
}
|
|
9940
9812
|
});
|
|
9941
9813
|
defineFunction({
|
|
9942
9814
|
type: "enclose",
|
|
9943
9815
|
names: ["\\fbox"],
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
allowedInText: true
|
|
9948
|
-
},
|
|
9816
|
+
numArgs: 1,
|
|
9817
|
+
argTypes: ["hbox"],
|
|
9818
|
+
allowedInText: true,
|
|
9949
9819
|
handler(_ref3, args) {
|
|
9950
|
-
let
|
|
9951
|
-
parser
|
|
9952
|
-
} = _ref3;
|
|
9820
|
+
let parser = _ref3.parser;
|
|
9953
9821
|
return {
|
|
9954
9822
|
type: "enclose",
|
|
9955
9823
|
mode: parser.mode,
|
|
@@ -9961,14 +9829,10 @@ defineFunction({
|
|
|
9961
9829
|
defineFunction({
|
|
9962
9830
|
type: "enclose",
|
|
9963
9831
|
names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
|
|
9964
|
-
|
|
9965
|
-
numArgs: 1
|
|
9966
|
-
},
|
|
9832
|
+
numArgs: 1,
|
|
9967
9833
|
handler(_ref4, args) {
|
|
9968
|
-
let
|
|
9969
|
-
|
|
9970
|
-
funcName
|
|
9971
|
-
} = _ref4;
|
|
9834
|
+
let parser = _ref4.parser,
|
|
9835
|
+
funcName = _ref4.funcName;
|
|
9972
9836
|
const body = args[0];
|
|
9973
9837
|
return {
|
|
9974
9838
|
type: "enclose",
|
|
@@ -9976,22 +9840,16 @@ defineFunction({
|
|
|
9976
9840
|
label: funcName,
|
|
9977
9841
|
body
|
|
9978
9842
|
};
|
|
9979
|
-
}
|
|
9980
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
9981
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9843
|
+
}
|
|
9982
9844
|
});
|
|
9983
9845
|
defineFunction({
|
|
9984
9846
|
type: "enclose",
|
|
9985
9847
|
names: ["\\sout"],
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
allowedInText: true
|
|
9989
|
-
},
|
|
9848
|
+
numArgs: 1,
|
|
9849
|
+
allowedInText: true,
|
|
9990
9850
|
handler(_ref5, args) {
|
|
9991
|
-
let
|
|
9992
|
-
|
|
9993
|
-
funcName
|
|
9994
|
-
} = _ref5;
|
|
9851
|
+
let parser = _ref5.parser,
|
|
9852
|
+
funcName = _ref5.funcName;
|
|
9995
9853
|
if (parser.mode === "math") {
|
|
9996
9854
|
parser.settings.reportNonstrict("mathVsSout", "LaTeX's \\sout works only in text mode");
|
|
9997
9855
|
}
|
|
@@ -10002,22 +9860,16 @@ defineFunction({
|
|
|
10002
9860
|
label: funcName,
|
|
10003
9861
|
body
|
|
10004
9862
|
};
|
|
10005
|
-
}
|
|
10006
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
10007
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9863
|
+
}
|
|
10008
9864
|
});
|
|
10009
9865
|
defineFunction({
|
|
10010
9866
|
type: "enclose",
|
|
10011
9867
|
names: ["\\angl"],
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
allowedInText: false
|
|
10016
|
-
},
|
|
9868
|
+
numArgs: 1,
|
|
9869
|
+
argTypes: ["hbox"],
|
|
9870
|
+
allowedInText: false,
|
|
10017
9871
|
handler(_ref6, args) {
|
|
10018
|
-
let
|
|
10019
|
-
parser
|
|
10020
|
-
} = _ref6;
|
|
9872
|
+
let parser = _ref6.parser;
|
|
10021
9873
|
return {
|
|
10022
9874
|
type: "enclose",
|
|
10023
9875
|
mode: parser.mode,
|
|
@@ -10065,14 +9917,12 @@ defineFunction({
|
|
|
10065
9917
|
*/
|
|
10066
9918
|
const _environments = {};
|
|
10067
9919
|
function defineEnvironment(_ref) {
|
|
10068
|
-
let
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
mathmlBuilder
|
|
10075
|
-
} = _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;
|
|
10076
9926
|
// Set default values of environments.
|
|
10077
9927
|
const data = {
|
|
10078
9928
|
type,
|
|
@@ -10266,18 +10116,16 @@ function getAutoTag(name) {
|
|
|
10266
10116
|
* ("text", "display", etc.), then each cell is cast into that style.
|
|
10267
10117
|
*/
|
|
10268
10118
|
function parseArray(parser, _ref, style) {
|
|
10269
|
-
let
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
leqno
|
|
10280
|
-
} = _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;
|
|
10281
10129
|
parser.gullet.beginGroup();
|
|
10282
10130
|
if (!singleRow) {
|
|
10283
10131
|
// \cr is equivalent to \\ without the optional size argument (see below)
|
|
@@ -10651,8 +10499,8 @@ const array_htmlBuilder = function (group, options) {
|
|
|
10651
10499
|
|
|
10652
10500
|
// Add \hline(s), if any.
|
|
10653
10501
|
if (hlines.length > 0) {
|
|
10654
|
-
const line = makeLineSpan("hline", options, ruleThickness);
|
|
10655
|
-
const dashes = makeLineSpan("hdashline", options, ruleThickness);
|
|
10502
|
+
const line = makeLineSpan("katex-hline", options, ruleThickness);
|
|
10503
|
+
const dashes = makeLineSpan("katex-hdashline", options, ruleThickness);
|
|
10656
10504
|
const vListElems = [{
|
|
10657
10505
|
type: "elem",
|
|
10658
10506
|
elem: tableBody,
|
|
@@ -10687,7 +10535,7 @@ const array_htmlBuilder = function (group, options) {
|
|
|
10687
10535
|
positionType: "individualShift",
|
|
10688
10536
|
children: tagSpans
|
|
10689
10537
|
}, options);
|
|
10690
|
-
const tagCol = makeSpan(["tag"], [eqnNumCol], options);
|
|
10538
|
+
const tagCol = makeSpan(["katex-tag"], [eqnNumCol], options);
|
|
10691
10539
|
return makeFragment([tableBody, tagCol]);
|
|
10692
10540
|
}
|
|
10693
10541
|
};
|
|
@@ -10827,14 +10675,13 @@ const alignedHandler = function (context, args) {
|
|
|
10827
10675
|
validateAmsEnvironmentContext(context);
|
|
10828
10676
|
}
|
|
10829
10677
|
const cols = [];
|
|
10830
|
-
const separationType = context.envName.includes("at") ? "alignat" : "align";
|
|
10831
10678
|
const isSplit = context.envName === "split";
|
|
10832
10679
|
const res = parseArray(context.parser, {
|
|
10833
10680
|
cols,
|
|
10834
10681
|
addJot: true,
|
|
10835
10682
|
autoTag: isSplit ? undefined : getAutoTag(context.envName),
|
|
10836
10683
|
emptySingleRow: true,
|
|
10837
|
-
colSeparationType:
|
|
10684
|
+
colSeparationType: context.envName.includes("at") ? "alignat" : "align",
|
|
10838
10685
|
maxNumCols: isSplit ? 2 : undefined,
|
|
10839
10686
|
leqno: context.parser.settings.leqno
|
|
10840
10687
|
}, "display");
|
|
@@ -11229,11 +11076,9 @@ defineFunction({
|
|
|
11229
11076
|
type: "text",
|
|
11230
11077
|
// Doesn't matter what this is.
|
|
11231
11078
|
names: ["\\hline", "\\hdashline"],
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
allowedInMath: true
|
|
11236
|
-
},
|
|
11079
|
+
numArgs: 0,
|
|
11080
|
+
allowedInText: true,
|
|
11081
|
+
allowedInMath: true,
|
|
11237
11082
|
handler(context, args) {
|
|
11238
11083
|
throw new src_ParseError(context.funcName + " valid only within array environment");
|
|
11239
11084
|
}
|
|
@@ -11255,15 +11100,11 @@ const environments = _environments;
|
|
|
11255
11100
|
defineFunction({
|
|
11256
11101
|
type: "environment",
|
|
11257
11102
|
names: ["\\begin", "\\end"],
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
argTypes: ["text"]
|
|
11261
|
-
},
|
|
11103
|
+
numArgs: 1,
|
|
11104
|
+
argTypes: ["text"],
|
|
11262
11105
|
handler(_ref, args) {
|
|
11263
|
-
let
|
|
11264
|
-
|
|
11265
|
-
funcName
|
|
11266
|
-
} = _ref;
|
|
11106
|
+
let parser = _ref.parser,
|
|
11107
|
+
funcName = _ref.funcName;
|
|
11267
11108
|
const nameGroup = args[0];
|
|
11268
11109
|
if (nameGroup.type !== "ordgroup") {
|
|
11269
11110
|
throw new src_ParseError("Invalid environment name", nameGroup);
|
|
@@ -11274,16 +11115,15 @@ defineFunction({
|
|
|
11274
11115
|
}
|
|
11275
11116
|
if (funcName === "\\begin") {
|
|
11276
11117
|
// begin...end is similar to left...right
|
|
11277
|
-
if (!
|
|
11118
|
+
if (!Object.prototype.hasOwnProperty.call(src_environments, envName)) {
|
|
11278
11119
|
throw new src_ParseError("No such environment: " + envName, nameGroup);
|
|
11279
11120
|
}
|
|
11280
11121
|
// Build the environment object. Arguments and other information will
|
|
11281
11122
|
// be made available to the begin and end methods using properties.
|
|
11282
11123
|
const env = src_environments[envName];
|
|
11283
|
-
const {
|
|
11284
|
-
args,
|
|
11285
|
-
optArgs
|
|
11286
|
-
} = parser.parseArguments("\\begin{" + envName + "}", env);
|
|
11124
|
+
const _parser$parseArgument = parser.parseArguments("\\begin{" + envName + "}", env),
|
|
11125
|
+
args = _parser$parseArgument.args,
|
|
11126
|
+
optArgs = _parser$parseArgument.optArgs;
|
|
11287
11127
|
const context = {
|
|
11288
11128
|
mode: parser.mode,
|
|
11289
11129
|
envName,
|
|
@@ -11342,20 +11182,13 @@ defineFunction({
|
|
|
11342
11182
|
"\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
|
|
11343
11183
|
// aliases, except \bm defined below
|
|
11344
11184
|
"\\Bbb", "\\bold", "\\frak"],
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
allowedInArgument: true
|
|
11348
|
-
},
|
|
11185
|
+
numArgs: 1,
|
|
11186
|
+
allowedInArgument: true,
|
|
11349
11187
|
handler: (_ref, args) => {
|
|
11350
|
-
let
|
|
11351
|
-
|
|
11352
|
-
funcName
|
|
11353
|
-
} = _ref;
|
|
11188
|
+
let parser = _ref.parser,
|
|
11189
|
+
funcName = _ref.funcName;
|
|
11354
11190
|
const body = normalizeArgument(args[0]);
|
|
11355
|
-
|
|
11356
|
-
if (func in fontAliases) {
|
|
11357
|
-
func = fontAliases[func];
|
|
11358
|
-
}
|
|
11191
|
+
const func = funcName in fontAliases ? fontAliases[funcName] : funcName;
|
|
11359
11192
|
return {
|
|
11360
11193
|
type: "font",
|
|
11361
11194
|
mode: parser.mode,
|
|
@@ -11369,13 +11202,9 @@ defineFunction({
|
|
|
11369
11202
|
defineFunction({
|
|
11370
11203
|
type: "mclass",
|
|
11371
11204
|
names: ["\\boldsymbol", "\\bm"],
|
|
11372
|
-
|
|
11373
|
-
numArgs: 1
|
|
11374
|
-
},
|
|
11205
|
+
numArgs: 1,
|
|
11375
11206
|
handler: (_ref2, args) => {
|
|
11376
|
-
let
|
|
11377
|
-
parser
|
|
11378
|
-
} = _ref2;
|
|
11207
|
+
let parser = _ref2.parser;
|
|
11379
11208
|
const body = args[0];
|
|
11380
11209
|
// amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
|
|
11381
11210
|
// argument's bin|rel|ord status
|
|
@@ -11398,19 +11227,13 @@ defineFunction({
|
|
|
11398
11227
|
defineFunction({
|
|
11399
11228
|
type: "font",
|
|
11400
11229
|
names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
allowedInText: true
|
|
11404
|
-
},
|
|
11230
|
+
numArgs: 0,
|
|
11231
|
+
allowedInText: true,
|
|
11405
11232
|
handler: (_ref3, args) => {
|
|
11406
|
-
let
|
|
11407
|
-
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
} = _ref3;
|
|
11411
|
-
const {
|
|
11412
|
-
mode
|
|
11413
|
-
} = parser;
|
|
11233
|
+
let parser = _ref3.parser,
|
|
11234
|
+
funcName = _ref3.funcName,
|
|
11235
|
+
breakOnTokenText = _ref3.breakOnTokenText;
|
|
11236
|
+
const mode = parser.mode;
|
|
11414
11237
|
const body = parser.parseExpression(true, breakOnTokenText);
|
|
11415
11238
|
return {
|
|
11416
11239
|
type: "font",
|
|
@@ -11422,9 +11245,7 @@ defineFunction({
|
|
|
11422
11245
|
body
|
|
11423
11246
|
}
|
|
11424
11247
|
};
|
|
11425
|
-
}
|
|
11426
|
-
htmlBuilder: font_htmlBuilder,
|
|
11427
|
-
mathmlBuilder: font_mathmlBuilder
|
|
11248
|
+
}
|
|
11428
11249
|
});
|
|
11429
11250
|
;// ./src/functions/genfrac.ts
|
|
11430
11251
|
|
|
@@ -11618,15 +11439,11 @@ defineFunction({
|
|
|
11618
11439
|
// can’t be entered directly
|
|
11619
11440
|
"\\\\bracefrac", "\\\\brackfrac" // ditto
|
|
11620
11441
|
],
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
allowedInArgument: true
|
|
11624
|
-
},
|
|
11442
|
+
numArgs: 2,
|
|
11443
|
+
allowedInArgument: true,
|
|
11625
11444
|
handler: (_ref, args) => {
|
|
11626
|
-
let
|
|
11627
|
-
|
|
11628
|
-
funcName
|
|
11629
|
-
} = _ref;
|
|
11445
|
+
let parser = _ref.parser,
|
|
11446
|
+
funcName = _ref.funcName;
|
|
11630
11447
|
const numer = args[0];
|
|
11631
11448
|
const denom = args[1];
|
|
11632
11449
|
let hasBarLine;
|
|
@@ -11690,16 +11507,12 @@ defineFunction({
|
|
|
11690
11507
|
defineFunction({
|
|
11691
11508
|
type: "infix",
|
|
11692
11509
|
names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
infix: true
|
|
11696
|
-
},
|
|
11510
|
+
numArgs: 0,
|
|
11511
|
+
infix: true,
|
|
11697
11512
|
handler(_ref2) {
|
|
11698
|
-
let
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
token
|
|
11702
|
-
} = _ref2;
|
|
11513
|
+
let parser = _ref2.parser,
|
|
11514
|
+
funcName = _ref2.funcName,
|
|
11515
|
+
token = _ref2.token;
|
|
11703
11516
|
let replaceWith;
|
|
11704
11517
|
switch (funcName) {
|
|
11705
11518
|
case "\\over":
|
|
@@ -11740,15 +11553,11 @@ const delimFromValue = function (delimString) {
|
|
|
11740
11553
|
defineFunction({
|
|
11741
11554
|
type: "genfrac",
|
|
11742
11555
|
names: ["\\genfrac"],
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
argTypes: ["math", "math", "size", "text", "math", "math"]
|
|
11747
|
-
},
|
|
11556
|
+
numArgs: 6,
|
|
11557
|
+
allowedInArgument: true,
|
|
11558
|
+
argTypes: ["math", "math", "size", "text", "math", "math"],
|
|
11748
11559
|
handler(_ref3, args) {
|
|
11749
|
-
let
|
|
11750
|
-
parser
|
|
11751
|
-
} = _ref3;
|
|
11560
|
+
let parser = _ref3.parser;
|
|
11752
11561
|
const numer = args[4];
|
|
11753
11562
|
const denom = args[5];
|
|
11754
11563
|
|
|
@@ -11800,17 +11609,13 @@ defineFunction({
|
|
|
11800
11609
|
defineFunction({
|
|
11801
11610
|
type: "infix",
|
|
11802
11611
|
names: ["\\above"],
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
infix: true
|
|
11807
|
-
},
|
|
11612
|
+
numArgs: 1,
|
|
11613
|
+
argTypes: ["size"],
|
|
11614
|
+
infix: true,
|
|
11808
11615
|
handler(_ref4, args) {
|
|
11809
|
-
let
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
token
|
|
11813
|
-
} = _ref4;
|
|
11616
|
+
let parser = _ref4.parser,
|
|
11617
|
+
funcName = _ref4.funcName,
|
|
11618
|
+
token = _ref4.token;
|
|
11814
11619
|
return {
|
|
11815
11620
|
type: "infix",
|
|
11816
11621
|
mode: parser.mode,
|
|
@@ -11823,15 +11628,11 @@ defineFunction({
|
|
|
11823
11628
|
defineFunction({
|
|
11824
11629
|
type: "genfrac",
|
|
11825
11630
|
names: ["\\\\abovefrac"],
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
argTypes: ["math", "size", "math"]
|
|
11829
|
-
},
|
|
11631
|
+
numArgs: 3,
|
|
11632
|
+
argTypes: ["math", "size", "math"],
|
|
11830
11633
|
handler: (_ref5, args) => {
|
|
11831
|
-
let
|
|
11832
|
-
|
|
11833
|
-
funcName
|
|
11834
|
-
} = _ref5;
|
|
11634
|
+
let parser = _ref5.parser,
|
|
11635
|
+
funcName = _ref5.funcName;
|
|
11835
11636
|
const numer = args[0];
|
|
11836
11637
|
const barSize = assertNodeType(args[1], "infix").size;
|
|
11837
11638
|
if (!barSize) {
|
|
@@ -11973,14 +11774,10 @@ const horizBrace_mathmlBuilder = (group, options) => {
|
|
|
11973
11774
|
defineFunction({
|
|
11974
11775
|
type: "horizBrace",
|
|
11975
11776
|
names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
|
|
11976
|
-
|
|
11977
|
-
numArgs: 1
|
|
11978
|
-
},
|
|
11777
|
+
numArgs: 1,
|
|
11979
11778
|
handler(_ref, args) {
|
|
11980
|
-
let
|
|
11981
|
-
|
|
11982
|
-
funcName
|
|
11983
|
-
} = _ref;
|
|
11779
|
+
let parser = _ref.parser,
|
|
11780
|
+
funcName = _ref.funcName;
|
|
11984
11781
|
return {
|
|
11985
11782
|
type: "horizBrace",
|
|
11986
11783
|
mode: parser.mode,
|
|
@@ -12002,15 +11799,11 @@ defineFunction({
|
|
|
12002
11799
|
defineFunction({
|
|
12003
11800
|
type: "href",
|
|
12004
11801
|
names: ["\\href"],
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
allowedInText: true
|
|
12009
|
-
},
|
|
11802
|
+
numArgs: 2,
|
|
11803
|
+
argTypes: ["url", "original"],
|
|
11804
|
+
allowedInText: true,
|
|
12010
11805
|
handler: (_ref, args) => {
|
|
12011
|
-
let
|
|
12012
|
-
parser
|
|
12013
|
-
} = _ref;
|
|
11806
|
+
let parser = _ref.parser;
|
|
12014
11807
|
const body = args[1];
|
|
12015
11808
|
const href = assertNodeType(args[0], "url").url;
|
|
12016
11809
|
if (!parser.settings.isTrusted({
|
|
@@ -12042,15 +11835,11 @@ defineFunction({
|
|
|
12042
11835
|
defineFunction({
|
|
12043
11836
|
type: "href",
|
|
12044
11837
|
names: ["\\url"],
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
allowedInText: true
|
|
12049
|
-
},
|
|
11838
|
+
numArgs: 1,
|
|
11839
|
+
argTypes: ["url"],
|
|
11840
|
+
allowedInText: true,
|
|
12050
11841
|
handler: (_ref2, args) => {
|
|
12051
|
-
let
|
|
12052
|
-
parser
|
|
12053
|
-
} = _ref2;
|
|
11842
|
+
let parser = _ref2.parser;
|
|
12054
11843
|
const href = assertNodeType(args[0], "url").url;
|
|
12055
11844
|
if (!parser.settings.isTrusted({
|
|
12056
11845
|
command: "\\url",
|
|
@@ -12099,16 +11888,12 @@ defineFunction({
|
|
|
12099
11888
|
defineFunction({
|
|
12100
11889
|
type: "hbox",
|
|
12101
11890
|
names: ["\\hbox"],
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
primitive: true
|
|
12107
|
-
},
|
|
11891
|
+
numArgs: 1,
|
|
11892
|
+
argTypes: ["text"],
|
|
11893
|
+
allowedInText: true,
|
|
11894
|
+
primitive: true,
|
|
12108
11895
|
handler(_ref, args) {
|
|
12109
|
-
let
|
|
12110
|
-
parser
|
|
12111
|
-
} = _ref;
|
|
11896
|
+
let parser = _ref.parser;
|
|
12112
11897
|
return {
|
|
12113
11898
|
type: "hbox",
|
|
12114
11899
|
mode: parser.mode,
|
|
@@ -12133,17 +11918,13 @@ defineFunction({
|
|
|
12133
11918
|
defineFunction({
|
|
12134
11919
|
type: "html",
|
|
12135
11920
|
names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
allowedInText: true
|
|
12140
|
-
},
|
|
11921
|
+
numArgs: 2,
|
|
11922
|
+
argTypes: ["raw", "original"],
|
|
11923
|
+
allowedInText: true,
|
|
12141
11924
|
handler: (_ref, args) => {
|
|
12142
|
-
let
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
token
|
|
12146
|
-
} = _ref;
|
|
11925
|
+
let parser = _ref.parser,
|
|
11926
|
+
funcName = _ref.funcName,
|
|
11927
|
+
token = _ref.token;
|
|
12147
11928
|
const value = assertNodeType(args[0], "raw").string;
|
|
12148
11929
|
const body = args[1];
|
|
12149
11930
|
if (parser.settings.strict) {
|
|
@@ -12212,9 +11993,11 @@ defineFunction({
|
|
|
12212
11993
|
classes.push(...group.attributes.class.trim().split(/\s+/));
|
|
12213
11994
|
}
|
|
12214
11995
|
const span = makeSpan(classes, elements, options);
|
|
12215
|
-
for (const
|
|
12216
|
-
|
|
12217
|
-
|
|
11996
|
+
for (const _ref2 of Object.entries(group.attributes)) {
|
|
11997
|
+
const attr = _ref2[0];
|
|
11998
|
+
const value = _ref2[1];
|
|
11999
|
+
if (attr !== "class") {
|
|
12000
|
+
span.setAttribute(attr, value);
|
|
12218
12001
|
}
|
|
12219
12002
|
}
|
|
12220
12003
|
return span;
|
|
@@ -12231,15 +12014,11 @@ defineFunction({
|
|
|
12231
12014
|
defineFunction({
|
|
12232
12015
|
type: "htmlmathml",
|
|
12233
12016
|
names: ["\\html@mathml"],
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
allowedInText: true
|
|
12238
|
-
},
|
|
12017
|
+
numArgs: 2,
|
|
12018
|
+
allowedInArgument: true,
|
|
12019
|
+
allowedInText: true,
|
|
12239
12020
|
handler: (_ref, args) => {
|
|
12240
|
-
let
|
|
12241
|
-
parser
|
|
12242
|
-
} = _ref;
|
|
12021
|
+
let parser = _ref.parser;
|
|
12243
12022
|
return {
|
|
12244
12023
|
type: "htmlmathml",
|
|
12245
12024
|
mode: parser.mode,
|
|
@@ -12289,16 +12068,12 @@ const sizeData = function (str) {
|
|
|
12289
12068
|
defineFunction({
|
|
12290
12069
|
type: "includegraphics",
|
|
12291
12070
|
names: ["\\includegraphics"],
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
allowedInText: false
|
|
12297
|
-
},
|
|
12071
|
+
numArgs: 1,
|
|
12072
|
+
numOptionalArgs: 1,
|
|
12073
|
+
argTypes: ["raw", "url"],
|
|
12074
|
+
allowedInText: false,
|
|
12298
12075
|
handler: (_ref, args, optArgs) => {
|
|
12299
|
-
let
|
|
12300
|
-
parser
|
|
12301
|
-
} = _ref;
|
|
12076
|
+
let parser = _ref.parser;
|
|
12302
12077
|
let width = {
|
|
12303
12078
|
number: 0,
|
|
12304
12079
|
unit: "em"
|
|
@@ -12419,17 +12194,13 @@ defineFunction({
|
|
|
12419
12194
|
defineFunction({
|
|
12420
12195
|
type: "kern",
|
|
12421
12196
|
names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
allowedInText: true
|
|
12427
|
-
},
|
|
12197
|
+
numArgs: 1,
|
|
12198
|
+
argTypes: ["size"],
|
|
12199
|
+
primitive: true,
|
|
12200
|
+
allowedInText: true,
|
|
12428
12201
|
handler(_ref, args) {
|
|
12429
|
-
let
|
|
12430
|
-
|
|
12431
|
-
funcName
|
|
12432
|
-
} = _ref;
|
|
12202
|
+
let parser = _ref.parser,
|
|
12203
|
+
funcName = _ref.funcName;
|
|
12433
12204
|
const size = assertNodeType(args[0], "size");
|
|
12434
12205
|
if (parser.settings.strict) {
|
|
12435
12206
|
const mathFunction = funcName[1] === 'm'; // \mkern, \mskip
|
|
@@ -12473,15 +12244,11 @@ defineFunction({
|
|
|
12473
12244
|
defineFunction({
|
|
12474
12245
|
type: "lap",
|
|
12475
12246
|
names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
allowedInText: true
|
|
12479
|
-
},
|
|
12247
|
+
numArgs: 1,
|
|
12248
|
+
allowedInText: true,
|
|
12480
12249
|
handler: (_ref, args) => {
|
|
12481
|
-
let
|
|
12482
|
-
|
|
12483
|
-
funcName
|
|
12484
|
-
} = _ref;
|
|
12250
|
+
let parser = _ref.parser,
|
|
12251
|
+
funcName = _ref.funcName;
|
|
12485
12252
|
const body = args[0];
|
|
12486
12253
|
return {
|
|
12487
12254
|
type: "lap",
|
|
@@ -12496,12 +12263,12 @@ defineFunction({
|
|
|
12496
12263
|
if (group.alignment === "clap") {
|
|
12497
12264
|
// ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/
|
|
12498
12265
|
inner = makeSpan([], [buildGroup(group.body, options)]);
|
|
12499
|
-
// wrap, since CSS will center a .clap > .inner > span
|
|
12500
|
-
inner = makeSpan(["inner"], [inner], options);
|
|
12266
|
+
// wrap, since CSS will center a .clap > .katex-inner > span
|
|
12267
|
+
inner = makeSpan(["katex-inner"], [inner], options);
|
|
12501
12268
|
} else {
|
|
12502
|
-
inner = makeSpan(["inner"], [buildGroup(group.body, options)]);
|
|
12269
|
+
inner = makeSpan(["katex-inner"], [buildGroup(group.body, options)]);
|
|
12503
12270
|
}
|
|
12504
|
-
const fix = makeSpan(["fix"], []);
|
|
12271
|
+
const fix = makeSpan(["katex-fix"], []);
|
|
12505
12272
|
let node = makeSpan([group.alignment], [inner, fix], options);
|
|
12506
12273
|
|
|
12507
12274
|
// At this point, we have correctly set horizontal alignment of the
|
|
@@ -12509,7 +12276,7 @@ defineFunction({
|
|
|
12509
12276
|
// Next, use a strut to set the height of the HTML bounding box.
|
|
12510
12277
|
// Otherwise, a tall argument may be misplaced.
|
|
12511
12278
|
// This code resolved issue #1153
|
|
12512
|
-
const strut = makeSpan(["strut"]);
|
|
12279
|
+
const strut = makeSpan(["katex-strut"]);
|
|
12513
12280
|
strut.style.height = makeEm(node.height + node.depth);
|
|
12514
12281
|
if (node.depth) {
|
|
12515
12282
|
strut.style.verticalAlign = makeEm(-node.depth);
|
|
@@ -12518,8 +12285,8 @@ defineFunction({
|
|
|
12518
12285
|
|
|
12519
12286
|
// Next, prevent vertical misplacement when next to something tall.
|
|
12520
12287
|
// This code resolves issue #1234
|
|
12521
|
-
node = makeSpan(["thinbox"], [node], options);
|
|
12522
|
-
return makeSpan(["mord", "vbox"], [node], options);
|
|
12288
|
+
node = makeSpan(["katex-thinbox"], [node], options);
|
|
12289
|
+
return makeSpan(["mord", "katex-vbox"], [node], options);
|
|
12523
12290
|
},
|
|
12524
12291
|
mathmlBuilder: (group, options) => {
|
|
12525
12292
|
// mathllap, mathrlap, mathclap
|
|
@@ -12540,16 +12307,12 @@ defineFunction({
|
|
|
12540
12307
|
defineFunction({
|
|
12541
12308
|
type: "styling",
|
|
12542
12309
|
names: ["\\(", "$"],
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
allowedInMath: false
|
|
12547
|
-
},
|
|
12310
|
+
numArgs: 0,
|
|
12311
|
+
allowedInText: true,
|
|
12312
|
+
allowedInMath: false,
|
|
12548
12313
|
handler(_ref, args) {
|
|
12549
|
-
let
|
|
12550
|
-
|
|
12551
|
-
parser
|
|
12552
|
-
} = _ref;
|
|
12314
|
+
let funcName = _ref.funcName,
|
|
12315
|
+
parser = _ref.parser;
|
|
12553
12316
|
const outerMode = parser.mode;
|
|
12554
12317
|
parser.switchMode("math");
|
|
12555
12318
|
const close = funcName === "\\(" ? "\\)" : "$";
|
|
@@ -12571,11 +12334,9 @@ defineFunction({
|
|
|
12571
12334
|
type: "text",
|
|
12572
12335
|
// Doesn't matter what this is.
|
|
12573
12336
|
names: ["\\)", "\\]"],
|
|
12574
|
-
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
allowedInMath: false
|
|
12578
|
-
},
|
|
12337
|
+
numArgs: 0,
|
|
12338
|
+
allowedInText: true,
|
|
12339
|
+
allowedInMath: false,
|
|
12579
12340
|
handler(context, args) {
|
|
12580
12341
|
throw new src_ParseError("Mismatched " + context.funcName);
|
|
12581
12342
|
}
|
|
@@ -12603,14 +12364,10 @@ const chooseMathStyle = (group, options) => {
|
|
|
12603
12364
|
defineFunction({
|
|
12604
12365
|
type: "mathchoice",
|
|
12605
12366
|
names: ["\\mathchoice"],
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
primitive: true
|
|
12609
|
-
},
|
|
12367
|
+
numArgs: 4,
|
|
12368
|
+
primitive: true,
|
|
12610
12369
|
handler: (_ref, args) => {
|
|
12611
|
-
let
|
|
12612
|
-
parser
|
|
12613
|
-
} = _ref;
|
|
12370
|
+
let parser = _ref.parser;
|
|
12614
12371
|
return {
|
|
12615
12372
|
type: "mathchoice",
|
|
12616
12373
|
mode: parser.mode,
|
|
@@ -12922,14 +12679,10 @@ const singleCharBigOps = {
|
|
|
12922
12679
|
defineFunction({
|
|
12923
12680
|
type: "op",
|
|
12924
12681
|
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"],
|
|
12925
|
-
|
|
12926
|
-
numArgs: 0
|
|
12927
|
-
},
|
|
12682
|
+
numArgs: 0,
|
|
12928
12683
|
handler: (_ref, args) => {
|
|
12929
|
-
let
|
|
12930
|
-
|
|
12931
|
-
funcName
|
|
12932
|
-
} = _ref;
|
|
12684
|
+
let parser = _ref.parser,
|
|
12685
|
+
funcName = _ref.funcName;
|
|
12933
12686
|
let fName = funcName;
|
|
12934
12687
|
if (fName.length === 1) {
|
|
12935
12688
|
fName = singleCharBigOps[fName];
|
|
@@ -12946,20 +12699,13 @@ defineFunction({
|
|
|
12946
12699
|
htmlBuilder: op_htmlBuilder,
|
|
12947
12700
|
mathmlBuilder: op_mathmlBuilder
|
|
12948
12701
|
});
|
|
12949
|
-
|
|
12950
|
-
// Note: calling defineFunction with a type that's already been defined only
|
|
12951
|
-
// works because the same htmlBuilder and mathmlBuilder are being used.
|
|
12952
12702
|
defineFunction({
|
|
12953
12703
|
type: "op",
|
|
12954
12704
|
names: ["\\mathop"],
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
primitive: true
|
|
12958
|
-
},
|
|
12705
|
+
numArgs: 1,
|
|
12706
|
+
primitive: true,
|
|
12959
12707
|
handler: (_ref2, args) => {
|
|
12960
|
-
let
|
|
12961
|
-
parser
|
|
12962
|
-
} = _ref2;
|
|
12708
|
+
let parser = _ref2.parser;
|
|
12963
12709
|
const body = args[0];
|
|
12964
12710
|
return {
|
|
12965
12711
|
type: "op",
|
|
@@ -12969,9 +12715,7 @@ defineFunction({
|
|
|
12969
12715
|
symbol: false,
|
|
12970
12716
|
body: ordargument(body)
|
|
12971
12717
|
};
|
|
12972
|
-
}
|
|
12973
|
-
htmlBuilder: op_htmlBuilder,
|
|
12974
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12718
|
+
}
|
|
12975
12719
|
});
|
|
12976
12720
|
|
|
12977
12721
|
// There are 2 flags for operators; whether they produce limits in
|
|
@@ -12990,14 +12734,10 @@ const singleCharIntegrals = {
|
|
|
12990
12734
|
defineFunction({
|
|
12991
12735
|
type: "op",
|
|
12992
12736
|
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"],
|
|
12993
|
-
|
|
12994
|
-
numArgs: 0
|
|
12995
|
-
},
|
|
12737
|
+
numArgs: 0,
|
|
12996
12738
|
handler(_ref3) {
|
|
12997
|
-
let
|
|
12998
|
-
|
|
12999
|
-
funcName
|
|
13000
|
-
} = _ref3;
|
|
12739
|
+
let parser = _ref3.parser,
|
|
12740
|
+
funcName = _ref3.funcName;
|
|
13001
12741
|
return {
|
|
13002
12742
|
type: "op",
|
|
13003
12743
|
mode: parser.mode,
|
|
@@ -13006,23 +12746,17 @@ defineFunction({
|
|
|
13006
12746
|
symbol: false,
|
|
13007
12747
|
name: funcName
|
|
13008
12748
|
};
|
|
13009
|
-
}
|
|
13010
|
-
htmlBuilder: op_htmlBuilder,
|
|
13011
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12749
|
+
}
|
|
13012
12750
|
});
|
|
13013
12751
|
|
|
13014
12752
|
// Limits, not symbols
|
|
13015
12753
|
defineFunction({
|
|
13016
12754
|
type: "op",
|
|
13017
12755
|
names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
|
|
13018
|
-
|
|
13019
|
-
numArgs: 0
|
|
13020
|
-
},
|
|
12756
|
+
numArgs: 0,
|
|
13021
12757
|
handler(_ref4) {
|
|
13022
|
-
let
|
|
13023
|
-
|
|
13024
|
-
funcName
|
|
13025
|
-
} = _ref4;
|
|
12758
|
+
let parser = _ref4.parser,
|
|
12759
|
+
funcName = _ref4.funcName;
|
|
13026
12760
|
return {
|
|
13027
12761
|
type: "op",
|
|
13028
12762
|
mode: parser.mode,
|
|
@@ -13031,24 +12765,18 @@ defineFunction({
|
|
|
13031
12765
|
symbol: false,
|
|
13032
12766
|
name: funcName
|
|
13033
12767
|
};
|
|
13034
|
-
}
|
|
13035
|
-
htmlBuilder: op_htmlBuilder,
|
|
13036
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12768
|
+
}
|
|
13037
12769
|
});
|
|
13038
12770
|
|
|
13039
12771
|
// No limits, symbols
|
|
13040
12772
|
defineFunction({
|
|
13041
12773
|
type: "op",
|
|
13042
12774
|
names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"],
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
allowedInArgument: true
|
|
13046
|
-
},
|
|
12775
|
+
numArgs: 0,
|
|
12776
|
+
allowedInArgument: true,
|
|
13047
12777
|
handler(_ref5) {
|
|
13048
|
-
let
|
|
13049
|
-
|
|
13050
|
-
funcName
|
|
13051
|
-
} = _ref5;
|
|
12778
|
+
let parser = _ref5.parser,
|
|
12779
|
+
funcName = _ref5.funcName;
|
|
13052
12780
|
let fName = funcName;
|
|
13053
12781
|
if (fName.length === 1) {
|
|
13054
12782
|
fName = singleCharIntegrals[fName];
|
|
@@ -13061,9 +12789,7 @@ defineFunction({
|
|
|
13061
12789
|
symbol: true,
|
|
13062
12790
|
name: fName
|
|
13063
12791
|
};
|
|
13064
|
-
}
|
|
13065
|
-
htmlBuilder: op_htmlBuilder,
|
|
13066
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12792
|
+
}
|
|
13067
12793
|
});
|
|
13068
12794
|
;// ./src/functions/operatorname.ts
|
|
13069
12795
|
|
|
@@ -13188,14 +12914,10 @@ const operatorname_mathmlBuilder = (group, options) => {
|
|
|
13188
12914
|
defineFunction({
|
|
13189
12915
|
type: "operatorname",
|
|
13190
12916
|
names: ["\\operatorname@", "\\operatornamewithlimits"],
|
|
13191
|
-
|
|
13192
|
-
numArgs: 1
|
|
13193
|
-
},
|
|
12917
|
+
numArgs: 1,
|
|
13194
12918
|
handler: (_ref, args) => {
|
|
13195
|
-
let
|
|
13196
|
-
|
|
13197
|
-
funcName
|
|
13198
|
-
} = _ref;
|
|
12919
|
+
let parser = _ref.parser,
|
|
12920
|
+
funcName = _ref.funcName;
|
|
13199
12921
|
const body = args[0];
|
|
13200
12922
|
return {
|
|
13201
12923
|
type: "operatorname",
|
|
@@ -13236,13 +12958,9 @@ defineFunctionBuilders({
|
|
|
13236
12958
|
defineFunction({
|
|
13237
12959
|
type: "overline",
|
|
13238
12960
|
names: ["\\overline"],
|
|
13239
|
-
|
|
13240
|
-
numArgs: 1
|
|
13241
|
-
},
|
|
12961
|
+
numArgs: 1,
|
|
13242
12962
|
handler(_ref, args) {
|
|
13243
|
-
let
|
|
13244
|
-
parser
|
|
13245
|
-
} = _ref;
|
|
12963
|
+
let parser = _ref.parser;
|
|
13246
12964
|
const body = args[0];
|
|
13247
12965
|
return {
|
|
13248
12966
|
type: "overline",
|
|
@@ -13277,7 +12995,7 @@ defineFunction({
|
|
|
13277
12995
|
size: defaultRuleThickness
|
|
13278
12996
|
}]
|
|
13279
12997
|
}, options);
|
|
13280
|
-
return makeSpan(["mord", "overline"], [vlist], options);
|
|
12998
|
+
return makeSpan(["mord", "katex-overline"], [vlist], options);
|
|
13281
12999
|
},
|
|
13282
13000
|
mathmlBuilder(group, options) {
|
|
13283
13001
|
const operator = new MathNode("mo", [new TextNode("\u203e")]);
|
|
@@ -13297,14 +13015,10 @@ defineFunction({
|
|
|
13297
13015
|
defineFunction({
|
|
13298
13016
|
type: "phantom",
|
|
13299
13017
|
names: ["\\phantom"],
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
allowedInText: true
|
|
13303
|
-
},
|
|
13018
|
+
numArgs: 1,
|
|
13019
|
+
allowedInText: true,
|
|
13304
13020
|
handler: (_ref, args) => {
|
|
13305
|
-
let
|
|
13306
|
-
parser
|
|
13307
|
-
} = _ref;
|
|
13021
|
+
let parser = _ref.parser;
|
|
13308
13022
|
const body = args[0];
|
|
13309
13023
|
return {
|
|
13310
13024
|
type: "phantom",
|
|
@@ -13328,14 +13042,10 @@ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
|
|
|
13328
13042
|
defineFunction({
|
|
13329
13043
|
type: "vphantom",
|
|
13330
13044
|
names: ["\\vphantom"],
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
allowedInText: true
|
|
13334
|
-
},
|
|
13045
|
+
numArgs: 1,
|
|
13046
|
+
allowedInText: true,
|
|
13335
13047
|
handler: (_ref2, args) => {
|
|
13336
|
-
let
|
|
13337
|
-
parser
|
|
13338
|
-
} = _ref2;
|
|
13048
|
+
let parser = _ref2.parser;
|
|
13339
13049
|
const body = args[0];
|
|
13340
13050
|
return {
|
|
13341
13051
|
type: "vphantom",
|
|
@@ -13344,8 +13054,8 @@ defineFunction({
|
|
|
13344
13054
|
};
|
|
13345
13055
|
},
|
|
13346
13056
|
htmlBuilder: (group, options) => {
|
|
13347
|
-
const inner = makeSpan(["inner"], [buildGroup(group.body, options.withPhantom())]);
|
|
13348
|
-
const fix = makeSpan(["fix"], []);
|
|
13057
|
+
const inner = makeSpan(["katex-inner"], [buildGroup(group.body, options.withPhantom())]);
|
|
13058
|
+
const fix = makeSpan(["katex-fix"], []);
|
|
13349
13059
|
return makeSpan(["mord", "rlap"], [inner, fix], options);
|
|
13350
13060
|
},
|
|
13351
13061
|
mathmlBuilder: (group, options) => {
|
|
@@ -13369,15 +13079,11 @@ defineFunction({
|
|
|
13369
13079
|
defineFunction({
|
|
13370
13080
|
type: "raisebox",
|
|
13371
13081
|
names: ["\\raisebox"],
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
allowedInText: true
|
|
13376
|
-
},
|
|
13082
|
+
numArgs: 2,
|
|
13083
|
+
argTypes: ["size", "hbox"],
|
|
13084
|
+
allowedInText: true,
|
|
13377
13085
|
handler(_ref, args) {
|
|
13378
|
-
let
|
|
13379
|
-
parser
|
|
13380
|
-
} = _ref;
|
|
13086
|
+
let parser = _ref.parser;
|
|
13381
13087
|
const amount = assertNodeType(args[0], "size").value;
|
|
13382
13088
|
const body = args[1];
|
|
13383
13089
|
return {
|
|
@@ -13411,15 +13117,11 @@ defineFunction({
|
|
|
13411
13117
|
defineFunction({
|
|
13412
13118
|
type: "internal",
|
|
13413
13119
|
names: ["\\relax"],
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
allowedInArgument: true
|
|
13418
|
-
},
|
|
13120
|
+
numArgs: 0,
|
|
13121
|
+
allowedInText: true,
|
|
13122
|
+
allowedInArgument: true,
|
|
13419
13123
|
handler(_ref) {
|
|
13420
|
-
let
|
|
13421
|
-
parser
|
|
13422
|
-
} = _ref;
|
|
13124
|
+
let parser = _ref.parser;
|
|
13423
13125
|
return {
|
|
13424
13126
|
type: "internal",
|
|
13425
13127
|
mode: parser.mode
|
|
@@ -13435,17 +13137,13 @@ defineFunction({
|
|
|
13435
13137
|
defineFunction({
|
|
13436
13138
|
type: "rule",
|
|
13437
13139
|
names: ["\\rule"],
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
argTypes: ["size", "size", "size"]
|
|
13444
|
-
},
|
|
13140
|
+
numArgs: 2,
|
|
13141
|
+
numOptionalArgs: 1,
|
|
13142
|
+
allowedInText: true,
|
|
13143
|
+
allowedInMath: true,
|
|
13144
|
+
argTypes: ["size", "size", "size"],
|
|
13445
13145
|
handler(_ref, args, optArgs) {
|
|
13446
|
-
let
|
|
13447
|
-
parser
|
|
13448
|
-
} = _ref;
|
|
13146
|
+
let parser = _ref.parser;
|
|
13449
13147
|
const shift = optArgs[0];
|
|
13450
13148
|
const width = assertNodeType(args[0], "size");
|
|
13451
13149
|
const height = assertNodeType(args[1], "size");
|
|
@@ -13459,7 +13157,7 @@ defineFunction({
|
|
|
13459
13157
|
},
|
|
13460
13158
|
htmlBuilder(group, options) {
|
|
13461
13159
|
// Make an empty span for the rule
|
|
13462
|
-
const rule = makeSpan(["mord", "rule"], [], options);
|
|
13160
|
+
const rule = makeSpan(["mord", "katex-rule"], [], options);
|
|
13463
13161
|
|
|
13464
13162
|
// Calculate the shift, width, and height of the rule, and account for units
|
|
13465
13163
|
const width = calculateSize(group.width, options);
|
|
@@ -13515,7 +13213,7 @@ function sizingGroup(value, options, baseOptions) {
|
|
|
13515
13213
|
// Add size-resetting classes to the inner list and set maxFontSize
|
|
13516
13214
|
// manually. Handle nested size changes.
|
|
13517
13215
|
for (let i = 0; i < inner.length; i++) {
|
|
13518
|
-
const pos = inner[i].classes.indexOf("sizing");
|
|
13216
|
+
const pos = inner[i].classes.indexOf("katex-sizing");
|
|
13519
13217
|
if (pos < 0) {
|
|
13520
13218
|
Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions));
|
|
13521
13219
|
} else if (inner[i].classes[pos + 1] === "reset-size" + options.size) {
|
|
@@ -13540,16 +13238,12 @@ const sizing_htmlBuilder = (group, options) => {
|
|
|
13540
13238
|
defineFunction({
|
|
13541
13239
|
type: "sizing",
|
|
13542
13240
|
names: sizeFuncs,
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
allowedInText: true
|
|
13546
|
-
},
|
|
13241
|
+
numArgs: 0,
|
|
13242
|
+
allowedInText: true,
|
|
13547
13243
|
handler: (_ref, args) => {
|
|
13548
|
-
let
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
parser
|
|
13552
|
-
} = _ref;
|
|
13244
|
+
let breakOnTokenText = _ref.breakOnTokenText,
|
|
13245
|
+
funcName = _ref.funcName,
|
|
13246
|
+
parser = _ref.parser;
|
|
13553
13247
|
const body = parser.parseExpression(false, breakOnTokenText);
|
|
13554
13248
|
return {
|
|
13555
13249
|
type: "sizing",
|
|
@@ -13585,15 +13279,11 @@ defineFunction({
|
|
|
13585
13279
|
defineFunction({
|
|
13586
13280
|
type: "smash",
|
|
13587
13281
|
names: ["\\smash"],
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
allowedInText: true
|
|
13592
|
-
},
|
|
13282
|
+
numArgs: 1,
|
|
13283
|
+
numOptionalArgs: 1,
|
|
13284
|
+
allowedInText: true,
|
|
13593
13285
|
handler: (_ref, args, optArgs) => {
|
|
13594
|
-
let
|
|
13595
|
-
parser
|
|
13596
|
-
} = _ref;
|
|
13286
|
+
let parser = _ref.parser;
|
|
13597
13287
|
let smashHeight = false;
|
|
13598
13288
|
let smashDepth = false;
|
|
13599
13289
|
const tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
|
|
@@ -13641,7 +13331,7 @@ defineFunction({
|
|
|
13641
13331
|
}
|
|
13642
13332
|
if (group.smashHeight && group.smashDepth) {
|
|
13643
13333
|
// Symmetric \smash can stay in inline layout.
|
|
13644
|
-
return makeSpan(["mord", "smash"], [node], options);
|
|
13334
|
+
return makeSpan(["mord", "katex-smash"], [node], options);
|
|
13645
13335
|
}
|
|
13646
13336
|
|
|
13647
13337
|
// In order to influence makeVList for asymmetric smashing, we have to
|
|
@@ -13696,14 +13386,10 @@ defineFunction({
|
|
|
13696
13386
|
defineFunction({
|
|
13697
13387
|
type: "sqrt",
|
|
13698
13388
|
names: ["\\sqrt"],
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
numOptionalArgs: 1
|
|
13702
|
-
},
|
|
13389
|
+
numArgs: 1,
|
|
13390
|
+
numOptionalArgs: 1,
|
|
13703
13391
|
handler(_ref, args, optArgs) {
|
|
13704
|
-
let
|
|
13705
|
-
parser
|
|
13706
|
-
} = _ref;
|
|
13392
|
+
let parser = _ref.parser;
|
|
13707
13393
|
const index = optArgs[0];
|
|
13708
13394
|
const body = args[0];
|
|
13709
13395
|
return {
|
|
@@ -13741,11 +13427,10 @@ defineFunction({
|
|
|
13741
13427
|
const minDelimiterHeight = inner.height + inner.depth + lineClearance + theta;
|
|
13742
13428
|
|
|
13743
13429
|
// Create a sqrt SVG of the required minimum size
|
|
13744
|
-
const
|
|
13745
|
-
span
|
|
13746
|
-
ruleWidth,
|
|
13747
|
-
advanceWidth
|
|
13748
|
-
} = makeSqrtImage(minDelimiterHeight, options);
|
|
13430
|
+
const _makeSqrtImage = makeSqrtImage(minDelimiterHeight, options),
|
|
13431
|
+
img = _makeSqrtImage.span,
|
|
13432
|
+
ruleWidth = _makeSqrtImage.ruleWidth,
|
|
13433
|
+
advanceWidth = _makeSqrtImage.advanceWidth;
|
|
13749
13434
|
const delimDepth = img.height - ruleWidth;
|
|
13750
13435
|
|
|
13751
13436
|
// Adjust the clearance based on the delimiter size
|
|
@@ -13799,15 +13484,13 @@ defineFunction({
|
|
|
13799
13484
|
}, options);
|
|
13800
13485
|
// Add a class surrounding it so we can add on the appropriate
|
|
13801
13486
|
// kerning
|
|
13802
|
-
const rootVListWrap = makeSpan(["root"], [rootVList]);
|
|
13487
|
+
const rootVListWrap = makeSpan(["katex-root"], [rootVList]);
|
|
13803
13488
|
return makeSpan(["mord", "sqrt"], [rootVListWrap, body], options);
|
|
13804
13489
|
}
|
|
13805
13490
|
},
|
|
13806
13491
|
mathmlBuilder(group, options) {
|
|
13807
|
-
const
|
|
13808
|
-
|
|
13809
|
-
index
|
|
13810
|
-
} = group;
|
|
13492
|
+
const body = group.body,
|
|
13493
|
+
index = group.index;
|
|
13811
13494
|
return index ? new MathNode("mroot", [buildMathML_buildGroup(body, options), buildMathML_buildGroup(index, options)]) : new MathNode("msqrt", [buildMathML_buildGroup(body, options)]);
|
|
13812
13495
|
}
|
|
13813
13496
|
});
|
|
@@ -13829,17 +13512,13 @@ function isStyleStr(s) {
|
|
|
13829
13512
|
defineFunction({
|
|
13830
13513
|
type: "styling",
|
|
13831
13514
|
names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
primitive: true
|
|
13836
|
-
},
|
|
13515
|
+
numArgs: 0,
|
|
13516
|
+
allowedInText: true,
|
|
13517
|
+
primitive: true,
|
|
13837
13518
|
handler(_ref, args) {
|
|
13838
|
-
let
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
parser
|
|
13842
|
-
} = _ref;
|
|
13519
|
+
let breakOnTokenText = _ref.breakOnTokenText,
|
|
13520
|
+
funcName = _ref.funcName,
|
|
13521
|
+
parser = _ref.parser;
|
|
13843
13522
|
// parse out the implicit body
|
|
13844
13523
|
const body = parser.parseExpression(true, breakOnTokenText);
|
|
13845
13524
|
|
|
@@ -13947,11 +13626,9 @@ defineFunctionBuilders({
|
|
|
13947
13626
|
if (builderDelegate) {
|
|
13948
13627
|
return builderDelegate(group, options);
|
|
13949
13628
|
}
|
|
13950
|
-
const
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
sub: valueSub
|
|
13954
|
-
} = group;
|
|
13629
|
+
const valueBase = group.base,
|
|
13630
|
+
valueSup = group.sup,
|
|
13631
|
+
valueSub = group.sub;
|
|
13955
13632
|
const base = buildGroup(valueBase, options);
|
|
13956
13633
|
let supm;
|
|
13957
13634
|
let subm;
|
|
@@ -14171,7 +13848,7 @@ const defaultVariant = {
|
|
|
14171
13848
|
defineFunctionBuilders({
|
|
14172
13849
|
type: "mathord",
|
|
14173
13850
|
htmlBuilder(group, options) {
|
|
14174
|
-
return makeOrd(group, options
|
|
13851
|
+
return makeOrd(group, options);
|
|
14175
13852
|
},
|
|
14176
13853
|
mathmlBuilder(group, options) {
|
|
14177
13854
|
const node = new MathNode("mi", [makeText(group.text, group.mode, options)]);
|
|
@@ -14185,7 +13862,7 @@ defineFunctionBuilders({
|
|
|
14185
13862
|
defineFunctionBuilders({
|
|
14186
13863
|
type: "textord",
|
|
14187
13864
|
htmlBuilder(group, options) {
|
|
14188
|
-
return makeOrd(group, options
|
|
13865
|
+
return makeOrd(group, options);
|
|
14189
13866
|
},
|
|
14190
13867
|
mathmlBuilder(group, options) {
|
|
14191
13868
|
const text = makeText(group.text, group.mode, options);
|
|
@@ -14213,57 +13890,50 @@ defineFunctionBuilders({
|
|
|
14213
13890
|
|
|
14214
13891
|
|
|
14215
13892
|
// A map of CSS-based spacing functions to their CSS class.
|
|
14216
|
-
const cssSpace =
|
|
14217
|
-
"\\nobreak": "nobreak",
|
|
14218
|
-
"\\allowbreak": "allowbreak"
|
|
14219
|
-
};
|
|
13893
|
+
const cssSpace = new Map([["\\nobreak", "nobreak"], ["\\allowbreak", "allowbreak"]]);
|
|
14220
13894
|
|
|
14221
13895
|
// A lookup table to determine whether a spacing function/symbol should be
|
|
14222
13896
|
// treated like a regular space character. If a symbol or command is a key
|
|
14223
13897
|
// in this table, then it should be a regular space character. Furthermore,
|
|
14224
13898
|
// the associated value may have a `className` specifying an extra CSS class
|
|
14225
13899
|
// to add to the created `span`.
|
|
14226
|
-
const regularSpace = {
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
"
|
|
14230
|
-
|
|
14231
|
-
},
|
|
14232
|
-
"\\space": {},
|
|
14233
|
-
"\\nobreakspace": {
|
|
14234
|
-
className: "nobreak"
|
|
14235
|
-
}
|
|
14236
|
-
};
|
|
13900
|
+
const regularSpace = new Map([[" ", {}], ["\\ ", {}], ["~", {
|
|
13901
|
+
className: "nobreak"
|
|
13902
|
+
}], ["\\space", {}], ["\\nobreakspace", {
|
|
13903
|
+
className: "nobreak"
|
|
13904
|
+
}]]);
|
|
14237
13905
|
|
|
14238
13906
|
// ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in
|
|
14239
13907
|
// src/symbols.js.
|
|
14240
13908
|
defineFunctionBuilders({
|
|
14241
13909
|
type: "spacing",
|
|
14242
13910
|
htmlBuilder(group, options) {
|
|
14243
|
-
|
|
14244
|
-
|
|
13911
|
+
const regularSpaceItem = regularSpace.get(group.text);
|
|
13912
|
+
const cssSpaceClass = cssSpace.get(group.text);
|
|
13913
|
+
if (regularSpaceItem) {
|
|
13914
|
+
const className = regularSpaceItem.className || "";
|
|
14245
13915
|
// Spaces are generated by adding an actual space. Each of these
|
|
14246
13916
|
// things has an entry in the symbols table, so these will be turned
|
|
14247
13917
|
// into appropriate outputs.
|
|
14248
13918
|
if (group.mode === "text") {
|
|
14249
|
-
const ord = makeOrd(group, options
|
|
13919
|
+
const ord = makeOrd(group, options);
|
|
14250
13920
|
ord.classes.push(className);
|
|
14251
13921
|
return ord;
|
|
14252
13922
|
} else {
|
|
14253
13923
|
return makeSpan(["mspace", className], [mathsym(group.text, group.mode, options)], options);
|
|
14254
13924
|
}
|
|
14255
|
-
} else if (
|
|
13925
|
+
} else if (cssSpaceClass) {
|
|
14256
13926
|
// Spaces based on just a CSS class.
|
|
14257
|
-
return makeSpan(["mspace",
|
|
13927
|
+
return makeSpan(["mspace", cssSpaceClass], [], options);
|
|
14258
13928
|
} else {
|
|
14259
13929
|
throw new src_ParseError("Unknown type of space \"" + group.text + "\"");
|
|
14260
13930
|
}
|
|
14261
13931
|
},
|
|
14262
13932
|
mathmlBuilder(group, options) {
|
|
14263
13933
|
let node;
|
|
14264
|
-
if (regularSpace.
|
|
13934
|
+
if (regularSpace.has(group.text)) {
|
|
14265
13935
|
node = new MathNode("mtext", [new TextNode("\u00a0")]);
|
|
14266
|
-
} else if (cssSpace.
|
|
13936
|
+
} else if (cssSpace.has(group.text)) {
|
|
14267
13937
|
// CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
|
|
14268
13938
|
return new MathNode("mspace");
|
|
14269
13939
|
} else {
|
|
@@ -14341,17 +14011,13 @@ defineFunction({
|
|
|
14341
14011
|
"\\textbf", "\\textmd",
|
|
14342
14012
|
// Font Shapes
|
|
14343
14013
|
"\\textit", "\\textup", "\\emph"],
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
allowedInText: true
|
|
14349
|
-
},
|
|
14014
|
+
numArgs: 1,
|
|
14015
|
+
argTypes: ["text"],
|
|
14016
|
+
allowedInArgument: true,
|
|
14017
|
+
allowedInText: true,
|
|
14350
14018
|
handler(_ref, args) {
|
|
14351
|
-
let
|
|
14352
|
-
|
|
14353
|
-
funcName
|
|
14354
|
-
} = _ref;
|
|
14019
|
+
let parser = _ref.parser,
|
|
14020
|
+
funcName = _ref.funcName;
|
|
14355
14021
|
const body = args[0];
|
|
14356
14022
|
return {
|
|
14357
14023
|
type: "text",
|
|
@@ -14379,14 +14045,10 @@ defineFunction({
|
|
|
14379
14045
|
defineFunction({
|
|
14380
14046
|
type: "underline",
|
|
14381
14047
|
names: ["\\underline"],
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
allowedInText: true
|
|
14385
|
-
},
|
|
14048
|
+
numArgs: 1,
|
|
14049
|
+
allowedInText: true,
|
|
14386
14050
|
handler(_ref, args) {
|
|
14387
|
-
let
|
|
14388
|
-
parser
|
|
14389
|
-
} = _ref;
|
|
14051
|
+
let parser = _ref.parser;
|
|
14390
14052
|
return {
|
|
14391
14053
|
type: "underline",
|
|
14392
14054
|
mode: parser.mode,
|
|
@@ -14420,7 +14082,7 @@ defineFunction({
|
|
|
14420
14082
|
elem: innerGroup
|
|
14421
14083
|
}]
|
|
14422
14084
|
}, options);
|
|
14423
|
-
return makeSpan(["mord", "underline"], [vlist], options);
|
|
14085
|
+
return makeSpan(["mord", "katex-underline"], [vlist], options);
|
|
14424
14086
|
},
|
|
14425
14087
|
mathmlBuilder(group, options) {
|
|
14426
14088
|
const operator = new MathNode("mo", [new TextNode("\u203e")]);
|
|
@@ -14442,16 +14104,12 @@ defineFunction({
|
|
|
14442
14104
|
defineFunction({
|
|
14443
14105
|
type: "vcenter",
|
|
14444
14106
|
names: ["\\vcenter"],
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
allowedInText: false
|
|
14450
|
-
},
|
|
14107
|
+
numArgs: 1,
|
|
14108
|
+
argTypes: ["original"],
|
|
14109
|
+
// In LaTeX, \vcenter can act only on a box.
|
|
14110
|
+
allowedInText: false,
|
|
14451
14111
|
handler(_ref, args) {
|
|
14452
|
-
let
|
|
14453
|
-
parser
|
|
14454
|
-
} = _ref;
|
|
14112
|
+
let parser = _ref.parser;
|
|
14455
14113
|
return {
|
|
14456
14114
|
type: "vcenter",
|
|
14457
14115
|
mode: parser.mode,
|
|
@@ -14488,10 +14146,8 @@ defineFunction({
|
|
|
14488
14146
|
defineFunction({
|
|
14489
14147
|
type: "verb",
|
|
14490
14148
|
names: ["\\verb"],
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
allowedInText: true
|
|
14494
|
-
},
|
|
14149
|
+
numArgs: 0,
|
|
14150
|
+
allowedInText: true,
|
|
14495
14151
|
handler(context, args, optArgs) {
|
|
14496
14152
|
// \verb and \verb* are dealt with directly in Parser.js.
|
|
14497
14153
|
// If we end up here, it's because of a failure to match the two delimiters
|
|
@@ -14742,13 +14398,11 @@ class Namespace {
|
|
|
14742
14398
|
throw new src_ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug");
|
|
14743
14399
|
}
|
|
14744
14400
|
const undefs = this.undefStack.pop();
|
|
14745
|
-
for (const
|
|
14746
|
-
if (undefs
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
this.current[undef] = undefs[undef];
|
|
14751
|
-
}
|
|
14401
|
+
for (const key of Object.keys(undefs)) {
|
|
14402
|
+
if (undefs[key] === undefined) {
|
|
14403
|
+
delete this.current[key];
|
|
14404
|
+
} else {
|
|
14405
|
+
this.current[key] = undefs[key];
|
|
14752
14406
|
}
|
|
14753
14407
|
}
|
|
14754
14408
|
}
|
|
@@ -14768,7 +14422,7 @@ class Namespace {
|
|
|
14768
14422
|
* `get(name) != null`.
|
|
14769
14423
|
*/
|
|
14770
14424
|
has(name) {
|
|
14771
|
-
return
|
|
14425
|
+
return Object.prototype.hasOwnProperty.call(this.current, name) || Object.prototype.hasOwnProperty.call(this.builtins, name);
|
|
14772
14426
|
}
|
|
14773
14427
|
|
|
14774
14428
|
/**
|
|
@@ -14780,7 +14434,7 @@ class Namespace {
|
|
|
14780
14434
|
* `if (namespace.has(...))`.
|
|
14781
14435
|
*/
|
|
14782
14436
|
get(name) {
|
|
14783
|
-
if (
|
|
14437
|
+
if (Object.prototype.hasOwnProperty.call(this.current, name)) {
|
|
14784
14438
|
return this.current[name];
|
|
14785
14439
|
} else {
|
|
14786
14440
|
return this.builtins[name];
|
|
@@ -14814,7 +14468,7 @@ class Namespace {
|
|
|
14814
14468
|
// unless an undo is already in place, in which case that older
|
|
14815
14469
|
// value is the correct one.
|
|
14816
14470
|
const top = this.undefStack[this.undefStack.length - 1];
|
|
14817
|
-
if (top && !
|
|
14471
|
+
if (top && !Object.prototype.hasOwnProperty.call(top, name)) {
|
|
14818
14472
|
top[name] = this.current[name];
|
|
14819
14473
|
}
|
|
14820
14474
|
}
|
|
@@ -15925,16 +15579,14 @@ class MacroExpander {
|
|
|
15925
15579
|
return null;
|
|
15926
15580
|
}
|
|
15927
15581
|
start = this.popToken(); // don't include [ in tokens
|
|
15928
|
-
(
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
} = this.consumeArg(["]"]));
|
|
15582
|
+
var _this$consumeArg = this.consumeArg(["]"]);
|
|
15583
|
+
tokens = _this$consumeArg.tokens;
|
|
15584
|
+
end = _this$consumeArg.end;
|
|
15932
15585
|
} else {
|
|
15933
|
-
(
|
|
15934
|
-
|
|
15935
|
-
|
|
15936
|
-
|
|
15937
|
-
} = this.consumeArg());
|
|
15586
|
+
var _this$consumeArg2 = this.consumeArg();
|
|
15587
|
+
tokens = _this$consumeArg2.tokens;
|
|
15588
|
+
start = _this$consumeArg2.start;
|
|
15589
|
+
end = _this$consumeArg2.end;
|
|
15938
15590
|
}
|
|
15939
15591
|
|
|
15940
15592
|
// indicate the end of an argument
|
|
@@ -16245,7 +15897,7 @@ class MacroExpander {
|
|
|
16245
15897
|
* `implicitCommands`.
|
|
16246
15898
|
*/
|
|
16247
15899
|
isDefined(name) {
|
|
16248
|
-
return this.macros.has(name) ||
|
|
15900
|
+
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);
|
|
16249
15901
|
}
|
|
16250
15902
|
|
|
16251
15903
|
/**
|
|
@@ -16253,7 +15905,10 @@ class MacroExpander {
|
|
|
16253
15905
|
*/
|
|
16254
15906
|
isExpandable(name) {
|
|
16255
15907
|
const macro = this.macros.get(name);
|
|
16256
|
-
|
|
15908
|
+
if (macro != null) {
|
|
15909
|
+
return typeof macro === "string" || typeof macro === "function" || !macro.unexpandable;
|
|
15910
|
+
}
|
|
15911
|
+
return Object.prototype.hasOwnProperty.call(src_functions, name) && !src_functions[name].primitive;
|
|
16257
15912
|
}
|
|
16258
15913
|
}
|
|
16259
15914
|
;// ./src/unicodeSupOrSub.ts
|
|
@@ -17077,7 +16732,7 @@ class Parser {
|
|
|
17077
16732
|
const base = this.parseGroup("atom", breakOnTokenText);
|
|
17078
16733
|
|
|
17079
16734
|
// Internal nodes (e.g. \relax) cannot support super/subscripts.
|
|
17080
|
-
// Instead we will pick up super/subscripts with blank base next round.
|
|
16735
|
+
// Instead, we will pick up super/subscripts with blank base next round.
|
|
17081
16736
|
if ((base == null ? void 0 : base.type) === "internal") {
|
|
17082
16737
|
return base;
|
|
17083
16738
|
}
|
|
@@ -17086,9 +16741,6 @@ class Parser {
|
|
|
17086
16741
|
if (this.mode === "text") {
|
|
17087
16742
|
return base;
|
|
17088
16743
|
}
|
|
17089
|
-
|
|
17090
|
-
// Note that base may be empty (i.e. null) at this point.
|
|
17091
|
-
|
|
17092
16744
|
let superscript;
|
|
17093
16745
|
let subscript;
|
|
17094
16746
|
while (true) {
|
|
@@ -17100,8 +16752,7 @@ class Parser {
|
|
|
17100
16752
|
if (lex.text === "\\limits" || lex.text === "\\nolimits") {
|
|
17101
16753
|
// We got a limit control
|
|
17102
16754
|
if (base && base.type === "op") {
|
|
17103
|
-
|
|
17104
|
-
base.limits = limits;
|
|
16755
|
+
base.limits = lex.text === "\\limits";
|
|
17105
16756
|
base.alwaysHandleSupSub = true;
|
|
17106
16757
|
} else if (base && base.type === "operatorname") {
|
|
17107
16758
|
if (base.alwaysHandleSupSub) {
|
|
@@ -17198,15 +16849,28 @@ class Parser {
|
|
|
17198
16849
|
|
|
17199
16850
|
// Base must be set if superscript or subscript are set per logic above,
|
|
17200
16851
|
// but need to check here for type check to pass.
|
|
17201
|
-
if (superscript
|
|
17202
|
-
// If we got either a superscript or subscript, create a supsub
|
|
16852
|
+
if (superscript && subscript) {
|
|
17203
16853
|
return {
|
|
17204
16854
|
type: "supsub",
|
|
17205
16855
|
mode: this.mode,
|
|
17206
|
-
base
|
|
16856
|
+
base,
|
|
17207
16857
|
sup: superscript,
|
|
17208
16858
|
sub: subscript
|
|
17209
16859
|
};
|
|
16860
|
+
} else if (superscript) {
|
|
16861
|
+
return {
|
|
16862
|
+
type: "supsub",
|
|
16863
|
+
mode: this.mode,
|
|
16864
|
+
base,
|
|
16865
|
+
sup: superscript
|
|
16866
|
+
};
|
|
16867
|
+
} else if (subscript) {
|
|
16868
|
+
return {
|
|
16869
|
+
type: "supsub",
|
|
16870
|
+
mode: this.mode,
|
|
16871
|
+
base,
|
|
16872
|
+
sub: subscript
|
|
16873
|
+
};
|
|
17210
16874
|
} else {
|
|
17211
16875
|
// Otherwise return the original body
|
|
17212
16876
|
return base;
|
|
@@ -17228,15 +16892,16 @@ class Parser {
|
|
|
17228
16892
|
|
|
17229
16893
|
if (name && name !== "atom" && !funcData.allowedInArgument) {
|
|
17230
16894
|
throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
|
|
16895
|
+
// Treat undefined allowedInText as false.
|
|
17231
16896
|
} else if (this.mode === "text" && !funcData.allowedInText) {
|
|
17232
16897
|
throw new src_ParseError("Can't use function '" + func + "' in text mode", token);
|
|
16898
|
+
// Treat undefined allowedInMath as true.
|
|
17233
16899
|
} else if (this.mode === "math" && funcData.allowedInMath === false) {
|
|
17234
16900
|
throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
|
|
17235
16901
|
}
|
|
17236
|
-
const
|
|
17237
|
-
args,
|
|
17238
|
-
optArgs
|
|
17239
|
-
} = this.parseArguments(func, funcData);
|
|
16902
|
+
const _this$parseArguments = this.parseArguments(func, funcData),
|
|
16903
|
+
args = _this$parseArguments.args,
|
|
16904
|
+
optArgs = _this$parseArguments.optArgs;
|
|
17240
16905
|
return this.callFunction(func, args, optArgs, token, breakOnTokenText);
|
|
17241
16906
|
}
|
|
17242
16907
|
|
|
@@ -17264,7 +16929,9 @@ class Parser {
|
|
|
17264
16929
|
parseArguments(func,
|
|
17265
16930
|
// Should look like "\name" or "\begin{name}".
|
|
17266
16931
|
funcData) {
|
|
17267
|
-
|
|
16932
|
+
var _funcData$numOptional;
|
|
16933
|
+
const numOptionalArgs = (_funcData$numOptional = funcData.numOptionalArgs) != null ? _funcData$numOptional : 0;
|
|
16934
|
+
const totalArgs = funcData.numArgs + numOptionalArgs;
|
|
17268
16935
|
if (totalArgs === 0) {
|
|
17269
16936
|
return {
|
|
17270
16937
|
args: [],
|
|
@@ -17274,8 +16941,9 @@ class Parser {
|
|
|
17274
16941
|
const args = [];
|
|
17275
16942
|
const optArgs = [];
|
|
17276
16943
|
for (let i = 0; i < totalArgs; i++) {
|
|
17277
|
-
|
|
17278
|
-
|
|
16944
|
+
var _funcData$argTypes;
|
|
16945
|
+
let argType = (_funcData$argTypes = funcData.argTypes) == null ? void 0 : _funcData$argTypes[i];
|
|
16946
|
+
const isOptional = i < numOptionalArgs;
|
|
17279
16947
|
if ("primitive" in funcData && funcData.primitive && argType == null ||
|
|
17280
16948
|
// \sqrt expands into primitive if optional argument doesn't exist
|
|
17281
16949
|
funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
|
|
@@ -17328,7 +16996,7 @@ class Parser {
|
|
|
17328
16996
|
}
|
|
17329
16997
|
case "raw":
|
|
17330
16998
|
{
|
|
17331
|
-
const token = this.parseStringGroup(
|
|
16999
|
+
const token = this.parseStringGroup(optional);
|
|
17332
17000
|
return token != null ? {
|
|
17333
17001
|
type: "raw",
|
|
17334
17002
|
mode: "text",
|
|
@@ -17347,7 +17015,6 @@ class Parser {
|
|
|
17347
17015
|
return group;
|
|
17348
17016
|
}
|
|
17349
17017
|
case "original":
|
|
17350
|
-
case null:
|
|
17351
17018
|
case undefined:
|
|
17352
17019
|
return this.parseArgumentGroup(optional);
|
|
17353
17020
|
default:
|
|
@@ -17368,9 +17035,7 @@ class Parser {
|
|
|
17368
17035
|
* Parses a group, essentially returning the string formed by the
|
|
17369
17036
|
* brace-enclosed tokens plus some position information.
|
|
17370
17037
|
*/
|
|
17371
|
-
parseStringGroup(
|
|
17372
|
-
// Used to describe the mode in error messages.
|
|
17373
|
-
optional) {
|
|
17038
|
+
parseStringGroup(optional) {
|
|
17374
17039
|
const argToken = this.gullet.scanArgument(optional);
|
|
17375
17040
|
if (argToken == null) {
|
|
17376
17041
|
return null;
|
|
@@ -17412,7 +17077,7 @@ class Parser {
|
|
|
17412
17077
|
* Parses a color description.
|
|
17413
17078
|
*/
|
|
17414
17079
|
parseColorGroup(optional) {
|
|
17415
|
-
const res = this.parseStringGroup(
|
|
17080
|
+
const res = this.parseStringGroup(optional);
|
|
17416
17081
|
if (res == null) {
|
|
17417
17082
|
return null;
|
|
17418
17083
|
}
|
|
@@ -17445,7 +17110,7 @@ class Parser {
|
|
|
17445
17110
|
if (!optional && this.gullet.future().text !== "{") {
|
|
17446
17111
|
res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
|
|
17447
17112
|
} else {
|
|
17448
|
-
res = this.parseStringGroup(
|
|
17113
|
+
res = this.parseStringGroup(optional);
|
|
17449
17114
|
}
|
|
17450
17115
|
if (!res) {
|
|
17451
17116
|
return null;
|
|
@@ -17484,7 +17149,7 @@ class Parser {
|
|
|
17484
17149
|
parseUrlGroup(optional) {
|
|
17485
17150
|
this.gullet.lexer.setCatcode("%", 13); // active character
|
|
17486
17151
|
this.gullet.lexer.setCatcode("~", 12); // other character
|
|
17487
|
-
const res = this.parseStringGroup(
|
|
17152
|
+
const res = this.parseStringGroup(optional);
|
|
17488
17153
|
this.gullet.lexer.setCatcode("%", 14); // comment character
|
|
17489
17154
|
this.gullet.lexer.setCatcode("~", 13); // active character
|
|
17490
17155
|
if (res == null) {
|
|
@@ -17570,7 +17235,7 @@ class Parser {
|
|
|
17570
17235
|
// If there exists a function with this name, parse the function.
|
|
17571
17236
|
// Otherwise, just return a nucleus
|
|
17572
17237
|
result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol();
|
|
17573
|
-
if (result == null && text[0] === "\\" && !
|
|
17238
|
+
if (result == null && text[0] === "\\" && !Object.prototype.hasOwnProperty.call(implicitCommands, text)) {
|
|
17574
17239
|
if (this.settings.throwOnError) {
|
|
17575
17240
|
throw new src_ParseError("Undefined control sequence: " + text, firstToken);
|
|
17576
17241
|
}
|
|
@@ -17663,7 +17328,7 @@ class Parser {
|
|
|
17663
17328
|
}
|
|
17664
17329
|
// At this point, we should have a symbol, possibly with accents.
|
|
17665
17330
|
// First expand any accented base symbol according to unicodeSymbols.
|
|
17666
|
-
if (
|
|
17331
|
+
if (Object.prototype.hasOwnProperty.call(unicodeSymbols, text[0]) && !src_symbols[this.mode][text[0]]) {
|
|
17667
17332
|
// This behavior is not strict (XeTeX-compatible) in math mode.
|
|
17668
17333
|
if (this.settings.strict && this.mode === "math") {
|
|
17669
17334
|
this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus);
|
|
@@ -17759,11 +17424,6 @@ class Parser {
|
|
|
17759
17424
|
}
|
|
17760
17425
|
Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]);
|
|
17761
17426
|
;// ./src/parseTree.ts
|
|
17762
|
-
/**
|
|
17763
|
-
* Provides a single function for parsing an expression using a Parser
|
|
17764
|
-
* TODO(emily): Remove this
|
|
17765
|
-
*/
|
|
17766
|
-
|
|
17767
17427
|
|
|
17768
17428
|
|
|
17769
17429
|
|
|
@@ -17899,7 +17559,7 @@ const renderToHTMLTree = function (expression, options) {
|
|
|
17899
17559
|
return renderError(error, expression, settings);
|
|
17900
17560
|
}
|
|
17901
17561
|
};
|
|
17902
|
-
const version = "0.
|
|
17562
|
+
const version = "0.18.0";
|
|
17903
17563
|
const __domTree = {
|
|
17904
17564
|
Span: Span,
|
|
17905
17565
|
Anchor: Anchor,
|