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/src/functions/math.ts
CHANGED
|
@@ -5,11 +5,10 @@ import ParseError from "../ParseError";
|
|
|
5
5
|
defineFunction({
|
|
6
6
|
type: "styling",
|
|
7
7
|
names: ["\\(", "$"],
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
8
|
+
numArgs: 0,
|
|
9
|
+
allowedInText: true,
|
|
10
|
+
allowedInMath: false,
|
|
11
|
+
|
|
13
12
|
handler({funcName, parser}, args) {
|
|
14
13
|
const outerMode = parser.mode;
|
|
15
14
|
parser.switchMode("math");
|
|
@@ -31,11 +30,10 @@ defineFunction({
|
|
|
31
30
|
defineFunction({
|
|
32
31
|
type: "text", // Doesn't matter what this is.
|
|
33
32
|
names: ["\\)", "\\]"],
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
33
|
+
numArgs: 0,
|
|
34
|
+
allowedInText: true,
|
|
35
|
+
allowedInMath: false,
|
|
36
|
+
|
|
39
37
|
handler(context, args) {
|
|
40
38
|
throw new ParseError(`Mismatched ${context.funcName}`);
|
|
41
39
|
},
|
|
@@ -6,7 +6,7 @@ import * as html from "../buildHTML";
|
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
|
|
8
8
|
import type Options from "../Options";
|
|
9
|
-
import type {ParseNode} from "../
|
|
9
|
+
import type {ParseNode} from "../types/nodes";
|
|
10
10
|
|
|
11
11
|
const chooseMathStyle = (group: ParseNode<"mathchoice">, options: Options) => {
|
|
12
12
|
switch (options.style.size) {
|
|
@@ -21,10 +21,9 @@ const chooseMathStyle = (group: ParseNode<"mathchoice">, options: Options) => {
|
|
|
21
21
|
defineFunction({
|
|
22
22
|
type: "mathchoice",
|
|
23
23
|
names: ["\\mathchoice"],
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
24
|
+
numArgs: 4,
|
|
25
|
+
primitive: true,
|
|
26
|
+
|
|
28
27
|
handler: ({parser}, args) => {
|
|
29
28
|
return {
|
|
30
29
|
type: "mathchoice",
|
|
@@ -35,6 +34,7 @@ defineFunction({
|
|
|
35
34
|
scriptscript: ordargument(args[3]),
|
|
36
35
|
};
|
|
37
36
|
},
|
|
37
|
+
|
|
38
38
|
htmlBuilder: (group, options) => {
|
|
39
39
|
const body = chooseMathStyle(group, options);
|
|
40
40
|
const elements = html.buildExpression(
|
package/src/functions/mclass.ts
CHANGED
|
@@ -2,13 +2,13 @@ import defineFunction, {ordargument} from "../defineFunction";
|
|
|
2
2
|
import {makeSpan} from "../buildCommon";
|
|
3
3
|
import {isCharacterBox} from "../utils";
|
|
4
4
|
import {MathNode} from "../mathMLTree";
|
|
5
|
-
import type {AnyParseNode} from "../
|
|
5
|
+
import type {AnyParseNode, ParseNode} from "../types/nodes";
|
|
6
6
|
|
|
7
7
|
import * as html from "../buildHTML";
|
|
8
8
|
import * as mml from "../buildMathML";
|
|
9
9
|
|
|
10
10
|
import type Options from "../Options";
|
|
11
|
-
import type {
|
|
11
|
+
import type {MathClass, Slice5} from "../types";
|
|
12
12
|
|
|
13
13
|
function htmlBuilder(group: ParseNode<"mclass">, options: Options) {
|
|
14
14
|
const elements = html.buildExpression(group.body, options, true);
|
|
@@ -47,9 +47,6 @@ function mathmlBuilder(group: ParseNode<"mclass">, options: Options) {
|
|
|
47
47
|
} else if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
48
48
|
node.attributes.lspace = "0em";
|
|
49
49
|
node.attributes.rspace = "0em";
|
|
50
|
-
} else if (group.mclass === "minner") {
|
|
51
|
-
node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
|
|
52
|
-
node.attributes.width = "+0.1111em";
|
|
53
50
|
}
|
|
54
51
|
// MathML <mo> default space is 5/18 em, so <mrel> needs no action.
|
|
55
52
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
|
|
@@ -64,32 +61,31 @@ defineFunction({
|
|
|
64
61
|
"\\mathord", "\\mathbin", "\\mathrel", "\\mathopen",
|
|
65
62
|
"\\mathclose", "\\mathpunct", "\\mathinner",
|
|
66
63
|
],
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
primitive: true,
|
|
70
|
-
},
|
|
64
|
+
numArgs: 1,
|
|
65
|
+
primitive: true,
|
|
71
66
|
handler({parser, funcName}, args) {
|
|
72
67
|
const body = args[0];
|
|
73
68
|
return {
|
|
74
69
|
type: "mclass",
|
|
75
70
|
mode: parser.mode,
|
|
76
|
-
mclass:
|
|
71
|
+
mclass: `m${funcName.slice(5) as Slice5<typeof funcName>}`,
|
|
77
72
|
body: ordargument(body),
|
|
78
73
|
isCharacterBox: isCharacterBox(body),
|
|
79
74
|
};
|
|
80
75
|
},
|
|
76
|
+
|
|
81
77
|
htmlBuilder,
|
|
82
78
|
mathmlBuilder,
|
|
83
79
|
});
|
|
84
80
|
|
|
85
|
-
export const binrelClass = (arg: AnyParseNode):
|
|
81
|
+
export const binrelClass = (arg: AnyParseNode): MathClass => {
|
|
86
82
|
// \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
|
|
87
83
|
// (by rendering separately and with {}s before and after, and measuring
|
|
88
84
|
// the change in spacing). We'll do roughly the same by detecting the
|
|
89
85
|
// atom type directly.
|
|
90
86
|
const atom = (arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg);
|
|
91
87
|
if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
|
|
92
|
-
return
|
|
88
|
+
return `m${atom.family}`;
|
|
93
89
|
} else {
|
|
94
90
|
return "mord";
|
|
95
91
|
}
|
|
@@ -100,9 +96,8 @@ export const binrelClass = (arg: AnyParseNode): string => {
|
|
|
100
96
|
defineFunction({
|
|
101
97
|
type: "mclass",
|
|
102
98
|
names: ["\\@binrel"],
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
99
|
+
numArgs: 2,
|
|
100
|
+
|
|
106
101
|
handler({parser}, args) {
|
|
107
102
|
return {
|
|
108
103
|
type: "mclass",
|
|
@@ -118,14 +113,13 @@ defineFunction({
|
|
|
118
113
|
defineFunction({
|
|
119
114
|
type: "mclass",
|
|
120
115
|
names: ["\\stackrel", "\\overset", "\\underset"],
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
},
|
|
116
|
+
numArgs: 2,
|
|
117
|
+
|
|
124
118
|
handler({parser, funcName}, args) {
|
|
125
119
|
const baseArg = args[1];
|
|
126
120
|
const shiftedArg = args[0];
|
|
127
121
|
|
|
128
|
-
let mclass;
|
|
122
|
+
let mclass: MathClass;
|
|
129
123
|
if (funcName !== "\\stackrel") {
|
|
130
124
|
// LaTeX applies \binrel spacing to \overset and \underset.
|
|
131
125
|
mclass = binrelClass(baseArg);
|
|
@@ -144,13 +138,9 @@ defineFunction({
|
|
|
144
138
|
body: ordargument(baseArg),
|
|
145
139
|
};
|
|
146
140
|
|
|
147
|
-
const supsub: ParseNode<"supsub"> =
|
|
148
|
-
type: "supsub",
|
|
149
|
-
mode: shiftedArg.mode,
|
|
150
|
-
base: baseOp,
|
|
151
|
-
sup: funcName === "\\underset" ? null : shiftedArg,
|
|
152
|
-
sub: funcName === "\\underset" ? shiftedArg : null,
|
|
153
|
-
};
|
|
141
|
+
const supsub: ParseNode<"supsub"> = funcName === "\\underset"
|
|
142
|
+
? {type: "supsub", mode: shiftedArg.mode, base: baseOp, sub: shiftedArg}
|
|
143
|
+
: {type: "supsub", mode: shiftedArg.mode, base: baseOp, sup: shiftedArg};
|
|
154
144
|
|
|
155
145
|
return {
|
|
156
146
|
type: "mclass",
|
|
@@ -160,6 +150,4 @@ defineFunction({
|
|
|
160
150
|
isCharacterBox: isCharacterBox(supsub),
|
|
161
151
|
};
|
|
162
152
|
},
|
|
163
|
-
htmlBuilder,
|
|
164
|
-
mathmlBuilder,
|
|
165
153
|
});
|
package/src/functions/op.ts
CHANGED
|
@@ -12,7 +12,7 @@ import * as html from "../buildHTML";
|
|
|
12
12
|
import * as mml from "../buildMathML";
|
|
13
13
|
|
|
14
14
|
import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
|
|
15
|
-
import type {ParseNode} from "../
|
|
15
|
+
import type {ParseNode} from "../types/nodes";
|
|
16
16
|
|
|
17
17
|
// Most operators have a large successor symbol, but these don't.
|
|
18
18
|
const noSuccessor = new Set([
|
|
@@ -200,11 +200,10 @@ defineFunction({
|
|
|
200
200
|
"\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00",
|
|
201
201
|
"\u2a01", "\u2a02", "\u2a04", "\u2a06",
|
|
202
202
|
],
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
},
|
|
203
|
+
numArgs: 0,
|
|
204
|
+
|
|
206
205
|
handler: ({parser, funcName}, args) => {
|
|
207
|
-
let fName = funcName;
|
|
206
|
+
let fName: string = funcName;
|
|
208
207
|
if (fName.length === 1) {
|
|
209
208
|
fName = singleCharBigOps[fName];
|
|
210
209
|
}
|
|
@@ -217,19 +216,17 @@ defineFunction({
|
|
|
217
216
|
name: fName,
|
|
218
217
|
};
|
|
219
218
|
},
|
|
219
|
+
|
|
220
220
|
htmlBuilder,
|
|
221
221
|
mathmlBuilder,
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
// Note: calling defineFunction with a type that's already been defined only
|
|
225
|
-
// works because the same htmlBuilder and mathmlBuilder are being used.
|
|
226
224
|
defineFunction({
|
|
227
225
|
type: "op",
|
|
228
226
|
names: ["\\mathop"],
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
227
|
+
numArgs: 1,
|
|
228
|
+
primitive: true,
|
|
229
|
+
|
|
233
230
|
handler: ({parser}, args) => {
|
|
234
231
|
const body = args[0];
|
|
235
232
|
return {
|
|
@@ -241,8 +238,6 @@ defineFunction({
|
|
|
241
238
|
body: ordargument(body),
|
|
242
239
|
};
|
|
243
240
|
},
|
|
244
|
-
htmlBuilder,
|
|
245
|
-
mathmlBuilder,
|
|
246
241
|
});
|
|
247
242
|
|
|
248
243
|
// There are 2 flags for operators; whether they produce limits in
|
|
@@ -267,9 +262,8 @@ defineFunction({
|
|
|
267
262
|
"\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin",
|
|
268
263
|
"\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th",
|
|
269
264
|
],
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
},
|
|
265
|
+
numArgs: 0,
|
|
266
|
+
|
|
273
267
|
handler({parser, funcName}) {
|
|
274
268
|
return {
|
|
275
269
|
type: "op",
|
|
@@ -280,8 +274,6 @@ defineFunction({
|
|
|
280
274
|
name: funcName,
|
|
281
275
|
};
|
|
282
276
|
},
|
|
283
|
-
htmlBuilder,
|
|
284
|
-
mathmlBuilder,
|
|
285
277
|
});
|
|
286
278
|
|
|
287
279
|
// Limits, not symbols
|
|
@@ -290,9 +282,8 @@ defineFunction({
|
|
|
290
282
|
names: [
|
|
291
283
|
"\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup",
|
|
292
284
|
],
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
},
|
|
285
|
+
numArgs: 0,
|
|
286
|
+
|
|
296
287
|
handler({parser, funcName}) {
|
|
297
288
|
return {
|
|
298
289
|
type: "op",
|
|
@@ -303,8 +294,6 @@ defineFunction({
|
|
|
303
294
|
name: funcName,
|
|
304
295
|
};
|
|
305
296
|
},
|
|
306
|
-
htmlBuilder,
|
|
307
|
-
mathmlBuilder,
|
|
308
297
|
});
|
|
309
298
|
|
|
310
299
|
// No limits, symbols
|
|
@@ -314,12 +303,11 @@ defineFunction({
|
|
|
314
303
|
"\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint",
|
|
315
304
|
"\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230",
|
|
316
305
|
],
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
306
|
+
numArgs: 0,
|
|
307
|
+
allowedInArgument: true,
|
|
308
|
+
|
|
321
309
|
handler({parser, funcName}) {
|
|
322
|
-
let fName = funcName;
|
|
310
|
+
let fName: string = funcName;
|
|
323
311
|
if (fName.length === 1) {
|
|
324
312
|
fName = singleCharIntegrals[fName];
|
|
325
313
|
}
|
|
@@ -332,6 +320,4 @@ defineFunction({
|
|
|
332
320
|
name: fName,
|
|
333
321
|
};
|
|
334
322
|
},
|
|
335
|
-
htmlBuilder,
|
|
336
|
-
mathmlBuilder,
|
|
337
323
|
});
|
|
@@ -10,7 +10,7 @@ import * as html from "../buildHTML";
|
|
|
10
10
|
import * as mml from "../buildMathML";
|
|
11
11
|
|
|
12
12
|
import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
|
|
13
|
-
import type {AnyParseNode, ParseNode} from "../
|
|
13
|
+
import type {AnyParseNode, ParseNode} from "../types/nodes";
|
|
14
14
|
|
|
15
15
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only
|
|
16
16
|
// "operatorname", but also "supsub" since \operatorname* can
|
|
@@ -139,9 +139,8 @@ const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => {
|
|
|
139
139
|
defineFunction({
|
|
140
140
|
type: "operatorname",
|
|
141
141
|
names: ["\\operatorname@", "\\operatornamewithlimits"],
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
},
|
|
142
|
+
numArgs: 1,
|
|
143
|
+
|
|
145
144
|
handler: ({parser, funcName}, args) => {
|
|
146
145
|
const body = args[0];
|
|
147
146
|
return {
|
|
@@ -153,6 +152,7 @@ defineFunction({
|
|
|
153
152
|
parentIsSupSub: false,
|
|
154
153
|
};
|
|
155
154
|
},
|
|
155
|
+
|
|
156
156
|
htmlBuilder,
|
|
157
157
|
mathmlBuilder,
|
|
158
158
|
});
|
|
@@ -8,9 +8,8 @@ import * as mml from "../buildMathML";
|
|
|
8
8
|
defineFunction({
|
|
9
9
|
type: "overline",
|
|
10
10
|
names: ["\\overline"],
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
11
|
+
numArgs: 1,
|
|
12
|
+
|
|
14
13
|
handler({parser}, args) {
|
|
15
14
|
const body = args[0];
|
|
16
15
|
return {
|
|
@@ -19,6 +18,7 @@ defineFunction({
|
|
|
19
18
|
body,
|
|
20
19
|
};
|
|
21
20
|
},
|
|
21
|
+
|
|
22
22
|
htmlBuilder(group, options) {
|
|
23
23
|
// Overlines are handled in the TeXbook pg 443, Rule 9.
|
|
24
24
|
|
package/src/functions/phantom.ts
CHANGED
|
@@ -9,10 +9,9 @@ import * as mml from "../buildMathML";
|
|
|
9
9
|
defineFunction({
|
|
10
10
|
type: "phantom",
|
|
11
11
|
names: ["\\phantom"],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
12
|
+
numArgs: 1,
|
|
13
|
+
allowedInText: true,
|
|
14
|
+
|
|
16
15
|
handler: ({parser}, args) => {
|
|
17
16
|
const body = args[0];
|
|
18
17
|
return {
|
|
@@ -21,6 +20,7 @@ defineFunction({
|
|
|
21
20
|
body: ordargument(body),
|
|
22
21
|
};
|
|
23
22
|
},
|
|
23
|
+
|
|
24
24
|
htmlBuilder: (group, options) => {
|
|
25
25
|
const elements = html.buildExpression(
|
|
26
26
|
group.body,
|
|
@@ -43,10 +43,9 @@ defineMacro("\\hphantom", "\\smash{\\phantom{#1}}");
|
|
|
43
43
|
defineFunction({
|
|
44
44
|
type: "vphantom",
|
|
45
45
|
names: ["\\vphantom"],
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
46
|
+
numArgs: 1,
|
|
47
|
+
allowedInText: true,
|
|
48
|
+
|
|
50
49
|
handler: ({parser}, args) => {
|
|
51
50
|
const body = args[0];
|
|
52
51
|
return {
|
|
@@ -55,6 +54,7 @@ defineFunction({
|
|
|
55
54
|
body,
|
|
56
55
|
};
|
|
57
56
|
},
|
|
57
|
+
|
|
58
58
|
htmlBuilder: (group, options) => {
|
|
59
59
|
const inner = makeSpan(
|
|
60
60
|
["inner"],
|
package/src/functions/pmb.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as html from "../buildHTML";
|
|
|
5
5
|
import * as mml from "../buildMathML";
|
|
6
6
|
import {binrelClass} from "./mclass";
|
|
7
7
|
|
|
8
|
-
import type {ParseNode} from "../
|
|
8
|
+
import type {ParseNode} from "../types/nodes";
|
|
9
9
|
|
|
10
10
|
// \pmb is a simulation of bold font.
|
|
11
11
|
// The version of \pmb in ambsy.sty works by typesetting three copies
|
|
@@ -15,10 +15,9 @@ import type {ParseNode} from "../parseNode";
|
|
|
15
15
|
defineFunction({
|
|
16
16
|
type: "pmb",
|
|
17
17
|
names: ["\\pmb"],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
18
|
+
numArgs: 1,
|
|
19
|
+
allowedInText: true,
|
|
20
|
+
|
|
22
21
|
handler({parser}, args) {
|
|
23
22
|
return {
|
|
24
23
|
type: "pmb",
|
|
@@ -27,6 +26,7 @@ defineFunction({
|
|
|
27
26
|
body: ordargument(args[0]),
|
|
28
27
|
};
|
|
29
28
|
},
|
|
29
|
+
|
|
30
30
|
htmlBuilder(group: ParseNode<"pmb">, options) {
|
|
31
31
|
const elements = html.buildExpression(group.body, options, true);
|
|
32
32
|
const node = makeSpan([group.mclass], elements, options);
|
|
@@ -11,11 +11,10 @@ import * as mml from "../buildMathML";
|
|
|
11
11
|
defineFunction({
|
|
12
12
|
type: "raisebox",
|
|
13
13
|
names: ["\\raisebox"],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
14
|
+
numArgs: 2,
|
|
15
|
+
argTypes: ["size", "hbox"],
|
|
16
|
+
allowedInText: true,
|
|
17
|
+
|
|
19
18
|
handler({parser}, args) {
|
|
20
19
|
const amount = assertNodeType(args[0], "size").value;
|
|
21
20
|
const body = args[1];
|
|
@@ -26,6 +25,7 @@ defineFunction({
|
|
|
26
25
|
body,
|
|
27
26
|
};
|
|
28
27
|
},
|
|
28
|
+
|
|
29
29
|
htmlBuilder(group, options) {
|
|
30
30
|
const body = html.buildGroup(group.body, options);
|
|
31
31
|
const dy = calculateSize(group.dy, options);
|
package/src/functions/relax.ts
CHANGED
|
@@ -3,11 +3,10 @@ import defineFunction from "../defineFunction";
|
|
|
3
3
|
defineFunction({
|
|
4
4
|
type: "internal",
|
|
5
5
|
names: ["\\relax"],
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
6
|
+
numArgs: 0,
|
|
7
|
+
allowedInText: true,
|
|
8
|
+
allowedInArgument: true,
|
|
9
|
+
|
|
11
10
|
handler({parser}) {
|
|
12
11
|
return {
|
|
13
12
|
type: "internal",
|
package/src/functions/rule.ts
CHANGED
|
@@ -7,13 +7,12 @@ import {calculateSize, makeEm} from "../units";
|
|
|
7
7
|
defineFunction({
|
|
8
8
|
type: "rule",
|
|
9
9
|
names: ["\\rule"],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
10
|
+
numArgs: 2,
|
|
11
|
+
numOptionalArgs: 1,
|
|
12
|
+
allowedInText: true,
|
|
13
|
+
allowedInMath: true,
|
|
14
|
+
argTypes: ["size", "size", "size"],
|
|
15
|
+
|
|
17
16
|
handler({parser}, args, optArgs) {
|
|
18
17
|
const shift = optArgs[0];
|
|
19
18
|
const width = assertNodeType(args[0], "size");
|
|
@@ -26,6 +25,7 @@ defineFunction({
|
|
|
26
25
|
height: height.value,
|
|
27
26
|
};
|
|
28
27
|
},
|
|
28
|
+
|
|
29
29
|
htmlBuilder(group, options) {
|
|
30
30
|
// Make an empty span for the rule
|
|
31
31
|
const rule = makeSpan(["mord", "rule"], [], options);
|
package/src/functions/sizing.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as html from "../buildHTML";
|
|
|
7
7
|
import * as mml from "../buildMathML";
|
|
8
8
|
|
|
9
9
|
import type Options from "../Options";
|
|
10
|
-
import type {AnyParseNode} from "../
|
|
10
|
+
import type {AnyParseNode} from "../types/nodes";
|
|
11
11
|
import type {HtmlBuilder} from "../defineFunction";
|
|
12
12
|
import type {documentFragment as HtmlDocumentFragment} from "../domTree";
|
|
13
13
|
|
|
@@ -43,7 +43,7 @@ export function sizingGroup(
|
|
|
43
43
|
const sizeFuncs = [
|
|
44
44
|
"\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small",
|
|
45
45
|
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge",
|
|
46
|
-
];
|
|
46
|
+
] as const;
|
|
47
47
|
|
|
48
48
|
export const htmlBuilder: HtmlBuilder<"sizing"> = (group, options) => {
|
|
49
49
|
// Handle sizing operators like \Huge. Real TeX doesn't actually allow
|
|
@@ -56,10 +56,9 @@ export const htmlBuilder: HtmlBuilder<"sizing"> = (group, options) => {
|
|
|
56
56
|
defineFunction({
|
|
57
57
|
type: "sizing",
|
|
58
58
|
names: sizeFuncs,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
59
|
+
numArgs: 0,
|
|
60
|
+
allowedInText: true,
|
|
61
|
+
|
|
63
62
|
handler: ({breakOnTokenText, funcName, parser}, args) => {
|
|
64
63
|
const body = parser.parseExpression(false, breakOnTokenText);
|
|
65
64
|
|
|
@@ -71,6 +70,7 @@ defineFunction({
|
|
|
71
70
|
body,
|
|
72
71
|
};
|
|
73
72
|
},
|
|
73
|
+
|
|
74
74
|
htmlBuilder,
|
|
75
75
|
mathmlBuilder: (group, options) => {
|
|
76
76
|
const newOptions = options.havingSize(group.size);
|
package/src/functions/smash.ts
CHANGED
|
@@ -10,11 +10,10 @@ import * as mml from "../buildMathML";
|
|
|
10
10
|
defineFunction({
|
|
11
11
|
type: "smash",
|
|
12
12
|
names: ["\\smash"],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
13
|
+
numArgs: 1,
|
|
14
|
+
numOptionalArgs: 1,
|
|
15
|
+
allowedInText: true,
|
|
16
|
+
|
|
18
17
|
handler: ({parser}, args, optArgs) => {
|
|
19
18
|
let smashHeight = false;
|
|
20
19
|
let smashDepth = false;
|
|
@@ -51,6 +50,7 @@ defineFunction({
|
|
|
51
50
|
smashDepth,
|
|
52
51
|
};
|
|
53
52
|
},
|
|
53
|
+
|
|
54
54
|
htmlBuilder: (group, options) => {
|
|
55
55
|
const node = makeSpan(
|
|
56
56
|
[], [html.buildGroup(group.body, options)]);
|
package/src/functions/sqrt.ts
CHANGED
|
@@ -11,10 +11,9 @@ import * as mml from "../buildMathML";
|
|
|
11
11
|
defineFunction({
|
|
12
12
|
type: "sqrt",
|
|
13
13
|
names: ["\\sqrt"],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
14
|
+
numArgs: 1,
|
|
15
|
+
numOptionalArgs: 1,
|
|
16
|
+
|
|
18
17
|
handler({parser}, args, optArgs) {
|
|
19
18
|
const index = optArgs[0];
|
|
20
19
|
const body = args[0];
|
|
@@ -25,6 +24,7 @@ defineFunction({
|
|
|
25
24
|
index,
|
|
26
25
|
};
|
|
27
26
|
},
|
|
27
|
+
|
|
28
28
|
htmlBuilder(group, options) {
|
|
29
29
|
// Square roots are handled in the TeXbook pg. 443, Rule 11.
|
|
30
30
|
|
package/src/functions/styling.ts
CHANGED
|
@@ -23,11 +23,10 @@ defineFunction({
|
|
|
23
23
|
"\\displaystyle", "\\textstyle", "\\scriptstyle",
|
|
24
24
|
"\\scriptscriptstyle",
|
|
25
25
|
],
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
26
|
+
numArgs: 0,
|
|
27
|
+
allowedInText: true,
|
|
28
|
+
primitive: true,
|
|
29
|
+
|
|
31
30
|
handler({breakOnTokenText, funcName, parser}, args) {
|
|
32
31
|
// parse out the implicit body
|
|
33
32
|
const body = parser.parseExpression(true, breakOnTokenText);
|
|
@@ -47,6 +46,7 @@ defineFunction({
|
|
|
47
46
|
body,
|
|
48
47
|
};
|
|
49
48
|
},
|
|
49
|
+
|
|
50
50
|
htmlBuilder(group, options) {
|
|
51
51
|
// Style changes are handled in the TeXbook on pg. 442, Rule 3.
|
|
52
52
|
const newStyle = styleMap[group.style];
|
package/src/functions/supsub.ts
CHANGED
|
@@ -14,7 +14,7 @@ import * as op from "./op";
|
|
|
14
14
|
import * as operatorname from "./operatorname";
|
|
15
15
|
|
|
16
16
|
import type Options from "../Options";
|
|
17
|
-
import type {ParseNode} from "../
|
|
17
|
+
import type {ParseNode} from "../types/nodes";
|
|
18
18
|
import type {HtmlBuilder} from "../defineFunction";
|
|
19
19
|
import type {MathNodeType} from "../mathMLTree";
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ import {MathNode} from "../mathMLTree";
|
|
|
4
4
|
|
|
5
5
|
import * as mml from "../buildMathML";
|
|
6
6
|
|
|
7
|
-
import type {ParseNode} from "../
|
|
7
|
+
import type {ParseNode} from "../types/nodes";
|
|
8
8
|
|
|
9
9
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
|
10
10
|
// src/symbols.js.
|
|
@@ -18,7 +18,7 @@ const defaultVariant: Record<string, string> = {
|
|
|
18
18
|
defineFunctionBuilders({
|
|
19
19
|
type: "mathord",
|
|
20
20
|
htmlBuilder(group, options) {
|
|
21
|
-
return makeOrd(group, options
|
|
21
|
+
return makeOrd(group, options);
|
|
22
22
|
},
|
|
23
23
|
mathmlBuilder(group: ParseNode<"mathord">, options) {
|
|
24
24
|
const node = new MathNode(
|
|
@@ -36,7 +36,7 @@ defineFunctionBuilders({
|
|
|
36
36
|
defineFunctionBuilders({
|
|
37
37
|
type: "textord",
|
|
38
38
|
htmlBuilder(group, options) {
|
|
39
|
-
return makeOrd(group, options
|
|
39
|
+
return makeOrd(group, options);
|
|
40
40
|
},
|
|
41
41
|
mathmlBuilder(group: ParseNode<"textord">, options) {
|
|
42
42
|
const text = mml.makeText(group.text, group.mode, options);
|
|
@@ -37,7 +37,7 @@ defineFunctionBuilders({
|
|
|
37
37
|
// things has an entry in the symbols table, so these will be turned
|
|
38
38
|
// into appropriate outputs.
|
|
39
39
|
if (group.mode === "text") {
|
|
40
|
-
const ord = makeOrd(group, options
|
|
40
|
+
const ord = makeOrd(group, options);
|
|
41
41
|
ord.classes.push(className);
|
|
42
42
|
return ord;
|
|
43
43
|
} else {
|