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/text.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {makeSpan} from "../buildCommon";
|
|
|
5
5
|
import * as html from "../buildHTML";
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
import type Options from "../Options";
|
|
8
|
-
import type {ParseNode} from "../
|
|
8
|
+
import type {ParseNode} from "../types/nodes";
|
|
9
9
|
|
|
10
10
|
// Non-mathy text, possibly in a font
|
|
11
11
|
const textFontFamilies: Record<string, TextFont | undefined> = {
|
|
@@ -54,12 +54,11 @@ defineFunction({
|
|
|
54
54
|
// Font Shapes
|
|
55
55
|
"\\textit", "\\textup", "\\emph",
|
|
56
56
|
],
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
57
|
+
numArgs: 1,
|
|
58
|
+
argTypes: ["text"],
|
|
59
|
+
allowedInArgument: true,
|
|
60
|
+
allowedInText: true,
|
|
61
|
+
|
|
63
62
|
handler({parser, funcName}, args) {
|
|
64
63
|
const body = args[0];
|
|
65
64
|
return {
|
|
@@ -69,6 +68,7 @@ defineFunction({
|
|
|
69
68
|
font: funcName,
|
|
70
69
|
};
|
|
71
70
|
},
|
|
71
|
+
|
|
72
72
|
htmlBuilder(group, options) {
|
|
73
73
|
const newOptions = optionsWithFont(group, options);
|
|
74
74
|
const inner = html.buildExpression(group.body, newOptions, true);
|
|
@@ -8,10 +8,9 @@ import * as mml from "../buildMathML";
|
|
|
8
8
|
defineFunction({
|
|
9
9
|
type: "underline",
|
|
10
10
|
names: ["\\underline"],
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
11
|
+
numArgs: 1,
|
|
12
|
+
allowedInText: true,
|
|
13
|
+
|
|
15
14
|
handler({parser}, args) {
|
|
16
15
|
return {
|
|
17
16
|
type: "underline",
|
|
@@ -19,6 +18,7 @@ defineFunction({
|
|
|
19
18
|
body: args[0],
|
|
20
19
|
};
|
|
21
20
|
},
|
|
21
|
+
|
|
22
22
|
htmlBuilder(group, options) {
|
|
23
23
|
// Underlines are handled in the TeXbook pg 443, Rule 10.
|
|
24
24
|
// Build the inner group.
|
|
@@ -4,7 +4,7 @@ import {isCharacterBox} from "../../utils";
|
|
|
4
4
|
import type {StyleInterface} from "../../Style";
|
|
5
5
|
import type Options from "../../Options";
|
|
6
6
|
import type {DomSpan, SymbolNode} from "../../domTree";
|
|
7
|
-
import type {AnyParseNode} from "../../
|
|
7
|
+
import type {AnyParseNode} from "../../types/nodes";
|
|
8
8
|
import {makeEm} from "../../units";
|
|
9
9
|
|
|
10
10
|
// For an operator with limits, assemble the base, sup, and sub into a span.
|
package/src/functions/vcenter.ts
CHANGED
|
@@ -10,11 +10,10 @@ import * as mml from "../buildMathML";
|
|
|
10
10
|
defineFunction({
|
|
11
11
|
type: "vcenter",
|
|
12
12
|
names: ["\\vcenter"],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
13
|
+
numArgs: 1,
|
|
14
|
+
argTypes: ["original"], // In LaTeX, \vcenter can act only on a box.
|
|
15
|
+
allowedInText: false,
|
|
16
|
+
|
|
18
17
|
handler({parser}, args) {
|
|
19
18
|
return {
|
|
20
19
|
type: "vcenter",
|
|
@@ -22,6 +21,7 @@ defineFunction({
|
|
|
22
21
|
body: args[0],
|
|
23
22
|
};
|
|
24
23
|
},
|
|
24
|
+
|
|
25
25
|
htmlBuilder(group, options) {
|
|
26
26
|
const body = html.buildGroup(group.body, options);
|
|
27
27
|
const axisHeight = options.fontMetrics().axisHeight;
|
package/src/functions/verb.ts
CHANGED
|
@@ -3,15 +3,14 @@ import {makeSpan, makeSymbol, tryCombineChars} from "../buildCommon";
|
|
|
3
3
|
import {MathNode, TextNode} from "../mathMLTree";
|
|
4
4
|
import ParseError from "../ParseError";
|
|
5
5
|
|
|
6
|
-
import type {ParseNode} from "../
|
|
6
|
+
import type {ParseNode} from "../types/nodes";
|
|
7
7
|
|
|
8
8
|
defineFunction({
|
|
9
9
|
type: "verb",
|
|
10
10
|
names: ["\\verb"],
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
11
|
+
numArgs: 0,
|
|
12
|
+
allowedInText: true,
|
|
13
|
+
|
|
15
14
|
handler(context, args, optArgs) {
|
|
16
15
|
// \verb and \verb* are dealt with directly in Parser.js.
|
|
17
16
|
// If we end up here, it's because of a failure to match the two delimiters
|
|
@@ -20,6 +19,7 @@ defineFunction({
|
|
|
20
19
|
throw new ParseError(
|
|
21
20
|
"\\verb ended by end of line instead of matching delimiter");
|
|
22
21
|
},
|
|
22
|
+
|
|
23
23
|
htmlBuilder(group, options) {
|
|
24
24
|
const text = makeVerb(group);
|
|
25
25
|
const body = [];
|
package/src/parseNode.ts
CHANGED
|
@@ -1,479 +1,5 @@
|
|
|
1
1
|
import {NON_ATOMS} from "./atoms";
|
|
2
|
-
import type {
|
|
3
|
-
import type SourceLocation from "./SourceLocation";
|
|
4
|
-
import type {AlignSpec, ColSeparationType} from "./environments/array";
|
|
5
|
-
import type {DelimiterSize, Mode, StyleStr} from "./types";
|
|
6
|
-
import type {MathFont} from "./types/fonts";
|
|
7
|
-
import type {Token} from "./Token";
|
|
8
|
-
import type {Measurement} from "./units";
|
|
9
|
-
export type NodeType = keyof ParseNodeTypes;
|
|
10
|
-
export type ParseNode<TYPE extends NodeType> = ParseNodeTypes[TYPE];
|
|
11
|
-
|
|
12
|
-
// ParseNode's corresponding to Symbol `Group`s in symbols.js.
|
|
13
|
-
export type SymbolParseNode =
|
|
14
|
-
ParseNode<"atom"> |
|
|
15
|
-
ParseNode<"accent-token"> |
|
|
16
|
-
ParseNode<"mathord"> |
|
|
17
|
-
ParseNode<"op-token"> |
|
|
18
|
-
ParseNode<"spacing"> |
|
|
19
|
-
ParseNode<"textord">;
|
|
20
|
-
|
|
21
|
-
// ParseNode from `Parser.formatUnsupportedCmd`
|
|
22
|
-
export type UnsupportedCmdParseNode = ParseNode<"color">;
|
|
23
|
-
|
|
24
|
-
// Union of all possible `ParseNode<>` types.
|
|
25
|
-
export type AnyParseNode = ParseNodeTypes[keyof ParseNodeTypes];
|
|
26
|
-
|
|
27
|
-
// Map from `NodeType` to the corresponding `ParseNode`.
|
|
28
|
-
type ParseNodeTypes = {
|
|
29
|
-
"array": {
|
|
30
|
-
type: "array";
|
|
31
|
-
mode: Mode;
|
|
32
|
-
loc?: SourceLocation | null | undefined;
|
|
33
|
-
colSeparationType?: ColSeparationType;
|
|
34
|
-
hskipBeforeAndAfter?: boolean;
|
|
35
|
-
addJot?: boolean;
|
|
36
|
-
cols?: AlignSpec[];
|
|
37
|
-
arraystretch: number;
|
|
38
|
-
body: AnyParseNode[][];
|
|
39
|
-
// List of rows in the (2D) array.
|
|
40
|
-
rowGaps: (Measurement | null | undefined)[];
|
|
41
|
-
hLinesBeforeRow: Array<boolean[]>;
|
|
42
|
-
// Whether each row should be automatically numbered, or an explicit tag
|
|
43
|
-
tags?: (boolean | AnyParseNode[])[];
|
|
44
|
-
leqno?: boolean;
|
|
45
|
-
isCD?: boolean;
|
|
46
|
-
};
|
|
47
|
-
"cdlabel": {
|
|
48
|
-
type: "cdlabel";
|
|
49
|
-
mode: Mode;
|
|
50
|
-
loc?: SourceLocation | null | undefined;
|
|
51
|
-
side: string;
|
|
52
|
-
label: AnyParseNode;
|
|
53
|
-
};
|
|
54
|
-
"cdlabelparent": {
|
|
55
|
-
type: "cdlabelparent";
|
|
56
|
-
mode: Mode;
|
|
57
|
-
loc?: SourceLocation | null | undefined;
|
|
58
|
-
fragment: AnyParseNode;
|
|
59
|
-
};
|
|
60
|
-
"color": {
|
|
61
|
-
type: "color";
|
|
62
|
-
mode: Mode;
|
|
63
|
-
loc?: SourceLocation | null | undefined;
|
|
64
|
-
color: string;
|
|
65
|
-
body: AnyParseNode[];
|
|
66
|
-
};
|
|
67
|
-
"color-token": {
|
|
68
|
-
type: "color-token";
|
|
69
|
-
mode: Mode;
|
|
70
|
-
loc?: SourceLocation | null | undefined;
|
|
71
|
-
color: string;
|
|
72
|
-
};
|
|
73
|
-
// To avoid requiring run-time type assertions, this more carefully captures
|
|
74
|
-
// the requirements on the fields per the op.js htmlBuilder logic:
|
|
75
|
-
// - `body` and `value` are NEVER set simultaneously.
|
|
76
|
-
// - When `symbol` is true, `body` is set.
|
|
77
|
-
"op": {
|
|
78
|
-
type: "op";
|
|
79
|
-
mode: Mode;
|
|
80
|
-
loc?: SourceLocation | null | undefined;
|
|
81
|
-
limits: boolean;
|
|
82
|
-
alwaysHandleSupSub?: boolean;
|
|
83
|
-
suppressBaseShift?: boolean;
|
|
84
|
-
parentIsSupSub: boolean;
|
|
85
|
-
symbol: boolean;
|
|
86
|
-
name: string;
|
|
87
|
-
body?: void;
|
|
88
|
-
} | {
|
|
89
|
-
type: "op";
|
|
90
|
-
mode: Mode;
|
|
91
|
-
loc?: SourceLocation | null | undefined;
|
|
92
|
-
limits: boolean;
|
|
93
|
-
alwaysHandleSupSub?: boolean;
|
|
94
|
-
suppressBaseShift?: boolean;
|
|
95
|
-
parentIsSupSub: boolean;
|
|
96
|
-
symbol: false;
|
|
97
|
-
// If 'symbol' is true, `body` *must* be set.
|
|
98
|
-
name?: void;
|
|
99
|
-
body: AnyParseNode[];
|
|
100
|
-
};
|
|
101
|
-
"ordgroup": {
|
|
102
|
-
type: "ordgroup";
|
|
103
|
-
mode: Mode;
|
|
104
|
-
loc?: SourceLocation | null | undefined;
|
|
105
|
-
body: AnyParseNode[];
|
|
106
|
-
semisimple?: boolean;
|
|
107
|
-
};
|
|
108
|
-
"raw": {
|
|
109
|
-
type: "raw";
|
|
110
|
-
mode: Mode;
|
|
111
|
-
loc?: SourceLocation | null | undefined;
|
|
112
|
-
string: string;
|
|
113
|
-
};
|
|
114
|
-
"size": {
|
|
115
|
-
type: "size";
|
|
116
|
-
mode: Mode;
|
|
117
|
-
loc?: SourceLocation | null | undefined;
|
|
118
|
-
value: Measurement;
|
|
119
|
-
isBlank: boolean;
|
|
120
|
-
};
|
|
121
|
-
"styling": {
|
|
122
|
-
type: "styling";
|
|
123
|
-
mode: Mode;
|
|
124
|
-
loc?: SourceLocation | null | undefined;
|
|
125
|
-
style: StyleStr;
|
|
126
|
-
resetFont?: boolean;
|
|
127
|
-
body: AnyParseNode[];
|
|
128
|
-
};
|
|
129
|
-
"supsub": {
|
|
130
|
-
type: "supsub";
|
|
131
|
-
mode: Mode;
|
|
132
|
-
loc?: SourceLocation | null | undefined;
|
|
133
|
-
base: AnyParseNode | null | undefined;
|
|
134
|
-
sup?: AnyParseNode | null | undefined;
|
|
135
|
-
sub?: AnyParseNode | null | undefined;
|
|
136
|
-
};
|
|
137
|
-
"tag": {
|
|
138
|
-
type: "tag";
|
|
139
|
-
mode: Mode;
|
|
140
|
-
loc?: SourceLocation | null | undefined;
|
|
141
|
-
body: AnyParseNode[];
|
|
142
|
-
tag: AnyParseNode[];
|
|
143
|
-
};
|
|
144
|
-
"text": {
|
|
145
|
-
type: "text";
|
|
146
|
-
mode: Mode;
|
|
147
|
-
loc?: SourceLocation | null | undefined;
|
|
148
|
-
body: AnyParseNode[];
|
|
149
|
-
font?: string;
|
|
150
|
-
};
|
|
151
|
-
"url": {
|
|
152
|
-
type: "url";
|
|
153
|
-
mode: Mode;
|
|
154
|
-
loc?: SourceLocation | null | undefined;
|
|
155
|
-
url: string;
|
|
156
|
-
};
|
|
157
|
-
"verb": {
|
|
158
|
-
type: "verb";
|
|
159
|
-
mode: Mode;
|
|
160
|
-
loc?: SourceLocation | null | undefined;
|
|
161
|
-
body: string;
|
|
162
|
-
star: boolean;
|
|
163
|
-
};
|
|
164
|
-
// From symbol groups, constructed in Parser.js via `symbols` lookup.
|
|
165
|
-
// (Some of these have "-token" suffix to distinguish them from existing
|
|
166
|
-
// `ParseNode` types.)
|
|
167
|
-
"atom": {
|
|
168
|
-
type: "atom";
|
|
169
|
-
family: Atom;
|
|
170
|
-
mode: Mode;
|
|
171
|
-
loc?: SourceLocation | null | undefined;
|
|
172
|
-
text: string;
|
|
173
|
-
};
|
|
174
|
-
"mathord": {
|
|
175
|
-
type: "mathord";
|
|
176
|
-
mode: Mode;
|
|
177
|
-
loc?: SourceLocation | null | undefined;
|
|
178
|
-
text: string;
|
|
179
|
-
};
|
|
180
|
-
"spacing": {
|
|
181
|
-
type: "spacing";
|
|
182
|
-
mode: Mode;
|
|
183
|
-
loc?: SourceLocation | null | undefined;
|
|
184
|
-
text: string;
|
|
185
|
-
};
|
|
186
|
-
"textord": {
|
|
187
|
-
type: "textord";
|
|
188
|
-
mode: Mode;
|
|
189
|
-
loc?: SourceLocation | null | undefined;
|
|
190
|
-
text: string;
|
|
191
|
-
};
|
|
192
|
-
// These "-token" types don't have corresponding HTML/MathML builders.
|
|
193
|
-
"accent-token": {
|
|
194
|
-
type: "accent-token";
|
|
195
|
-
mode: Mode;
|
|
196
|
-
loc?: SourceLocation | null | undefined;
|
|
197
|
-
text: string;
|
|
198
|
-
};
|
|
199
|
-
"op-token": {
|
|
200
|
-
type: "op-token";
|
|
201
|
-
mode: Mode;
|
|
202
|
-
loc?: SourceLocation | null | undefined;
|
|
203
|
-
text: string;
|
|
204
|
-
};
|
|
205
|
-
// From functions.js and functions/*.js. See also "color", "op", "styling",
|
|
206
|
-
// and "text" above.
|
|
207
|
-
"accent": {
|
|
208
|
-
type: "accent";
|
|
209
|
-
mode: Mode;
|
|
210
|
-
loc?: SourceLocation | null | undefined;
|
|
211
|
-
label: string;
|
|
212
|
-
isStretchy?: boolean;
|
|
213
|
-
isShifty?: boolean;
|
|
214
|
-
base: AnyParseNode;
|
|
215
|
-
};
|
|
216
|
-
"accentUnder": {
|
|
217
|
-
type: "accentUnder";
|
|
218
|
-
mode: Mode;
|
|
219
|
-
loc?: SourceLocation | null | undefined;
|
|
220
|
-
label: string;
|
|
221
|
-
isStretchy?: boolean;
|
|
222
|
-
isShifty?: boolean;
|
|
223
|
-
base: AnyParseNode;
|
|
224
|
-
};
|
|
225
|
-
"cr": {
|
|
226
|
-
type: "cr";
|
|
227
|
-
mode: Mode;
|
|
228
|
-
loc?: SourceLocation | null | undefined;
|
|
229
|
-
newLine: boolean;
|
|
230
|
-
size: Measurement | null | undefined;
|
|
231
|
-
};
|
|
232
|
-
"delimsizing": {
|
|
233
|
-
type: "delimsizing";
|
|
234
|
-
mode: Mode;
|
|
235
|
-
loc?: SourceLocation | null | undefined;
|
|
236
|
-
size: DelimiterSize;
|
|
237
|
-
mclass: "mopen" | "mclose" | "mrel" | "mord";
|
|
238
|
-
delim: string;
|
|
239
|
-
};
|
|
240
|
-
"enclose": {
|
|
241
|
-
type: "enclose";
|
|
242
|
-
mode: Mode;
|
|
243
|
-
loc?: SourceLocation | null | undefined;
|
|
244
|
-
label: string;
|
|
245
|
-
backgroundColor?: string;
|
|
246
|
-
borderColor?: string;
|
|
247
|
-
body: AnyParseNode;
|
|
248
|
-
};
|
|
249
|
-
"environment": {
|
|
250
|
-
type: "environment";
|
|
251
|
-
mode: Mode;
|
|
252
|
-
loc?: SourceLocation | null | undefined;
|
|
253
|
-
name: string;
|
|
254
|
-
nameGroup: AnyParseNode;
|
|
255
|
-
};
|
|
256
|
-
"font": {
|
|
257
|
-
type: "font";
|
|
258
|
-
mode: Mode;
|
|
259
|
-
loc?: SourceLocation | null | undefined;
|
|
260
|
-
font: Exclude<MathFont, "">;
|
|
261
|
-
body: AnyParseNode;
|
|
262
|
-
};
|
|
263
|
-
"genfrac": {
|
|
264
|
-
type: "genfrac";
|
|
265
|
-
mode: Mode;
|
|
266
|
-
loc?: SourceLocation | null | undefined;
|
|
267
|
-
continued: boolean;
|
|
268
|
-
numer: AnyParseNode;
|
|
269
|
-
denom: AnyParseNode;
|
|
270
|
-
hasBarLine: boolean;
|
|
271
|
-
leftDelim: string | null | undefined;
|
|
272
|
-
rightDelim: string | null | undefined;
|
|
273
|
-
barSize: Measurement | null;
|
|
274
|
-
};
|
|
275
|
-
"hbox": {
|
|
276
|
-
type: "hbox";
|
|
277
|
-
mode: Mode;
|
|
278
|
-
loc?: SourceLocation | null | undefined;
|
|
279
|
-
body: AnyParseNode[];
|
|
280
|
-
};
|
|
281
|
-
"horizBrace": {
|
|
282
|
-
type: "horizBrace";
|
|
283
|
-
mode: Mode;
|
|
284
|
-
loc?: SourceLocation | null | undefined;
|
|
285
|
-
label: string;
|
|
286
|
-
isOver: boolean;
|
|
287
|
-
base: AnyParseNode;
|
|
288
|
-
};
|
|
289
|
-
"href": {
|
|
290
|
-
type: "href";
|
|
291
|
-
mode: Mode;
|
|
292
|
-
loc?: SourceLocation | null | undefined;
|
|
293
|
-
href: string;
|
|
294
|
-
body: AnyParseNode[];
|
|
295
|
-
};
|
|
296
|
-
"html": {
|
|
297
|
-
type: "html";
|
|
298
|
-
mode: Mode;
|
|
299
|
-
loc?: SourceLocation | null | undefined;
|
|
300
|
-
attributes: Record<string, string>;
|
|
301
|
-
body: AnyParseNode[];
|
|
302
|
-
};
|
|
303
|
-
"htmlmathml": {
|
|
304
|
-
type: "htmlmathml";
|
|
305
|
-
mode: Mode;
|
|
306
|
-
loc?: SourceLocation | null | undefined;
|
|
307
|
-
html: AnyParseNode[];
|
|
308
|
-
mathml: AnyParseNode[];
|
|
309
|
-
};
|
|
310
|
-
"includegraphics": {
|
|
311
|
-
type: "includegraphics";
|
|
312
|
-
mode: Mode;
|
|
313
|
-
loc?: SourceLocation | null | undefined;
|
|
314
|
-
alt: string;
|
|
315
|
-
width: Measurement;
|
|
316
|
-
height: Measurement;
|
|
317
|
-
totalheight: Measurement;
|
|
318
|
-
src: string;
|
|
319
|
-
};
|
|
320
|
-
"infix": {
|
|
321
|
-
type: "infix";
|
|
322
|
-
mode: Mode;
|
|
323
|
-
loc?: SourceLocation | null | undefined;
|
|
324
|
-
replaceWith: string;
|
|
325
|
-
size?: Measurement;
|
|
326
|
-
token: Token | null | undefined;
|
|
327
|
-
};
|
|
328
|
-
"internal": {
|
|
329
|
-
type: "internal";
|
|
330
|
-
mode: Mode;
|
|
331
|
-
loc?: SourceLocation | null | undefined;
|
|
332
|
-
};
|
|
333
|
-
"kern": {
|
|
334
|
-
type: "kern";
|
|
335
|
-
mode: Mode;
|
|
336
|
-
loc?: SourceLocation | null | undefined;
|
|
337
|
-
dimension: Measurement;
|
|
338
|
-
};
|
|
339
|
-
"lap": {
|
|
340
|
-
type: "lap";
|
|
341
|
-
mode: Mode;
|
|
342
|
-
loc?: SourceLocation | null | undefined;
|
|
343
|
-
alignment: string;
|
|
344
|
-
body: AnyParseNode;
|
|
345
|
-
};
|
|
346
|
-
"leftright": {
|
|
347
|
-
type: "leftright";
|
|
348
|
-
mode: Mode;
|
|
349
|
-
loc?: SourceLocation | null | undefined;
|
|
350
|
-
body: AnyParseNode[];
|
|
351
|
-
left: string;
|
|
352
|
-
right: string;
|
|
353
|
-
rightColor: string | null | undefined; // undefined means "inherit"
|
|
354
|
-
};
|
|
355
|
-
"leftright-right": {
|
|
356
|
-
type: "leftright-right";
|
|
357
|
-
mode: Mode;
|
|
358
|
-
loc?: SourceLocation | null | undefined;
|
|
359
|
-
delim: string;
|
|
360
|
-
color: string | null | undefined; // undefined means "inherit"
|
|
361
|
-
};
|
|
362
|
-
"mathchoice": {
|
|
363
|
-
type: "mathchoice";
|
|
364
|
-
mode: Mode;
|
|
365
|
-
loc?: SourceLocation | null | undefined;
|
|
366
|
-
display: AnyParseNode[];
|
|
367
|
-
text: AnyParseNode[];
|
|
368
|
-
script: AnyParseNode[];
|
|
369
|
-
scriptscript: AnyParseNode[];
|
|
370
|
-
};
|
|
371
|
-
"middle": {
|
|
372
|
-
type: "middle";
|
|
373
|
-
mode: Mode;
|
|
374
|
-
loc?: SourceLocation | null | undefined;
|
|
375
|
-
delim: string;
|
|
376
|
-
};
|
|
377
|
-
"mclass": {
|
|
378
|
-
type: "mclass";
|
|
379
|
-
mode: Mode;
|
|
380
|
-
loc?: SourceLocation | null | undefined;
|
|
381
|
-
mclass: string;
|
|
382
|
-
body: AnyParseNode[];
|
|
383
|
-
isCharacterBox: boolean;
|
|
384
|
-
};
|
|
385
|
-
"operatorname": {
|
|
386
|
-
type: "operatorname";
|
|
387
|
-
mode: Mode;
|
|
388
|
-
loc?: SourceLocation | null | undefined;
|
|
389
|
-
body: AnyParseNode[];
|
|
390
|
-
alwaysHandleSupSub: boolean;
|
|
391
|
-
limits: boolean;
|
|
392
|
-
parentIsSupSub: boolean;
|
|
393
|
-
};
|
|
394
|
-
"overline": {
|
|
395
|
-
type: "overline";
|
|
396
|
-
mode: Mode;
|
|
397
|
-
loc?: SourceLocation | null | undefined;
|
|
398
|
-
body: AnyParseNode;
|
|
399
|
-
};
|
|
400
|
-
"phantom": {
|
|
401
|
-
type: "phantom";
|
|
402
|
-
mode: Mode;
|
|
403
|
-
loc?: SourceLocation | null | undefined;
|
|
404
|
-
body: AnyParseNode[];
|
|
405
|
-
};
|
|
406
|
-
"vphantom": {
|
|
407
|
-
type: "vphantom";
|
|
408
|
-
mode: Mode;
|
|
409
|
-
loc?: SourceLocation | null | undefined;
|
|
410
|
-
body: AnyParseNode;
|
|
411
|
-
};
|
|
412
|
-
"pmb": {
|
|
413
|
-
type: "pmb";
|
|
414
|
-
mode: Mode;
|
|
415
|
-
loc?: SourceLocation | null | undefined;
|
|
416
|
-
mclass: string;
|
|
417
|
-
body: AnyParseNode[];
|
|
418
|
-
};
|
|
419
|
-
"raisebox": {
|
|
420
|
-
type: "raisebox";
|
|
421
|
-
mode: Mode;
|
|
422
|
-
loc?: SourceLocation | null | undefined;
|
|
423
|
-
dy: Measurement;
|
|
424
|
-
body: AnyParseNode;
|
|
425
|
-
};
|
|
426
|
-
"rule": {
|
|
427
|
-
type: "rule";
|
|
428
|
-
mode: Mode;
|
|
429
|
-
loc?: SourceLocation | null | undefined;
|
|
430
|
-
shift: Measurement | null | undefined;
|
|
431
|
-
width: Measurement;
|
|
432
|
-
height: Measurement;
|
|
433
|
-
};
|
|
434
|
-
"sizing": {
|
|
435
|
-
type: "sizing";
|
|
436
|
-
mode: Mode;
|
|
437
|
-
loc?: SourceLocation | null | undefined;
|
|
438
|
-
size: number;
|
|
439
|
-
body: AnyParseNode[];
|
|
440
|
-
};
|
|
441
|
-
"smash": {
|
|
442
|
-
type: "smash";
|
|
443
|
-
mode: Mode;
|
|
444
|
-
loc?: SourceLocation | null | undefined;
|
|
445
|
-
body: AnyParseNode;
|
|
446
|
-
smashHeight: boolean;
|
|
447
|
-
smashDepth: boolean;
|
|
448
|
-
};
|
|
449
|
-
"sqrt": {
|
|
450
|
-
type: "sqrt";
|
|
451
|
-
mode: Mode;
|
|
452
|
-
loc?: SourceLocation | null | undefined;
|
|
453
|
-
body: AnyParseNode;
|
|
454
|
-
index: AnyParseNode | null | undefined;
|
|
455
|
-
};
|
|
456
|
-
"underline": {
|
|
457
|
-
type: "underline";
|
|
458
|
-
mode: Mode;
|
|
459
|
-
loc?: SourceLocation | null | undefined;
|
|
460
|
-
body: AnyParseNode;
|
|
461
|
-
};
|
|
462
|
-
"vcenter": {
|
|
463
|
-
type: "vcenter";
|
|
464
|
-
mode: Mode;
|
|
465
|
-
loc?: SourceLocation | null | undefined;
|
|
466
|
-
body: AnyParseNode;
|
|
467
|
-
};
|
|
468
|
-
"xArrow": {
|
|
469
|
-
type: "xArrow";
|
|
470
|
-
mode: Mode;
|
|
471
|
-
loc?: SourceLocation | null | undefined;
|
|
472
|
-
label: string;
|
|
473
|
-
body: AnyParseNode;
|
|
474
|
-
below: AnyParseNode | null | undefined;
|
|
475
|
-
};
|
|
476
|
-
};
|
|
2
|
+
import type {AnyParseNode, NodeType, ParseNode, SymbolParseNode} from "./types/nodes";
|
|
477
3
|
|
|
478
4
|
/**
|
|
479
5
|
* Asserts that the node is of the given type and returns it with stricter
|
|
@@ -507,7 +33,7 @@ export function assertSymbolNodeType(node: AnyParseNode | null | undefined): Sym
|
|
|
507
33
|
}
|
|
508
34
|
|
|
509
35
|
/**
|
|
510
|
-
* Returns the node more strictly typed
|
|
36
|
+
* Returns the node more strictly typed if it is of the given type. Otherwise,
|
|
511
37
|
* returns null.
|
|
512
38
|
*/
|
|
513
39
|
export function checkSymbolNodeType(node: AnyParseNode | null | undefined): SymbolParseNode | null | undefined {
|
package/src/parseTree.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides a single function for parsing an expression using a Parser
|
|
3
|
-
* TODO(emily): Remove this
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
import Parser from "./Parser";
|
|
7
2
|
import ParseError from "./ParseError";
|
|
8
3
|
import {Token} from "./Token";
|
|
9
4
|
|
|
10
5
|
import type Settings from "./Settings";
|
|
11
|
-
import type {AnyParseNode} from "./
|
|
6
|
+
import type {AnyParseNode} from "./types/nodes";
|
|
12
7
|
|
|
13
8
|
/**
|
|
14
9
|
* Parses an expression using a Parser, then returns the parsed result.
|
package/src/spacingData.ts
CHANGED
package/src/stretchy.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {MathNode, TextNode} from "./mathMLTree";
|
|
|
10
10
|
import {makeEm} from "./units";
|
|
11
11
|
|
|
12
12
|
import type Options from "./Options";
|
|
13
|
-
import type {ParseNode} from "./
|
|
13
|
+
import type {ParseNode} from "./types/nodes";
|
|
14
14
|
import type {DomSpan, HtmlDomNode, SvgSpan} from "./domTree";
|
|
15
15
|
|
|
16
16
|
const stretchyCodePoint: Record<string, string> = {
|
package/src/svgGeometry.ts
CHANGED
|
@@ -507,8 +507,8 @@ M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`,
|
|
|
507
507
|
export const tallDelim = function(label: string, midHeight: number): string {
|
|
508
508
|
switch (label) {
|
|
509
509
|
case "lbrack":
|
|
510
|
-
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 h347 v-84
|
|
511
|
-
H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 h84z`;
|
|
510
|
+
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 v84 h347 v-84
|
|
511
|
+
H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 v84 h84z`;
|
|
512
512
|
case "rbrack":
|
|
513
513
|
return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v1759 H0 v84 H347z
|
|
514
514
|
M347 1759 V0 H263 V1759 v${midHeight} v1759 h84z`;
|
package/src/types/index.ts
CHANGED
|
@@ -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";
|