katex 0.16.46 → 0.17.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/contrib/copy-tex/README.md +2 -2
- 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/katex-swap.css +1 -1
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +1 -1
- package/dist/katex.js +255 -434
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +243 -415
- package/katex.ts +1 -1
- package/package.json +1 -2
- package/src/MacroExpander.ts +1 -1
- package/src/Namespace.ts +1 -1
- package/src/ParseError.ts +1 -1
- package/src/Parser.ts +42 -48
- package/src/Settings.ts +1 -1
- package/src/SourceLocation.ts +2 -2
- package/src/buildCommon.ts +6 -6
- package/src/buildHTML.ts +4 -5
- package/src/buildMathML.ts +1 -1
- package/src/buildTree.ts +1 -1
- package/src/defineEnvironment.ts +1 -2
- package/src/defineFunction.ts +104 -112
- package/src/environments/array.ts +8 -12
- package/src/environments/cd.ts +8 -8
- package/src/functions/accent.ts +10 -13
- 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 +3 -5
- package/src/functions/def.ts +15 -19
- package/src/functions/delimsizing.ts +23 -23
- package/src/functions/enclose.ts +22 -33
- package/src/functions/environment.ts +4 -5
- 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 +5 -5
- 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 +4 -4
- 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 +3 -3
- package/src/functions/phantom.ts +8 -8
- 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 +7 -7
- package/src/functions/sizing.ts +6 -6
- package/src/functions/smash.ts +5 -5
- package/src/functions/sqrt.ts +4 -4
- 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 +1 -1
- package/src/functions/text.ts +7 -7
- package/src/functions/underline.ts +4 -4
- package/src/functions/utils/assembleSupSub.ts +1 -1
- package/src/functions/vcenter.ts +5 -5
- package/src/functions/verb.ts +5 -5
- package/src/parseNode.ts +2 -476
- package/src/parseTree.ts +1 -6
- package/src/spacingData.ts +2 -1
- package/src/stretchy.ts +1 -1
- package/src/svgGeometry.ts +2 -2
- 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/dist/katex.js
CHANGED
|
@@ -872,7 +872,7 @@ const path = {
|
|
|
872
872
|
const tallDelim = function (label, midHeight) {
|
|
873
873
|
switch (label) {
|
|
874
874
|
case "lbrack":
|
|
875
|
-
return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z";
|
|
875
|
+
return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 v84 h84z";
|
|
876
876
|
case "rbrack":
|
|
877
877
|
return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z";
|
|
878
878
|
case "vert":
|
|
@@ -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.
|
|
@@ -5027,7 +5028,9 @@ const boldSymbol = function (value, mode, type) {
|
|
|
5027
5028
|
/**
|
|
5028
5029
|
* Makes either a mathord or textord in the correct font and color.
|
|
5029
5030
|
*/
|
|
5030
|
-
const makeOrd = function (group, options
|
|
5031
|
+
const makeOrd = function (group, options) {
|
|
5032
|
+
// Spacing nodes are rendered as textord.
|
|
5033
|
+
const type = group.type === "mathord" ? "mathord" : "textord";
|
|
5031
5034
|
const mode = group.mode;
|
|
5032
5035
|
const text = group.text;
|
|
5033
5036
|
const classes = ["mord"];
|
|
@@ -5630,11 +5633,19 @@ const tightSpacings = {
|
|
|
5630
5633
|
// delegates its HTML building to the HtmlBuilder corresponding to these nodes.
|
|
5631
5634
|
|
|
5632
5635
|
/**
|
|
5633
|
-
*
|
|
5634
|
-
*
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5636
|
+
* Parser-facing function spec. Optional properties should use the defaults
|
|
5637
|
+
* documented below.
|
|
5638
|
+
*/
|
|
5639
|
+
|
|
5640
|
+
/**
|
|
5641
|
+
* Builder fields consumed during registration. These are stored separately in
|
|
5642
|
+
* `_htmlGroupBuilders` and `_mathmlGroupBuilders`, and are not used by Parser.
|
|
5643
|
+
*/
|
|
5644
|
+
|
|
5645
|
+
/**
|
|
5646
|
+
* Full registration spec passed to `defineFunction`. It combines the
|
|
5647
|
+
* parser-facing fields with optional builder fields and the names being
|
|
5648
|
+
* registered.
|
|
5638
5649
|
*/
|
|
5639
5650
|
|
|
5640
5651
|
/**
|
|
@@ -5662,29 +5673,17 @@ const _htmlGroupBuilders = {};
|
|
|
5662
5673
|
*/
|
|
5663
5674
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5664
5675
|
const _mathmlGroupBuilders = {};
|
|
5665
|
-
function defineFunction(
|
|
5666
|
-
|
|
5676
|
+
function defineFunction(data) {
|
|
5677
|
+
const {
|
|
5667
5678
|
type,
|
|
5668
5679
|
names,
|
|
5669
|
-
props,
|
|
5670
|
-
handler,
|
|
5671
5680
|
htmlBuilder,
|
|
5672
5681
|
mathmlBuilder
|
|
5673
|
-
} =
|
|
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
|
-
};
|
|
5682
|
+
} = data;
|
|
5687
5683
|
for (let i = 0; i < names.length; ++i) {
|
|
5684
|
+
// To avoid destructuring and rebuilding an object,
|
|
5685
|
+
// we store the entire FunctionDefSpec object,
|
|
5686
|
+
// even though Parser only needs the FunctionSpec fields.
|
|
5688
5687
|
_functions[names[i]] = data;
|
|
5689
5688
|
}
|
|
5690
5689
|
if (type) {
|
|
@@ -5702,24 +5701,18 @@ function defineFunction(_ref) {
|
|
|
5702
5701
|
* if the function's ParseNode is generated in Parser.js rather than via a
|
|
5703
5702
|
* stand-alone handler provided to `defineFunction`).
|
|
5704
5703
|
*/
|
|
5705
|
-
function defineFunctionBuilders(
|
|
5704
|
+
function defineFunctionBuilders(_ref) {
|
|
5706
5705
|
let {
|
|
5707
5706
|
type,
|
|
5708
5707
|
htmlBuilder,
|
|
5709
5708
|
mathmlBuilder
|
|
5710
|
-
} =
|
|
5711
|
-
|
|
5712
|
-
type
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
handler() {
|
|
5718
|
-
throw new Error('Should never be called.');
|
|
5719
|
-
},
|
|
5720
|
-
htmlBuilder,
|
|
5721
|
-
mathmlBuilder
|
|
5722
|
-
});
|
|
5709
|
+
} = _ref;
|
|
5710
|
+
if (htmlBuilder) {
|
|
5711
|
+
_htmlGroupBuilders[type] = htmlBuilder;
|
|
5712
|
+
}
|
|
5713
|
+
if (mathmlBuilder) {
|
|
5714
|
+
_mathmlGroupBuilders[type] = mathmlBuilder;
|
|
5715
|
+
}
|
|
5723
5716
|
}
|
|
5724
5717
|
const normalizeArgument = function (arg) {
|
|
5725
5718
|
return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg;
|
|
@@ -7251,15 +7244,6 @@ function isAtom(value) {
|
|
|
7251
7244
|
}
|
|
7252
7245
|
;// ./src/parseNode.ts
|
|
7253
7246
|
|
|
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
7247
|
/**
|
|
7264
7248
|
* Asserts that the node is of the given type and returns it with stricter
|
|
7265
7249
|
* typing. Throws if the node's type does not match.
|
|
@@ -7284,7 +7268,7 @@ function assertSymbolNodeType(node) {
|
|
|
7284
7268
|
}
|
|
7285
7269
|
|
|
7286
7270
|
/**
|
|
7287
|
-
* Returns the node more strictly typed
|
|
7271
|
+
* Returns the node more strictly typed if it is of the given type. Otherwise,
|
|
7288
7272
|
* returns null.
|
|
7289
7273
|
*/
|
|
7290
7274
|
function checkSymbolNodeType(node) {
|
|
@@ -7388,7 +7372,7 @@ const htmlBuilder = (grp, options) => {
|
|
|
7388
7372
|
type: "textord",
|
|
7389
7373
|
mode: group.mode,
|
|
7390
7374
|
text: group.label
|
|
7391
|
-
}, options
|
|
7375
|
+
}, options);
|
|
7392
7376
|
accent = assertSymbolDomNode(accent);
|
|
7393
7377
|
// Remove the italic correction of the accent, because it only serves to
|
|
7394
7378
|
// shift the accent over to a place we don't want.
|
|
@@ -7486,9 +7470,7 @@ const NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\
|
|
|
7486
7470
|
defineFunction({
|
|
7487
7471
|
type: "accent",
|
|
7488
7472
|
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
|
-
},
|
|
7473
|
+
numArgs: 1,
|
|
7492
7474
|
handler: (context, args) => {
|
|
7493
7475
|
const base = normalizeArgument(args[0]);
|
|
7494
7476
|
const isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName);
|
|
@@ -7510,13 +7492,11 @@ defineFunction({
|
|
|
7510
7492
|
defineFunction({
|
|
7511
7493
|
type: "accent",
|
|
7512
7494
|
names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"],
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
argTypes: ["primitive"]
|
|
7519
|
-
},
|
|
7495
|
+
numArgs: 1,
|
|
7496
|
+
allowedInText: true,
|
|
7497
|
+
allowedInMath: true,
|
|
7498
|
+
// unless in strict mode
|
|
7499
|
+
argTypes: ["primitive"],
|
|
7520
7500
|
handler: (context, args) => {
|
|
7521
7501
|
const base = args[0];
|
|
7522
7502
|
let mode = context.parser.mode;
|
|
@@ -7532,9 +7512,7 @@ defineFunction({
|
|
|
7532
7512
|
isShifty: true,
|
|
7533
7513
|
base: base
|
|
7534
7514
|
};
|
|
7535
|
-
}
|
|
7536
|
-
htmlBuilder,
|
|
7537
|
-
mathmlBuilder
|
|
7515
|
+
}
|
|
7538
7516
|
});
|
|
7539
7517
|
;// ./src/functions/accentunder.ts
|
|
7540
7518
|
// Horizontal overlap functions
|
|
@@ -7547,9 +7525,7 @@ defineFunction({
|
|
|
7547
7525
|
defineFunction({
|
|
7548
7526
|
type: "accentUnder",
|
|
7549
7527
|
names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"],
|
|
7550
|
-
|
|
7551
|
-
numArgs: 1
|
|
7552
|
-
},
|
|
7528
|
+
numArgs: 1,
|
|
7553
7529
|
handler: (_ref, args) => {
|
|
7554
7530
|
let {
|
|
7555
7531
|
parser,
|
|
@@ -7618,10 +7594,8 @@ defineFunction({
|
|
|
7618
7594
|
"\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium",
|
|
7619
7595
|
// The next 3 functions are here only to support the {CD} environment.
|
|
7620
7596
|
"\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"],
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
numOptionalArgs: 1
|
|
7624
|
-
},
|
|
7597
|
+
numArgs: 1,
|
|
7598
|
+
numOptionalArgs: 1,
|
|
7625
7599
|
handler(_ref, args, optArgs) {
|
|
7626
7600
|
let {
|
|
7627
7601
|
parser,
|
|
@@ -7769,9 +7743,6 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
7769
7743
|
} else if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
7770
7744
|
node.attributes.lspace = "0em";
|
|
7771
7745
|
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
7746
|
}
|
|
7776
7747
|
// MathML <mo> default space is 5/18 em, so <mrel> needs no action.
|
|
7777
7748
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
|
|
@@ -7783,10 +7754,8 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
7783
7754
|
defineFunction({
|
|
7784
7755
|
type: "mclass",
|
|
7785
7756
|
names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"],
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
primitive: true
|
|
7789
|
-
},
|
|
7757
|
+
numArgs: 1,
|
|
7758
|
+
primitive: true,
|
|
7790
7759
|
handler(_ref, args) {
|
|
7791
7760
|
let {
|
|
7792
7761
|
parser,
|
|
@@ -7797,7 +7766,6 @@ defineFunction({
|
|
|
7797
7766
|
type: "mclass",
|
|
7798
7767
|
mode: parser.mode,
|
|
7799
7768
|
mclass: "m" + funcName.slice(5),
|
|
7800
|
-
// TODO(kevinb): don't prefix with 'm'
|
|
7801
7769
|
body: ordargument(body),
|
|
7802
7770
|
isCharacterBox: isCharacterBox(body)
|
|
7803
7771
|
};
|
|
@@ -7823,9 +7791,7 @@ const binrelClass = arg => {
|
|
|
7823
7791
|
defineFunction({
|
|
7824
7792
|
type: "mclass",
|
|
7825
7793
|
names: ["\\@binrel"],
|
|
7826
|
-
|
|
7827
|
-
numArgs: 2
|
|
7828
|
-
},
|
|
7794
|
+
numArgs: 2,
|
|
7829
7795
|
handler(_ref2, args) {
|
|
7830
7796
|
let {
|
|
7831
7797
|
parser
|
|
@@ -7844,9 +7810,7 @@ defineFunction({
|
|
|
7844
7810
|
defineFunction({
|
|
7845
7811
|
type: "mclass",
|
|
7846
7812
|
names: ["\\stackrel", "\\overset", "\\underset"],
|
|
7847
|
-
|
|
7848
|
-
numArgs: 2
|
|
7849
|
-
},
|
|
7813
|
+
numArgs: 2,
|
|
7850
7814
|
handler(_ref3, args) {
|
|
7851
7815
|
let {
|
|
7852
7816
|
parser,
|
|
@@ -7871,12 +7835,16 @@ defineFunction({
|
|
|
7871
7835
|
suppressBaseShift: funcName !== "\\stackrel",
|
|
7872
7836
|
body: ordargument(baseArg)
|
|
7873
7837
|
};
|
|
7874
|
-
const supsub = {
|
|
7838
|
+
const supsub = funcName === "\\underset" ? {
|
|
7839
|
+
type: "supsub",
|
|
7840
|
+
mode: shiftedArg.mode,
|
|
7841
|
+
base: baseOp,
|
|
7842
|
+
sub: shiftedArg
|
|
7843
|
+
} : {
|
|
7875
7844
|
type: "supsub",
|
|
7876
7845
|
mode: shiftedArg.mode,
|
|
7877
7846
|
base: baseOp,
|
|
7878
|
-
sup:
|
|
7879
|
-
sub: funcName === "\\underset" ? shiftedArg : null
|
|
7847
|
+
sup: shiftedArg
|
|
7880
7848
|
};
|
|
7881
7849
|
return {
|
|
7882
7850
|
type: "mclass",
|
|
@@ -7885,9 +7853,7 @@ defineFunction({
|
|
|
7885
7853
|
body: [supsub],
|
|
7886
7854
|
isCharacterBox: isCharacterBox(supsub)
|
|
7887
7855
|
};
|
|
7888
|
-
}
|
|
7889
|
-
htmlBuilder: mclass_htmlBuilder,
|
|
7890
|
-
mathmlBuilder: mclass_mathmlBuilder
|
|
7856
|
+
}
|
|
7891
7857
|
});
|
|
7892
7858
|
;// ./src/functions/pmb.ts
|
|
7893
7859
|
|
|
@@ -7904,10 +7870,8 @@ defineFunction({
|
|
|
7904
7870
|
defineFunction({
|
|
7905
7871
|
type: "pmb",
|
|
7906
7872
|
names: ["\\pmb"],
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
allowedInText: true
|
|
7910
|
-
},
|
|
7873
|
+
numArgs: 1,
|
|
7874
|
+
allowedInText: true,
|
|
7911
7875
|
handler(_ref, args) {
|
|
7912
7876
|
let {
|
|
7913
7877
|
parser
|
|
@@ -8175,9 +8139,7 @@ function parseCD(parser) {
|
|
|
8175
8139
|
defineFunction({
|
|
8176
8140
|
type: "cdlabel",
|
|
8177
8141
|
names: ["\\\\cdleft", "\\\\cdright"],
|
|
8178
|
-
|
|
8179
|
-
numArgs: 1
|
|
8180
|
-
},
|
|
8142
|
+
numArgs: 1,
|
|
8181
8143
|
handler(_ref, args) {
|
|
8182
8144
|
let {
|
|
8183
8145
|
parser,
|
|
@@ -8220,9 +8182,7 @@ defineFunction({
|
|
|
8220
8182
|
defineFunction({
|
|
8221
8183
|
type: "cdlabelparent",
|
|
8222
8184
|
names: ["\\\\cdparent"],
|
|
8223
|
-
|
|
8224
|
-
numArgs: 1
|
|
8225
|
-
},
|
|
8185
|
+
numArgs: 1,
|
|
8226
8186
|
handler(_ref2, args) {
|
|
8227
8187
|
let {
|
|
8228
8188
|
parser
|
|
@@ -8256,10 +8216,8 @@ defineFunction({
|
|
|
8256
8216
|
defineFunction({
|
|
8257
8217
|
type: "textord",
|
|
8258
8218
|
names: ["\\@char"],
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
allowedInText: true
|
|
8262
|
-
},
|
|
8219
|
+
numArgs: 1,
|
|
8220
|
+
allowedInText: true,
|
|
8263
8221
|
handler(_ref, args) {
|
|
8264
8222
|
let {
|
|
8265
8223
|
parser
|
|
@@ -8318,11 +8276,9 @@ const color_mathmlBuilder = (group, options) => {
|
|
|
8318
8276
|
defineFunction({
|
|
8319
8277
|
type: "color",
|
|
8320
8278
|
names: ["\\textcolor"],
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
argTypes: ["color", "original"]
|
|
8325
|
-
},
|
|
8279
|
+
numArgs: 2,
|
|
8280
|
+
allowedInText: true,
|
|
8281
|
+
argTypes: ["color", "original"],
|
|
8326
8282
|
handler(_ref, args) {
|
|
8327
8283
|
let {
|
|
8328
8284
|
parser
|
|
@@ -8342,11 +8298,9 @@ defineFunction({
|
|
|
8342
8298
|
defineFunction({
|
|
8343
8299
|
type: "color",
|
|
8344
8300
|
names: ["\\color"],
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
argTypes: ["color"]
|
|
8349
|
-
},
|
|
8301
|
+
numArgs: 1,
|
|
8302
|
+
allowedInText: true,
|
|
8303
|
+
argTypes: ["color"],
|
|
8350
8304
|
handler(_ref2, args) {
|
|
8351
8305
|
let {
|
|
8352
8306
|
parser,
|
|
@@ -8368,9 +8322,7 @@ defineFunction({
|
|
|
8368
8322
|
color,
|
|
8369
8323
|
body
|
|
8370
8324
|
};
|
|
8371
|
-
}
|
|
8372
|
-
htmlBuilder: color_htmlBuilder,
|
|
8373
|
-
mathmlBuilder: color_mathmlBuilder
|
|
8325
|
+
}
|
|
8374
8326
|
});
|
|
8375
8327
|
;// ./src/functions/cr.ts
|
|
8376
8328
|
// Row breaks within tabular environments, and line breaks at top level
|
|
@@ -8385,11 +8337,9 @@ defineFunction({
|
|
|
8385
8337
|
defineFunction({
|
|
8386
8338
|
type: "cr",
|
|
8387
8339
|
names: ["\\\\"],
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
allowedInText: true
|
|
8392
|
-
},
|
|
8340
|
+
numArgs: 0,
|
|
8341
|
+
numOptionalArgs: 0,
|
|
8342
|
+
allowedInText: true,
|
|
8393
8343
|
handler(_ref, args, optArgs) {
|
|
8394
8344
|
let {
|
|
8395
8345
|
parser
|
|
@@ -8485,10 +8435,8 @@ defineFunction({
|
|
|
8485
8435
|
type: "internal",
|
|
8486
8436
|
names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly
|
|
8487
8437
|
],
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
allowedInText: true
|
|
8491
|
-
},
|
|
8438
|
+
numArgs: 0,
|
|
8439
|
+
allowedInText: true,
|
|
8492
8440
|
handler(_ref) {
|
|
8493
8441
|
let {
|
|
8494
8442
|
parser,
|
|
@@ -8514,11 +8462,9 @@ defineFunction({
|
|
|
8514
8462
|
defineFunction({
|
|
8515
8463
|
type: "internal",
|
|
8516
8464
|
names: ["\\def", "\\gdef", "\\edef", "\\xdef"],
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
primitive: true
|
|
8521
|
-
},
|
|
8465
|
+
numArgs: 0,
|
|
8466
|
+
allowedInText: true,
|
|
8467
|
+
primitive: true,
|
|
8522
8468
|
handler(_ref2) {
|
|
8523
8469
|
let {
|
|
8524
8470
|
parser,
|
|
@@ -8595,11 +8541,9 @@ defineFunction({
|
|
|
8595
8541
|
type: "internal",
|
|
8596
8542
|
names: ["\\let", "\\\\globallet" // can’t be entered directly
|
|
8597
8543
|
],
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
primitive: true
|
|
8602
|
-
},
|
|
8544
|
+
numArgs: 0,
|
|
8545
|
+
allowedInText: true,
|
|
8546
|
+
primitive: true,
|
|
8603
8547
|
handler(_ref3) {
|
|
8604
8548
|
let {
|
|
8605
8549
|
parser,
|
|
@@ -8621,11 +8565,9 @@ defineFunction({
|
|
|
8621
8565
|
type: "internal",
|
|
8622
8566
|
names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly
|
|
8623
8567
|
],
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
primitive: true
|
|
8628
|
-
},
|
|
8568
|
+
numArgs: 0,
|
|
8569
|
+
allowedInText: true,
|
|
8570
|
+
primitive: true,
|
|
8629
8571
|
handler(_ref4) {
|
|
8630
8572
|
let {
|
|
8631
8573
|
parser,
|
|
@@ -9450,10 +9392,8 @@ function checkDelimiter(delim, context) {
|
|
|
9450
9392
|
defineFunction({
|
|
9451
9393
|
type: "delimsizing",
|
|
9452
9394
|
names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"],
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
argTypes: ["primitive"]
|
|
9456
|
-
},
|
|
9395
|
+
numArgs: 1,
|
|
9396
|
+
argTypes: ["primitive"],
|
|
9457
9397
|
handler: (context, args) => {
|
|
9458
9398
|
const delim = checkDelimiter(args[0], context);
|
|
9459
9399
|
return {
|
|
@@ -9502,10 +9442,8 @@ function assertParsed(group) {
|
|
|
9502
9442
|
defineFunction({
|
|
9503
9443
|
type: "leftright-right",
|
|
9504
9444
|
names: ["\\right"],
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
primitive: true
|
|
9508
|
-
},
|
|
9445
|
+
numArgs: 1,
|
|
9446
|
+
primitive: true,
|
|
9509
9447
|
handler: (context, args) => {
|
|
9510
9448
|
// \left case below triggers parsing of \right in
|
|
9511
9449
|
// `const right = parser.parseFunction();`
|
|
@@ -9518,17 +9456,15 @@ defineFunction({
|
|
|
9518
9456
|
type: "leftright-right",
|
|
9519
9457
|
mode: context.parser.mode,
|
|
9520
9458
|
delim: checkDelimiter(args[0], context).text,
|
|
9521
|
-
color
|
|
9459
|
+
color // undefined if not set via \color
|
|
9522
9460
|
};
|
|
9523
9461
|
}
|
|
9524
9462
|
});
|
|
9525
9463
|
defineFunction({
|
|
9526
9464
|
type: "leftright",
|
|
9527
9465
|
names: ["\\left"],
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
primitive: true
|
|
9531
|
-
},
|
|
9466
|
+
numArgs: 1,
|
|
9467
|
+
primitive: true,
|
|
9532
9468
|
handler: (context, args) => {
|
|
9533
9469
|
const delim = checkDelimiter(args[0], context);
|
|
9534
9470
|
const parser = context.parser;
|
|
@@ -9630,10 +9566,8 @@ defineFunction({
|
|
|
9630
9566
|
defineFunction({
|
|
9631
9567
|
type: "middle",
|
|
9632
9568
|
names: ["\\middle"],
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
primitive: true
|
|
9636
|
-
},
|
|
9569
|
+
numArgs: 1,
|
|
9570
|
+
primitive: true,
|
|
9637
9571
|
handler: (context, args) => {
|
|
9638
9572
|
const delim = checkDelimiter(args[0], context);
|
|
9639
9573
|
if (!context.parser.leftrightDepth) {
|
|
@@ -9887,11 +9821,9 @@ const enclose_mathmlBuilder = (group, options) => {
|
|
|
9887
9821
|
defineFunction({
|
|
9888
9822
|
type: "enclose",
|
|
9889
9823
|
names: ["\\colorbox"],
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
argTypes: ["color", "hbox"]
|
|
9894
|
-
},
|
|
9824
|
+
numArgs: 2,
|
|
9825
|
+
allowedInText: true,
|
|
9826
|
+
argTypes: ["color", "hbox"],
|
|
9895
9827
|
handler(_ref, args, optArgs) {
|
|
9896
9828
|
let {
|
|
9897
9829
|
parser,
|
|
@@ -9913,11 +9845,9 @@ defineFunction({
|
|
|
9913
9845
|
defineFunction({
|
|
9914
9846
|
type: "enclose",
|
|
9915
9847
|
names: ["\\fcolorbox"],
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
argTypes: ["color", "color", "hbox"]
|
|
9920
|
-
},
|
|
9848
|
+
numArgs: 3,
|
|
9849
|
+
allowedInText: true,
|
|
9850
|
+
argTypes: ["color", "color", "hbox"],
|
|
9921
9851
|
handler(_ref2, args, optArgs) {
|
|
9922
9852
|
let {
|
|
9923
9853
|
parser,
|
|
@@ -9934,18 +9864,14 @@ defineFunction({
|
|
|
9934
9864
|
borderColor,
|
|
9935
9865
|
body
|
|
9936
9866
|
};
|
|
9937
|
-
}
|
|
9938
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
9939
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9867
|
+
}
|
|
9940
9868
|
});
|
|
9941
9869
|
defineFunction({
|
|
9942
9870
|
type: "enclose",
|
|
9943
9871
|
names: ["\\fbox"],
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
allowedInText: true
|
|
9948
|
-
},
|
|
9872
|
+
numArgs: 1,
|
|
9873
|
+
argTypes: ["hbox"],
|
|
9874
|
+
allowedInText: true,
|
|
9949
9875
|
handler(_ref3, args) {
|
|
9950
9876
|
let {
|
|
9951
9877
|
parser
|
|
@@ -9961,9 +9887,7 @@ defineFunction({
|
|
|
9961
9887
|
defineFunction({
|
|
9962
9888
|
type: "enclose",
|
|
9963
9889
|
names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
|
|
9964
|
-
|
|
9965
|
-
numArgs: 1
|
|
9966
|
-
},
|
|
9890
|
+
numArgs: 1,
|
|
9967
9891
|
handler(_ref4, args) {
|
|
9968
9892
|
let {
|
|
9969
9893
|
parser,
|
|
@@ -9976,17 +9900,13 @@ defineFunction({
|
|
|
9976
9900
|
label: funcName,
|
|
9977
9901
|
body
|
|
9978
9902
|
};
|
|
9979
|
-
}
|
|
9980
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
9981
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9903
|
+
}
|
|
9982
9904
|
});
|
|
9983
9905
|
defineFunction({
|
|
9984
9906
|
type: "enclose",
|
|
9985
9907
|
names: ["\\sout"],
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
allowedInText: true
|
|
9989
|
-
},
|
|
9908
|
+
numArgs: 1,
|
|
9909
|
+
allowedInText: true,
|
|
9990
9910
|
handler(_ref5, args) {
|
|
9991
9911
|
let {
|
|
9992
9912
|
parser,
|
|
@@ -10002,18 +9922,14 @@ defineFunction({
|
|
|
10002
9922
|
label: funcName,
|
|
10003
9923
|
body
|
|
10004
9924
|
};
|
|
10005
|
-
}
|
|
10006
|
-
htmlBuilder: enclose_htmlBuilder,
|
|
10007
|
-
mathmlBuilder: enclose_mathmlBuilder
|
|
9925
|
+
}
|
|
10008
9926
|
});
|
|
10009
9927
|
defineFunction({
|
|
10010
9928
|
type: "enclose",
|
|
10011
9929
|
names: ["\\angl"],
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
allowedInText: false
|
|
10016
|
-
},
|
|
9930
|
+
numArgs: 1,
|
|
9931
|
+
argTypes: ["hbox"],
|
|
9932
|
+
allowedInText: false,
|
|
10017
9933
|
handler(_ref6, args) {
|
|
10018
9934
|
let {
|
|
10019
9935
|
parser
|
|
@@ -10827,14 +10743,13 @@ const alignedHandler = function (context, args) {
|
|
|
10827
10743
|
validateAmsEnvironmentContext(context);
|
|
10828
10744
|
}
|
|
10829
10745
|
const cols = [];
|
|
10830
|
-
const separationType = context.envName.includes("at") ? "alignat" : "align";
|
|
10831
10746
|
const isSplit = context.envName === "split";
|
|
10832
10747
|
const res = parseArray(context.parser, {
|
|
10833
10748
|
cols,
|
|
10834
10749
|
addJot: true,
|
|
10835
10750
|
autoTag: isSplit ? undefined : getAutoTag(context.envName),
|
|
10836
10751
|
emptySingleRow: true,
|
|
10837
|
-
colSeparationType:
|
|
10752
|
+
colSeparationType: context.envName.includes("at") ? "alignat" : "align",
|
|
10838
10753
|
maxNumCols: isSplit ? 2 : undefined,
|
|
10839
10754
|
leqno: context.parser.settings.leqno
|
|
10840
10755
|
}, "display");
|
|
@@ -11229,11 +11144,9 @@ defineFunction({
|
|
|
11229
11144
|
type: "text",
|
|
11230
11145
|
// Doesn't matter what this is.
|
|
11231
11146
|
names: ["\\hline", "\\hdashline"],
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
allowedInMath: true
|
|
11236
|
-
},
|
|
11147
|
+
numArgs: 0,
|
|
11148
|
+
allowedInText: true,
|
|
11149
|
+
allowedInMath: true,
|
|
11237
11150
|
handler(context, args) {
|
|
11238
11151
|
throw new src_ParseError(context.funcName + " valid only within array environment");
|
|
11239
11152
|
}
|
|
@@ -11255,10 +11168,8 @@ const environments = _environments;
|
|
|
11255
11168
|
defineFunction({
|
|
11256
11169
|
type: "environment",
|
|
11257
11170
|
names: ["\\begin", "\\end"],
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
argTypes: ["text"]
|
|
11261
|
-
},
|
|
11171
|
+
numArgs: 1,
|
|
11172
|
+
argTypes: ["text"],
|
|
11262
11173
|
handler(_ref, args) {
|
|
11263
11174
|
let {
|
|
11264
11175
|
parser,
|
|
@@ -11342,20 +11253,15 @@ defineFunction({
|
|
|
11342
11253
|
"\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt",
|
|
11343
11254
|
// aliases, except \bm defined below
|
|
11344
11255
|
"\\Bbb", "\\bold", "\\frak"],
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
allowedInArgument: true
|
|
11348
|
-
},
|
|
11256
|
+
numArgs: 1,
|
|
11257
|
+
allowedInArgument: true,
|
|
11349
11258
|
handler: (_ref, args) => {
|
|
11350
11259
|
let {
|
|
11351
11260
|
parser,
|
|
11352
11261
|
funcName
|
|
11353
11262
|
} = _ref;
|
|
11354
11263
|
const body = normalizeArgument(args[0]);
|
|
11355
|
-
|
|
11356
|
-
if (func in fontAliases) {
|
|
11357
|
-
func = fontAliases[func];
|
|
11358
|
-
}
|
|
11264
|
+
const func = funcName in fontAliases ? fontAliases[funcName] : funcName;
|
|
11359
11265
|
return {
|
|
11360
11266
|
type: "font",
|
|
11361
11267
|
mode: parser.mode,
|
|
@@ -11369,9 +11275,7 @@ defineFunction({
|
|
|
11369
11275
|
defineFunction({
|
|
11370
11276
|
type: "mclass",
|
|
11371
11277
|
names: ["\\boldsymbol", "\\bm"],
|
|
11372
|
-
|
|
11373
|
-
numArgs: 1
|
|
11374
|
-
},
|
|
11278
|
+
numArgs: 1,
|
|
11375
11279
|
handler: (_ref2, args) => {
|
|
11376
11280
|
let {
|
|
11377
11281
|
parser
|
|
@@ -11398,10 +11302,8 @@ defineFunction({
|
|
|
11398
11302
|
defineFunction({
|
|
11399
11303
|
type: "font",
|
|
11400
11304
|
names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
allowedInText: true
|
|
11404
|
-
},
|
|
11305
|
+
numArgs: 0,
|
|
11306
|
+
allowedInText: true,
|
|
11405
11307
|
handler: (_ref3, args) => {
|
|
11406
11308
|
let {
|
|
11407
11309
|
parser,
|
|
@@ -11422,9 +11324,7 @@ defineFunction({
|
|
|
11422
11324
|
body
|
|
11423
11325
|
}
|
|
11424
11326
|
};
|
|
11425
|
-
}
|
|
11426
|
-
htmlBuilder: font_htmlBuilder,
|
|
11427
|
-
mathmlBuilder: font_mathmlBuilder
|
|
11327
|
+
}
|
|
11428
11328
|
});
|
|
11429
11329
|
;// ./src/functions/genfrac.ts
|
|
11430
11330
|
|
|
@@ -11618,10 +11518,8 @@ defineFunction({
|
|
|
11618
11518
|
// can’t be entered directly
|
|
11619
11519
|
"\\\\bracefrac", "\\\\brackfrac" // ditto
|
|
11620
11520
|
],
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
allowedInArgument: true
|
|
11624
|
-
},
|
|
11521
|
+
numArgs: 2,
|
|
11522
|
+
allowedInArgument: true,
|
|
11625
11523
|
handler: (_ref, args) => {
|
|
11626
11524
|
let {
|
|
11627
11525
|
parser,
|
|
@@ -11690,10 +11588,8 @@ defineFunction({
|
|
|
11690
11588
|
defineFunction({
|
|
11691
11589
|
type: "infix",
|
|
11692
11590
|
names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
infix: true
|
|
11696
|
-
},
|
|
11591
|
+
numArgs: 0,
|
|
11592
|
+
infix: true,
|
|
11697
11593
|
handler(_ref2) {
|
|
11698
11594
|
let {
|
|
11699
11595
|
parser,
|
|
@@ -11740,11 +11636,9 @@ const delimFromValue = function (delimString) {
|
|
|
11740
11636
|
defineFunction({
|
|
11741
11637
|
type: "genfrac",
|
|
11742
11638
|
names: ["\\genfrac"],
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
argTypes: ["math", "math", "size", "text", "math", "math"]
|
|
11747
|
-
},
|
|
11639
|
+
numArgs: 6,
|
|
11640
|
+
allowedInArgument: true,
|
|
11641
|
+
argTypes: ["math", "math", "size", "text", "math", "math"],
|
|
11748
11642
|
handler(_ref3, args) {
|
|
11749
11643
|
let {
|
|
11750
11644
|
parser
|
|
@@ -11800,11 +11694,9 @@ defineFunction({
|
|
|
11800
11694
|
defineFunction({
|
|
11801
11695
|
type: "infix",
|
|
11802
11696
|
names: ["\\above"],
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
infix: true
|
|
11807
|
-
},
|
|
11697
|
+
numArgs: 1,
|
|
11698
|
+
argTypes: ["size"],
|
|
11699
|
+
infix: true,
|
|
11808
11700
|
handler(_ref4, args) {
|
|
11809
11701
|
let {
|
|
11810
11702
|
parser,
|
|
@@ -11823,10 +11715,8 @@ defineFunction({
|
|
|
11823
11715
|
defineFunction({
|
|
11824
11716
|
type: "genfrac",
|
|
11825
11717
|
names: ["\\\\abovefrac"],
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
argTypes: ["math", "size", "math"]
|
|
11829
|
-
},
|
|
11718
|
+
numArgs: 3,
|
|
11719
|
+
argTypes: ["math", "size", "math"],
|
|
11830
11720
|
handler: (_ref5, args) => {
|
|
11831
11721
|
let {
|
|
11832
11722
|
parser,
|
|
@@ -11973,9 +11863,7 @@ const horizBrace_mathmlBuilder = (group, options) => {
|
|
|
11973
11863
|
defineFunction({
|
|
11974
11864
|
type: "horizBrace",
|
|
11975
11865
|
names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
|
|
11976
|
-
|
|
11977
|
-
numArgs: 1
|
|
11978
|
-
},
|
|
11866
|
+
numArgs: 1,
|
|
11979
11867
|
handler(_ref, args) {
|
|
11980
11868
|
let {
|
|
11981
11869
|
parser,
|
|
@@ -12002,11 +11890,9 @@ defineFunction({
|
|
|
12002
11890
|
defineFunction({
|
|
12003
11891
|
type: "href",
|
|
12004
11892
|
names: ["\\href"],
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
allowedInText: true
|
|
12009
|
-
},
|
|
11893
|
+
numArgs: 2,
|
|
11894
|
+
argTypes: ["url", "original"],
|
|
11895
|
+
allowedInText: true,
|
|
12010
11896
|
handler: (_ref, args) => {
|
|
12011
11897
|
let {
|
|
12012
11898
|
parser
|
|
@@ -12042,11 +11928,9 @@ defineFunction({
|
|
|
12042
11928
|
defineFunction({
|
|
12043
11929
|
type: "href",
|
|
12044
11930
|
names: ["\\url"],
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
allowedInText: true
|
|
12049
|
-
},
|
|
11931
|
+
numArgs: 1,
|
|
11932
|
+
argTypes: ["url"],
|
|
11933
|
+
allowedInText: true,
|
|
12050
11934
|
handler: (_ref2, args) => {
|
|
12051
11935
|
let {
|
|
12052
11936
|
parser
|
|
@@ -12099,12 +11983,10 @@ defineFunction({
|
|
|
12099
11983
|
defineFunction({
|
|
12100
11984
|
type: "hbox",
|
|
12101
11985
|
names: ["\\hbox"],
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
primitive: true
|
|
12107
|
-
},
|
|
11986
|
+
numArgs: 1,
|
|
11987
|
+
argTypes: ["text"],
|
|
11988
|
+
allowedInText: true,
|
|
11989
|
+
primitive: true,
|
|
12108
11990
|
handler(_ref, args) {
|
|
12109
11991
|
let {
|
|
12110
11992
|
parser
|
|
@@ -12133,11 +12015,9 @@ defineFunction({
|
|
|
12133
12015
|
defineFunction({
|
|
12134
12016
|
type: "html",
|
|
12135
12017
|
names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
allowedInText: true
|
|
12140
|
-
},
|
|
12018
|
+
numArgs: 2,
|
|
12019
|
+
argTypes: ["raw", "original"],
|
|
12020
|
+
allowedInText: true,
|
|
12141
12021
|
handler: (_ref, args) => {
|
|
12142
12022
|
let {
|
|
12143
12023
|
parser,
|
|
@@ -12231,11 +12111,9 @@ defineFunction({
|
|
|
12231
12111
|
defineFunction({
|
|
12232
12112
|
type: "htmlmathml",
|
|
12233
12113
|
names: ["\\html@mathml"],
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
allowedInText: true
|
|
12238
|
-
},
|
|
12114
|
+
numArgs: 2,
|
|
12115
|
+
allowedInArgument: true,
|
|
12116
|
+
allowedInText: true,
|
|
12239
12117
|
handler: (_ref, args) => {
|
|
12240
12118
|
let {
|
|
12241
12119
|
parser
|
|
@@ -12289,12 +12167,10 @@ const sizeData = function (str) {
|
|
|
12289
12167
|
defineFunction({
|
|
12290
12168
|
type: "includegraphics",
|
|
12291
12169
|
names: ["\\includegraphics"],
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
allowedInText: false
|
|
12297
|
-
},
|
|
12170
|
+
numArgs: 1,
|
|
12171
|
+
numOptionalArgs: 1,
|
|
12172
|
+
argTypes: ["raw", "url"],
|
|
12173
|
+
allowedInText: false,
|
|
12298
12174
|
handler: (_ref, args, optArgs) => {
|
|
12299
12175
|
let {
|
|
12300
12176
|
parser
|
|
@@ -12419,12 +12295,10 @@ defineFunction({
|
|
|
12419
12295
|
defineFunction({
|
|
12420
12296
|
type: "kern",
|
|
12421
12297
|
names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
allowedInText: true
|
|
12427
|
-
},
|
|
12298
|
+
numArgs: 1,
|
|
12299
|
+
argTypes: ["size"],
|
|
12300
|
+
primitive: true,
|
|
12301
|
+
allowedInText: true,
|
|
12428
12302
|
handler(_ref, args) {
|
|
12429
12303
|
let {
|
|
12430
12304
|
parser,
|
|
@@ -12473,10 +12347,8 @@ defineFunction({
|
|
|
12473
12347
|
defineFunction({
|
|
12474
12348
|
type: "lap",
|
|
12475
12349
|
names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
allowedInText: true
|
|
12479
|
-
},
|
|
12350
|
+
numArgs: 1,
|
|
12351
|
+
allowedInText: true,
|
|
12480
12352
|
handler: (_ref, args) => {
|
|
12481
12353
|
let {
|
|
12482
12354
|
parser,
|
|
@@ -12540,11 +12412,9 @@ defineFunction({
|
|
|
12540
12412
|
defineFunction({
|
|
12541
12413
|
type: "styling",
|
|
12542
12414
|
names: ["\\(", "$"],
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
allowedInMath: false
|
|
12547
|
-
},
|
|
12415
|
+
numArgs: 0,
|
|
12416
|
+
allowedInText: true,
|
|
12417
|
+
allowedInMath: false,
|
|
12548
12418
|
handler(_ref, args) {
|
|
12549
12419
|
let {
|
|
12550
12420
|
funcName,
|
|
@@ -12571,11 +12441,9 @@ defineFunction({
|
|
|
12571
12441
|
type: "text",
|
|
12572
12442
|
// Doesn't matter what this is.
|
|
12573
12443
|
names: ["\\)", "\\]"],
|
|
12574
|
-
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
allowedInMath: false
|
|
12578
|
-
},
|
|
12444
|
+
numArgs: 0,
|
|
12445
|
+
allowedInText: true,
|
|
12446
|
+
allowedInMath: false,
|
|
12579
12447
|
handler(context, args) {
|
|
12580
12448
|
throw new src_ParseError("Mismatched " + context.funcName);
|
|
12581
12449
|
}
|
|
@@ -12603,10 +12471,8 @@ const chooseMathStyle = (group, options) => {
|
|
|
12603
12471
|
defineFunction({
|
|
12604
12472
|
type: "mathchoice",
|
|
12605
12473
|
names: ["\\mathchoice"],
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
primitive: true
|
|
12609
|
-
},
|
|
12474
|
+
numArgs: 4,
|
|
12475
|
+
primitive: true,
|
|
12610
12476
|
handler: (_ref, args) => {
|
|
12611
12477
|
let {
|
|
12612
12478
|
parser
|
|
@@ -12922,9 +12788,7 @@ const singleCharBigOps = {
|
|
|
12922
12788
|
defineFunction({
|
|
12923
12789
|
type: "op",
|
|
12924
12790
|
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
|
-
},
|
|
12791
|
+
numArgs: 0,
|
|
12928
12792
|
handler: (_ref, args) => {
|
|
12929
12793
|
let {
|
|
12930
12794
|
parser,
|
|
@@ -12946,16 +12810,11 @@ defineFunction({
|
|
|
12946
12810
|
htmlBuilder: op_htmlBuilder,
|
|
12947
12811
|
mathmlBuilder: op_mathmlBuilder
|
|
12948
12812
|
});
|
|
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
12813
|
defineFunction({
|
|
12953
12814
|
type: "op",
|
|
12954
12815
|
names: ["\\mathop"],
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
primitive: true
|
|
12958
|
-
},
|
|
12816
|
+
numArgs: 1,
|
|
12817
|
+
primitive: true,
|
|
12959
12818
|
handler: (_ref2, args) => {
|
|
12960
12819
|
let {
|
|
12961
12820
|
parser
|
|
@@ -12969,9 +12828,7 @@ defineFunction({
|
|
|
12969
12828
|
symbol: false,
|
|
12970
12829
|
body: ordargument(body)
|
|
12971
12830
|
};
|
|
12972
|
-
}
|
|
12973
|
-
htmlBuilder: op_htmlBuilder,
|
|
12974
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12831
|
+
}
|
|
12975
12832
|
});
|
|
12976
12833
|
|
|
12977
12834
|
// There are 2 flags for operators; whether they produce limits in
|
|
@@ -12990,9 +12847,7 @@ const singleCharIntegrals = {
|
|
|
12990
12847
|
defineFunction({
|
|
12991
12848
|
type: "op",
|
|
12992
12849
|
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
|
-
},
|
|
12850
|
+
numArgs: 0,
|
|
12996
12851
|
handler(_ref3) {
|
|
12997
12852
|
let {
|
|
12998
12853
|
parser,
|
|
@@ -13006,18 +12861,14 @@ defineFunction({
|
|
|
13006
12861
|
symbol: false,
|
|
13007
12862
|
name: funcName
|
|
13008
12863
|
};
|
|
13009
|
-
}
|
|
13010
|
-
htmlBuilder: op_htmlBuilder,
|
|
13011
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12864
|
+
}
|
|
13012
12865
|
});
|
|
13013
12866
|
|
|
13014
12867
|
// Limits, not symbols
|
|
13015
12868
|
defineFunction({
|
|
13016
12869
|
type: "op",
|
|
13017
12870
|
names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"],
|
|
13018
|
-
|
|
13019
|
-
numArgs: 0
|
|
13020
|
-
},
|
|
12871
|
+
numArgs: 0,
|
|
13021
12872
|
handler(_ref4) {
|
|
13022
12873
|
let {
|
|
13023
12874
|
parser,
|
|
@@ -13031,19 +12882,15 @@ defineFunction({
|
|
|
13031
12882
|
symbol: false,
|
|
13032
12883
|
name: funcName
|
|
13033
12884
|
};
|
|
13034
|
-
}
|
|
13035
|
-
htmlBuilder: op_htmlBuilder,
|
|
13036
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12885
|
+
}
|
|
13037
12886
|
});
|
|
13038
12887
|
|
|
13039
12888
|
// No limits, symbols
|
|
13040
12889
|
defineFunction({
|
|
13041
12890
|
type: "op",
|
|
13042
12891
|
names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"],
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
allowedInArgument: true
|
|
13046
|
-
},
|
|
12892
|
+
numArgs: 0,
|
|
12893
|
+
allowedInArgument: true,
|
|
13047
12894
|
handler(_ref5) {
|
|
13048
12895
|
let {
|
|
13049
12896
|
parser,
|
|
@@ -13061,9 +12908,7 @@ defineFunction({
|
|
|
13061
12908
|
symbol: true,
|
|
13062
12909
|
name: fName
|
|
13063
12910
|
};
|
|
13064
|
-
}
|
|
13065
|
-
htmlBuilder: op_htmlBuilder,
|
|
13066
|
-
mathmlBuilder: op_mathmlBuilder
|
|
12911
|
+
}
|
|
13067
12912
|
});
|
|
13068
12913
|
;// ./src/functions/operatorname.ts
|
|
13069
12914
|
|
|
@@ -13188,9 +13033,7 @@ const operatorname_mathmlBuilder = (group, options) => {
|
|
|
13188
13033
|
defineFunction({
|
|
13189
13034
|
type: "operatorname",
|
|
13190
13035
|
names: ["\\operatorname@", "\\operatornamewithlimits"],
|
|
13191
|
-
|
|
13192
|
-
numArgs: 1
|
|
13193
|
-
},
|
|
13036
|
+
numArgs: 1,
|
|
13194
13037
|
handler: (_ref, args) => {
|
|
13195
13038
|
let {
|
|
13196
13039
|
parser,
|
|
@@ -13236,9 +13079,7 @@ defineFunctionBuilders({
|
|
|
13236
13079
|
defineFunction({
|
|
13237
13080
|
type: "overline",
|
|
13238
13081
|
names: ["\\overline"],
|
|
13239
|
-
|
|
13240
|
-
numArgs: 1
|
|
13241
|
-
},
|
|
13082
|
+
numArgs: 1,
|
|
13242
13083
|
handler(_ref, args) {
|
|
13243
13084
|
let {
|
|
13244
13085
|
parser
|
|
@@ -13297,10 +13138,8 @@ defineFunction({
|
|
|
13297
13138
|
defineFunction({
|
|
13298
13139
|
type: "phantom",
|
|
13299
13140
|
names: ["\\phantom"],
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
allowedInText: true
|
|
13303
|
-
},
|
|
13141
|
+
numArgs: 1,
|
|
13142
|
+
allowedInText: true,
|
|
13304
13143
|
handler: (_ref, args) => {
|
|
13305
13144
|
let {
|
|
13306
13145
|
parser
|
|
@@ -13328,10 +13167,8 @@ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
|
|
|
13328
13167
|
defineFunction({
|
|
13329
13168
|
type: "vphantom",
|
|
13330
13169
|
names: ["\\vphantom"],
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
allowedInText: true
|
|
13334
|
-
},
|
|
13170
|
+
numArgs: 1,
|
|
13171
|
+
allowedInText: true,
|
|
13335
13172
|
handler: (_ref2, args) => {
|
|
13336
13173
|
let {
|
|
13337
13174
|
parser
|
|
@@ -13369,11 +13206,9 @@ defineFunction({
|
|
|
13369
13206
|
defineFunction({
|
|
13370
13207
|
type: "raisebox",
|
|
13371
13208
|
names: ["\\raisebox"],
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
allowedInText: true
|
|
13376
|
-
},
|
|
13209
|
+
numArgs: 2,
|
|
13210
|
+
argTypes: ["size", "hbox"],
|
|
13211
|
+
allowedInText: true,
|
|
13377
13212
|
handler(_ref, args) {
|
|
13378
13213
|
let {
|
|
13379
13214
|
parser
|
|
@@ -13411,11 +13246,9 @@ defineFunction({
|
|
|
13411
13246
|
defineFunction({
|
|
13412
13247
|
type: "internal",
|
|
13413
13248
|
names: ["\\relax"],
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
allowedInArgument: true
|
|
13418
|
-
},
|
|
13249
|
+
numArgs: 0,
|
|
13250
|
+
allowedInText: true,
|
|
13251
|
+
allowedInArgument: true,
|
|
13419
13252
|
handler(_ref) {
|
|
13420
13253
|
let {
|
|
13421
13254
|
parser
|
|
@@ -13435,13 +13268,11 @@ defineFunction({
|
|
|
13435
13268
|
defineFunction({
|
|
13436
13269
|
type: "rule",
|
|
13437
13270
|
names: ["\\rule"],
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
argTypes: ["size", "size", "size"]
|
|
13444
|
-
},
|
|
13271
|
+
numArgs: 2,
|
|
13272
|
+
numOptionalArgs: 1,
|
|
13273
|
+
allowedInText: true,
|
|
13274
|
+
allowedInMath: true,
|
|
13275
|
+
argTypes: ["size", "size", "size"],
|
|
13445
13276
|
handler(_ref, args, optArgs) {
|
|
13446
13277
|
let {
|
|
13447
13278
|
parser
|
|
@@ -13540,10 +13371,8 @@ const sizing_htmlBuilder = (group, options) => {
|
|
|
13540
13371
|
defineFunction({
|
|
13541
13372
|
type: "sizing",
|
|
13542
13373
|
names: sizeFuncs,
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
allowedInText: true
|
|
13546
|
-
},
|
|
13374
|
+
numArgs: 0,
|
|
13375
|
+
allowedInText: true,
|
|
13547
13376
|
handler: (_ref, args) => {
|
|
13548
13377
|
let {
|
|
13549
13378
|
breakOnTokenText,
|
|
@@ -13585,11 +13414,9 @@ defineFunction({
|
|
|
13585
13414
|
defineFunction({
|
|
13586
13415
|
type: "smash",
|
|
13587
13416
|
names: ["\\smash"],
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
allowedInText: true
|
|
13592
|
-
},
|
|
13417
|
+
numArgs: 1,
|
|
13418
|
+
numOptionalArgs: 1,
|
|
13419
|
+
allowedInText: true,
|
|
13593
13420
|
handler: (_ref, args, optArgs) => {
|
|
13594
13421
|
let {
|
|
13595
13422
|
parser
|
|
@@ -13696,10 +13523,8 @@ defineFunction({
|
|
|
13696
13523
|
defineFunction({
|
|
13697
13524
|
type: "sqrt",
|
|
13698
13525
|
names: ["\\sqrt"],
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
numOptionalArgs: 1
|
|
13702
|
-
},
|
|
13526
|
+
numArgs: 1,
|
|
13527
|
+
numOptionalArgs: 1,
|
|
13703
13528
|
handler(_ref, args, optArgs) {
|
|
13704
13529
|
let {
|
|
13705
13530
|
parser
|
|
@@ -13829,11 +13654,9 @@ function isStyleStr(s) {
|
|
|
13829
13654
|
defineFunction({
|
|
13830
13655
|
type: "styling",
|
|
13831
13656
|
names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"],
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
primitive: true
|
|
13836
|
-
},
|
|
13657
|
+
numArgs: 0,
|
|
13658
|
+
allowedInText: true,
|
|
13659
|
+
primitive: true,
|
|
13837
13660
|
handler(_ref, args) {
|
|
13838
13661
|
let {
|
|
13839
13662
|
breakOnTokenText,
|
|
@@ -14171,7 +13994,7 @@ const defaultVariant = {
|
|
|
14171
13994
|
defineFunctionBuilders({
|
|
14172
13995
|
type: "mathord",
|
|
14173
13996
|
htmlBuilder(group, options) {
|
|
14174
|
-
return makeOrd(group, options
|
|
13997
|
+
return makeOrd(group, options);
|
|
14175
13998
|
},
|
|
14176
13999
|
mathmlBuilder(group, options) {
|
|
14177
14000
|
const node = new MathNode("mi", [makeText(group.text, group.mode, options)]);
|
|
@@ -14185,7 +14008,7 @@ defineFunctionBuilders({
|
|
|
14185
14008
|
defineFunctionBuilders({
|
|
14186
14009
|
type: "textord",
|
|
14187
14010
|
htmlBuilder(group, options) {
|
|
14188
|
-
return makeOrd(group, options
|
|
14011
|
+
return makeOrd(group, options);
|
|
14189
14012
|
},
|
|
14190
14013
|
mathmlBuilder(group, options) {
|
|
14191
14014
|
const text = makeText(group.text, group.mode, options);
|
|
@@ -14246,7 +14069,7 @@ defineFunctionBuilders({
|
|
|
14246
14069
|
// things has an entry in the symbols table, so these will be turned
|
|
14247
14070
|
// into appropriate outputs.
|
|
14248
14071
|
if (group.mode === "text") {
|
|
14249
|
-
const ord = makeOrd(group, options
|
|
14072
|
+
const ord = makeOrd(group, options);
|
|
14250
14073
|
ord.classes.push(className);
|
|
14251
14074
|
return ord;
|
|
14252
14075
|
} else {
|
|
@@ -14341,12 +14164,10 @@ defineFunction({
|
|
|
14341
14164
|
"\\textbf", "\\textmd",
|
|
14342
14165
|
// Font Shapes
|
|
14343
14166
|
"\\textit", "\\textup", "\\emph"],
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
allowedInText: true
|
|
14349
|
-
},
|
|
14167
|
+
numArgs: 1,
|
|
14168
|
+
argTypes: ["text"],
|
|
14169
|
+
allowedInArgument: true,
|
|
14170
|
+
allowedInText: true,
|
|
14350
14171
|
handler(_ref, args) {
|
|
14351
14172
|
let {
|
|
14352
14173
|
parser,
|
|
@@ -14379,10 +14200,8 @@ defineFunction({
|
|
|
14379
14200
|
defineFunction({
|
|
14380
14201
|
type: "underline",
|
|
14381
14202
|
names: ["\\underline"],
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
allowedInText: true
|
|
14385
|
-
},
|
|
14203
|
+
numArgs: 1,
|
|
14204
|
+
allowedInText: true,
|
|
14386
14205
|
handler(_ref, args) {
|
|
14387
14206
|
let {
|
|
14388
14207
|
parser
|
|
@@ -14442,12 +14261,10 @@ defineFunction({
|
|
|
14442
14261
|
defineFunction({
|
|
14443
14262
|
type: "vcenter",
|
|
14444
14263
|
names: ["\\vcenter"],
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
allowedInText: false
|
|
14450
|
-
},
|
|
14264
|
+
numArgs: 1,
|
|
14265
|
+
argTypes: ["original"],
|
|
14266
|
+
// In LaTeX, \vcenter can act only on a box.
|
|
14267
|
+
allowedInText: false,
|
|
14451
14268
|
handler(_ref, args) {
|
|
14452
14269
|
let {
|
|
14453
14270
|
parser
|
|
@@ -14488,10 +14305,8 @@ defineFunction({
|
|
|
14488
14305
|
defineFunction({
|
|
14489
14306
|
type: "verb",
|
|
14490
14307
|
names: ["\\verb"],
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
allowedInText: true
|
|
14494
|
-
},
|
|
14308
|
+
numArgs: 0,
|
|
14309
|
+
allowedInText: true,
|
|
14495
14310
|
handler(context, args, optArgs) {
|
|
14496
14311
|
// \verb and \verb* are dealt with directly in Parser.js.
|
|
14497
14312
|
// If we end up here, it's because of a failure to match the two delimiters
|
|
@@ -17077,7 +16892,7 @@ class Parser {
|
|
|
17077
16892
|
const base = this.parseGroup("atom", breakOnTokenText);
|
|
17078
16893
|
|
|
17079
16894
|
// Internal nodes (e.g. \relax) cannot support super/subscripts.
|
|
17080
|
-
// Instead we will pick up super/subscripts with blank base next round.
|
|
16895
|
+
// Instead, we will pick up super/subscripts with blank base next round.
|
|
17081
16896
|
if ((base == null ? void 0 : base.type) === "internal") {
|
|
17082
16897
|
return base;
|
|
17083
16898
|
}
|
|
@@ -17086,9 +16901,6 @@ class Parser {
|
|
|
17086
16901
|
if (this.mode === "text") {
|
|
17087
16902
|
return base;
|
|
17088
16903
|
}
|
|
17089
|
-
|
|
17090
|
-
// Note that base may be empty (i.e. null) at this point.
|
|
17091
|
-
|
|
17092
16904
|
let superscript;
|
|
17093
16905
|
let subscript;
|
|
17094
16906
|
while (true) {
|
|
@@ -17100,8 +16912,7 @@ class Parser {
|
|
|
17100
16912
|
if (lex.text === "\\limits" || lex.text === "\\nolimits") {
|
|
17101
16913
|
// We got a limit control
|
|
17102
16914
|
if (base && base.type === "op") {
|
|
17103
|
-
|
|
17104
|
-
base.limits = limits;
|
|
16915
|
+
base.limits = lex.text === "\\limits";
|
|
17105
16916
|
base.alwaysHandleSupSub = true;
|
|
17106
16917
|
} else if (base && base.type === "operatorname") {
|
|
17107
16918
|
if (base.alwaysHandleSupSub) {
|
|
@@ -17198,15 +17009,28 @@ class Parser {
|
|
|
17198
17009
|
|
|
17199
17010
|
// Base must be set if superscript or subscript are set per logic above,
|
|
17200
17011
|
// 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
|
|
17012
|
+
if (superscript && subscript) {
|
|
17203
17013
|
return {
|
|
17204
17014
|
type: "supsub",
|
|
17205
17015
|
mode: this.mode,
|
|
17206
|
-
base
|
|
17016
|
+
base,
|
|
17207
17017
|
sup: superscript,
|
|
17208
17018
|
sub: subscript
|
|
17209
17019
|
};
|
|
17020
|
+
} else if (superscript) {
|
|
17021
|
+
return {
|
|
17022
|
+
type: "supsub",
|
|
17023
|
+
mode: this.mode,
|
|
17024
|
+
base,
|
|
17025
|
+
sup: superscript
|
|
17026
|
+
};
|
|
17027
|
+
} else if (subscript) {
|
|
17028
|
+
return {
|
|
17029
|
+
type: "supsub",
|
|
17030
|
+
mode: this.mode,
|
|
17031
|
+
base,
|
|
17032
|
+
sub: subscript
|
|
17033
|
+
};
|
|
17210
17034
|
} else {
|
|
17211
17035
|
// Otherwise return the original body
|
|
17212
17036
|
return base;
|
|
@@ -17228,8 +17052,10 @@ class Parser {
|
|
|
17228
17052
|
|
|
17229
17053
|
if (name && name !== "atom" && !funcData.allowedInArgument) {
|
|
17230
17054
|
throw new src_ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token);
|
|
17055
|
+
// Treat undefined allowedInText as false.
|
|
17231
17056
|
} else if (this.mode === "text" && !funcData.allowedInText) {
|
|
17232
17057
|
throw new src_ParseError("Can't use function '" + func + "' in text mode", token);
|
|
17058
|
+
// Treat undefined allowedInMath as true.
|
|
17233
17059
|
} else if (this.mode === "math" && funcData.allowedInMath === false) {
|
|
17234
17060
|
throw new src_ParseError("Can't use function '" + func + "' in math mode", token);
|
|
17235
17061
|
}
|
|
@@ -17264,7 +17090,9 @@ class Parser {
|
|
|
17264
17090
|
parseArguments(func,
|
|
17265
17091
|
// Should look like "\name" or "\begin{name}".
|
|
17266
17092
|
funcData) {
|
|
17267
|
-
|
|
17093
|
+
var _funcData$numOptional;
|
|
17094
|
+
const numOptionalArgs = (_funcData$numOptional = funcData.numOptionalArgs) != null ? _funcData$numOptional : 0;
|
|
17095
|
+
const totalArgs = funcData.numArgs + numOptionalArgs;
|
|
17268
17096
|
if (totalArgs === 0) {
|
|
17269
17097
|
return {
|
|
17270
17098
|
args: [],
|
|
@@ -17274,8 +17102,9 @@ class Parser {
|
|
|
17274
17102
|
const args = [];
|
|
17275
17103
|
const optArgs = [];
|
|
17276
17104
|
for (let i = 0; i < totalArgs; i++) {
|
|
17277
|
-
|
|
17278
|
-
|
|
17105
|
+
var _funcData$argTypes;
|
|
17106
|
+
let argType = (_funcData$argTypes = funcData.argTypes) == null ? void 0 : _funcData$argTypes[i];
|
|
17107
|
+
const isOptional = i < numOptionalArgs;
|
|
17279
17108
|
if ("primitive" in funcData && funcData.primitive && argType == null ||
|
|
17280
17109
|
// \sqrt expands into primitive if optional argument doesn't exist
|
|
17281
17110
|
funcData.type === "sqrt" && i === 1 && optArgs[0] == null) {
|
|
@@ -17328,7 +17157,7 @@ class Parser {
|
|
|
17328
17157
|
}
|
|
17329
17158
|
case "raw":
|
|
17330
17159
|
{
|
|
17331
|
-
const token = this.parseStringGroup(
|
|
17160
|
+
const token = this.parseStringGroup(optional);
|
|
17332
17161
|
return token != null ? {
|
|
17333
17162
|
type: "raw",
|
|
17334
17163
|
mode: "text",
|
|
@@ -17347,7 +17176,6 @@ class Parser {
|
|
|
17347
17176
|
return group;
|
|
17348
17177
|
}
|
|
17349
17178
|
case "original":
|
|
17350
|
-
case null:
|
|
17351
17179
|
case undefined:
|
|
17352
17180
|
return this.parseArgumentGroup(optional);
|
|
17353
17181
|
default:
|
|
@@ -17368,9 +17196,7 @@ class Parser {
|
|
|
17368
17196
|
* Parses a group, essentially returning the string formed by the
|
|
17369
17197
|
* brace-enclosed tokens plus some position information.
|
|
17370
17198
|
*/
|
|
17371
|
-
parseStringGroup(
|
|
17372
|
-
// Used to describe the mode in error messages.
|
|
17373
|
-
optional) {
|
|
17199
|
+
parseStringGroup(optional) {
|
|
17374
17200
|
const argToken = this.gullet.scanArgument(optional);
|
|
17375
17201
|
if (argToken == null) {
|
|
17376
17202
|
return null;
|
|
@@ -17412,7 +17238,7 @@ class Parser {
|
|
|
17412
17238
|
* Parses a color description.
|
|
17413
17239
|
*/
|
|
17414
17240
|
parseColorGroup(optional) {
|
|
17415
|
-
const res = this.parseStringGroup(
|
|
17241
|
+
const res = this.parseStringGroup(optional);
|
|
17416
17242
|
if (res == null) {
|
|
17417
17243
|
return null;
|
|
17418
17244
|
}
|
|
@@ -17445,7 +17271,7 @@ class Parser {
|
|
|
17445
17271
|
if (!optional && this.gullet.future().text !== "{") {
|
|
17446
17272
|
res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size");
|
|
17447
17273
|
} else {
|
|
17448
|
-
res = this.parseStringGroup(
|
|
17274
|
+
res = this.parseStringGroup(optional);
|
|
17449
17275
|
}
|
|
17450
17276
|
if (!res) {
|
|
17451
17277
|
return null;
|
|
@@ -17484,7 +17310,7 @@ class Parser {
|
|
|
17484
17310
|
parseUrlGroup(optional) {
|
|
17485
17311
|
this.gullet.lexer.setCatcode("%", 13); // active character
|
|
17486
17312
|
this.gullet.lexer.setCatcode("~", 12); // other character
|
|
17487
|
-
const res = this.parseStringGroup(
|
|
17313
|
+
const res = this.parseStringGroup(optional);
|
|
17488
17314
|
this.gullet.lexer.setCatcode("%", 14); // comment character
|
|
17489
17315
|
this.gullet.lexer.setCatcode("~", 13); // active character
|
|
17490
17316
|
if (res == null) {
|
|
@@ -17759,11 +17585,6 @@ class Parser {
|
|
|
17759
17585
|
}
|
|
17760
17586
|
Parser.endOfExpression = new Set(["}", "\\endgroup", "\\end", "\\right", "&"]);
|
|
17761
17587
|
;// ./src/parseTree.ts
|
|
17762
|
-
/**
|
|
17763
|
-
* Provides a single function for parsing an expression using a Parser
|
|
17764
|
-
* TODO(emily): Remove this
|
|
17765
|
-
*/
|
|
17766
|
-
|
|
17767
17588
|
|
|
17768
17589
|
|
|
17769
17590
|
|
|
@@ -17899,7 +17720,7 @@ const renderToHTMLTree = function (expression, options) {
|
|
|
17899
17720
|
return renderError(error, expression, settings);
|
|
17900
17721
|
}
|
|
17901
17722
|
};
|
|
17902
|
-
const version = "0.
|
|
17723
|
+
const version = "0.17.0";
|
|
17903
17724
|
const __domTree = {
|
|
17904
17725
|
Span: Span,
|
|
17905
17726
|
Anchor: Anchor,
|