katex 0.16.47 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +5 -10
  2. package/cli.js +6 -9
  3. package/contrib/auto-render/index.html +1 -1
  4. package/contrib/copy-tex/README.md +3 -3
  5. package/contrib/copy-tex/index.html +1 -1
  6. package/contrib/mathtex-script-type/README.md +5 -5
  7. package/contrib/mhchem/README.md +1 -1
  8. package/contrib/render-a11y-string/render-a11y-string.ts +1 -1
  9. package/dist/README.md +5 -10
  10. package/dist/contrib/render-a11y-string.js +15 -40
  11. package/dist/contrib/render-a11y-string.min.js +1 -1
  12. package/dist/contrib/render-a11y-string.mjs +13 -33
  13. package/dist/katex-swap.css +159 -164
  14. package/dist/katex-swap.min.css +1 -1
  15. package/dist/katex.css +159 -164
  16. package/dist/katex.js +509 -849
  17. package/dist/katex.min.css +1 -1
  18. package/dist/katex.min.js +1 -1
  19. package/dist/katex.mjs +498 -831
  20. package/katex.ts +1 -1
  21. package/package.json +12 -16
  22. package/src/MacroExpander.ts +11 -8
  23. package/src/Namespace.ts +17 -21
  24. package/src/Options.ts +2 -2
  25. package/src/ParseError.ts +1 -1
  26. package/src/Parser.ts +44 -50
  27. package/src/Settings.ts +1 -1
  28. package/src/SourceLocation.ts +2 -2
  29. package/src/atoms.ts +22 -22
  30. package/src/buildCommon.ts +8 -8
  31. package/src/buildHTML.ts +12 -13
  32. package/src/buildMathML.ts +4 -4
  33. package/src/buildTree.ts +1 -1
  34. package/src/defineEnvironment.ts +1 -2
  35. package/src/defineFunction.ts +104 -112
  36. package/src/environments/array.ts +11 -15
  37. package/src/environments/cd.ts +8 -8
  38. package/src/fontMetrics.ts +2 -4
  39. package/src/functions/accent.ts +12 -15
  40. package/src/functions/accentunder.ts +4 -4
  41. package/src/functions/arrow.ts +5 -5
  42. package/src/functions/char.ts +3 -4
  43. package/src/functions/color.ts +10 -13
  44. package/src/functions/cr.ts +4 -6
  45. package/src/functions/def.ts +15 -19
  46. package/src/functions/delimsizing.ts +23 -23
  47. package/src/functions/enclose.ts +23 -34
  48. package/src/functions/environment.ts +5 -6
  49. package/src/functions/font.ts +15 -27
  50. package/src/functions/genfrac.ts +19 -23
  51. package/src/functions/hbox.ts +6 -6
  52. package/src/functions/horizBrace.ts +4 -4
  53. package/src/functions/href.ts +10 -11
  54. package/src/functions/html.ts +8 -8
  55. package/src/functions/htmlmathml.ts +5 -5
  56. package/src/functions/includegraphics.ts +7 -7
  57. package/src/functions/kern.ts +6 -6
  58. package/src/functions/lap.ts +11 -11
  59. package/src/functions/math.ts +8 -10
  60. package/src/functions/mathchoice.ts +5 -5
  61. package/src/functions/mclass.ts +16 -28
  62. package/src/functions/op.ts +16 -30
  63. package/src/functions/operatorname.ts +4 -4
  64. package/src/functions/overline.ts +4 -4
  65. package/src/functions/phantom.ts +10 -10
  66. package/src/functions/pmb.ts +5 -5
  67. package/src/functions/raisebox.ts +5 -5
  68. package/src/functions/relax.ts +4 -5
  69. package/src/functions/rule.ts +8 -8
  70. package/src/functions/sizing.ts +7 -7
  71. package/src/functions/smash.ts +6 -6
  72. package/src/functions/sqrt.ts +5 -5
  73. package/src/functions/styling.ts +5 -5
  74. package/src/functions/supsub.ts +1 -1
  75. package/src/functions/symbolsOrd.ts +3 -3
  76. package/src/functions/symbolsSpacing.ts +21 -22
  77. package/src/functions/text.ts +7 -7
  78. package/src/functions/underline.ts +5 -5
  79. package/src/functions/utils/assembleSupSub.ts +1 -1
  80. package/src/functions/vcenter.ts +5 -5
  81. package/src/functions/verb.ts +5 -5
  82. package/src/macros.ts +3 -3
  83. package/src/mathMLTree.ts +6 -10
  84. package/src/parseNode.ts +6 -480
  85. package/src/parseTree.ts +1 -6
  86. package/src/spacingData.ts +2 -1
  87. package/src/stretchy.ts +3 -3
  88. package/src/styles/katex.scss +31 -37
  89. package/src/types/index.ts +12 -0
  90. package/src/types/nodes.ts +456 -0
  91. package/src/units.ts +1 -2
  92. package/src/utils.ts +1 -1
  93. package/src/wide-character.ts +2 -2
@@ -58,13 +58,13 @@ $display-margin: 1em 0 !default;
58
58
  }
59
59
 
60
60
  .katex-html {
61
- /* \newline is an empty block at top level, between .base elements */
62
- > .newline {
61
+ /* \newline is an empty block at top level, between .katex-base elements */
62
+ > .katex-newline {
63
63
  display: block;
64
64
  }
65
65
  }
66
66
 
67
- .base {
67
+ .katex-base {
68
68
  position: relative;
69
69
  display: inline-block;
70
70
  white-space: nowrap;
@@ -73,7 +73,7 @@ $display-margin: 1em 0 !default;
73
73
  width: min-content;
74
74
  }
75
75
 
76
- .strut {
76
+ .katex-strut {
77
77
  display: inline-block;
78
78
  }
79
79
 
@@ -242,19 +242,13 @@ $display-margin: 1em 0 !default;
242
242
  min-width: 2px;
243
243
  }
244
244
 
245
- .vbox {
245
+ .katex-vbox {
246
246
  display: inline-flex;
247
247
  flex-direction: column;
248
248
  align-items: baseline;
249
249
  }
250
250
 
251
- .hbox {
252
- display: inline-flex;
253
- flex-direction: row;
254
- width: 100%;
255
- }
256
-
257
- .thinbox {
251
+ .katex-thinbox {
258
252
  display: inline-flex;
259
253
  flex-direction: row;
260
254
  width: 0;
@@ -279,11 +273,11 @@ $display-margin: 1em 0 !default;
279
273
 
280
274
  // Prevent Chrome from disappearing frac-lines, rules, etc.
281
275
  .mfrac .frac-line,
282
- .overline .overline-line,
283
- .underline .underline-line,
284
- .hline,
285
- .hdashline,
286
- .rule {
276
+ .katex-overline .overline-line,
277
+ .katex-underline .underline-line,
278
+ .katex-hline,
279
+ .katex-hdashline,
280
+ .katex-rule {
287
281
  min-height: 1px;
288
282
  }
289
283
 
@@ -291,7 +285,7 @@ $display-margin: 1em 0 !default;
291
285
  display: inline-block;
292
286
  }
293
287
 
294
- .smash {
288
+ .katex-smash {
295
289
  display: inline;
296
290
  line-height: 0;
297
291
  }
@@ -302,51 +296,51 @@ $display-margin: 1em 0 !default;
302
296
  width: 0;
303
297
  position: relative;
304
298
 
305
- > .inner {
299
+ > .katex-inner {
306
300
  position: absolute;
307
301
  }
308
302
 
309
- > .fix {
303
+ > .katex-fix {
310
304
  display: inline-block;
311
305
  }
312
306
  }
313
307
 
314
- .llap > .inner {
308
+ .llap > .katex-inner {
315
309
  right: 0;
316
310
  }
317
311
 
318
- .rlap > .inner,
319
- .clap > .inner {
312
+ .rlap > .katex-inner,
313
+ .clap > .katex-inner {
320
314
  left: 0;
321
315
  }
322
316
 
323
- .clap > .inner > span {
317
+ .clap > .katex-inner > span {
324
318
  margin-left: -50%;
325
319
  margin-right: 50%;
326
320
  }
327
321
 
328
- .rule {
322
+ .katex-rule {
329
323
  display: inline-block;
330
324
  border: solid 0;
331
325
  position: relative;
332
326
  }
333
327
 
334
- .overline .overline-line,
335
- .underline .underline-line,
336
- .hline {
328
+ .katex-overline .overline-line,
329
+ .katex-underline .underline-line,
330
+ .katex-hline {
337
331
  display: inline-block;
338
332
  width: 100%;
339
333
  border-bottom-style: solid;
340
334
  }
341
335
 
342
- .hdashline {
336
+ .katex-hdashline {
343
337
  display: inline-block;
344
338
  width: 100%;
345
339
  border-bottom-style: dashed;
346
340
  }
347
341
 
348
342
  .sqrt {
349
- > .root {
343
+ > .katex-root {
350
344
  /* These values are taken from the definition of `\r@@t`,
351
345
  `\mkern 5mu` and `\mkern -10mu`. */
352
346
  /* stylelint-disable-next-line declaration-property-value-no-unknown */
@@ -356,7 +350,7 @@ $display-margin: 1em 0 !default;
356
350
  }
357
351
  }
358
352
 
359
- .sizing,
353
+ .katex-sizing,
360
354
  .fontsize-ensurer {
361
355
  $sizes: 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.2, 1.44, 1.728, 2.074, 2.488;
362
356
 
@@ -414,7 +408,7 @@ $display-margin: 1em 0 !default;
414
408
  }
415
409
  }
416
410
 
417
- .accent {
411
+ .katex-accent {
418
412
  > .vlist-t {
419
413
  text-align: center;
420
414
  }
@@ -430,7 +424,7 @@ $display-margin: 1em 0 !default;
430
424
  }
431
425
  }
432
426
 
433
- .overlay {
427
+ .katex-overlay {
434
428
  display: block;
435
429
  }
436
430
 
@@ -503,7 +497,7 @@ $display-margin: 1em 0 !default;
503
497
  }
504
498
 
505
499
  // Define CSS for image whose width will match its span width.
506
- .stretchy {
500
+ .katex-stretchy {
507
501
  width: 100%;
508
502
  display: block;
509
503
  position: relative;
@@ -591,7 +585,7 @@ $display-margin: 1em 0 !default;
591
585
  margin-right: -0.2em; // Apply negative margin to correct for 0.2em padding
592
586
  } // inside the \cancel group.
593
587
 
594
- .sout {
588
+ .katex-sout {
595
589
  border-bottom-style: solid;
596
590
  border-bottom-width: 0.08em;
597
591
  }
@@ -656,7 +650,7 @@ $display-margin: 1em 0 !default;
656
650
  display: block;
657
651
  position: relative;
658
652
 
659
- > .tag {
653
+ > .katex-tag {
660
654
  position: absolute;
661
655
  right: 0;
662
656
  }
@@ -665,7 +659,7 @@ $display-margin: 1em 0 !default;
665
659
  }
666
660
 
667
661
  // Left-justified tags (default is right-justified)
668
- .katex-display.leqno > .katex > .katex-html > .tag {
662
+ .katex-display.leqno > .katex > .katex-html > .katex-tag {
669
663
  left: 0;
670
664
  right: auto;
671
665
  }
@@ -27,3 +27,15 @@ export type DelimiterSize = 1 | 2 | 3 | 4;
27
27
 
28
28
  export type Slice1<S extends string> =
29
29
  S extends `${string}${infer Rest}` ? Rest : "";
30
+
31
+ export type Slice4<S extends string> =
32
+ S extends `${string}${string}${string}${string}${infer Rest}` ? Rest : "";
33
+
34
+ export type Slice5<S extends string> =
35
+ S extends `${string}${string}${string}${string}${string}${infer Rest}` ? Rest : "";
36
+
37
+ export type Measurement = {number: number, unit: string};
38
+
39
+ export type MathClass = "mord" | "mop" | "mbin" | "mrel" | "mopen" | "mclose" | "mpunct" | "minner";
40
+
41
+ export type Side = "left" | "right";
@@ -0,0 +1,456 @@
1
+ import type SourceLocation from "../SourceLocation";
2
+ import type {DelimiterSize, MathClass, Measurement, Mode, Side, StyleStr} from "./index";
3
+ import type {AlignSpec, ColSeparationType} from "../environments/array";
4
+ import type {Atom} from "../atoms";
5
+ import type {MathFont} from "./fonts";
6
+ import type {Token} from "../Token";
7
+
8
+ // ParseNode from `Parser.formatUnsupportedCmd`
9
+ export type UnsupportedCmdParseNode = ColorNode;
10
+
11
+ export type NodeType = AnyParseNode["type"];
12
+
13
+ export type ParseNode<T extends NodeType> = ParseNodeMap[T];
14
+
15
+ export type AnyParseNode =
16
+ | ArrayNode
17
+ | CommutativeDiagramLabelNode
18
+ | CommutativeDiagramLabelParentNode
19
+ | ColorNode
20
+ | ColorTokenNode
21
+ | OperatorNode
22
+ | OrdinaryGroupNode
23
+ | RawNode
24
+ | SizeNode
25
+ | StylingNode
26
+ | SupSubNode
27
+ | TagNode
28
+ | TextNode
29
+ | UrlNode
30
+ | VerbatimNode
31
+ | AtomNode
32
+ | MathOrdinaryNode
33
+ | TextOrdinaryNode
34
+ | SpacingNode
35
+ | AccentTokenNode
36
+ | OperatorTokenNode
37
+ | AccentNode
38
+ | AccentUnderNode
39
+ | CarriageReturnNode
40
+ | DelimiterSizingNode
41
+ | EncloseNode
42
+ | EnvironmentNode
43
+ | FontNode
44
+ | GeneralizedFractionNode
45
+ | HorizontalBoxNode
46
+ | HorizontalBraceNode
47
+ | HrefNode
48
+ | HtmlNode
49
+ | HtmlMathmlNode
50
+ | IncludeGraphicsNode
51
+ | InfixNode
52
+ | InternalNode
53
+ | KernNode
54
+ | LapNode
55
+ | LeftRightNode
56
+ | ClosingDelimiterNode
57
+ | MathChoiceNode
58
+ | MiddleNode
59
+ | MathClassNode
60
+ | OperatorNameNode
61
+ | OverlineNode
62
+ | UnderlineNode
63
+ | PhantomNode
64
+ | VerticalPhantomNode
65
+ | PoorMansBoldNode
66
+ | RaiseBoxNode
67
+ | RuleNode
68
+ | SizingNode
69
+ | SmashNode
70
+ | SqrtNode
71
+ | VerticalCenterNode
72
+ | ExtensibleArrowNode;
73
+
74
+ // ParseNode's corresponding to Symbol `Group`s in symbols.js.
75
+ export type SymbolParseNode =
76
+ ParseNode<"atom"> |
77
+ ParseNode<"accent-token"> |
78
+ ParseNode<"mathord"> |
79
+ ParseNode<"op-token"> |
80
+ ParseNode<"spacing"> |
81
+ ParseNode<"textord">;
82
+
83
+ type ParseNodeMap = {
84
+ [K in NodeType]: Extract<AnyParseNode, {type: K}>;
85
+ };
86
+
87
+ type BaseNode = {
88
+ mode: Mode;
89
+ loc?: SourceLocation | null;
90
+ };
91
+
92
+ type ArrayNode = BaseNode & {
93
+ type: "array";
94
+ colSeparationType?: ColSeparationType;
95
+ hskipBeforeAndAfter?: boolean;
96
+ addJot?: boolean;
97
+ cols?: AlignSpec[];
98
+ arraystretch: number;
99
+ body: AnyParseNode[][];
100
+ // List of rows in the (2D) array.
101
+ rowGaps: (Measurement | null)[];
102
+ hLinesBeforeRow: boolean[][];
103
+ // Whether each row should be automatically numbered, or an explicit tag
104
+ tags?: (boolean | AnyParseNode[])[];
105
+ leqno?: boolean;
106
+ };
107
+
108
+ type CommutativeDiagramLabelNode = BaseNode & {
109
+ type: "cdlabel";
110
+ side: Side;
111
+ label: AnyParseNode;
112
+ };
113
+
114
+ type CommutativeDiagramLabelParentNode = BaseNode & {
115
+ type: "cdlabelparent";
116
+ fragment: AnyParseNode;
117
+ }
118
+
119
+ type ColorNode = BaseNode & {
120
+ type: "color";
121
+ color: string;
122
+ body: AnyParseNode[];
123
+ }
124
+
125
+ type ColorTokenNode = BaseNode & {
126
+ type: "color-token";
127
+ color: string;
128
+ }
129
+
130
+ type OperatorNodeBase = BaseNode & {
131
+ type: "op";
132
+ limits: boolean;
133
+ alwaysHandleSupSub?: boolean;
134
+ suppressBaseShift?: boolean;
135
+ parentIsSupSub: boolean;
136
+ }
137
+
138
+ type OperatorNode =
139
+ | OperatorNodeBase & {symbol: true; name: string; body?: never;}
140
+ | OperatorNodeBase & {symbol: false; body: AnyParseNode[]; name?: never;}
141
+ | OperatorNodeBase & {symbol: false; name: string; body?: never;};
142
+
143
+ type OrdinaryGroupNode = BaseNode & {
144
+ type: "ordgroup";
145
+ body: AnyParseNode[];
146
+ semisimple?: boolean;
147
+ }
148
+
149
+ type RawNode = BaseNode & {
150
+ type: "raw";
151
+ string: string;
152
+ }
153
+
154
+ type SizeNode = BaseNode & {
155
+ type: "size";
156
+ value: Measurement;
157
+ isBlank: boolean;
158
+ }
159
+
160
+ type StylingNode = BaseNode & {
161
+ type: "styling";
162
+ style: StyleStr;
163
+ resetFont?: boolean;
164
+ body: AnyParseNode[];
165
+ }
166
+
167
+ type SupSubNode = BaseNode & {
168
+ type: "supsub";
169
+ base: AnyParseNode | null;
170
+ } & (
171
+ | {sup: AnyParseNode; sub?: AnyParseNode;}
172
+ | {sup?: AnyParseNode; sub: AnyParseNode;}
173
+ );
174
+
175
+ type TagNode = BaseNode & {
176
+ type: "tag";
177
+ body: AnyParseNode[];
178
+ tag: AnyParseNode[];
179
+ }
180
+
181
+ type TextNode = BaseNode & {
182
+ type: "text";
183
+ body: AnyParseNode[];
184
+ font?: string;
185
+ }
186
+
187
+ type UrlNode = BaseNode & {
188
+ type: "url";
189
+ url: string;
190
+ }
191
+
192
+ type VerbatimNode = BaseNode & {
193
+ type: "verb";
194
+ body: string;
195
+ star: boolean;
196
+ }
197
+
198
+ type SymbolNode = BaseNode & {
199
+ text: string;
200
+ }
201
+
202
+ type AtomNode = SymbolNode & {
203
+ type: "atom";
204
+ family: Atom;
205
+ }
206
+
207
+ type MathOrdinaryNode = SymbolNode & {
208
+ type: "mathord";
209
+ }
210
+
211
+ type TextOrdinaryNode = SymbolNode & {
212
+ type: "textord";
213
+ }
214
+
215
+ type SpacingNode = SymbolNode & {
216
+ type: "spacing";
217
+ }
218
+
219
+ type AccentTokenNode = SymbolNode & {
220
+ type: "accent-token";
221
+ }
222
+
223
+ type OperatorTokenNode = SymbolNode & {
224
+ type: "op-token";
225
+ }
226
+
227
+ type AccentBaseNode = BaseNode & {
228
+ label: string;
229
+ isStretchy?: boolean;
230
+ isShifty?: boolean;
231
+ base: AnyParseNode;
232
+ }
233
+
234
+ type AccentNode = AccentBaseNode & {
235
+ type: "accent";
236
+ }
237
+
238
+ type AccentUnderNode = AccentBaseNode & {
239
+ type: "accentUnder";
240
+ }
241
+
242
+ type CarriageReturnNode = BaseNode & {
243
+ type: "cr";
244
+ newLine: boolean;
245
+ size: Measurement | null;
246
+ }
247
+
248
+ type DelimiterSizingNode = BaseNode & {
249
+ type: "delimsizing";
250
+ size: DelimiterSize;
251
+ mclass: "mopen" | "mclose" | "mrel" | "mord";
252
+ delim: string;
253
+ }
254
+
255
+ type EncloseNode = BaseNode & {
256
+ type: "enclose";
257
+ body: AnyParseNode;
258
+ label: string;
259
+ backgroundColor?: string;
260
+ borderColor?: string;
261
+ }
262
+
263
+ type EnvironmentNode = BaseNode & {
264
+ type: "environment";
265
+ name: string;
266
+ nameGroup: AnyParseNode;
267
+ }
268
+
269
+ type FontNode = BaseNode & {
270
+ type: "font";
271
+ font: Exclude<MathFont, "">;
272
+ body: AnyParseNode;
273
+ }
274
+
275
+ type GeneralizedFractionNode = BaseNode & {
276
+ type: "genfrac";
277
+ continued: boolean;
278
+ numer: AnyParseNode;
279
+ denom: AnyParseNode;
280
+ hasBarLine: boolean;
281
+ leftDelim: string | null;
282
+ rightDelim: string | null;
283
+ barSize: Measurement | null;
284
+ }
285
+
286
+ type HorizontalBoxNode = BaseNode & {
287
+ type: "hbox";
288
+ body: AnyParseNode[];
289
+ }
290
+
291
+ type HorizontalBraceNode = BaseNode & {
292
+ type: "horizBrace";
293
+ label: string;
294
+ isOver: boolean;
295
+ base: AnyParseNode;
296
+ }
297
+
298
+ type HrefNode = BaseNode & {
299
+ type: "href";
300
+ href: string;
301
+ body: AnyParseNode[];
302
+ }
303
+
304
+ type HtmlNode = BaseNode & {
305
+ type: "html";
306
+ attributes: Record<string, string>;
307
+ body: AnyParseNode[];
308
+ }
309
+
310
+ type HtmlMathmlNode = BaseNode & {
311
+ type: "htmlmathml";
312
+ html: AnyParseNode[];
313
+ mathml: AnyParseNode[];
314
+ }
315
+
316
+ type IncludeGraphicsNode = BaseNode & {
317
+ type: "includegraphics";
318
+ alt: string;
319
+ width: Measurement;
320
+ height: Measurement;
321
+ totalheight: Measurement;
322
+ src: string;
323
+ }
324
+
325
+ type InfixNode = BaseNode & {
326
+ type: "infix";
327
+ replaceWith: string;
328
+ size?: Measurement;
329
+ token?: Token;
330
+ }
331
+
332
+ type InternalNode = BaseNode & {
333
+ type: "internal";
334
+ }
335
+
336
+ type KernNode = BaseNode & {
337
+ type: "kern";
338
+ dimension: Measurement;
339
+ }
340
+
341
+ type LapNode = BaseNode & {
342
+ type: "lap";
343
+ alignment: string;
344
+ body: AnyParseNode;
345
+ }
346
+ type LeftRightNode = BaseNode & {
347
+ type: "leftright";
348
+ body: AnyParseNode[];
349
+ left: string;
350
+ right: string;
351
+ rightColor?: string;
352
+ }
353
+
354
+ type ClosingDelimiterNode = BaseNode & {
355
+ type: "leftright-right";
356
+ delim: string;
357
+ color?: string;
358
+ }
359
+
360
+ type MathChoiceNode = BaseNode & {
361
+ type: "mathchoice";
362
+ display: AnyParseNode[];
363
+ text: AnyParseNode[];
364
+ script: AnyParseNode[];
365
+ scriptscript: AnyParseNode[];
366
+ }
367
+
368
+ type MiddleNode = BaseNode & {
369
+ type: "middle";
370
+ delim: string;
371
+ }
372
+
373
+ type MathClassNode = BaseNode & {
374
+ type: "mclass";
375
+ mclass: MathClass;
376
+ body: AnyParseNode[];
377
+ isCharacterBox: boolean;
378
+ }
379
+
380
+ type OperatorNameNode = BaseNode & {
381
+ type: "operatorname";
382
+ body: AnyParseNode[];
383
+ alwaysHandleSupSub: boolean;
384
+ limits: boolean;
385
+ parentIsSupSub: boolean;
386
+ }
387
+
388
+ type OverlineNode = BaseNode & {
389
+ type: "overline";
390
+ body: AnyParseNode;
391
+ }
392
+
393
+ type UnderlineNode = BaseNode & {
394
+ type: "underline";
395
+ body: AnyParseNode;
396
+ }
397
+
398
+ type PhantomNode = BaseNode & {
399
+ type: "phantom";
400
+ body: AnyParseNode[];
401
+ }
402
+
403
+ type VerticalPhantomNode = BaseNode & {
404
+ type: "vphantom";
405
+ body: AnyParseNode;
406
+ }
407
+
408
+ type PoorMansBoldNode = BaseNode & {
409
+ type: "pmb";
410
+ mclass: MathClass;
411
+ body: AnyParseNode[];
412
+ }
413
+
414
+ type RaiseBoxNode = BaseNode & {
415
+ type: "raisebox";
416
+ dy: Measurement;
417
+ body: AnyParseNode;
418
+ }
419
+
420
+ type RuleNode = BaseNode & {
421
+ type: "rule";
422
+ shift: Measurement | null | undefined;
423
+ width: Measurement;
424
+ height: Measurement;
425
+ }
426
+
427
+ type SizingNode = BaseNode & {
428
+ type: "sizing";
429
+ size: number;
430
+ body: AnyParseNode[];
431
+ }
432
+
433
+ type SmashNode = BaseNode & {
434
+ type: "smash";
435
+ body: AnyParseNode;
436
+ smashHeight: boolean;
437
+ smashDepth: boolean;
438
+ }
439
+
440
+ type SqrtNode = BaseNode & {
441
+ type: "sqrt";
442
+ body: AnyParseNode;
443
+ index: AnyParseNode | null;
444
+ }
445
+
446
+ type VerticalCenterNode = BaseNode & {
447
+ type: "vcenter";
448
+ body: AnyParseNode;
449
+ }
450
+
451
+ type ExtensibleArrowNode = BaseNode & {
452
+ type: "xArrow";
453
+ label: string;
454
+ body: AnyParseNode;
455
+ below: AnyParseNode | null;
456
+ }
package/src/units.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  import ParseError from "./ParseError";
7
7
  import Options from "./Options";
8
+ import type {Measurement} from "./types";
8
9
 
9
10
  // This table gives the number of TeX pts in one of each *absolute* TeX unit.
10
11
  // Thus, multiplying a length by this number converts the length from units
@@ -35,8 +36,6 @@ const relativeUnit = {
35
36
  "mu": true,
36
37
  };
37
38
 
38
- export type Measurement = { number: number, unit: string };
39
-
40
39
  /**
41
40
  * Determine whether the specified unit (either a string defining the unit
42
41
  * or a "size" parse node containing a unit field) is valid.
package/src/utils.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * files.
4
4
  */
5
5
 
6
- import type {AnyParseNode} from "./parseNode";
6
+ import type {AnyParseNode} from "./types/nodes";
7
7
 
8
8
  // hyphenate and escape adapted from Facebook's React under Apache 2 license
9
9
  const uppercase = /([A-Z])/g;
@@ -110,7 +110,7 @@ const wideLatinLetterData = [
110
110
  italicSansSerif, italicSansSerif, // A-Z, a-z
111
111
  noFont, noFont, // A-Z bold italic sans, a-z bold italic sans - no font
112
112
  monospace, monospace, // A-Z, a-z
113
- ] as const;
113
+ ] as const satisfies readonly WideChar[];
114
114
 
115
115
  const wideNumeralData = [
116
116
  boldUpright, // 0-9
@@ -118,7 +118,7 @@ const wideNumeralData = [
118
118
  sansSerif, // 0-9
119
119
  boldSansSerif, // 0-9
120
120
  monospace, // 0-9
121
- ] as const;
121
+ ] as const satisfies readonly WideChar[];
122
122
 
123
123
  export const wideCharacterFont = (
124
124
  wideChar: string,