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.
Files changed (81) hide show
  1. package/README.md +5 -10
  2. package/contrib/copy-tex/README.md +2 -2
  3. package/contrib/mathtex-script-type/README.md +5 -5
  4. package/contrib/mhchem/README.md +1 -1
  5. package/contrib/render-a11y-string/render-a11y-string.ts +1 -1
  6. package/dist/README.md +5 -10
  7. package/dist/katex-swap.css +1 -1
  8. package/dist/katex-swap.min.css +1 -1
  9. package/dist/katex.css +1 -1
  10. package/dist/katex.js +255 -434
  11. package/dist/katex.min.css +1 -1
  12. package/dist/katex.min.js +1 -1
  13. package/dist/katex.mjs +243 -415
  14. package/katex.ts +1 -1
  15. package/package.json +1 -2
  16. package/src/MacroExpander.ts +1 -1
  17. package/src/Namespace.ts +1 -1
  18. package/src/ParseError.ts +1 -1
  19. package/src/Parser.ts +42 -48
  20. package/src/Settings.ts +1 -1
  21. package/src/SourceLocation.ts +2 -2
  22. package/src/buildCommon.ts +6 -6
  23. package/src/buildHTML.ts +4 -5
  24. package/src/buildMathML.ts +1 -1
  25. package/src/buildTree.ts +1 -1
  26. package/src/defineEnvironment.ts +1 -2
  27. package/src/defineFunction.ts +104 -112
  28. package/src/environments/array.ts +8 -12
  29. package/src/environments/cd.ts +8 -8
  30. package/src/functions/accent.ts +10 -13
  31. package/src/functions/accentunder.ts +4 -4
  32. package/src/functions/arrow.ts +5 -5
  33. package/src/functions/char.ts +3 -4
  34. package/src/functions/color.ts +10 -13
  35. package/src/functions/cr.ts +3 -5
  36. package/src/functions/def.ts +15 -19
  37. package/src/functions/delimsizing.ts +23 -23
  38. package/src/functions/enclose.ts +22 -33
  39. package/src/functions/environment.ts +4 -5
  40. package/src/functions/font.ts +15 -27
  41. package/src/functions/genfrac.ts +19 -23
  42. package/src/functions/hbox.ts +6 -6
  43. package/src/functions/horizBrace.ts +4 -4
  44. package/src/functions/href.ts +10 -11
  45. package/src/functions/html.ts +5 -5
  46. package/src/functions/htmlmathml.ts +5 -5
  47. package/src/functions/includegraphics.ts +7 -7
  48. package/src/functions/kern.ts +6 -6
  49. package/src/functions/lap.ts +4 -4
  50. package/src/functions/math.ts +8 -10
  51. package/src/functions/mathchoice.ts +5 -5
  52. package/src/functions/mclass.ts +16 -28
  53. package/src/functions/op.ts +16 -30
  54. package/src/functions/operatorname.ts +4 -4
  55. package/src/functions/overline.ts +3 -3
  56. package/src/functions/phantom.ts +8 -8
  57. package/src/functions/pmb.ts +5 -5
  58. package/src/functions/raisebox.ts +5 -5
  59. package/src/functions/relax.ts +4 -5
  60. package/src/functions/rule.ts +7 -7
  61. package/src/functions/sizing.ts +6 -6
  62. package/src/functions/smash.ts +5 -5
  63. package/src/functions/sqrt.ts +4 -4
  64. package/src/functions/styling.ts +5 -5
  65. package/src/functions/supsub.ts +1 -1
  66. package/src/functions/symbolsOrd.ts +3 -3
  67. package/src/functions/symbolsSpacing.ts +1 -1
  68. package/src/functions/text.ts +7 -7
  69. package/src/functions/underline.ts +4 -4
  70. package/src/functions/utils/assembleSupSub.ts +1 -1
  71. package/src/functions/vcenter.ts +5 -5
  72. package/src/functions/verb.ts +5 -5
  73. package/src/parseNode.ts +2 -476
  74. package/src/parseTree.ts +1 -6
  75. package/src/spacingData.ts +2 -1
  76. package/src/stretchy.ts +1 -1
  77. package/src/svgGeometry.ts +2 -2
  78. package/src/types/index.ts +12 -0
  79. package/src/types/nodes.ts +456 -0
  80. package/src/units.ts +1 -2
  81. package/src/utils.ts +1 -1
@@ -10,15 +10,13 @@ import * as html from "../buildHTML";
10
10
  import * as mml from "../buildMathML";
11
11
 
12
12
  import type Options from "../Options";
13
- import type {AnyParseNode, ParseNode, SymbolParseNode} from "../parseNode";
14
13
  import type {FunctionContext} from "../defineFunction";
15
14
  import type {HtmlDomNode} from "../domTree";
15
+ import type {DelimiterSize, MathClass} from "../types";
16
+ import type {AnyParseNode, ParseNode, SymbolParseNode} from "../types/nodes";
16
17
 
17
18
  // Extra data needed for the delimiter handler down below
18
- const delimiterSizes: Record<string, {
19
- mclass: "mopen" | "mclose" | "mrel" | "mord";
20
- size: 1 | 2 | 3 | 4;
21
- }> = {
19
+ const delimiterSizes = {
22
20
  "\\bigl" : {mclass: "mopen", size: 1},
23
21
  "\\Bigl" : {mclass: "mopen", size: 2},
24
22
  "\\biggl": {mclass: "mopen", size: 3},
@@ -35,7 +33,10 @@ const delimiterSizes: Record<string, {
35
33
  "\\Big" : {mclass: "mord", size: 2},
36
34
  "\\bigg" : {mclass: "mord", size: 3},
37
35
  "\\Bigg" : {mclass: "mord", size: 4},
38
- };
36
+ } as const satisfies Record<string, {
37
+ mclass: MathClass;
38
+ size: DelimiterSize;
39
+ }>;
39
40
 
40
41
  const delimiters = new Set([
41
42
  "(", "\\lparen", ")", "\\rparen",
@@ -92,10 +93,9 @@ defineFunction({
92
93
  "\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
93
94
  "\\big", "\\Big", "\\bigg", "\\Bigg",
94
95
  ],
95
- props: {
96
- numArgs: 1,
97
- argTypes: ["primitive"],
98
- },
96
+ numArgs: 1,
97
+ argTypes: ["primitive"],
98
+
99
99
  handler: (context, args) => {
100
100
  const delim = checkDelimiter(args[0], context);
101
101
 
@@ -107,6 +107,7 @@ defineFunction({
107
107
  delim: delim.text,
108
108
  };
109
109
  },
110
+
110
111
  htmlBuilder: (group, options) => {
111
112
  if (group.delim === ".") {
112
113
  // Empty delimiters still count as elements, even though they don't
@@ -157,10 +158,9 @@ function assertParsed(group: ParseNode<"leftright">) {
157
158
  defineFunction({
158
159
  type: "leftright-right",
159
160
  names: ["\\right"],
160
- props: {
161
- numArgs: 1,
162
- primitive: true,
163
- },
161
+ numArgs: 1,
162
+ primitive: true,
163
+
164
164
  handler: (context, args) => {
165
165
  // \left case below triggers parsing of \right in
166
166
  // `const right = parser.parseFunction();`
@@ -174,7 +174,7 @@ defineFunction({
174
174
  type: "leftright-right",
175
175
  mode: context.parser.mode,
176
176
  delim: checkDelimiter(args[0], context).text,
177
- color: color as string | null | undefined, // undefined if not set via \color
177
+ color, // undefined if not set via \color
178
178
  };
179
179
  },
180
180
  });
@@ -183,10 +183,9 @@ defineFunction({
183
183
  defineFunction({
184
184
  type: "leftright",
185
185
  names: ["\\left"],
186
- props: {
187
- numArgs: 1,
188
- primitive: true,
189
- },
186
+ numArgs: 1,
187
+ primitive: true,
188
+
190
189
  handler: (context, args) => {
191
190
  const delim = checkDelimiter(args[0], context);
192
191
 
@@ -208,6 +207,7 @@ defineFunction({
208
207
  rightColor: right.color,
209
208
  };
210
209
  },
210
+
211
211
  htmlBuilder: (group, options) => {
212
212
  assertParsed(group);
213
213
  // Build the inner expression
@@ -312,10 +312,9 @@ defineFunction({
312
312
  defineFunction({
313
313
  type: "middle",
314
314
  names: ["\\middle"],
315
- props: {
316
- numArgs: 1,
317
- primitive: true,
318
- },
315
+ numArgs: 1,
316
+ primitive: true,
317
+
319
318
  handler: (context, args) => {
320
319
  const delim = checkDelimiter(args[0], context);
321
320
  if (!context.parser.leftrightDepth) {
@@ -328,6 +327,7 @@ defineFunction({
328
327
  delim: delim.text,
329
328
  };
330
329
  },
330
+
331
331
  htmlBuilder: (group, options) => {
332
332
  let middleDelim;
333
333
  if (group.delim === ".") {
@@ -220,11 +220,10 @@ const mathmlBuilder: MathMLBuilder<"enclose"> = (group, options) => {
220
220
  defineFunction({
221
221
  type: "enclose",
222
222
  names: ["\\colorbox"],
223
- props: {
224
- numArgs: 2,
225
- allowedInText: true,
226
- argTypes: ["color", "hbox"],
227
- },
223
+ numArgs: 2,
224
+ allowedInText: true,
225
+ argTypes: ["color", "hbox"],
226
+
228
227
  handler({parser, funcName}, args, optArgs) {
229
228
  const color = assertNodeType(args[0], "color-token").color;
230
229
  const body = args[1];
@@ -236,6 +235,7 @@ defineFunction({
236
235
  body,
237
236
  };
238
237
  },
238
+
239
239
  htmlBuilder,
240
240
  mathmlBuilder,
241
241
  });
@@ -243,11 +243,10 @@ defineFunction({
243
243
  defineFunction({
244
244
  type: "enclose",
245
245
  names: ["\\fcolorbox"],
246
- props: {
247
- numArgs: 3,
248
- allowedInText: true,
249
- argTypes: ["color", "color", "hbox"],
250
- },
246
+ numArgs: 3,
247
+ allowedInText: true,
248
+ argTypes: ["color", "color", "hbox"],
249
+
251
250
  handler({parser, funcName}, args, optArgs) {
252
251
  const borderColor = assertNodeType(args[0], "color-token").color;
253
252
  const backgroundColor = assertNodeType(args[1], "color-token").color;
@@ -261,18 +260,15 @@ defineFunction({
261
260
  body,
262
261
  };
263
262
  },
264
- htmlBuilder,
265
- mathmlBuilder,
266
263
  });
267
264
 
268
265
  defineFunction({
269
266
  type: "enclose",
270
267
  names: ["\\fbox"],
271
- props: {
272
- numArgs: 1,
273
- argTypes: ["hbox"],
274
- allowedInText: true,
275
- },
268
+ numArgs: 1,
269
+ argTypes: ["hbox"],
270
+ allowedInText: true,
271
+
276
272
  handler({parser}, args) {
277
273
  return {
278
274
  type: "enclose",
@@ -286,9 +282,8 @@ defineFunction({
286
282
  defineFunction({
287
283
  type: "enclose",
288
284
  names: ["\\cancel", "\\bcancel", "\\xcancel", "\\phase"],
289
- props: {
290
- numArgs: 1,
291
- },
285
+ numArgs: 1,
286
+
292
287
  handler({parser, funcName}, args) {
293
288
  const body = args[0];
294
289
  return {
@@ -298,17 +293,14 @@ defineFunction({
298
293
  body,
299
294
  };
300
295
  },
301
- htmlBuilder,
302
- mathmlBuilder,
303
296
  });
304
297
 
305
298
  defineFunction({
306
299
  type: "enclose",
307
300
  names: ["\\sout"],
308
- props: {
309
- numArgs: 1,
310
- allowedInText: true,
311
- },
301
+ numArgs: 1,
302
+ allowedInText: true,
303
+
312
304
  handler({parser, funcName}, args) {
313
305
  if (parser.mode === "math") {
314
306
  parser.settings.reportNonstrict("mathVsSout",
@@ -322,18 +314,15 @@ defineFunction({
322
314
  body,
323
315
  };
324
316
  },
325
- htmlBuilder,
326
- mathmlBuilder,
327
317
  });
328
318
 
329
319
  defineFunction({
330
320
  type: "enclose",
331
321
  names: ["\\angl"],
332
- props: {
333
- numArgs: 1,
334
- argTypes: ["hbox"],
335
- allowedInText: false,
336
- },
322
+ numArgs: 1,
323
+ argTypes: ["hbox"],
324
+ allowedInText: false,
325
+
337
326
  handler({parser}, args) {
338
327
  return {
339
328
  type: "enclose",
@@ -3,17 +3,16 @@ import ParseError from "../ParseError";
3
3
  import {assertNodeType} from "../parseNode";
4
4
  import environments from "../environments";
5
5
 
6
- import type {ParseNode} from "../parseNode";
6
+ import type {ParseNode} from "../types/nodes";
7
7
 
8
8
  // Environment delimiters. HTML/MathML rendering is defined in the corresponding
9
9
  // defineEnvironment definitions.
10
10
  defineFunction({
11
11
  type: "environment",
12
12
  names: ["\\begin", "\\end"],
13
- props: {
14
- numArgs: 1,
15
- argTypes: ["text"],
16
- },
13
+ numArgs: 1,
14
+ argTypes: ["text"],
15
+
17
16
  handler({parser, funcName}, args) {
18
17
  const nameGroup = args[0];
19
18
  if (nameGroup.type !== "ordgroup") {
@@ -8,7 +8,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 {ParseNode} from "../parseNode";
11
+ import type {ParseNode} from "../types/nodes";
12
12
  import type {Slice1} from "../types";
13
13
 
14
14
  const htmlBuilder = (group: ParseNode<"font">, options: Options) => {
@@ -29,12 +29,6 @@ const fontAliases = {
29
29
  "\\frak": "\\mathfrak",
30
30
  } as const;
31
31
 
32
- type OldFontCommands = "\\rm" | "\\sf" | "\\tt" | "\\bf" | "\\it" | "\\cal";
33
- type FontCommands =
34
- "\\mathrm" | "\\mathit" | "\\mathbf" | "\\mathnormal" | "\\mathsfit" |
35
- "\\mathbb" | "\\mathcal" | "\\mathfrak" | "\\mathscr" | "\\mathsf" |
36
- "\\mathtt";
37
-
38
32
  defineFunction({
39
33
  type: "font",
40
34
  names: [
@@ -47,24 +41,23 @@ defineFunction({
47
41
 
48
42
  // aliases, except \bm defined below
49
43
  "\\Bbb", "\\bold", "\\frak",
50
- ] satisfies (FontCommands | keyof typeof fontAliases)[],
51
- props: {
52
- numArgs: 1,
53
- allowedInArgument: true,
54
- },
44
+ ],
45
+ numArgs: 1,
46
+ allowedInArgument: true,
47
+
55
48
  handler: ({parser, funcName}, args) => {
56
49
  const body = normalizeArgument(args[0]);
57
- let func = funcName;
58
- if (func in fontAliases) {
59
- func = fontAliases[func as keyof typeof fontAliases];
60
- }
50
+ const func = funcName in fontAliases
51
+ ? fontAliases[funcName as keyof typeof fontAliases]
52
+ : funcName as Exclude<typeof funcName, keyof typeof fontAliases>;
61
53
  return {
62
54
  type: "font",
63
55
  mode: parser.mode,
64
- font: func.slice(1) as Slice1<FontCommands>,
56
+ font: func.slice(1) as Slice1<typeof func>,
65
57
  body,
66
58
  };
67
59
  },
60
+
68
61
  htmlBuilder,
69
62
  mathmlBuilder,
70
63
  });
@@ -72,9 +65,8 @@ defineFunction({
72
65
  defineFunction({
73
66
  type: "mclass",
74
67
  names: ["\\boldsymbol", "\\bm"],
75
- props: {
76
- numArgs: 1,
77
- },
68
+ numArgs: 1,
69
+
78
70
  handler: ({parser}, args) => {
79
71
  const body = args[0];
80
72
  // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
@@ -100,10 +92,8 @@ defineFunction({
100
92
  defineFunction({
101
93
  type: "font",
102
94
  names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
103
- props: {
104
- numArgs: 0,
105
- allowedInText: true,
106
- },
95
+ numArgs: 0,
96
+ allowedInText: true,
107
97
  handler: ({parser, funcName, breakOnTokenText}, args) => {
108
98
  const {mode} = parser;
109
99
  const body = parser.parseExpression(true, breakOnTokenText);
@@ -111,7 +101,7 @@ defineFunction({
111
101
  return {
112
102
  type: "font",
113
103
  mode: mode,
114
- font: `math${funcName.slice(1) as Slice1<OldFontCommands>}`,
104
+ font: `math${funcName.slice(1) as Slice1<typeof funcName>}` as const,
115
105
  body: {
116
106
  type: "ordgroup",
117
107
  mode: parser.mode,
@@ -119,6 +109,4 @@ defineFunction({
119
109
  },
120
110
  };
121
111
  },
122
- htmlBuilder,
123
- mathmlBuilder,
124
112
  });
@@ -2,7 +2,7 @@ import defineFunction, {normalizeArgument} from "../defineFunction";
2
2
  import {makeLineSpan, makeSpan, makeVList} from "../buildCommon";
3
3
  import {makeCustomSizedDelim} from "../delimiter";
4
4
  import {MathNode, TextNode} from "../mathMLTree";
5
- import type {ParseNode} from "../parseNode";
5
+ import type {ParseNode} from "../types/nodes";
6
6
  import Style from "../Style";
7
7
  import {assertNodeType} from "../parseNode";
8
8
  import * as html from "../buildHTML";
@@ -239,10 +239,9 @@ defineFunction({
239
239
  "\\\\atopfrac", // can’t be entered directly
240
240
  "\\\\bracefrac", "\\\\brackfrac", // ditto
241
241
  ],
242
- props: {
243
- numArgs: 2,
244
- allowedInArgument: true,
245
- },
242
+ numArgs: 2,
243
+ allowedInArgument: true,
244
+
246
245
  handler: ({parser, funcName}, args) => {
247
246
  const numer = args[0];
248
247
  const denom = args[1];
@@ -302,6 +301,7 @@ defineFunction({
302
301
  }, style);
303
302
  },
304
303
 
304
+
305
305
  htmlBuilder,
306
306
  mathmlBuilder,
307
307
  });
@@ -311,10 +311,9 @@ defineFunction({
311
311
  defineFunction({
312
312
  type: "infix",
313
313
  names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"],
314
- props: {
315
- numArgs: 0,
316
- infix: true,
317
- },
314
+ numArgs: 0,
315
+ infix: true,
316
+
318
317
  handler({parser, funcName, token}) {
319
318
  let replaceWith;
320
319
  switch (funcName) {
@@ -359,11 +358,10 @@ const delimFromValue = function(delimString: string): string | null {
359
358
  defineFunction({
360
359
  type: "genfrac",
361
360
  names: ["\\genfrac"],
362
- props: {
363
- numArgs: 6,
364
- allowedInArgument: true,
365
- argTypes: ["math", "math", "size", "text", "math", "math"],
366
- },
361
+ numArgs: 6,
362
+ allowedInArgument: true,
363
+ argTypes: ["math", "math", "size", "text", "math", "math"],
364
+
367
365
  handler({parser}, args) {
368
366
  const numer = args[4];
369
367
  const denom = args[5];
@@ -420,11 +418,10 @@ defineFunction({
420
418
  defineFunction({
421
419
  type: "infix",
422
420
  names: ["\\above"],
423
- props: {
424
- numArgs: 1,
425
- argTypes: ["size"],
426
- infix: true,
427
- },
421
+ numArgs: 1,
422
+ argTypes: ["size"],
423
+ infix: true,
424
+
428
425
  handler({parser, funcName, token}, args) {
429
426
  return {
430
427
  type: "infix",
@@ -439,10 +436,9 @@ defineFunction({
439
436
  defineFunction({
440
437
  type: "genfrac",
441
438
  names: ["\\\\abovefrac"],
442
- props: {
443
- numArgs: 3,
444
- argTypes: ["math", "size", "math"],
445
- },
439
+ numArgs: 3,
440
+ argTypes: ["math", "size", "math"],
441
+
446
442
  handler: ({parser, funcName}, args) => {
447
443
  const numer = args[0];
448
444
  const barSize = assertNodeType(args[1], "infix").size;
@@ -13,12 +13,11 @@ import * as mml from "../buildMathML";
13
13
  defineFunction({
14
14
  type: "hbox",
15
15
  names: ["\\hbox"],
16
- props: {
17
- numArgs: 1,
18
- argTypes: ["text"],
19
- allowedInText: true,
20
- primitive: true,
21
- },
16
+ numArgs: 1,
17
+ argTypes: ["text"],
18
+ allowedInText: true,
19
+ primitive: true,
20
+
22
21
  handler({parser}, args) {
23
22
  return {
24
23
  type: "hbox",
@@ -26,6 +25,7 @@ defineFunction({
26
25
  body: ordargument(args[0]),
27
26
  };
28
27
  },
28
+
29
29
  htmlBuilder(group, options) {
30
30
  const elements = html.buildExpression(group.body, options.withFont(''), false);
31
31
  return makeFragment(elements);
@@ -9,7 +9,7 @@ import * as html from "../buildHTML";
9
9
  import * as mml from "../buildMathML";
10
10
 
11
11
  import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
12
- import type {ParseNode} from "../parseNode";
12
+ import type {ParseNode} from "../types/nodes";
13
13
 
14
14
  // NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but
15
15
  // also "supsub" since an over/underbrace can affect super/subscripting.
@@ -117,9 +117,8 @@ const mathmlBuilder: MathMLBuilder<"horizBrace"> = (group, options) => {
117
117
  defineFunction({
118
118
  type: "horizBrace",
119
119
  names: ["\\overbrace", "\\underbrace", "\\overbracket", "\\underbracket"],
120
- props: {
121
- numArgs: 1,
122
- },
120
+ numArgs: 1,
121
+
123
122
  handler({parser, funcName}, args) {
124
123
  return {
125
124
  type: "horizBrace",
@@ -129,6 +128,7 @@ defineFunction({
129
128
  base: args[0],
130
129
  };
131
130
  },
131
+
132
132
  htmlBuilder,
133
133
  mathmlBuilder,
134
134
  });
@@ -5,16 +5,15 @@ import {MathNode} from "../mathMLTree";
5
5
 
6
6
  import * as html from "../buildHTML";
7
7
  import * as mml from "../buildMathML";
8
- import type {ParseNode} from "../parseNode";
8
+ import type {ParseNode} from "../types/nodes";
9
9
 
10
10
  defineFunction({
11
11
  type: "href",
12
12
  names: ["\\href"],
13
- props: {
14
- numArgs: 2,
15
- argTypes: ["url", "original"],
16
- allowedInText: true,
17
- },
13
+ numArgs: 2,
14
+ argTypes: ["url", "original"],
15
+ allowedInText: true,
16
+
18
17
  handler: ({parser}, args) => {
19
18
  const body = args[1];
20
19
  const href = assertNodeType(args[0], "url").url;
@@ -33,6 +32,7 @@ defineFunction({
33
32
  body: ordargument(body),
34
33
  };
35
34
  },
35
+
36
36
  htmlBuilder: (group, options) => {
37
37
  const elements = html.buildExpression(group.body, options, false);
38
38
  return makeAnchor(group.href, [], elements, options);
@@ -50,11 +50,10 @@ defineFunction({
50
50
  defineFunction({
51
51
  type: "href",
52
52
  names: ["\\url"],
53
- props: {
54
- numArgs: 1,
55
- argTypes: ["url"],
56
- allowedInText: true,
57
- },
53
+ numArgs: 1,
54
+ argTypes: ["url"],
55
+ allowedInText: true,
56
+
58
57
  handler: ({parser}, args) => {
59
58
  const href = assertNodeType(args[0], "url").url;
60
59
 
@@ -10,11 +10,10 @@ import type {AnyTrustContext} from "../Settings";
10
10
  defineFunction({
11
11
  type: "html",
12
12
  names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"],
13
- props: {
14
- numArgs: 2,
15
- argTypes: ["raw", "original"],
16
- allowedInText: true,
17
- },
13
+ numArgs: 2,
14
+ argTypes: ["raw", "original"],
15
+ allowedInText: true,
16
+
18
17
  handler: ({parser, funcName, token}, args) => {
19
18
  const value = assertNodeType(args[0], "raw").string;
20
19
  const body = args[1];
@@ -83,6 +82,7 @@ defineFunction({
83
82
  body: ordargument(body),
84
83
  };
85
84
  },
85
+
86
86
  htmlBuilder: (group, options) => {
87
87
  const elements = html.buildExpression(group.body, options, false);
88
88
 
@@ -7,11 +7,10 @@ import * as mml from "../buildMathML";
7
7
  defineFunction({
8
8
  type: "htmlmathml",
9
9
  names: ["\\html@mathml"],
10
- props: {
11
- numArgs: 2,
12
- allowedInArgument: true,
13
- allowedInText: true,
14
- },
10
+ numArgs: 2,
11
+ allowedInArgument: true,
12
+ allowedInText: true,
13
+
15
14
  handler: ({parser}, args) => {
16
15
  return {
17
16
  type: "htmlmathml",
@@ -20,6 +19,7 @@ defineFunction({
20
19
  mathml: ordargument(args[1]),
21
20
  };
22
21
  },
22
+
23
23
  htmlBuilder: (group, options) => {
24
24
  const elements = html.buildExpression(
25
25
  group.html,
@@ -1,11 +1,11 @@
1
1
  import defineFunction from "../defineFunction";
2
- import type {Measurement} from "../units";
3
2
  import {calculateSize, validUnit, makeEm} from "../units";
4
3
  import ParseError from "../ParseError";
5
4
  import {Img} from "../domTree";
6
5
  import {MathNode} from "../mathMLTree";
7
6
  import {assertNodeType} from "../parseNode";
8
7
  import type {CssStyle} from "../domTree";
8
+ import type {Measurement} from "../types";
9
9
 
10
10
  const sizeData = function(str: string): Measurement {
11
11
  if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
@@ -33,12 +33,11 @@ const sizeData = function(str: string): Measurement {
33
33
  defineFunction({
34
34
  type: "includegraphics",
35
35
  names: ["\\includegraphics"],
36
- props: {
37
- numArgs: 1,
38
- numOptionalArgs: 1,
39
- argTypes: ["raw", "url"],
40
- allowedInText: false,
41
- },
36
+ numArgs: 1,
37
+ numOptionalArgs: 1,
38
+ argTypes: ["raw", "url"],
39
+ allowedInText: false,
40
+
42
41
  handler: ({parser}, args, optArgs) => {
43
42
  let width = {number: 0, unit: "em"};
44
43
  let height = {number: 0.9, unit: "em"}; // sorta character sized.
@@ -101,6 +100,7 @@ defineFunction({
101
100
  src: src,
102
101
  };
103
102
  },
103
+
104
104
  htmlBuilder: (group, options) => {
105
105
  const height = calculateSize(group.height, options);
106
106
  let depth = 0;
@@ -11,12 +11,11 @@ import {assertNodeType} from "../parseNode";
11
11
  defineFunction({
12
12
  type: "kern",
13
13
  names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"],
14
- props: {
15
- numArgs: 1,
16
- argTypes: ["size"],
17
- primitive: true,
18
- allowedInText: true,
19
- },
14
+ numArgs: 1,
15
+ argTypes: ["size"],
16
+ primitive: true,
17
+ allowedInText: true,
18
+
20
19
  handler({parser, funcName}, args) {
21
20
  const size = assertNodeType(args[0], "size");
22
21
  if (parser.settings.strict) {
@@ -45,6 +44,7 @@ defineFunction({
45
44
  dimension: size.value,
46
45
  };
47
46
  },
47
+
48
48
  htmlBuilder(group, options) {
49
49
  return makeGlue(group.dimension, options);
50
50
  },
@@ -10,10 +10,9 @@ import * as mml from "../buildMathML";
10
10
  defineFunction({
11
11
  type: "lap",
12
12
  names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
13
- props: {
14
- numArgs: 1,
15
- allowedInText: true,
16
- },
13
+ numArgs: 1,
14
+ allowedInText: true,
15
+
17
16
  handler: ({parser, funcName}, args) => {
18
17
  const body = args[0];
19
18
  return {
@@ -23,6 +22,7 @@ defineFunction({
23
22
  body,
24
23
  };
25
24
  },
25
+
26
26
  htmlBuilder: (group, options) => {
27
27
  // mathllap, mathrlap, mathclap
28
28
  let inner;