tex2typst 0.3.23 → 0.3.24
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/dist/convert.d.ts +9 -3
- package/dist/generic.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2092 -2009
- package/dist/tex-parser.d.ts +1 -1
- package/dist/tex-tokenizer.d.ts +1 -1
- package/dist/tex-types.d.ts +103 -0
- package/dist/tex-writer.d.ts +1 -2
- package/dist/tex2typst.min.js +13 -13
- package/dist/typst-parser.d.ts +6 -4
- package/dist/typst-tokenizer.d.ts +1 -1
- package/dist/typst-types.d.ts +95 -0
- package/dist/typst-writer.d.ts +4 -2
- package/package.json +1 -1
- package/src/convert.ts +455 -393
- package/src/generic.ts +28 -2
- package/src/index.ts +1 -1
- package/src/map.ts +5 -0
- package/src/tex-parser.ts +45 -54
- package/src/tex-tokenizer.ts +1 -1
- package/src/tex-types.ts +358 -0
- package/src/tex-writer.ts +3 -51
- package/src/typst-parser.ts +53 -55
- package/src/typst-tokenizer.ts +86 -85
- package/src/typst-types.ts +221 -0
- package/src/typst-writer.ts +79 -65
- package/src/util.ts +1 -1
- package/dist/types.d.ts +0 -109
- package/src/types.ts +0 -414
package/dist/index.js
CHANGED
|
@@ -1,1124 +1,15 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
["hspace", "#h"],
|
|
5
|
-
["|", "bar.v.double"],
|
|
6
|
-
[",", "thin"],
|
|
7
|
-
[":", "med"],
|
|
8
|
-
[";", "thick"],
|
|
9
|
-
/* textual operators */
|
|
10
|
-
["ln", "ln"],
|
|
11
|
-
["log", "log"],
|
|
12
|
-
["cos", "cos"],
|
|
13
|
-
["sin", "sin"],
|
|
14
|
-
["tan", "tan"],
|
|
15
|
-
["cot", "cot"],
|
|
16
|
-
["sec", "sec"],
|
|
17
|
-
["csc", "csc"],
|
|
18
|
-
["mod", "mod"],
|
|
19
|
-
["omicron", "omicron"],
|
|
20
|
-
["Xi", "Xi"],
|
|
21
|
-
["Upsilon", "Upsilon"],
|
|
22
|
-
["lim", "lim"],
|
|
23
|
-
["nonumber", ""],
|
|
24
|
-
["vec", "arrow"],
|
|
25
|
-
["neq", "eq.not"],
|
|
26
|
-
["dot", "dot"],
|
|
27
|
-
["ddot", "dot.double"],
|
|
28
|
-
["doteq", "dot(eq)"],
|
|
29
|
-
["dots", "dots.h"],
|
|
30
|
-
["vdots", "dots.v"],
|
|
31
|
-
["ddots", "dots.down"],
|
|
32
|
-
["widehat", "hat"],
|
|
33
|
-
// Ideally, the result of \widehat should be longer than \hat. But it is not implemented now.
|
|
34
|
-
["widetilde", "tilde"],
|
|
35
|
-
// Ideally, the result of \widetilde should be longer than \tilde. But it is not implemented now.
|
|
36
|
-
["quad", "quad"],
|
|
37
|
-
["qquad", "wide"],
|
|
38
|
-
["overbrace", "overbrace"],
|
|
39
|
-
// same
|
|
40
|
-
["underbrace", "underbrace"],
|
|
41
|
-
// same
|
|
42
|
-
["overline", "overline"],
|
|
43
|
-
// same
|
|
44
|
-
["underline", "underline"],
|
|
45
|
-
// same
|
|
46
|
-
["bar", "macron"],
|
|
47
|
-
["dbinom", "binom"],
|
|
48
|
-
["tbinom", "binom"],
|
|
49
|
-
["dfrac", "frac"],
|
|
50
|
-
["tfrac", "frac"],
|
|
51
|
-
["operatorname", "op"],
|
|
52
|
-
["boldsymbol", "bold"],
|
|
53
|
-
["mathbb", "bb"],
|
|
54
|
-
["mathbf", "bold"],
|
|
55
|
-
["mathcal", "cal"],
|
|
56
|
-
["mathit", "italic"],
|
|
57
|
-
["mathfrak", "frak"],
|
|
58
|
-
["mathrm", "upright"],
|
|
59
|
-
["mathsf", "sans"],
|
|
60
|
-
["mathtt", "mono"],
|
|
61
|
-
["rm", "upright"],
|
|
62
|
-
// TODO: \pmb need special logic to handle but it is not implemented now. See the commented test case.
|
|
63
|
-
["pmb", "bold"],
|
|
64
|
-
["leadsto", "arrow.r.squiggly"],
|
|
65
|
-
["P", "pilcrow"],
|
|
66
|
-
["S", "section"],
|
|
67
|
-
["aleph", "alef"],
|
|
68
|
-
["infin", "infinity"],
|
|
69
|
-
["Delta", "Delta"],
|
|
70
|
-
["Gamma", "Gamma"],
|
|
71
|
-
["Lambda", "Lambda"],
|
|
72
|
-
["Omega", "Omega"],
|
|
73
|
-
["Phi", "Phi"],
|
|
74
|
-
["Pi", "Pi"],
|
|
75
|
-
["Psi", "Psi"],
|
|
76
|
-
["Sigma", "Sigma"],
|
|
77
|
-
["Theta", "Theta"],
|
|
78
|
-
["alpha", "alpha"],
|
|
79
|
-
// ['amalg', 'product.co'],
|
|
80
|
-
["beta", "beta"],
|
|
81
|
-
["bigcirc", "circle.big"],
|
|
82
|
-
// ['bowtie', 'join'],
|
|
83
|
-
["bullet", "bullet"],
|
|
84
|
-
["cdot", "dot.op"],
|
|
85
|
-
// 'dot.op' or 'dot.c'
|
|
86
|
-
["cdots", "dots.c"],
|
|
87
|
-
["checkmark", "checkmark"],
|
|
88
|
-
["chi", "chi"],
|
|
89
|
-
["circ", "circle.small"],
|
|
90
|
-
// 'circle.small' or 'compose'
|
|
91
|
-
["colon", "colon"],
|
|
92
|
-
["cong", "tilde.equiv"],
|
|
93
|
-
["coprod", "product.co"],
|
|
94
|
-
["copyright", "copyright"],
|
|
95
|
-
["cup", "union"],
|
|
96
|
-
["curlyvee", "or.curly"],
|
|
97
|
-
["curlywedge", "and.curly"],
|
|
98
|
-
["dagger", "dagger"],
|
|
99
|
-
["dashv", "tack.l"],
|
|
100
|
-
["ddagger", "dagger.double"],
|
|
101
|
-
["delta", "delta"],
|
|
102
|
-
["ddots", "dots.down"],
|
|
103
|
-
["diamond", "diamond"],
|
|
104
|
-
["div", "div"],
|
|
105
|
-
["divideontimes", "times.div"],
|
|
106
|
-
["dotplus", "plus.dot"],
|
|
107
|
-
["ell", "ell"],
|
|
108
|
-
["emptyset", "nothing"],
|
|
109
|
-
["epsilon", "epsilon.alt"],
|
|
110
|
-
["equiv", "equiv"],
|
|
111
|
-
["eta", "eta"],
|
|
112
|
-
["exists", "exists"],
|
|
113
|
-
["forall", "forall"],
|
|
114
|
-
// ['frown', 'paren.t'],
|
|
115
|
-
["gamma", "gamma"],
|
|
116
|
-
["ge", "gt.eq"],
|
|
117
|
-
["geq", "gt.eq"],
|
|
118
|
-
["geqslant", "gt.eq.slant"],
|
|
119
|
-
["gg", "gt.double"],
|
|
120
|
-
["hbar", "planck.reduce"],
|
|
121
|
-
["imath", "dotless.i"],
|
|
122
|
-
["iiiint", "integral.quad"],
|
|
123
|
-
["iiint", "integral.triple"],
|
|
124
|
-
["iint", "integral.double"],
|
|
125
|
-
["in", "in"],
|
|
126
|
-
["infty", "infinity"],
|
|
127
|
-
["int", "integral"],
|
|
128
|
-
["intercal", "top"],
|
|
129
|
-
// 'top' or 'tack.b'
|
|
130
|
-
["iota", "iota"],
|
|
131
|
-
["jmath", "dotless.j"],
|
|
132
|
-
["kappa", "kappa"],
|
|
133
|
-
["lambda", "lambda"],
|
|
134
|
-
["land", "and"],
|
|
135
|
-
["langle", "angle.l"],
|
|
136
|
-
["lbrace", "brace.l"],
|
|
137
|
-
["lbrack", "bracket.l"],
|
|
138
|
-
["ldots", "dots.h"],
|
|
139
|
-
["le", "lt.eq"],
|
|
140
|
-
["leftthreetimes", "times.three.l"],
|
|
141
|
-
["leftrightarrow", "arrow.l.r"],
|
|
142
|
-
["leq", "lt.eq"],
|
|
143
|
-
["leqslant", "lt.eq.slant"],
|
|
144
|
-
["lhd", "triangle.l"],
|
|
145
|
-
["ll", "lt.double"],
|
|
146
|
-
// ['longmapsto', 'arrow.bar.long'],
|
|
147
|
-
// ['longrightarrow', 'arrow.long'],
|
|
148
|
-
["lor", "or"],
|
|
149
|
-
["ltimes", "times.l"],
|
|
150
|
-
// ['mapsto', 'arrow.bar'],
|
|
151
|
-
["measuredangle", "angle.arc"],
|
|
152
|
-
["mid", "divides"],
|
|
153
|
-
["models", "models"],
|
|
154
|
-
["mp", "minus.plus"],
|
|
155
|
-
["mu", "mu"],
|
|
156
|
-
// ['nRightarrow', 'arrow.double.not'],
|
|
157
|
-
["nabla", "nabla"],
|
|
158
|
-
["ncong", "tilde.equiv.not"],
|
|
159
|
-
["ne", "eq.not"],
|
|
160
|
-
["neg", "not"],
|
|
161
|
-
["neq", "eq.not"],
|
|
162
|
-
["nexists", "exists.not"],
|
|
163
|
-
["ni", "in.rev"],
|
|
164
|
-
["nleftarrow", "arrow.l.not"],
|
|
165
|
-
["nleq", "lt.eq.not"],
|
|
166
|
-
["nparallel", "parallel.not"],
|
|
167
|
-
["ngeq", "gt.eq.not"],
|
|
168
|
-
["nmid", "divides.not"],
|
|
169
|
-
["notin", "in.not"],
|
|
170
|
-
// ['nrightarrow', 'arrow.not'],
|
|
171
|
-
["nsim", "tilde.not"],
|
|
172
|
-
["nsubseteq", "subset.eq.not"],
|
|
173
|
-
["nu", "nu"],
|
|
174
|
-
["ntriangleleft", "lt.tri.not"],
|
|
175
|
-
["ntriangleright", "gt.tri.not"],
|
|
176
|
-
["odot", "dot.circle"],
|
|
177
|
-
["oint", "integral.cont"],
|
|
178
|
-
["oiint", "integral.surf"],
|
|
179
|
-
["oiiint", "integral.vol"],
|
|
180
|
-
["omega", "omega"],
|
|
181
|
-
["ominus", "minus.circle"],
|
|
182
|
-
// ['oplus', 'xor'], // or 'plus.circle'
|
|
183
|
-
["otimes", "times.circle"],
|
|
184
|
-
["parallel", "parallel"],
|
|
185
|
-
["partial", "diff"],
|
|
186
|
-
["perp", "perp"],
|
|
187
|
-
["phi", "phi.alt"],
|
|
188
|
-
["pi", "pi"],
|
|
189
|
-
["pm", "plus.minus"],
|
|
190
|
-
["pounds", "pound"],
|
|
191
|
-
["prec", "prec"],
|
|
192
|
-
["preceq", "prec.eq"],
|
|
193
|
-
["prime", "prime"],
|
|
194
|
-
["prod", "product"],
|
|
195
|
-
["propto", "prop"],
|
|
196
|
-
["psi", "psi"],
|
|
197
|
-
["rangle", "angle.r"],
|
|
198
|
-
["rbrace", "brace.r"],
|
|
199
|
-
["rbrack", "bracket.r"],
|
|
200
|
-
["rhd", "triangle"],
|
|
201
|
-
["rho", "rho"],
|
|
202
|
-
["rightarrow", "arrow.r"],
|
|
203
|
-
["rightthreetimes", "times.three.r"],
|
|
204
|
-
["rtimes", "times.r"],
|
|
205
|
-
["setminus", "without"],
|
|
206
|
-
["sigma", "sigma"],
|
|
207
|
-
["sim", "tilde.op"],
|
|
208
|
-
["simeq", "tilde.eq"],
|
|
209
|
-
["slash", "slash"],
|
|
210
|
-
["smallsetminus", "without"],
|
|
211
|
-
// ['smile', 'paren.b'],
|
|
212
|
-
["spadesuit", "suit.spade"],
|
|
213
|
-
["sqsubseteq", "subset.eq.sq"],
|
|
214
|
-
["sqsupseteq", "supset.eq.sq"],
|
|
215
|
-
// ['star', 'star'],
|
|
216
|
-
["subset", "subset"],
|
|
217
|
-
["subseteq", "subset.eq"],
|
|
218
|
-
["subsetneq", "subset.neq"],
|
|
219
|
-
["succ", "succ"],
|
|
220
|
-
["succeq", "succ.eq"],
|
|
221
|
-
["sum", "sum"],
|
|
222
|
-
["supset", "supset"],
|
|
223
|
-
["supseteq", "supset.eq"],
|
|
224
|
-
["supsetneq", "supset.neq"],
|
|
225
|
-
["tau", "tau"],
|
|
226
|
-
["theta", "theta"],
|
|
227
|
-
["times", "times"],
|
|
228
|
-
["to", "arrow.r"],
|
|
229
|
-
["top", "top"],
|
|
230
|
-
["triangle", "triangle.t"],
|
|
231
|
-
// ['triangledown', 'triangle.b.small'],
|
|
232
|
-
// ['triangleleft', 'triangle.l.small'],
|
|
233
|
-
// ['triangleright', 'triangle.r.small'],
|
|
234
|
-
["twoheadrightarrow", "arrow.r.twohead"],
|
|
235
|
-
["upharpoonright", "harpoon.tr"],
|
|
236
|
-
["uplus", "union.plus"],
|
|
237
|
-
["upsilon", "upsilon"],
|
|
238
|
-
["varepsilon", "epsilon"],
|
|
239
|
-
["varnothing", "diameter"],
|
|
240
|
-
// empty set
|
|
241
|
-
["varphi", "phi"],
|
|
242
|
-
["varpi", "pi.alt"],
|
|
243
|
-
["varrho", "rho.alt"],
|
|
244
|
-
["varsigma", "sigma.alt"],
|
|
245
|
-
["vartheta", "theta.alt"],
|
|
246
|
-
["vdash", "tack.r"],
|
|
247
|
-
["vdots", "dots.v"],
|
|
248
|
-
["vee", "or"],
|
|
249
|
-
["wedge", "and"],
|
|
250
|
-
["wr", "wreath"],
|
|
251
|
-
["xi", "xi"],
|
|
252
|
-
["yen", "yen"],
|
|
253
|
-
["zeta", "zeta"],
|
|
254
|
-
// extended
|
|
255
|
-
["mathscr", "scr"],
|
|
256
|
-
["LaTeX", "#LaTeX"],
|
|
257
|
-
["TeX", "#TeX"]
|
|
258
|
-
]);
|
|
259
|
-
var map_from_official_docs = /* @__PURE__ */ new Map([
|
|
260
|
-
["acwopencirclearrow", "arrow.ccw"],
|
|
261
|
-
["adots", "dots.up"],
|
|
262
|
-
["angdnr", "angle.acute"],
|
|
263
|
-
["angle", "angle"],
|
|
264
|
-
["angles", "angle.s"],
|
|
265
|
-
["approx", "approx"],
|
|
266
|
-
["approxeq", "approx.eq"],
|
|
267
|
-
["approxident", "tilde.triple"],
|
|
268
|
-
["assert", "tack.r.short"],
|
|
269
|
-
["ast", "ast.op"],
|
|
270
|
-
["asymp", "asymp"],
|
|
271
|
-
["awint", "integral.ccw"],
|
|
272
|
-
["backcong", "tilde.rev.equiv"],
|
|
273
|
-
["backdprime", "prime.double.rev"],
|
|
274
|
-
["backprime", "prime.rev"],
|
|
275
|
-
["backsim", "tilde.rev"],
|
|
276
|
-
["backsimeq", "tilde.eq.rev"],
|
|
277
|
-
["backslash", "backslash"],
|
|
278
|
-
["backtrprime", "prime.triple.rev"],
|
|
279
|
-
["bardownharpoonleft", "harpoon.bl.bar"],
|
|
280
|
-
["bardownharpoonright", "harpoon.br.bar"],
|
|
281
|
-
["barleftarrow", "arrow.l.stop"],
|
|
282
|
-
["barleftarrowrightarrowbar", "arrows.lr.stop"],
|
|
283
|
-
["barleftharpoondown", "harpoon.lb.stop"],
|
|
284
|
-
["barleftharpoonup", "harpoon.lt.stop"],
|
|
285
|
-
["barrightharpoondown", "harpoon.rb.bar"],
|
|
286
|
-
["barrightharpoonup", "harpoon.rt.bar"],
|
|
287
|
-
["baruparrow", "arrow.t.stop"],
|
|
288
|
-
["barupharpoonleft", "harpoon.tl.stop"],
|
|
289
|
-
["barupharpoonright", "harpoon.tr.stop"],
|
|
290
|
-
["barV", "tack.b.double"],
|
|
291
|
-
["BbbA", "AA"],
|
|
292
|
-
["BbbB", "BB"],
|
|
293
|
-
["BbbC", "CC"],
|
|
294
|
-
["BbbD", "DD"],
|
|
295
|
-
["BbbE", "EE"],
|
|
296
|
-
["BbbF", "FF"],
|
|
297
|
-
["BbbG", "GG"],
|
|
298
|
-
["BbbH", "HH"],
|
|
299
|
-
["BbbI", "II"],
|
|
300
|
-
["BbbJ", "JJ"],
|
|
301
|
-
["BbbK", "KK"],
|
|
302
|
-
["BbbL", "LL"],
|
|
303
|
-
["BbbM", "MM"],
|
|
304
|
-
["BbbN", "NN"],
|
|
305
|
-
["BbbO", "OO"],
|
|
306
|
-
["BbbP", "PP"],
|
|
307
|
-
["BbbQ", "QQ"],
|
|
308
|
-
["BbbR", "RR"],
|
|
309
|
-
["BbbS", "SS"],
|
|
310
|
-
["BbbT", "TT"],
|
|
311
|
-
["BbbU", "UU"],
|
|
312
|
-
["BbbV", "VV"],
|
|
313
|
-
["BbbW", "WW"],
|
|
314
|
-
["BbbX", "XX"],
|
|
315
|
-
["BbbY", "YY"],
|
|
316
|
-
["BbbZ", "ZZ"],
|
|
317
|
-
["because", "because"],
|
|
318
|
-
["bigblacktriangledown", "triangle.filled.b"],
|
|
319
|
-
["bigblacktriangleup", "triangle.filled.t"],
|
|
320
|
-
["bigbot", "tack.t.big"],
|
|
321
|
-
["bigcap", "inter.big"],
|
|
322
|
-
["bigcup", "union.big"],
|
|
323
|
-
["bigcupdot", "union.dot.big"],
|
|
324
|
-
["biginterleave", "interleave.big"],
|
|
325
|
-
["bigodot", "dot.circle.big"],
|
|
326
|
-
["bigoplus", "plus.circle.big"],
|
|
327
|
-
// or 'xor.big'
|
|
328
|
-
["bigotimes", "times.circle.big"],
|
|
329
|
-
["bigsqcap", "inter.sq.big"],
|
|
330
|
-
["bigsqcup", "union.sq.big"],
|
|
331
|
-
["bigstar", "star.filled"],
|
|
332
|
-
["bigtimes", "times.big"],
|
|
333
|
-
["bigtop", "tack.b.big"],
|
|
334
|
-
["bigtriangledown", "triangle.stroked.b"],
|
|
335
|
-
// or 'triangle.b'
|
|
336
|
-
["bigtriangleup", "triangle.stroked.t"],
|
|
337
|
-
// or 'triangle.t'
|
|
338
|
-
["biguplus", "union.plus.big"],
|
|
339
|
-
["bigvee", "or.big"],
|
|
340
|
-
["bigwedge", "and.big"],
|
|
341
|
-
["bigwhitestar", "star.stroked"],
|
|
342
|
-
["blackhourglass", "hourglass.filled"],
|
|
343
|
-
["blacktriangle", "triangle.filled.small.t"],
|
|
344
|
-
["blacktriangledown", "triangle.filled.small.b"],
|
|
345
|
-
["blacktriangleleft", "triangle.filled.l"],
|
|
346
|
-
["blacktriangleright", "triangle.filled.r"],
|
|
347
|
-
["blkhorzoval", "ellipse.filled.h"],
|
|
348
|
-
["blkvertoval", "ellipse.filled.v"],
|
|
349
|
-
["bot", "bot"],
|
|
350
|
-
["boxast", "ast.square"],
|
|
351
|
-
["boxdot", "dot.square"],
|
|
352
|
-
["boxminus", "minus.square"],
|
|
353
|
-
["boxplus", "plus.square"],
|
|
354
|
-
["boxtimes", "times.square"],
|
|
355
|
-
["cap", "inter"],
|
|
356
|
-
["Cap", "inter.double"],
|
|
357
|
-
["capdot", "inter.dot"],
|
|
358
|
-
["capwedge", "inter.and"],
|
|
359
|
-
["caretinsert", "caret"],
|
|
360
|
-
["cdot", "dot.op"],
|
|
361
|
-
["cdotp", "dot.c"],
|
|
362
|
-
["checkmark", "checkmark"],
|
|
363
|
-
["circledast", "ast.circle"],
|
|
364
|
-
["circledcirc", "circle.nested"],
|
|
365
|
-
["circleddash", "dash.circle"],
|
|
366
|
-
["circledequal", "eq.circle"],
|
|
367
|
-
["circledparallel", "parallel.circle"],
|
|
368
|
-
["circledvert", "bar.v.circle"],
|
|
369
|
-
["clubsuit", "suit.club.filled"],
|
|
370
|
-
["Colon", "colon.double"],
|
|
371
|
-
["coloneq", "colon.eq"],
|
|
372
|
-
["Coloneq", "colon.double.eq"],
|
|
373
|
-
["complement", "complement"],
|
|
374
|
-
["cong", "tilde.equiv"],
|
|
375
|
-
["coprod", "product.co"],
|
|
376
|
-
["cup", "union"],
|
|
377
|
-
["Cup", "union.double"],
|
|
378
|
-
["cupdot", "union.dot"],
|
|
379
|
-
["cupleftarrow", "union.arrow"],
|
|
380
|
-
["cupvee", "union.or"],
|
|
381
|
-
["curlyeqprec", "eq.prec"],
|
|
382
|
-
["curlyeqsucc", "eq.succ"],
|
|
383
|
-
["curlyvee", "or.curly"],
|
|
384
|
-
["curlywedge", "and.curly"],
|
|
385
|
-
["curvearrowleft", "arrow.ccw.half"],
|
|
386
|
-
["curvearrowright", "arrow.cw.half"],
|
|
387
|
-
["cwopencirclearrow", "arrow.cw"],
|
|
388
|
-
["dagger", "dagger"],
|
|
389
|
-
["dashcolon", "dash.colon"],
|
|
390
|
-
["dashv", "tack.l"],
|
|
391
|
-
["Dashv", "tack.l.double"],
|
|
392
|
-
["dashVdash", "tack.l.r"],
|
|
393
|
-
["ddagger", "dagger.double"],
|
|
394
|
-
["ddddot", "dot.quad"],
|
|
395
|
-
["dddot", "dot.triple"],
|
|
396
|
-
["ddots", "dots.down"],
|
|
397
|
-
["DDownarrow", "arrow.b.quad"],
|
|
398
|
-
["Ddownarrow", "arrow.b.triple"],
|
|
399
|
-
["diameter", "diameter"],
|
|
400
|
-
["diamondcdot", "diamond.stroked.dot"],
|
|
401
|
-
["diamondsuit", "suit.diamond.stroked"],
|
|
402
|
-
["dicei", "die.one"],
|
|
403
|
-
["diceii", "die.two"],
|
|
404
|
-
["diceiii", "die.three"],
|
|
405
|
-
["diceiv", "die.four"],
|
|
406
|
-
["dicev", "die.five"],
|
|
407
|
-
["dicevi", "die.six"],
|
|
408
|
-
["div", "div"],
|
|
409
|
-
["divideontimes", "times.div"],
|
|
410
|
-
["Doteq", "eq.dots"],
|
|
411
|
-
["dotminus", "minus.dot"],
|
|
412
|
-
["dotplus", "plus.dot"],
|
|
413
|
-
["dotsim", "tilde.dot"],
|
|
414
|
-
["dottedcircle", "circle.dotted"],
|
|
415
|
-
["dottedsquare", "square.stroked.dotted"],
|
|
416
|
-
["doubleplus", "plus.double"],
|
|
417
|
-
["downarrow", "arrow.b"],
|
|
418
|
-
["Downarrow", "arrow.b.double"],
|
|
419
|
-
["downarrowbar", "arrow.b.stop"],
|
|
420
|
-
["downdasharrow", "arrow.b.dashed"],
|
|
421
|
-
["downdownarrows", "arrows.bb"],
|
|
422
|
-
["downharpoonleft", "harpoon.bl"],
|
|
423
|
-
["downharpoonleftbar", "harpoon.bl.stop"],
|
|
424
|
-
["downharpoonright", "harpoon.br"],
|
|
425
|
-
["downharpoonrightbar", "harpoon.br.stop"],
|
|
426
|
-
["downharpoonsleftright", "harpoons.blbr"],
|
|
427
|
-
["downrightcurvedarrow", "arrow.b.curve"],
|
|
428
|
-
["downuparrows", "arrows.bt"],
|
|
429
|
-
["downupharpoonsleftright", "harpoons.bltr"],
|
|
430
|
-
["downwhitearrow", "arrow.b.stroked"],
|
|
431
|
-
["downzigzagarrow", "arrow.zigzag"],
|
|
432
|
-
["dprime", "prime.double"],
|
|
433
|
-
["dualmap", "multimap.double"],
|
|
434
|
-
["eighthnote", "note.eighth.alt"],
|
|
435
|
-
["ell", "ell"],
|
|
436
|
-
["emptysetoarr", "emptyset.arrow.r"],
|
|
437
|
-
["emptysetoarrl", "emptyset.arrow.l"],
|
|
438
|
-
["emptysetobar", "emptyset.bar"],
|
|
439
|
-
["emptysetocirc", "emptyset.circle"],
|
|
440
|
-
["eparsl", "parallel.slanted.eq"],
|
|
441
|
-
["eqcolon", "eq.colon"],
|
|
442
|
-
["eqdef", "eq.def"],
|
|
443
|
-
// \usepackage{mathtools} defines \eqdef
|
|
444
|
-
["eqgtr", "eq.gt"],
|
|
445
|
-
["eqless", "eq.lt"],
|
|
446
|
-
["eqsim", "minus.tilde"],
|
|
447
|
-
["equal", "eq"],
|
|
448
|
-
["equalparallel", "parallel.eq"],
|
|
449
|
-
["equiv", "eq.triple"],
|
|
450
|
-
["Equiv", "eq.quad"],
|
|
451
|
-
["equivVert", "parallel.equiv"],
|
|
452
|
-
["eqvparsl", "parallel.slanted.equiv"],
|
|
453
|
-
["errbarblackcircle", "errorbar.circle.filled"],
|
|
454
|
-
["errbarblackdiamond", "errorbar.diamond.filled"],
|
|
455
|
-
["errbarblacksquare", "errorbar.square.filled"],
|
|
456
|
-
["errbarcircle", "errorbar.circle.stroked"],
|
|
457
|
-
["errbardiamond", "errorbar.diamond.stroked"],
|
|
458
|
-
["errbarsquare", "errorbar.square.stroked"],
|
|
459
|
-
["euro", "euro"],
|
|
460
|
-
["Exclam", "excl.double"],
|
|
461
|
-
["exists", "exists"],
|
|
462
|
-
["fallingdotseq", "eq.dots.down"],
|
|
463
|
-
["fint", "integral.slash"],
|
|
464
|
-
["flat", "flat"],
|
|
465
|
-
["forall", "forall"],
|
|
466
|
-
["fourvdots", "fence.dotted"],
|
|
467
|
-
["fullouterjoin", "join.l.r"],
|
|
468
|
-
["geq", "gt.eq"],
|
|
469
|
-
["geqq", "gt.equiv"],
|
|
470
|
-
["geqslant", "gt.eq.slant"],
|
|
471
|
-
["gg", "gt.double"],
|
|
472
|
-
["ggg", "gt.triple"],
|
|
473
|
-
["gggnest", "gt.triple.nested"],
|
|
474
|
-
["gnapprox", "gt.napprox"],
|
|
475
|
-
["gneq", "gt.neq"],
|
|
476
|
-
["gneqq", "gt.nequiv"],
|
|
477
|
-
["gnsim", "gt.ntilde"],
|
|
478
|
-
["greater", "gt"],
|
|
479
|
-
["gtlpar", "angle.spheric.rev"],
|
|
480
|
-
["gtrapprox", "gt.approx"],
|
|
481
|
-
["gtrdot", "gt.dot"],
|
|
482
|
-
["gtreqless", "gt.eq.lt"],
|
|
483
|
-
["gtrless", "gt.lt"],
|
|
484
|
-
["gtrsim", "gt.tilde"],
|
|
485
|
-
["heartsuit", "suit.heart.stroked"],
|
|
486
|
-
["hknearrow", "arrow.tr.hook"],
|
|
487
|
-
["hknwarrow", "arrow.tl.hook"],
|
|
488
|
-
["hksearrow", "arrow.br.hook"],
|
|
489
|
-
["hkswarrow", "arrow.bl.hook"],
|
|
490
|
-
["hookleftarrow", "arrow.l.hook"],
|
|
491
|
-
["hookrightarrow", "arrow.r.hook"],
|
|
492
|
-
["horizbar", "bar.h"],
|
|
493
|
-
["hourglass", "hourglass.stroked"],
|
|
494
|
-
["hrectangle", "rect.stroked.h"],
|
|
495
|
-
["hrectangleblack", "rect.filled.h"],
|
|
496
|
-
["hslash", "planck.reduce"],
|
|
497
|
-
["hzigzag", "dash.wave.double"],
|
|
498
|
-
["iiiint", "integral.quad"],
|
|
499
|
-
["iiint", "integral.triple"],
|
|
500
|
-
["iinfin", "infinity.incomplete"],
|
|
501
|
-
["iint", "integral.double"],
|
|
502
|
-
["Im", "Im"],
|
|
503
|
-
["imageof", "image"],
|
|
504
|
-
["in", "in"],
|
|
505
|
-
["increment", "laplace"],
|
|
506
|
-
["infty", "infinity"],
|
|
507
|
-
["int", "integral"],
|
|
508
|
-
["intbar", "integral.dash"],
|
|
509
|
-
["intBar", "integral.dash.double"],
|
|
510
|
-
["intcap", "integral.inter"],
|
|
511
|
-
["intclockwise", "integral.cw"],
|
|
512
|
-
["intcup", "integral.union"],
|
|
513
|
-
["interleave", "interleave"],
|
|
514
|
-
["intlarhk", "integral.arrow.hook"],
|
|
515
|
-
["intx", "integral.times"],
|
|
516
|
-
["Join", "join"],
|
|
517
|
-
["langle", "angle.l"],
|
|
518
|
-
["lAngle", "angle.l.double"],
|
|
519
|
-
["langledot", "angle.l.dot"],
|
|
520
|
-
["lat", "lat"],
|
|
521
|
-
["late", "lat.eq"],
|
|
522
|
-
["lbrace", "brace.l"],
|
|
523
|
-
["lBrace", "brace.l.double"],
|
|
524
|
-
["lbrack", "bracket.l"],
|
|
525
|
-
["lBrack", "bracket.l.double"],
|
|
526
|
-
["lbrbrak", "shell.l"],
|
|
527
|
-
["Lbrbrak", "shell.l.double"],
|
|
528
|
-
["lceil", "ceil.l"],
|
|
529
|
-
["lcurvyangle", "angle.l.curly"],
|
|
530
|
-
["leftarrow", "arrow.l"],
|
|
531
|
-
["Leftarrow", "arrow.l.double"],
|
|
532
|
-
["leftarrowtail", "arrow.l.tail"],
|
|
533
|
-
["leftdasharrow", "arrow.l.dashed"],
|
|
534
|
-
["leftdotarrow", "arrow.l.dotted"],
|
|
535
|
-
["leftdowncurvedarrow", "arrow.l.curve"],
|
|
536
|
-
["leftharpoondown", "harpoon.lb"],
|
|
537
|
-
["leftharpoondownbar", "harpoon.lb.bar"],
|
|
538
|
-
["leftharpoonsupdown", "harpoons.ltlb"],
|
|
539
|
-
["leftharpoonup", "harpoon.lt"],
|
|
540
|
-
["leftharpoonupbar", "harpoon.lt.bar"],
|
|
541
|
-
["leftleftarrows", "arrows.ll"],
|
|
542
|
-
["leftouterjoin", "join.l"],
|
|
543
|
-
["leftrightarrow", "arrow.l.r"],
|
|
544
|
-
["Leftrightarrow", "arrow.l.r.double"],
|
|
545
|
-
["leftrightarrows", "arrows.lr"],
|
|
546
|
-
["leftrightharpoondowndown", "harpoon.lb.rb"],
|
|
547
|
-
["leftrightharpoondownup", "harpoon.lb.rt"],
|
|
548
|
-
["leftrightharpoons", "harpoons.ltrb"],
|
|
549
|
-
["leftrightharpoonsdown", "harpoons.lbrb"],
|
|
550
|
-
["leftrightharpoonsup", "harpoons.ltrt"],
|
|
551
|
-
["leftrightharpoonupdown", "harpoon.lt.rb"],
|
|
552
|
-
["leftrightharpoonupup", "harpoon.lt.rt"],
|
|
553
|
-
["leftrightsquigarrow", "arrow.l.r.wave"],
|
|
554
|
-
["leftsquigarrow", "arrow.l.squiggly"],
|
|
555
|
-
["leftthreearrows", "arrows.lll"],
|
|
556
|
-
["leftthreetimes", "times.three.l"],
|
|
557
|
-
["leftwavearrow", "arrow.l.wave"],
|
|
558
|
-
["leftwhitearrow", "arrow.l.stroked"],
|
|
559
|
-
["leq", "lt.eq"],
|
|
560
|
-
["leqq", "lt.equiv"],
|
|
561
|
-
["leqslant", "lt.eq.slant"],
|
|
562
|
-
["less", "lt"],
|
|
563
|
-
["lessapprox", "lt.approx"],
|
|
564
|
-
["lessdot", "lt.dot"],
|
|
565
|
-
["lesseqgtr", "lt.eq.gt"],
|
|
566
|
-
["lessgtr", "lt.gt"],
|
|
567
|
-
["lesssim", "lt.tilde"],
|
|
568
|
-
["lfloor", "floor.l"],
|
|
569
|
-
["lgblkcircle", "circle.filled.big"],
|
|
570
|
-
["lgblksquare", "square.filled.big"],
|
|
571
|
-
["lgwhtcircle", "circle.stroked.big"],
|
|
572
|
-
["lgwhtsquare", "square.stroked.big"],
|
|
573
|
-
["ll", "lt.double"],
|
|
574
|
-
["llblacktriangle", "triangle.filled.bl"],
|
|
575
|
-
["LLeftarrow", "arrow.l.quad"],
|
|
576
|
-
["Lleftarrow", "arrow.l.triple"],
|
|
577
|
-
["lll", "lt.triple"],
|
|
578
|
-
["lllnest", "lt.triple.nested"],
|
|
579
|
-
["lltriangle", "triangle.stroked.bl"],
|
|
580
|
-
["lnapprox", "lt.napprox"],
|
|
581
|
-
["lneq", "lt.neq"],
|
|
582
|
-
["lneqq", "lt.nequiv"],
|
|
583
|
-
["lnsim", "lt.ntilde"],
|
|
584
|
-
["longdashv", "tack.l.long"],
|
|
585
|
-
["Longleftarrow", "arrow.l.double.long"],
|
|
586
|
-
["longleftarrow", "arrow.l.long"],
|
|
587
|
-
["Longleftrightarrow", "arrow.l.r.double.long"],
|
|
588
|
-
["longleftrightarrow", "arrow.l.r.long"],
|
|
589
|
-
["longleftsquigarrow", "arrow.l.long.squiggly"],
|
|
590
|
-
["Longmapsfrom", "arrow.l.double.long.bar"],
|
|
591
|
-
["longmapsfrom", "arrow.l.long.bar"],
|
|
592
|
-
["longmapsto", "arrow.r.long.bar"],
|
|
593
|
-
["Longmapsto", "arrow.r.double.long.bar"],
|
|
594
|
-
["Longrightarrow", "arrow.r.double.long"],
|
|
595
|
-
["longrightarrow", "arrow.r.long"],
|
|
596
|
-
["longrightsquigarrow", "arrow.r.long.squiggly"],
|
|
597
|
-
["looparrowleft", "arrow.l.loop"],
|
|
598
|
-
["looparrowright", "arrow.r.loop"],
|
|
599
|
-
["lparen", "paren.l"],
|
|
600
|
-
["lParen", "paren.l.double"],
|
|
601
|
-
["lrblacktriangle", "triangle.filled.br"],
|
|
602
|
-
["lrtriangle", "triangle.stroked.br"],
|
|
603
|
-
["ltimes", "times.l"],
|
|
604
|
-
["lvzigzag", "fence.l"],
|
|
605
|
-
["Lvzigzag", "fence.l.double"],
|
|
606
|
-
["maltese", "maltese"],
|
|
607
|
-
["mapsdown", "arrow.b.bar"],
|
|
608
|
-
["mapsfrom", "arrow.l.bar"],
|
|
609
|
-
["Mapsfrom", "arrow.l.double.bar"],
|
|
610
|
-
["mapsto", "arrow.r.bar"],
|
|
611
|
-
["Mapsto", "arrow.r.double.bar"],
|
|
612
|
-
["mapsup", "arrow.t.bar"],
|
|
613
|
-
["mathampersand", "amp"],
|
|
614
|
-
["mathatsign", "at"],
|
|
615
|
-
["mathcolon", "colon"],
|
|
616
|
-
["mathcomma", "comma"],
|
|
617
|
-
["mathdollar", "dollar"],
|
|
618
|
-
["mathexclam", "excl"],
|
|
619
|
-
// ['mathhyphen', 'hyph'], // \mathhyphen is not defined in standard amsmath package
|
|
620
|
-
["mathoctothorpe", "hash"],
|
|
621
|
-
["mathparagraph", "pilcrow"],
|
|
622
|
-
["mathpercent", "percent"],
|
|
623
|
-
["mathperiod", "dot.basic"],
|
|
624
|
-
["mathplus", "plus"],
|
|
625
|
-
["mathquestion", "quest"],
|
|
626
|
-
["mathratio", "ratio"],
|
|
627
|
-
["mathsection", "section"],
|
|
628
|
-
["mathsemicolon", "semi"],
|
|
629
|
-
["mathslash", "slash"],
|
|
630
|
-
["mathsterling", "pound"],
|
|
631
|
-
["mathyen", "yen"],
|
|
632
|
-
["mdblkdiamond", "diamond.filled.medium"],
|
|
633
|
-
["mdblklozenge", "lozenge.filled.medium"],
|
|
634
|
-
["mdblksquare", "square.filled.medium"],
|
|
635
|
-
["mdlgblkcircle", "circle.filled"],
|
|
636
|
-
["mdlgblkdiamond", "diamond.filled"],
|
|
637
|
-
["mdlgblklozenge", "lozenge.filled"],
|
|
638
|
-
["mdlgblksquare", "square.filled"],
|
|
639
|
-
["mdlgwhtcircle", "circle.stroked"],
|
|
640
|
-
["mdlgwhtdiamond", "diamond.stroked"],
|
|
641
|
-
["mdlgwhtlozenge", "lozenge.stroked"],
|
|
642
|
-
["mdlgwhtsquare", "square.stroked"],
|
|
643
|
-
["mdsmblkcircle", "circle.filled.tiny"],
|
|
644
|
-
["mdsmblksquare", "square.filled.small"],
|
|
645
|
-
["mdsmwhtcircle", "circle.stroked.small"],
|
|
646
|
-
["mdsmwhtsquare", "square.stroked.small"],
|
|
647
|
-
["mdwhtdiamond", "diamond.stroked.medium"],
|
|
648
|
-
["mdwhtlozenge", "lozenge.stroked.medium"],
|
|
649
|
-
["mdwhtsquare", "square.stroked.medium"],
|
|
650
|
-
["measeq", "eq.m"],
|
|
651
|
-
["measuredangle", "angle.arc"],
|
|
652
|
-
["measuredangleleft", "angle.arc.rev"],
|
|
653
|
-
["measuredrightangle", "angle.right.arc"],
|
|
654
|
-
["mho", "Omega.inv"],
|
|
655
|
-
["mid", "divides"],
|
|
656
|
-
["minus", "minus"],
|
|
657
|
-
["models", "models"],
|
|
658
|
-
["mp", "minus.plus"],
|
|
659
|
-
["multimap", "multimap"],
|
|
660
|
-
/* ['mupAlpha', 'Alpha'],
|
|
661
|
-
['mupalpha', 'alpha'],
|
|
662
|
-
['mupBeta', 'Beta'],
|
|
663
|
-
['mupbeta', 'beta'],
|
|
664
|
-
['mupChi', 'Chi'],
|
|
665
|
-
['mupchi', 'chi'],
|
|
666
|
-
['mupDelta', 'Delta'],
|
|
667
|
-
['mupdelta', 'delta'],
|
|
668
|
-
['mupEpsilon', 'Epsilon'],
|
|
669
|
-
['mupepsilon', 'epsilon.alt'],
|
|
670
|
-
['mupEta', 'Eta'],
|
|
671
|
-
['mupeta', 'eta'],
|
|
672
|
-
['mupGamma', 'Gamma'],
|
|
673
|
-
['mupgamma', 'gamma'],
|
|
674
|
-
['mupIota', 'Iota'],
|
|
675
|
-
['mupiota', 'iota'],
|
|
676
|
-
['mupKappa', 'Kappa'],
|
|
677
|
-
['mupkappa', 'kappa'],
|
|
678
|
-
['mupLambda', 'Lambda'],
|
|
679
|
-
['muplambda', 'lambda'],
|
|
680
|
-
['mupMu', 'Mu'],
|
|
681
|
-
['mupmu', 'mu'],
|
|
682
|
-
['mupNu', 'Nu'],
|
|
683
|
-
['mupnu', 'nu'],
|
|
684
|
-
['mupOmega', 'Omega'],
|
|
685
|
-
['mupomega', 'omega'],
|
|
686
|
-
['mupOmicron', 'Omicron'],
|
|
687
|
-
['mupomicron', 'omicron'],
|
|
688
|
-
['mupPhi', 'Phi'],
|
|
689
|
-
['mupphi', 'phi.alt'],
|
|
690
|
-
['mupPi', 'Pi'],
|
|
691
|
-
['muppi', 'pi'],
|
|
692
|
-
['mupPsi', 'Psi'],
|
|
693
|
-
['muppsi', 'psi'],
|
|
694
|
-
['mupRho', 'Rho'],
|
|
695
|
-
['muprho', 'rho'],
|
|
696
|
-
['mupSigma', 'Sigma'],
|
|
697
|
-
['mupsigma', 'sigma'],
|
|
698
|
-
['mupTau', 'Tau'],
|
|
699
|
-
['muptau', 'tau'],
|
|
700
|
-
['mupTheta', 'Theta'],
|
|
701
|
-
['muptheta', 'theta'],
|
|
702
|
-
['mupUpsilon', 'Upsilon'],
|
|
703
|
-
['mupupsilon', 'upsilon'],
|
|
704
|
-
['mupvarepsilon', 'epsilon'],
|
|
705
|
-
['mupvarkappa', 'kappa.alt'],
|
|
706
|
-
['mupvarphi', 'phi'],
|
|
707
|
-
['mupvarpi', 'pi.alt'],
|
|
708
|
-
['mupvarrho', 'rho.alt'],
|
|
709
|
-
['mupvarsigma', 'sigma.alt'],
|
|
710
|
-
['mupvartheta', 'theta.alt'],
|
|
711
|
-
['mupXi', 'Xi'],
|
|
712
|
-
['mupxi', 'xi'],
|
|
713
|
-
['mupZeta', 'Zeta'],
|
|
714
|
-
['mupzeta', 'zeta'], */
|
|
715
|
-
["nabla", "gradient"],
|
|
716
|
-
["napprox", "approx.not"],
|
|
717
|
-
["nasymp", "asymp.not"],
|
|
718
|
-
["natural", "natural"],
|
|
719
|
-
["ncong", "tilde.equiv.not"],
|
|
720
|
-
["ne", "eq.not"],
|
|
721
|
-
["nearrow", "arrow.tr"],
|
|
722
|
-
["Nearrow", "arrow.tr.double"],
|
|
723
|
-
["neg", "not"],
|
|
724
|
-
["nequiv", "equiv.not"],
|
|
725
|
-
// or eq.triple.not
|
|
726
|
-
["neswarrow", "arrow.tr.bl"],
|
|
727
|
-
["nexists", "exists.not"],
|
|
728
|
-
["ngeq", "gt.eq.not"],
|
|
729
|
-
["ngtr", "gt.not"],
|
|
730
|
-
["ngtrless", "gt.lt.not"],
|
|
731
|
-
["ngtrsim", "gt.tilde.not"],
|
|
732
|
-
["nhpar", "parallel.struck"],
|
|
733
|
-
["nhVvert", "interleave.struck"],
|
|
734
|
-
["ni", "in.rev"],
|
|
735
|
-
["nLeftarrow", "arrow.l.double.not"],
|
|
736
|
-
["nleftarrow", "arrow.l.not"],
|
|
737
|
-
["nLeftrightarrow", "arrow.l.r.double.not"],
|
|
738
|
-
["nleftrightarrow", "arrow.l.r.not"],
|
|
739
|
-
["nleq", "lt.eq.not"],
|
|
740
|
-
["nless", "lt.not"],
|
|
741
|
-
["nlessgtr", "lt.gt.not"],
|
|
742
|
-
["nlesssim", "lt.tilde.not"],
|
|
743
|
-
["nmid", "divides.not"],
|
|
744
|
-
["nni", "in.rev.not"],
|
|
745
|
-
["notin", "in.not"],
|
|
746
|
-
["nparallel", "parallel.not"],
|
|
747
|
-
["nprec", "prec.not"],
|
|
748
|
-
["npreccurlyeq", "prec.curly.eq.not"],
|
|
749
|
-
["nRightarrow", "arrow.r.double.not"],
|
|
750
|
-
["nrightarrow", "arrow.r.not"],
|
|
751
|
-
["nsim", "tilde.not"],
|
|
752
|
-
["nsimeq", "tilde.eq.not"],
|
|
753
|
-
["nsqsubseteq", "subset.eq.sq.not"],
|
|
754
|
-
["nsqsupseteq", "supset.eq.sq.not"],
|
|
755
|
-
["nsubset", "subset.not"],
|
|
756
|
-
["nsubseteq", "subset.eq.not"],
|
|
757
|
-
["nsucc", "succ.not"],
|
|
758
|
-
["nsucccurlyeq", "succ.curly.eq.not"],
|
|
759
|
-
["nsupset", "supset.not"],
|
|
760
|
-
["nsupseteq", "supset.eq.not"],
|
|
761
|
-
["ntrianglelefteq", "lt.tri.eq.not"],
|
|
762
|
-
["ntrianglerighteq", "gt.tri.eq.not"],
|
|
763
|
-
["nvartriangleleft", "lt.tri.not"],
|
|
764
|
-
["nvartriangleright", "gt.tri.not"],
|
|
765
|
-
["nVdash", "forces.not"],
|
|
766
|
-
["nvdash", "tack.r.not"],
|
|
767
|
-
["nvDash", "tack.r.double.not"],
|
|
768
|
-
["nvinfty", "infinity.bar"],
|
|
769
|
-
["nwarrow", "arrow.tl"],
|
|
770
|
-
["Nwarrow", "arrow.tl.double"],
|
|
771
|
-
["nwsearrow", "arrow.tl.br"],
|
|
772
|
-
["obrbrak", "shell.t"],
|
|
773
|
-
["obslash", "backslash.circle"],
|
|
774
|
-
["odiv", "div.circle"],
|
|
775
|
-
["odot", "dot.circle"],
|
|
776
|
-
["ogreaterthan", "gt.circle"],
|
|
777
|
-
["oiiint", "integral.vol"],
|
|
778
|
-
["oiint", "integral.surf"],
|
|
779
|
-
["oint", "integral.cont"],
|
|
780
|
-
["ointctrclockwise", "integral.cont.ccw"],
|
|
781
|
-
["olessthan", "lt.circle"],
|
|
782
|
-
["ominus", "minus.circle"],
|
|
783
|
-
["operp", "perp.circle"],
|
|
784
|
-
["oplus", "plus.circle"],
|
|
785
|
-
["origof", "original"],
|
|
786
|
-
["otimes", "times.circle"],
|
|
787
|
-
// ['overbrace', 'brace.t'],
|
|
788
|
-
["overbracket", "bracket.t"],
|
|
789
|
-
["overparen", "paren.t"],
|
|
790
|
-
["parallel", "parallel"],
|
|
791
|
-
["parallelogram", "parallelogram.stroked"],
|
|
792
|
-
["parallelogramblack", "parallelogram.filled"],
|
|
793
|
-
["parsim", "parallel.tilde"],
|
|
794
|
-
["partial", "diff"],
|
|
795
|
-
["pentagon", "penta.stroked"],
|
|
796
|
-
["pentagonblack", "penta.filled"],
|
|
797
|
-
["perp", "perp"],
|
|
798
|
-
["Planckconst", "planck"],
|
|
799
|
-
["pm", "plus.minus"],
|
|
800
|
-
["prec", "prec"],
|
|
801
|
-
["Prec", "prec.double"],
|
|
802
|
-
["precapprox", "prec.approx"],
|
|
803
|
-
["preccurlyeq", "prec.curly.eq"],
|
|
804
|
-
["preceq", "prec.eq"],
|
|
805
|
-
["preceqq", "prec.equiv"],
|
|
806
|
-
["precnapprox", "prec.napprox"],
|
|
807
|
-
["precneq", "prec.neq"],
|
|
808
|
-
["precneqq", "prec.nequiv"],
|
|
809
|
-
["precnsim", "prec.ntilde"],
|
|
810
|
-
["precsim", "prec.tilde"],
|
|
811
|
-
["prime", "prime"],
|
|
812
|
-
["prod", "product"],
|
|
813
|
-
["propto", "prop"],
|
|
814
|
-
["QED", "qed"],
|
|
815
|
-
["qprime", "prime.quad"],
|
|
816
|
-
["quarternote", "note.quarter.alt"],
|
|
817
|
-
["questeq", "eq.quest"],
|
|
818
|
-
["Question", "quest.double"],
|
|
819
|
-
["rangle", "angle.r"],
|
|
820
|
-
["rAngle", "angle.r.double"],
|
|
821
|
-
["rangledot", "angle.r.dot"],
|
|
822
|
-
["rbrace", "brace.r"],
|
|
823
|
-
["rBrace", "brace.r.double"],
|
|
824
|
-
["rbrack", "bracket.r"],
|
|
825
|
-
["rBrack", "bracket.r.double"],
|
|
826
|
-
["rbrbrak", "shell.r"],
|
|
827
|
-
["Rbrbrak", "shell.r.double"],
|
|
828
|
-
["rceil", "ceil.r"],
|
|
829
|
-
["rcurvyangle", "angle.r.curly"],
|
|
830
|
-
["Re", "Re"],
|
|
831
|
-
["revangle", "angle.rev"],
|
|
832
|
-
["revemptyset", "emptyset.rev"],
|
|
833
|
-
["revnmid", "divides.not.rev"],
|
|
834
|
-
["rfloor", "floor.r"],
|
|
835
|
-
["rightangle", "angle.right"],
|
|
836
|
-
["rightanglemdot", "angle.right.dot"],
|
|
837
|
-
["rightanglesqr", "angle.right.sq"],
|
|
838
|
-
["rightarrow", "arrow.r"],
|
|
839
|
-
["Rightarrow", "arrow.r.double"],
|
|
840
|
-
["rightarrowbar", "arrow.r.stop"],
|
|
841
|
-
["rightarrowonoplus", "plus.circle.arrow"],
|
|
842
|
-
["rightarrowtail", "arrow.r.tail"],
|
|
843
|
-
["rightdasharrow", "arrow.r.dashed"],
|
|
844
|
-
["rightdotarrow", "arrow.r.dotted"],
|
|
845
|
-
["rightdowncurvedarrow", "arrow.r.curve"],
|
|
846
|
-
["rightharpoondown", "harpoon.rb"],
|
|
847
|
-
["rightharpoondownbar", "harpoon.rb.stop"],
|
|
848
|
-
["rightharpoonsupdown", "harpoons.rtrb"],
|
|
849
|
-
["rightharpoonup", "harpoon.rt"],
|
|
850
|
-
["rightharpoonupbar", "harpoon.rt.stop"],
|
|
851
|
-
["rightleftarrows", "arrows.rl"],
|
|
852
|
-
["rightleftharpoons", "harpoons.rtlb"],
|
|
853
|
-
["rightleftharpoonsdown", "harpoons.rblb"],
|
|
854
|
-
["rightleftharpoonsup", "harpoons.rtlt"],
|
|
855
|
-
["rightouterjoin", "join.r"],
|
|
856
|
-
["rightrightarrows", "arrows.rr"],
|
|
857
|
-
["rightsquigarrow", "arrow.r.squiggly"],
|
|
858
|
-
["rightthreearrows", "arrows.rrr"],
|
|
859
|
-
["rightthreetimes", "times.three.r"],
|
|
860
|
-
["rightwavearrow", "arrow.r.wave"],
|
|
861
|
-
["rightwhitearrow", "arrow.r.stroked"],
|
|
862
|
-
["risingdotseq", "eq.dots.up"],
|
|
863
|
-
["rparen", "paren.r"],
|
|
864
|
-
["rParen", "paren.r.double"],
|
|
865
|
-
["RRightarrow", "arrow.r.quad"],
|
|
866
|
-
["Rrightarrow", "arrow.r.triple"],
|
|
867
|
-
["rsolbar", "backslash.not"],
|
|
868
|
-
["rtimes", "times.r"],
|
|
869
|
-
["rvzigzag", "fence.r"],
|
|
870
|
-
["Rvzigzag", "fence.r.double"],
|
|
871
|
-
["searrow", "arrow.br"],
|
|
872
|
-
["Searrow", "arrow.br.double"],
|
|
873
|
-
["setminus", "without"],
|
|
874
|
-
["sharp", "sharp"],
|
|
875
|
-
["shortdowntack", "tack.b.short"],
|
|
876
|
-
["shortlefttack", "tack.l.short"],
|
|
877
|
-
["shortuptack", "tack.t.short"],
|
|
878
|
-
["sim", "tilde.op"],
|
|
879
|
-
["sime", "tilde.eq"],
|
|
880
|
-
["similarleftarrow", "arrow.l.tilde"],
|
|
881
|
-
["similarrightarrow", "arrow.r.tilde"],
|
|
882
|
-
["simneqq", "tilde.nequiv"],
|
|
883
|
-
["smallblacktriangleleft", "triangle.filled.small.l"],
|
|
884
|
-
["smallblacktriangleright", "triangle.filled.small.r"],
|
|
885
|
-
["smallin", "in.small"],
|
|
886
|
-
["smallni", "in.rev.small"],
|
|
887
|
-
["smalltriangleleft", "triangle.stroked.small.l"],
|
|
888
|
-
["smalltriangleright", "triangle.stroked.small.r"],
|
|
889
|
-
["smashtimes", "smash"],
|
|
890
|
-
["smblkcircle", "bullet"],
|
|
891
|
-
["smblkdiamond", "diamond.filled.small"],
|
|
892
|
-
["smblklozenge", "lozenge.filled.small"],
|
|
893
|
-
["smblksquare", "square.filled.tiny"],
|
|
894
|
-
["smeparsl", "parallel.slanted.eq.tilde"],
|
|
895
|
-
["smt", "smt"],
|
|
896
|
-
["smte", "smt.eq"],
|
|
897
|
-
["smwhtdiamond", "diamond.stroked.small"],
|
|
898
|
-
["smwhtlozenge", "lozenge.stroked.small"],
|
|
899
|
-
["smwhtsquare", "square.stroked.tiny"],
|
|
900
|
-
["spadesuit", "suit.spade.filled"],
|
|
901
|
-
["sphericalangle", "angle.spheric"],
|
|
902
|
-
["sphericalangleup", "angle.spheric.top"],
|
|
903
|
-
["sqcap", "inter.sq"],
|
|
904
|
-
["Sqcap", "inter.sq.double"],
|
|
905
|
-
["sqcup", "union.sq"],
|
|
906
|
-
["Sqcup", "union.sq.double"],
|
|
907
|
-
["sqint", "integral.square"],
|
|
908
|
-
["sqsubset", "subset.sq"],
|
|
909
|
-
["sqsubseteq", "subset.eq.sq"],
|
|
910
|
-
["sqsubsetneq", "subset.sq.neq"],
|
|
911
|
-
["sqsupset", "supset.sq"],
|
|
912
|
-
["sqsupseteq", "supset.eq.sq"],
|
|
913
|
-
["sqsupsetneq", "supset.sq.neq"],
|
|
914
|
-
["squoval", "square.stroked.rounded"],
|
|
915
|
-
["sslash", "slash.double"],
|
|
916
|
-
["star", "star.op"],
|
|
917
|
-
["stareq", "eq.star"],
|
|
918
|
-
["subset", "subset"],
|
|
919
|
-
["Subset", "subset.double"],
|
|
920
|
-
["subsetdot", "subset.dot"],
|
|
921
|
-
["subseteq", "subset.eq"],
|
|
922
|
-
["subsetneq", "subset.neq"],
|
|
923
|
-
["succ", "succ"],
|
|
924
|
-
["Succ", "succ.double"],
|
|
925
|
-
["succapprox", "succ.approx"],
|
|
926
|
-
["succcurlyeq", "succ.curly.eq"],
|
|
927
|
-
["succeq", "succ.eq"],
|
|
928
|
-
["succeqq", "succ.equiv"],
|
|
929
|
-
["succnapprox", "succ.napprox"],
|
|
930
|
-
["succneq", "succ.neq"],
|
|
931
|
-
["succneqq", "succ.nequiv"],
|
|
932
|
-
["succnsim", "succ.ntilde"],
|
|
933
|
-
["succsim", "succ.tilde"],
|
|
934
|
-
["sum", "sum"],
|
|
935
|
-
["sumint", "sum.integral"],
|
|
936
|
-
["supset", "supset"],
|
|
937
|
-
["Supset", "supset.double"],
|
|
938
|
-
["supsetdot", "supset.dot"],
|
|
939
|
-
["supseteq", "supset.eq"],
|
|
940
|
-
["supsetneq", "supset.neq"],
|
|
941
|
-
["swarrow", "arrow.bl"],
|
|
942
|
-
["Swarrow", "arrow.bl.double"],
|
|
943
|
-
["therefore", "therefore"],
|
|
944
|
-
["threedangle", "angle.spatial"],
|
|
945
|
-
["threedotcolon", "colon.tri.op"],
|
|
946
|
-
["tieinfty", "infinity.tie"],
|
|
947
|
-
["times", "times"],
|
|
948
|
-
["tminus", "miny"],
|
|
949
|
-
["top", "tack.b"],
|
|
950
|
-
["tplus", "tiny"],
|
|
951
|
-
["trianglecdot", "triangle.stroked.dot"],
|
|
952
|
-
["triangledown", "triangle.stroked.small.b"],
|
|
953
|
-
["triangleleft", "triangle.stroked.l"],
|
|
954
|
-
["trianglelefteq", "lt.tri.eq"],
|
|
955
|
-
["triangleminus", "minus.triangle"],
|
|
956
|
-
["triangleplus", "plus.triangle"],
|
|
957
|
-
["triangleq", "eq.delta"],
|
|
958
|
-
["triangleright", "triangle.stroked.r"],
|
|
959
|
-
["trianglerighteq", "gt.tri.eq"],
|
|
960
|
-
["triangletimes", "times.triangle"],
|
|
961
|
-
["tripleplus", "plus.triple"],
|
|
962
|
-
["trprime", "prime.triple"],
|
|
963
|
-
["trslash", "slash.triple"],
|
|
964
|
-
["twoheaddownarrow", "arrow.b.twohead"],
|
|
965
|
-
["twoheadleftarrow", "arrow.l.twohead"],
|
|
966
|
-
["twoheadmapsfrom", "arrow.l.twohead.bar"],
|
|
967
|
-
["twoheadmapsto", "arrow.r.twohead.bar"],
|
|
968
|
-
["twoheadrightarrow", "arrow.r.twohead"],
|
|
969
|
-
["twoheaduparrow", "arrow.t.twohead"],
|
|
970
|
-
["twonotes", "note.eighth.beamed"],
|
|
971
|
-
["ubrbrak", "shell.b"],
|
|
972
|
-
["ulblacktriangle", "triangle.filled.tl"],
|
|
973
|
-
["ultriangle", "triangle.stroked.tl"],
|
|
974
|
-
["uminus", "union.minus"],
|
|
975
|
-
["underbrace", "brace.b"],
|
|
976
|
-
["underbracket", "bracket.b"],
|
|
977
|
-
["underparen", "paren.b"],
|
|
978
|
-
["unicodecdots", "dots.h.c"],
|
|
979
|
-
["unicodeellipsis", "dots.h"],
|
|
980
|
-
["upand", "amp.inv"],
|
|
981
|
-
["uparrow", "arrow.t"],
|
|
982
|
-
["Uparrow", "arrow.t.double"],
|
|
983
|
-
["updasharrow", "arrow.t.dashed"],
|
|
984
|
-
["updownarrow", "arrow.t.b"],
|
|
985
|
-
["Updownarrow", "arrow.t.b.double"],
|
|
986
|
-
["updownarrows", "arrows.tb"],
|
|
987
|
-
["updownharpoonleftleft", "harpoon.tl.bl"],
|
|
988
|
-
["updownharpoonleftright", "harpoon.tl.br"],
|
|
989
|
-
["updownharpoonrightleft", "harpoon.tr.bl"],
|
|
990
|
-
["updownharpoonrightright", "harpoon.tr.br"],
|
|
991
|
-
["updownharpoonsleftright", "harpoons.tlbr"],
|
|
992
|
-
["upharpoonleft", "harpoon.tl"],
|
|
993
|
-
["upharpoonleftbar", "harpoon.tl.bar"],
|
|
994
|
-
["upharpoonright", "harpoon.tr"],
|
|
995
|
-
["upharpoonrightbar", "harpoon.tr.bar"],
|
|
996
|
-
["upharpoonsleftright", "harpoons.tltr"],
|
|
997
|
-
["uplus", "union.plus"],
|
|
998
|
-
["uprightcurvearrow", "arrow.t.curve"],
|
|
999
|
-
["upuparrows", "arrows.tt"],
|
|
1000
|
-
["upwhitearrow", "arrow.t.stroked"],
|
|
1001
|
-
["urblacktriangle", "triangle.filled.tr"],
|
|
1002
|
-
["urtriangle", "triangle.stroked.tr"],
|
|
1003
|
-
["UUparrow", "arrow.t.quad"],
|
|
1004
|
-
["Uuparrow", "arrow.t.triple"],
|
|
1005
|
-
["varclubsuit", "suit.club.stroked"],
|
|
1006
|
-
["vardiamondsuit", "suit.diamond.filled"],
|
|
1007
|
-
["varheartsuit", "suit.heart.filled"],
|
|
1008
|
-
["varhexagon", "hexa.stroked"],
|
|
1009
|
-
["varhexagonblack", "hexa.filled"],
|
|
1010
|
-
["varnothing", "emptyset"],
|
|
1011
|
-
["varointclockwise", "integral.cont.cw"],
|
|
1012
|
-
["varspadesuit", "suit.spade.stroked"],
|
|
1013
|
-
["vartriangle", "triangle.stroked.small.t"],
|
|
1014
|
-
["vartriangleleft", "lt.tri"],
|
|
1015
|
-
["vartriangleright", "gt.tri"],
|
|
1016
|
-
["Vbar", "tack.t.double"],
|
|
1017
|
-
["Vdash", "forces"],
|
|
1018
|
-
["vdash", "tack.r"],
|
|
1019
|
-
["vDash", "tack.r.double"],
|
|
1020
|
-
["vdots", "dots.v"],
|
|
1021
|
-
["vee", "or"],
|
|
1022
|
-
["Vee", "or.double"],
|
|
1023
|
-
["veedot", "or.dot"],
|
|
1024
|
-
["veeeq", "eq.equi"],
|
|
1025
|
-
["vert", "bar.v"],
|
|
1026
|
-
["Vert", "bar.v.double"],
|
|
1027
|
-
["vlongdash", "tack.r.long"],
|
|
1028
|
-
["vrectangle", "rect.stroked.v"],
|
|
1029
|
-
["vrectangleblack", "rect.filled.v"],
|
|
1030
|
-
["Vvert", "bar.v.triple"],
|
|
1031
|
-
["vysmblkcircle", "circle.filled.small"],
|
|
1032
|
-
["vysmwhtcircle", "circle.stroked.tiny"],
|
|
1033
|
-
// or compose
|
|
1034
|
-
["wedge", "and"],
|
|
1035
|
-
["Wedge", "and.double"],
|
|
1036
|
-
["wedgedot", "and.dot"],
|
|
1037
|
-
["wedgeq", "eq.est"],
|
|
1038
|
-
["whiteinwhitetriangle", "triangle.stroked.nested"],
|
|
1039
|
-
["whthorzoval", "ellipse.stroked.h"],
|
|
1040
|
-
["whtvertoval", "ellipse.stroked.v"],
|
|
1041
|
-
["wideangledown", "angle.oblique"],
|
|
1042
|
-
["wr", "wreath"],
|
|
1043
|
-
["xsol", "slash.big"]
|
|
1044
|
-
]);
|
|
1045
|
-
var texAliasMap = /* @__PURE__ */ new Map([
|
|
1046
|
-
["gets", "leftarrow"],
|
|
1047
|
-
["iff", "Longleftrightarrow"],
|
|
1048
|
-
["implies", "Longrightarrow"]
|
|
1049
|
-
]);
|
|
1050
|
-
for (const [key, value] of map_from_official_docs) {
|
|
1051
|
-
if (!symbolMap.has(key)) {
|
|
1052
|
-
symbolMap.set(key, value);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
var reverseSymbolMap = /* @__PURE__ */ new Map();
|
|
1056
|
-
for (const [key, value] of Array.from(symbolMap.entries()).reverse()) {
|
|
1057
|
-
reverseSymbolMap.set(value, key);
|
|
1058
|
-
}
|
|
1059
|
-
reverseSymbolMap.set("oo", "infty");
|
|
1060
|
-
var typst_to_tex_map = /* @__PURE__ */ new Map([
|
|
1061
|
-
["top", "top"],
|
|
1062
|
-
["frac", "frac"],
|
|
1063
|
-
["tilde", "tilde"],
|
|
1064
|
-
["hat", "hat"],
|
|
1065
|
-
["upright", "mathrm"],
|
|
1066
|
-
["bold", "boldsymbol"],
|
|
1067
|
-
["infinity", "infty"]
|
|
1068
|
-
]);
|
|
1069
|
-
for (const [key, value] of typst_to_tex_map) {
|
|
1070
|
-
reverseSymbolMap.set(key, value);
|
|
1071
|
-
}
|
|
1072
|
-
for (const [key, value] of texAliasMap) {
|
|
1073
|
-
if (!symbolMap.has(key)) {
|
|
1074
|
-
symbolMap.set(key, symbolMap.get(value));
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// src/generic.ts
|
|
1079
|
-
function array_find(array, item, start = 0) {
|
|
1080
|
-
for (let i = start; i < array.length; i++) {
|
|
1081
|
-
if (array[i].eq(item)) {
|
|
1082
|
-
return i;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
return -1;
|
|
1086
|
-
}
|
|
1087
|
-
function array_includes(array, item) {
|
|
1088
|
-
for (const i of array) {
|
|
1089
|
-
if (i.eq(item)) {
|
|
1090
|
-
return true;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
return false;
|
|
1094
|
-
}
|
|
1095
|
-
function array_split(array, sep) {
|
|
1096
|
-
const res = [];
|
|
1097
|
-
let current_slice = [];
|
|
1098
|
-
for (const i of array) {
|
|
1099
|
-
if (i.eq(sep)) {
|
|
1100
|
-
res.push(current_slice);
|
|
1101
|
-
current_slice = [];
|
|
1102
|
-
} else {
|
|
1103
|
-
current_slice.push(i);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
res.push(current_slice);
|
|
1107
|
-
return res;
|
|
1
|
+
// src/util.ts
|
|
2
|
+
function isalpha(char) {
|
|
3
|
+
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".includes(char);
|
|
1108
4
|
}
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
res.push(array[i]);
|
|
1113
|
-
if (i != array.length - 1) {
|
|
1114
|
-
res.push(sep);
|
|
1115
|
-
}
|
|
5
|
+
function assert(condition, message = "Assertion failed.") {
|
|
6
|
+
if (!condition) {
|
|
7
|
+
throw new Error(message);
|
|
1116
8
|
}
|
|
1117
|
-
return res;
|
|
1118
9
|
}
|
|
1119
10
|
|
|
1120
|
-
// src/types.ts
|
|
1121
|
-
var TexToken = class {
|
|
11
|
+
// src/tex-types.ts
|
|
12
|
+
var TexToken = class _TexToken {
|
|
1122
13
|
constructor(type, value) {
|
|
1123
14
|
this.type = type;
|
|
1124
15
|
this.value = value;
|
|
@@ -1128,283 +19,248 @@ var TexToken = class {
|
|
|
1128
19
|
}
|
|
1129
20
|
toString() {
|
|
1130
21
|
switch (this.type) {
|
|
1131
|
-
case
|
|
22
|
+
case 4 /* COMMENT */:
|
|
1132
23
|
return "%" + this.value;
|
|
1133
24
|
default:
|
|
1134
25
|
return this.value;
|
|
1135
26
|
}
|
|
1136
27
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
if (["{", "}", "%"].includes(c)) {
|
|
1140
|
-
return "\\" + c;
|
|
28
|
+
toNode() {
|
|
29
|
+
return new TexTerminal(this);
|
|
1141
30
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
31
|
+
static {
|
|
32
|
+
this.EMPTY = new _TexToken(0 /* EMPTY */, "");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
1144
35
|
var TexNode = class {
|
|
1145
|
-
constructor(type,
|
|
36
|
+
constructor(type, head, args) {
|
|
1146
37
|
this.type = type;
|
|
1147
|
-
this.
|
|
38
|
+
this.head = head ? head : TexToken.EMPTY;
|
|
1148
39
|
this.args = args;
|
|
1149
|
-
this.data = data;
|
|
1150
40
|
}
|
|
1151
41
|
// Note that this is only shallow equality.
|
|
1152
42
|
eq(other) {
|
|
1153
|
-
return this.type === other.type && this.
|
|
43
|
+
return this.type === other.type && this.head.eq(other.head);
|
|
44
|
+
}
|
|
45
|
+
// Note: toString() is expensive. Do not use it on performance-critical code path.
|
|
46
|
+
toString() {
|
|
47
|
+
return this.serialize().reduce(writeTexTokenBuffer, "");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var TexTerminal = class extends TexNode {
|
|
51
|
+
constructor(head) {
|
|
52
|
+
super("terminal", head);
|
|
1154
53
|
}
|
|
1155
54
|
serialize() {
|
|
1156
|
-
switch (this.type) {
|
|
1157
|
-
case
|
|
55
|
+
switch (this.head.type) {
|
|
56
|
+
case 0 /* EMPTY */:
|
|
1158
57
|
return [];
|
|
1159
|
-
case
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
case
|
|
1167
|
-
|
|
1168
|
-
case "text":
|
|
1169
|
-
return [
|
|
1170
|
-
new TexToken(1 /* COMMAND */, "\\text"),
|
|
1171
|
-
new TexToken(0 /* ELEMENT */, "{"),
|
|
1172
|
-
new TexToken(2 /* LITERAL */, this.content),
|
|
1173
|
-
new TexToken(0 /* ELEMENT */, "}")
|
|
1174
|
-
];
|
|
1175
|
-
case "comment":
|
|
1176
|
-
return [new TexToken(3 /* COMMENT */, this.content)];
|
|
1177
|
-
case "whitespace": {
|
|
58
|
+
case 1 /* ELEMENT */:
|
|
59
|
+
case 2 /* COMMAND */:
|
|
60
|
+
case 3 /* LITERAL */:
|
|
61
|
+
case 4 /* COMMENT */:
|
|
62
|
+
case 7 /* CONTROL */: {
|
|
63
|
+
return [this.head];
|
|
64
|
+
}
|
|
65
|
+
case 5 /* SPACE */:
|
|
66
|
+
case 6 /* NEWLINE */: {
|
|
1178
67
|
const tokens = [];
|
|
1179
|
-
for (const c of this.
|
|
1180
|
-
const token_type = c === " " ?
|
|
68
|
+
for (const c of this.head.value) {
|
|
69
|
+
const token_type = c === " " ? 5 /* SPACE */ : 6 /* NEWLINE */;
|
|
1181
70
|
tokens.push(new TexToken(token_type, c));
|
|
1182
71
|
}
|
|
1183
72
|
return tokens;
|
|
1184
73
|
}
|
|
1185
|
-
case "ordgroup": {
|
|
1186
|
-
return this.args.map((n) => n.serialize()).flat();
|
|
1187
|
-
}
|
|
1188
|
-
case "leftright": {
|
|
1189
|
-
let tokens = this.args.map((n) => n.serialize()).flat();
|
|
1190
|
-
tokens.splice(0, 0, new TexToken(1 /* COMMAND */, "\\left"));
|
|
1191
|
-
tokens.splice(tokens.length - 1, 0, new TexToken(1 /* COMMAND */, "\\right"));
|
|
1192
|
-
return tokens;
|
|
1193
|
-
}
|
|
1194
|
-
case "unaryFunc": {
|
|
1195
|
-
let tokens = [];
|
|
1196
|
-
tokens.push(new TexToken(1 /* COMMAND */, this.content));
|
|
1197
|
-
if (this.content === "\\sqrt" && this.data) {
|
|
1198
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "["));
|
|
1199
|
-
tokens = tokens.concat(this.data.serialize());
|
|
1200
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "]"));
|
|
1201
|
-
}
|
|
1202
|
-
if (this.content === "\\operatorname" && this.args.length === 1 && this.args[0].type === "text") {
|
|
1203
|
-
const text = this.args[0].content;
|
|
1204
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1205
|
-
tokens.push(new TexToken(1 /* COMMAND */, text));
|
|
1206
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1207
|
-
return tokens;
|
|
1208
|
-
}
|
|
1209
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1210
|
-
tokens = tokens.concat(this.args[0].serialize());
|
|
1211
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1212
|
-
return tokens;
|
|
1213
|
-
}
|
|
1214
|
-
case "binaryFunc": {
|
|
1215
|
-
let tokens = [];
|
|
1216
|
-
tokens.push(new TexToken(1 /* COMMAND */, this.content));
|
|
1217
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1218
|
-
tokens = tokens.concat(this.args[0].serialize());
|
|
1219
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1220
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1221
|
-
tokens = tokens.concat(this.args[1].serialize());
|
|
1222
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1223
|
-
return tokens;
|
|
1224
|
-
}
|
|
1225
|
-
case "supsub": {
|
|
1226
|
-
let should_wrap_in_braces2 = function(node) {
|
|
1227
|
-
if (node.type === "ordgroup" || node.type === "supsub" || node.type === "empty") {
|
|
1228
|
-
return true;
|
|
1229
|
-
} else if (node.type === "element" && /\d+(\.\d+)?/.test(node.content) && node.content.length > 1) {
|
|
1230
|
-
return true;
|
|
1231
|
-
} else {
|
|
1232
|
-
return false;
|
|
1233
|
-
}
|
|
1234
|
-
};
|
|
1235
|
-
var should_wrap_in_braces = should_wrap_in_braces2;
|
|
1236
|
-
let tokens = [];
|
|
1237
|
-
const { base, sup, sub } = this.data;
|
|
1238
|
-
tokens = tokens.concat(base.serialize());
|
|
1239
|
-
if (sub) {
|
|
1240
|
-
tokens.push(new TexToken(6 /* CONTROL */, "_"));
|
|
1241
|
-
if (should_wrap_in_braces2(sub)) {
|
|
1242
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1243
|
-
tokens = tokens.concat(sub.serialize());
|
|
1244
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1245
|
-
} else {
|
|
1246
|
-
tokens = tokens.concat(sub.serialize());
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
if (sup) {
|
|
1250
|
-
tokens.push(new TexToken(6 /* CONTROL */, "^"));
|
|
1251
|
-
if (should_wrap_in_braces2(sup)) {
|
|
1252
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "{"));
|
|
1253
|
-
tokens = tokens.concat(sup.serialize());
|
|
1254
|
-
tokens.push(new TexToken(0 /* ELEMENT */, "}"));
|
|
1255
|
-
} else {
|
|
1256
|
-
tokens = tokens.concat(sup.serialize());
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
return tokens;
|
|
1260
|
-
}
|
|
1261
|
-
case "control": {
|
|
1262
|
-
return [new TexToken(6 /* CONTROL */, this.content)];
|
|
1263
|
-
}
|
|
1264
|
-
case "beginend": {
|
|
1265
|
-
let tokens = [];
|
|
1266
|
-
const matrix = this.data;
|
|
1267
|
-
tokens.push(new TexToken(1 /* COMMAND */, `\\begin{${this.content}}`));
|
|
1268
|
-
tokens.push(new TexToken(5 /* NEWLINE */, "\n"));
|
|
1269
|
-
for (let i = 0; i < matrix.length; i++) {
|
|
1270
|
-
const row = matrix[i];
|
|
1271
|
-
for (let j = 0; j < row.length; j++) {
|
|
1272
|
-
const cell = row[j];
|
|
1273
|
-
tokens = tokens.concat(cell.serialize());
|
|
1274
|
-
if (j !== row.length - 1) {
|
|
1275
|
-
tokens.push(new TexToken(6 /* CONTROL */, "&"));
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
if (i !== matrix.length - 1) {
|
|
1279
|
-
tokens.push(new TexToken(6 /* CONTROL */, "\\\\"));
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
tokens.push(new TexToken(5 /* NEWLINE */, "\n"));
|
|
1283
|
-
tokens.push(new TexToken(1 /* COMMAND */, `\\end{${this.content}}`));
|
|
1284
|
-
return tokens;
|
|
1285
|
-
}
|
|
1286
74
|
default:
|
|
1287
|
-
throw new Error(
|
|
75
|
+
throw new Error(`Unknown terminal token type: ${this.head.type}`);
|
|
1288
76
|
}
|
|
1289
77
|
}
|
|
1290
78
|
};
|
|
1291
|
-
var
|
|
1292
|
-
constructor(
|
|
1293
|
-
|
|
1294
|
-
|
|
79
|
+
var TexText = class extends TexNode {
|
|
80
|
+
constructor(head) {
|
|
81
|
+
assert(head.type === 3 /* LITERAL */);
|
|
82
|
+
super("text", head);
|
|
1295
83
|
}
|
|
1296
|
-
|
|
1297
|
-
return
|
|
84
|
+
serialize() {
|
|
85
|
+
return [
|
|
86
|
+
new TexToken(2 /* COMMAND */, "\\text"),
|
|
87
|
+
new TexToken(1 /* ELEMENT */, "{"),
|
|
88
|
+
this.head,
|
|
89
|
+
new TexToken(1 /* ELEMENT */, "}")
|
|
90
|
+
];
|
|
1298
91
|
}
|
|
1299
|
-
|
|
1300
|
-
|
|
92
|
+
};
|
|
93
|
+
var TexGroup = class extends TexNode {
|
|
94
|
+
constructor(args) {
|
|
95
|
+
super("ordgroup", TexToken.EMPTY, args);
|
|
1301
96
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
case "^":
|
|
1325
|
-
throw new Error(`Should not convert ${controlChar} to a node`);
|
|
1326
|
-
case "&":
|
|
1327
|
-
return new TypstNode("control", "&");
|
|
1328
|
-
case "\\":
|
|
1329
|
-
return new TypstNode("control", "\\");
|
|
1330
|
-
default:
|
|
1331
|
-
throw new Error(`Unexpected control character ${controlChar}`);
|
|
1332
|
-
}
|
|
97
|
+
serialize() {
|
|
98
|
+
return this.args.map((n) => n.serialize()).flat();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var TexSupSub = class extends TexNode {
|
|
102
|
+
constructor(data) {
|
|
103
|
+
super("supsub", TexToken.EMPTY, []);
|
|
104
|
+
this.base = data.base;
|
|
105
|
+
this.sup = data.sup;
|
|
106
|
+
this.sub = data.sub;
|
|
107
|
+
}
|
|
108
|
+
serialize() {
|
|
109
|
+
let tokens = [];
|
|
110
|
+
const { base, sup, sub } = this;
|
|
111
|
+
tokens = tokens.concat(base.serialize());
|
|
112
|
+
function should_wrap_in_braces(node) {
|
|
113
|
+
if (node.type === "ordgroup" || node.type === "supsub" || node.head.type === 0 /* EMPTY */) {
|
|
114
|
+
return true;
|
|
115
|
+
} else if (node.head.type === 1 /* ELEMENT */ && /\d+(\.\d+)?/.test(node.head.value) && node.head.value.length > 1) {
|
|
116
|
+
return true;
|
|
117
|
+
} else {
|
|
118
|
+
return false;
|
|
1333
119
|
}
|
|
1334
|
-
default:
|
|
1335
|
-
throw new Error(`Unexpected token type ${this.type}`);
|
|
1336
120
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
121
|
+
if (sub) {
|
|
122
|
+
tokens.push(new TexToken(7 /* CONTROL */, "_"));
|
|
123
|
+
if (should_wrap_in_braces(sub)) {
|
|
124
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "{"));
|
|
125
|
+
tokens = tokens.concat(sub.serialize());
|
|
126
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "}"));
|
|
127
|
+
} else {
|
|
128
|
+
tokens = tokens.concat(sub.serialize());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (sup) {
|
|
132
|
+
tokens.push(new TexToken(7 /* CONTROL */, "^"));
|
|
133
|
+
if (should_wrap_in_braces(sup)) {
|
|
134
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "{"));
|
|
135
|
+
tokens = tokens.concat(sup.serialize());
|
|
136
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "}"));
|
|
137
|
+
} else {
|
|
138
|
+
tokens = tokens.concat(sup.serialize());
|
|
139
|
+
}
|
|
1346
140
|
}
|
|
141
|
+
return tokens;
|
|
1347
142
|
}
|
|
1348
143
|
};
|
|
1349
|
-
var
|
|
1350
|
-
constructor(
|
|
1351
|
-
|
|
1352
|
-
this.content = content;
|
|
1353
|
-
this.args = args;
|
|
144
|
+
var TexFuncCall = class extends TexNode {
|
|
145
|
+
constructor(head, args, data = null) {
|
|
146
|
+
super("funcCall", head, args);
|
|
1354
147
|
this.data = data;
|
|
1355
148
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
149
|
+
serialize() {
|
|
150
|
+
let tokens = [];
|
|
151
|
+
tokens.push(this.head);
|
|
152
|
+
if (this.head.value === "\\sqrt" && this.data) {
|
|
153
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "["));
|
|
154
|
+
tokens = tokens.concat(this.data.serialize());
|
|
155
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "]"));
|
|
156
|
+
}
|
|
157
|
+
for (const arg of this.args) {
|
|
158
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "{"));
|
|
159
|
+
tokens = tokens.concat(arg.serialize());
|
|
160
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "}"));
|
|
161
|
+
}
|
|
162
|
+
return tokens;
|
|
1358
163
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
164
|
+
};
|
|
165
|
+
var TexLeftRight = class extends TexNode {
|
|
166
|
+
constructor(args, data) {
|
|
167
|
+
super("leftright", TexToken.EMPTY, args);
|
|
168
|
+
this.left = data.left;
|
|
169
|
+
this.right = data.right;
|
|
1362
170
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
return true;
|
|
1372
|
-
}
|
|
1373
|
-
return this.args.some((n) => n.isOverHigh());
|
|
1374
|
-
}
|
|
1375
|
-
case "group":
|
|
1376
|
-
return this.args.some((n) => n.isOverHigh());
|
|
1377
|
-
case "supsub":
|
|
1378
|
-
return this.data.base.isOverHigh();
|
|
1379
|
-
case "align":
|
|
1380
|
-
case "cases":
|
|
1381
|
-
case "matrix":
|
|
1382
|
-
return true;
|
|
1383
|
-
default:
|
|
1384
|
-
return false;
|
|
1385
|
-
}
|
|
171
|
+
serialize() {
|
|
172
|
+
let tokens = [];
|
|
173
|
+
tokens.push(new TexToken(2 /* COMMAND */, "\\left"));
|
|
174
|
+
tokens.push(new TexToken(1 /* ELEMENT */, this.left ? this.left.value : "."));
|
|
175
|
+
tokens = tokens.concat(this.args.map((n) => n.serialize()).flat());
|
|
176
|
+
tokens.push(new TexToken(2 /* COMMAND */, "\\right"));
|
|
177
|
+
tokens.push(new TexToken(1 /* ELEMENT */, this.right ? this.right.value : "."));
|
|
178
|
+
return tokens;
|
|
1386
179
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
180
|
+
};
|
|
181
|
+
var TexBeginEnd = class extends TexNode {
|
|
182
|
+
constructor(head, args, data) {
|
|
183
|
+
assert(head.type === 3 /* LITERAL */);
|
|
184
|
+
super("beginend", head, args);
|
|
185
|
+
this.matrix = data;
|
|
186
|
+
}
|
|
187
|
+
serialize() {
|
|
188
|
+
let tokens = [];
|
|
189
|
+
const matrix = this.matrix;
|
|
190
|
+
tokens.push(new TexToken(2 /* COMMAND */, "\\begin"));
|
|
191
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "{"));
|
|
192
|
+
tokens = tokens.concat(this.head);
|
|
193
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "}"));
|
|
194
|
+
tokens.push(new TexToken(6 /* NEWLINE */, "\n"));
|
|
195
|
+
for (let i = 0; i < matrix.length; i++) {
|
|
196
|
+
const row = matrix[i];
|
|
197
|
+
for (let j = 0; j < row.length; j++) {
|
|
198
|
+
const cell = row[j];
|
|
199
|
+
tokens = tokens.concat(cell.serialize());
|
|
200
|
+
if (j !== row.length - 1) {
|
|
201
|
+
tokens.push(new TexToken(7 /* CONTROL */, "&"));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (i !== matrix.length - 1) {
|
|
205
|
+
tokens.push(new TexToken(7 /* CONTROL */, "\\\\"));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
tokens.push(new TexToken(6 /* NEWLINE */, "\n"));
|
|
209
|
+
tokens.push(new TexToken(2 /* COMMAND */, "\\end"));
|
|
210
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "{"));
|
|
211
|
+
tokens = tokens.concat(this.head);
|
|
212
|
+
tokens.push(new TexToken(1 /* ELEMENT */, "}"));
|
|
213
|
+
return tokens;
|
|
1396
214
|
}
|
|
1397
215
|
};
|
|
1398
|
-
|
|
216
|
+
function writeTexTokenBuffer(buffer, token) {
|
|
217
|
+
const str = token.toString();
|
|
218
|
+
let no_need_space = false;
|
|
219
|
+
if (token.type === 5 /* SPACE */) {
|
|
220
|
+
no_need_space = true;
|
|
221
|
+
} else {
|
|
222
|
+
no_need_space ||= /[{\(\[\|]$/.test(buffer);
|
|
223
|
+
no_need_space ||= /\\\w+$/.test(buffer) && str === "[";
|
|
224
|
+
no_need_space ||= /^[\.,;:!\?\(\)\]{}_^]$/.test(str);
|
|
225
|
+
no_need_space ||= ["\\{", "\\}"].includes(str);
|
|
226
|
+
no_need_space ||= str === "'";
|
|
227
|
+
no_need_space ||= buffer.endsWith("_") || buffer.endsWith("^");
|
|
228
|
+
no_need_space ||= /\s$/.test(buffer);
|
|
229
|
+
no_need_space ||= /^\s/.test(str);
|
|
230
|
+
no_need_space ||= buffer === "";
|
|
231
|
+
no_need_space ||= /[\(\[{]\s*(-|\+)$/.test(buffer) || buffer === "-" || buffer === "+";
|
|
232
|
+
no_need_space ||= buffer.endsWith("&") && str === "=";
|
|
233
|
+
}
|
|
234
|
+
if (!no_need_space) {
|
|
235
|
+
buffer += " ";
|
|
236
|
+
}
|
|
237
|
+
return buffer + str;
|
|
238
|
+
}
|
|
1399
239
|
|
|
1400
|
-
// src/
|
|
1401
|
-
function
|
|
1402
|
-
|
|
240
|
+
// src/generic.ts
|
|
241
|
+
function array_find(array, item, start = 0) {
|
|
242
|
+
const index = array.slice(start).findIndex((x) => x.eq(item));
|
|
243
|
+
return index === -1 ? -1 : index + start;
|
|
1403
244
|
}
|
|
1404
|
-
function
|
|
1405
|
-
|
|
1406
|
-
|
|
245
|
+
function array_includes(array, item) {
|
|
246
|
+
return array.some((x) => x.eq(item));
|
|
247
|
+
}
|
|
248
|
+
function array_split(array, sep) {
|
|
249
|
+
const res = [];
|
|
250
|
+
let current_slice = [];
|
|
251
|
+
for (const i of array) {
|
|
252
|
+
if (i.eq(sep)) {
|
|
253
|
+
res.push(current_slice);
|
|
254
|
+
current_slice = [];
|
|
255
|
+
} else {
|
|
256
|
+
current_slice.push(i);
|
|
257
|
+
}
|
|
1407
258
|
}
|
|
259
|
+
res.push(current_slice);
|
|
260
|
+
return res;
|
|
261
|
+
}
|
|
262
|
+
function array_intersperse(array, sep) {
|
|
263
|
+
return array.flatMap((x, i) => i !== array.length - 1 ? [x, sep] : [x]);
|
|
1408
264
|
}
|
|
1409
265
|
|
|
1410
266
|
// src/jslex.ts
|
|
@@ -1709,13 +565,13 @@ var rules_map = /* @__PURE__ */ new Map([
|
|
|
1709
565
|
(s) => {
|
|
1710
566
|
const match = s.reMatchArray();
|
|
1711
567
|
return [
|
|
1712
|
-
new TexToken(
|
|
1713
|
-
new TexToken(
|
|
1714
|
-
new TexToken(
|
|
1715
|
-
new TexToken(
|
|
1716
|
-
new TexToken(
|
|
1717
|
-
new TexToken(
|
|
1718
|
-
new TexToken(
|
|
568
|
+
new TexToken(2 /* COMMAND */, "\\begin"),
|
|
569
|
+
new TexToken(7 /* CONTROL */, "{"),
|
|
570
|
+
new TexToken(3 /* LITERAL */, match[1]),
|
|
571
|
+
new TexToken(7 /* CONTROL */, "}"),
|
|
572
|
+
new TexToken(7 /* CONTROL */, "{"),
|
|
573
|
+
new TexToken(3 /* LITERAL */, match[2]),
|
|
574
|
+
new TexToken(7 /* CONTROL */, "}")
|
|
1719
575
|
];
|
|
1720
576
|
}
|
|
1721
577
|
],
|
|
@@ -1724,19 +580,19 @@ var rules_map = /* @__PURE__ */ new Map([
|
|
|
1724
580
|
(s) => {
|
|
1725
581
|
const match = s.reMatchArray();
|
|
1726
582
|
return [
|
|
1727
|
-
new TexToken(
|
|
1728
|
-
new TexToken(
|
|
1729
|
-
new TexToken(
|
|
1730
|
-
new TexToken(
|
|
583
|
+
new TexToken(2 /* COMMAND */, "\\" + match[1]),
|
|
584
|
+
new TexToken(7 /* CONTROL */, "{"),
|
|
585
|
+
new TexToken(3 /* LITERAL */, unescape(match[2])),
|
|
586
|
+
new TexToken(7 /* CONTROL */, "}")
|
|
1731
587
|
];
|
|
1732
588
|
}
|
|
1733
589
|
],
|
|
1734
|
-
[String.raw`%[^\n]*`, (s) => new TexToken(
|
|
1735
|
-
[String.raw`[{}_^&]`, (s) => new TexToken(
|
|
1736
|
-
[String.raw`\\[\\,:;! ]`, (s) => new TexToken(
|
|
1737
|
-
[String.raw`\r?\n`, (_s) => new TexToken(
|
|
1738
|
-
[String.raw`\s+`, (s) => new TexToken(
|
|
1739
|
-
[String.raw`\\[{}%$&#_|]`, (s) => new TexToken(
|
|
590
|
+
[String.raw`%[^\n]*`, (s) => new TexToken(4 /* COMMENT */, s.text().substring(1))],
|
|
591
|
+
[String.raw`[{}_^&]`, (s) => new TexToken(7 /* CONTROL */, s.text())],
|
|
592
|
+
[String.raw`\\[\\,:;! ]`, (s) => new TexToken(7 /* CONTROL */, s.text())],
|
|
593
|
+
[String.raw`\r?\n`, (_s) => new TexToken(6 /* NEWLINE */, "\n")],
|
|
594
|
+
[String.raw`\s+`, (s) => new TexToken(5 /* SPACE */, s.text())],
|
|
595
|
+
[String.raw`\\[{}%$&#_|]`, (s) => new TexToken(1 /* ELEMENT */, s.text())],
|
|
1740
596
|
// e.g. match `\frac13`, `\frac1 b`, `\frac a b`
|
|
1741
597
|
[String.raw`(\\[a-zA-Z]+)(\s*\d|\s+[a-zA-Z])\s*([0-9a-zA-Z])`, (s) => {
|
|
1742
598
|
const match = s.reMatchArray();
|
|
@@ -1745,9 +601,9 @@ var rules_map = /* @__PURE__ */ new Map([
|
|
|
1745
601
|
const arg1 = match[2].trimStart();
|
|
1746
602
|
const arg2 = match[3];
|
|
1747
603
|
return [
|
|
1748
|
-
new TexToken(
|
|
1749
|
-
new TexToken(
|
|
1750
|
-
new TexToken(
|
|
604
|
+
new TexToken(2 /* COMMAND */, command),
|
|
605
|
+
new TexToken(1 /* ELEMENT */, arg1),
|
|
606
|
+
new TexToken(1 /* ELEMENT */, arg2)
|
|
1751
607
|
];
|
|
1752
608
|
} else {
|
|
1753
609
|
s.reject();
|
|
@@ -1761,22 +617,22 @@ var rules_map = /* @__PURE__ */ new Map([
|
|
|
1761
617
|
if (TEX_UNARY_COMMANDS.includes(command.substring(1))) {
|
|
1762
618
|
const arg1 = match[2].trimStart();
|
|
1763
619
|
return [
|
|
1764
|
-
new TexToken(
|
|
1765
|
-
new TexToken(
|
|
620
|
+
new TexToken(2 /* COMMAND */, command),
|
|
621
|
+
new TexToken(1 /* ELEMENT */, arg1)
|
|
1766
622
|
];
|
|
1767
623
|
} else {
|
|
1768
624
|
s.reject();
|
|
1769
625
|
return [];
|
|
1770
626
|
}
|
|
1771
627
|
}],
|
|
1772
|
-
[String.raw`\\[a-zA-Z]+`, (s) => new TexToken(
|
|
628
|
+
[String.raw`\\[a-zA-Z]+`, (s) => new TexToken(2 /* COMMAND */, s.text())],
|
|
1773
629
|
// Numbers like "123", "3.14"
|
|
1774
|
-
[String.raw`[0-9]+(\.[0-9]+)?`, (s) => new TexToken(
|
|
1775
|
-
[String.raw`[a-zA-Z]`, (s) => new TexToken(
|
|
1776
|
-
[String.raw`[+\-*/='<>!.,;:?()\[\]|]`, (s) => new TexToken(
|
|
630
|
+
[String.raw`[0-9]+(\.[0-9]+)?`, (s) => new TexToken(1 /* ELEMENT */, s.text())],
|
|
631
|
+
[String.raw`[a-zA-Z]`, (s) => new TexToken(1 /* ELEMENT */, s.text())],
|
|
632
|
+
[String.raw`[+\-*/='<>!.,;:?()\[\]|]`, (s) => new TexToken(1 /* ELEMENT */, s.text())],
|
|
1777
633
|
// non-ASCII characters
|
|
1778
|
-
[String.raw`[^\x00-\x7F]`, (s) => new TexToken(
|
|
1779
|
-
[String.raw`.`, (s) => new TexToken(
|
|
634
|
+
[String.raw`[^\x00-\x7F]`, (s) => new TexToken(1 /* ELEMENT */, s.text())],
|
|
635
|
+
[String.raw`.`, (s) => new TexToken(8 /* UNKNOWN */, s.text())]
|
|
1780
636
|
]);
|
|
1781
637
|
var spec = {
|
|
1782
638
|
"start": rules_map
|
|
@@ -1797,7 +653,7 @@ var IGNORED_COMMANDS = [
|
|
|
1797
653
|
"Biggl",
|
|
1798
654
|
"Biggr"
|
|
1799
655
|
];
|
|
1800
|
-
var EMPTY_NODE =
|
|
656
|
+
var EMPTY_NODE = TexToken.EMPTY.toNode();
|
|
1801
657
|
function get_command_param_num(command) {
|
|
1802
658
|
if (TEX_UNARY_COMMANDS.includes(command)) {
|
|
1803
659
|
return 1;
|
|
@@ -1807,22 +663,22 @@ function get_command_param_num(command) {
|
|
|
1807
663
|
return 0;
|
|
1808
664
|
}
|
|
1809
665
|
}
|
|
1810
|
-
var LEFT_CURLY_BRACKET = new TexToken(
|
|
1811
|
-
var RIGHT_CURLY_BRACKET = new TexToken(
|
|
1812
|
-
var LEFT_SQUARE_BRACKET = new TexToken(
|
|
1813
|
-
var RIGHT_SQUARE_BRACKET = new TexToken(
|
|
666
|
+
var LEFT_CURLY_BRACKET = new TexToken(7 /* CONTROL */, "{");
|
|
667
|
+
var RIGHT_CURLY_BRACKET = new TexToken(7 /* CONTROL */, "}");
|
|
668
|
+
var LEFT_SQUARE_BRACKET = new TexToken(1 /* ELEMENT */, "[");
|
|
669
|
+
var RIGHT_SQUARE_BRACKET = new TexToken(1 /* ELEMENT */, "]");
|
|
1814
670
|
function eat_whitespaces(tokens, start) {
|
|
1815
671
|
let pos = start;
|
|
1816
|
-
while (pos < tokens.length && [
|
|
672
|
+
while (pos < tokens.length && [5 /* SPACE */, 6 /* NEWLINE */].includes(tokens[pos].type)) {
|
|
1817
673
|
pos++;
|
|
1818
674
|
}
|
|
1819
675
|
return tokens.slice(start, pos);
|
|
1820
676
|
}
|
|
1821
677
|
function eat_parenthesis(tokens, start) {
|
|
1822
678
|
const firstToken = tokens[start];
|
|
1823
|
-
if (firstToken.type ===
|
|
679
|
+
if (firstToken.type === 1 /* ELEMENT */ && ["(", ")", "[", "]", "|", "\\{", "\\}", ".", "\\|"].includes(firstToken.value)) {
|
|
1824
680
|
return firstToken;
|
|
1825
|
-
} else if (firstToken.type ===
|
|
681
|
+
} else if (firstToken.type === 2 /* COMMAND */ && ["lfloor", "rfloor", "lceil", "rceil", "langle", "rangle"].includes(firstToken.value.slice(1))) {
|
|
1826
682
|
return firstToken;
|
|
1827
683
|
} else {
|
|
1828
684
|
return null;
|
|
@@ -1830,7 +686,7 @@ function eat_parenthesis(tokens, start) {
|
|
|
1830
686
|
}
|
|
1831
687
|
function eat_primes(tokens, start) {
|
|
1832
688
|
let pos = start;
|
|
1833
|
-
while (pos < tokens.length && tokens[pos].eq(new TexToken(
|
|
689
|
+
while (pos < tokens.length && tokens[pos].eq(new TexToken(1 /* ELEMENT */, "'"))) {
|
|
1834
690
|
pos += 1;
|
|
1835
691
|
}
|
|
1836
692
|
return pos - start;
|
|
@@ -1852,13 +708,13 @@ function find_closing_match(tokens, start, leftToken, rightToken) {
|
|
|
1852
708
|
}
|
|
1853
709
|
return pos - 1;
|
|
1854
710
|
}
|
|
1855
|
-
var LEFT_COMMAND = new TexToken(
|
|
1856
|
-
var RIGHT_COMMAND = new TexToken(
|
|
711
|
+
var LEFT_COMMAND = new TexToken(2 /* COMMAND */, "\\left");
|
|
712
|
+
var RIGHT_COMMAND = new TexToken(2 /* COMMAND */, "\\right");
|
|
1857
713
|
function find_closing_right_command(tokens, start) {
|
|
1858
714
|
return find_closing_match(tokens, start, LEFT_COMMAND, RIGHT_COMMAND);
|
|
1859
715
|
}
|
|
1860
|
-
var BEGIN_COMMAND = new TexToken(
|
|
1861
|
-
var END_COMMAND = new TexToken(
|
|
716
|
+
var BEGIN_COMMAND = new TexToken(2 /* COMMAND */, "\\begin");
|
|
717
|
+
var END_COMMAND = new TexToken(2 /* COMMAND */, "\\end");
|
|
1862
718
|
function find_closing_end_command(tokens, start) {
|
|
1863
719
|
return find_closing_match(tokens, start, BEGIN_COMMAND, END_COMMAND);
|
|
1864
720
|
}
|
|
@@ -1868,26 +724,27 @@ var LatexParserError = class extends Error {
|
|
|
1868
724
|
this.name = "LatexParserError";
|
|
1869
725
|
}
|
|
1870
726
|
};
|
|
1871
|
-
var SUB_SYMBOL = new TexToken(
|
|
1872
|
-
var SUP_SYMBOL = new TexToken(
|
|
727
|
+
var SUB_SYMBOL = new TexToken(7 /* CONTROL */, "_");
|
|
728
|
+
var SUP_SYMBOL = new TexToken(7 /* CONTROL */, "^");
|
|
1873
729
|
var LatexParser = class {
|
|
1874
730
|
constructor(space_sensitive = false, newline_sensitive = true) {
|
|
1875
731
|
this.space_sensitive = space_sensitive;
|
|
1876
732
|
this.newline_sensitive = newline_sensitive;
|
|
1877
733
|
}
|
|
1878
734
|
parse(tokens) {
|
|
1879
|
-
const
|
|
735
|
+
const token_displaystyle = new TexToken(2 /* COMMAND */, "\\displaystyle");
|
|
736
|
+
const idx = array_find(tokens, token_displaystyle);
|
|
1880
737
|
if (idx === -1) {
|
|
1881
738
|
const [tree, _] = this.parseGroup(tokens, 0, tokens.length);
|
|
1882
739
|
return tree;
|
|
1883
740
|
} else if (idx === 0) {
|
|
1884
741
|
const [tree, _] = this.parseGroup(tokens, 1, tokens.length);
|
|
1885
|
-
return new
|
|
742
|
+
return new TexFuncCall(token_displaystyle, [tree]);
|
|
1886
743
|
} else {
|
|
1887
744
|
const [tree1, _1] = this.parseGroup(tokens, 0, idx);
|
|
1888
745
|
const [tree2, _2] = this.parseGroup(tokens, idx + 1, tokens.length);
|
|
1889
|
-
const display = new
|
|
1890
|
-
return new
|
|
746
|
+
const display = new TexFuncCall(token_displaystyle, [tree2]);
|
|
747
|
+
return new TexGroup([tree1, display]);
|
|
1891
748
|
}
|
|
1892
749
|
}
|
|
1893
750
|
parseGroup(tokens, start, end) {
|
|
@@ -1896,15 +753,15 @@ var LatexParser = class {
|
|
|
1896
753
|
while (pos < end) {
|
|
1897
754
|
const [res, newPos] = this.parseNextExpr(tokens, pos);
|
|
1898
755
|
pos = newPos;
|
|
1899
|
-
if (res.type ===
|
|
1900
|
-
if (!this.space_sensitive && res.
|
|
756
|
+
if (res.head.type === 5 /* SPACE */ || res.head.type === 6 /* NEWLINE */) {
|
|
757
|
+
if (!this.space_sensitive && res.head.value.replace(/ /g, "").length === 0) {
|
|
1901
758
|
continue;
|
|
1902
759
|
}
|
|
1903
|
-
if (!this.newline_sensitive && res.
|
|
760
|
+
if (!this.newline_sensitive && res.head.value === "\n") {
|
|
1904
761
|
continue;
|
|
1905
762
|
}
|
|
1906
763
|
}
|
|
1907
|
-
if (res.
|
|
764
|
+
if (res.head.eq(new TexToken(7 /* CONTROL */, "&"))) {
|
|
1908
765
|
throw new LatexParserError("Unexpected & outside of an alignment");
|
|
1909
766
|
}
|
|
1910
767
|
results.push(res);
|
|
@@ -1913,7 +770,7 @@ var LatexParser = class {
|
|
|
1913
770
|
if (results.length === 1) {
|
|
1914
771
|
node = results[0];
|
|
1915
772
|
} else {
|
|
1916
|
-
node = new
|
|
773
|
+
node = new TexGroup(results);
|
|
1917
774
|
}
|
|
1918
775
|
return [node, end + 1];
|
|
1919
776
|
}
|
|
@@ -1947,14 +804,14 @@ var LatexParser = class {
|
|
|
1947
804
|
}
|
|
1948
805
|
}
|
|
1949
806
|
if (sub !== null || sup !== null || num_prime > 0) {
|
|
1950
|
-
const res = { base };
|
|
807
|
+
const res = { base, sup: null, sub: null };
|
|
1951
808
|
if (sub) {
|
|
1952
809
|
res.sub = sub;
|
|
1953
810
|
}
|
|
1954
811
|
if (num_prime > 0) {
|
|
1955
|
-
res.sup = new
|
|
812
|
+
res.sup = new TexGroup([]);
|
|
1956
813
|
for (let i = 0; i < num_prime; i++) {
|
|
1957
|
-
res.sup.args.push(new
|
|
814
|
+
res.sup.args.push(new TexToken(1 /* ELEMENT */, "'").toNode());
|
|
1958
815
|
}
|
|
1959
816
|
if (sup) {
|
|
1960
817
|
res.sup.args.push(sup);
|
|
@@ -1965,7 +822,7 @@ var LatexParser = class {
|
|
|
1965
822
|
} else if (sup) {
|
|
1966
823
|
res.sup = sup;
|
|
1967
824
|
}
|
|
1968
|
-
return [new
|
|
825
|
+
return [new TexSupSub(res), pos];
|
|
1969
826
|
} else {
|
|
1970
827
|
return [base, pos];
|
|
1971
828
|
}
|
|
@@ -1976,16 +833,13 @@ var LatexParser = class {
|
|
|
1976
833
|
}
|
|
1977
834
|
const firstToken = tokens[start];
|
|
1978
835
|
switch (firstToken.type) {
|
|
1979
|
-
case
|
|
1980
|
-
|
|
1981
|
-
case
|
|
1982
|
-
|
|
1983
|
-
case
|
|
1984
|
-
return [
|
|
1985
|
-
case
|
|
1986
|
-
case 5 /* NEWLINE */:
|
|
1987
|
-
return [new TexNode("whitespace", firstToken.value), start + 1];
|
|
1988
|
-
case 1 /* COMMAND */:
|
|
836
|
+
case 1 /* ELEMENT */:
|
|
837
|
+
case 3 /* LITERAL */:
|
|
838
|
+
case 4 /* COMMENT */:
|
|
839
|
+
case 5 /* SPACE */:
|
|
840
|
+
case 6 /* NEWLINE */:
|
|
841
|
+
return [firstToken.toNode(), start + 1];
|
|
842
|
+
case 2 /* COMMAND */:
|
|
1989
843
|
const commandName = firstToken.value.slice(1);
|
|
1990
844
|
if (IGNORED_COMMANDS.includes(commandName)) {
|
|
1991
845
|
return this.parseNextExprWithoutSupSub(tokens, start + 1);
|
|
@@ -1997,7 +851,7 @@ var LatexParser = class {
|
|
|
1997
851
|
} else {
|
|
1998
852
|
return this.parseCommandExpr(tokens, start);
|
|
1999
853
|
}
|
|
2000
|
-
case
|
|
854
|
+
case 7 /* CONTROL */:
|
|
2001
855
|
const controlChar = firstToken.value;
|
|
2002
856
|
switch (controlChar) {
|
|
2003
857
|
case "{":
|
|
@@ -2013,14 +867,14 @@ var LatexParser = class {
|
|
|
2013
867
|
case "\\,":
|
|
2014
868
|
case "\\:":
|
|
2015
869
|
case "\\;":
|
|
2016
|
-
return [
|
|
870
|
+
return [firstToken.toNode(), start + 1];
|
|
2017
871
|
case "\\ ":
|
|
2018
|
-
return [
|
|
872
|
+
return [firstToken.toNode(), start + 1];
|
|
2019
873
|
case "_":
|
|
2020
874
|
case "^":
|
|
2021
875
|
return [EMPTY_NODE, start];
|
|
2022
876
|
case "&":
|
|
2023
|
-
return [
|
|
877
|
+
return [firstToken.toNode(), start + 1];
|
|
2024
878
|
default:
|
|
2025
879
|
throw new LatexParserError("Unknown control sequence");
|
|
2026
880
|
}
|
|
@@ -2029,8 +883,9 @@ var LatexParser = class {
|
|
|
2029
883
|
}
|
|
2030
884
|
}
|
|
2031
885
|
parseCommandExpr(tokens, start) {
|
|
2032
|
-
assert(tokens[start].type ===
|
|
2033
|
-
const
|
|
886
|
+
assert(tokens[start].type === 2 /* COMMAND */);
|
|
887
|
+
const command_token = tokens[start];
|
|
888
|
+
const command = command_token.value;
|
|
2034
889
|
let pos = start + 1;
|
|
2035
890
|
if (["left", "right", "begin", "end"].includes(command.slice(1))) {
|
|
2036
891
|
throw new LatexParserError("Unexpected command: " + command);
|
|
@@ -2038,10 +893,7 @@ var LatexParser = class {
|
|
|
2038
893
|
const paramNum = get_command_param_num(command.slice(1));
|
|
2039
894
|
switch (paramNum) {
|
|
2040
895
|
case 0:
|
|
2041
|
-
|
|
2042
|
-
return [new TexNode("unknownMacro", command), pos];
|
|
2043
|
-
}
|
|
2044
|
-
return [new TexNode("symbol", command), pos];
|
|
896
|
+
return [command_token.toNode(), pos];
|
|
2045
897
|
case 1: {
|
|
2046
898
|
if (pos >= tokens.length) {
|
|
2047
899
|
throw new LatexParserError("Expecting argument for " + command);
|
|
@@ -2054,24 +906,24 @@ var LatexParser = class {
|
|
|
2054
906
|
}
|
|
2055
907
|
const [exponent, _] = this.parseGroup(tokens, posLeftSquareBracket + 1, posRightSquareBracket);
|
|
2056
908
|
const [arg12, newPos2] = this.parseNextArg(tokens, posRightSquareBracket + 1);
|
|
2057
|
-
return [new
|
|
909
|
+
return [new TexFuncCall(command_token, [arg12], exponent), newPos2];
|
|
2058
910
|
} else if (command === "\\text") {
|
|
2059
911
|
if (pos + 2 >= tokens.length) {
|
|
2060
912
|
throw new LatexParserError("Expecting content for \\text command");
|
|
2061
913
|
}
|
|
2062
914
|
assert(tokens[pos].eq(LEFT_CURLY_BRACKET));
|
|
2063
|
-
assert(tokens[pos + 1].type ===
|
|
915
|
+
assert(tokens[pos + 1].type === 3 /* LITERAL */);
|
|
2064
916
|
assert(tokens[pos + 2].eq(RIGHT_CURLY_BRACKET));
|
|
2065
|
-
const
|
|
2066
|
-
return [new
|
|
917
|
+
const literal = tokens[pos + 1];
|
|
918
|
+
return [new TexText(literal), pos + 3];
|
|
2067
919
|
}
|
|
2068
920
|
let [arg1, newPos] = this.parseNextArg(tokens, pos);
|
|
2069
|
-
return [new
|
|
921
|
+
return [new TexFuncCall(command_token, [arg1]), newPos];
|
|
2070
922
|
}
|
|
2071
923
|
case 2: {
|
|
2072
924
|
const [arg1, pos1] = this.parseNextArg(tokens, pos);
|
|
2073
925
|
const [arg2, pos2] = this.parseNextArg(tokens, pos1);
|
|
2074
|
-
return [new
|
|
926
|
+
return [new TexFuncCall(command_token, [arg1, arg2]), pos2];
|
|
2075
927
|
}
|
|
2076
928
|
default:
|
|
2077
929
|
throw new Error("Invalid number of parameters");
|
|
@@ -2080,9 +932,9 @@ var LatexParser = class {
|
|
|
2080
932
|
/*
|
|
2081
933
|
Extract a non-space argument from the token stream.
|
|
2082
934
|
So that `\frac{12} 3` is parsed as
|
|
2083
|
-
|
|
935
|
+
TypstFuncCall{ head: '\frac', args: [ELEMENT_12, ELEMENT_3] }
|
|
2084
936
|
rather than
|
|
2085
|
-
|
|
937
|
+
TypstFuncCall{ head: '\frac', args: [ELEMENT_12, SPACE] }, ELEMENT_3
|
|
2086
938
|
*/
|
|
2087
939
|
parseNextArg(tokens, start) {
|
|
2088
940
|
let pos = start;
|
|
@@ -2090,7 +942,7 @@ var LatexParser = class {
|
|
|
2090
942
|
while (pos < tokens.length) {
|
|
2091
943
|
let node;
|
|
2092
944
|
[node, pos] = this.parseNextExprWithoutSupSub(tokens, pos);
|
|
2093
|
-
if (node.type
|
|
945
|
+
if (!(node.head.type === 5 /* SPACE */ || node.head.type === 6 /* NEWLINE */)) {
|
|
2094
946
|
arg = node;
|
|
2095
947
|
break;
|
|
2096
948
|
}
|
|
@@ -2129,27 +981,23 @@ var LatexParser = class {
|
|
|
2129
981
|
}
|
|
2130
982
|
pos++;
|
|
2131
983
|
const [body, _] = this.parseGroup(tokens, exprInsideStart, exprInsideEnd);
|
|
2132
|
-
const args = [
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
];
|
|
2137
|
-
const res = new TexNode("leftright", "", args);
|
|
984
|
+
const args = [body];
|
|
985
|
+
const left = leftDelimiter.value === "." ? null : leftDelimiter;
|
|
986
|
+
const right = rightDelimiter.value === "." ? null : rightDelimiter;
|
|
987
|
+
const res = new TexLeftRight(args, { left, right });
|
|
2138
988
|
return [res, pos];
|
|
2139
989
|
}
|
|
2140
990
|
parseBeginEndExpr(tokens, start) {
|
|
2141
991
|
assert(tokens[start].eq(BEGIN_COMMAND));
|
|
2142
992
|
let pos = start + 1;
|
|
2143
993
|
assert(tokens[pos].eq(LEFT_CURLY_BRACKET));
|
|
2144
|
-
assert(tokens[pos + 1].type ===
|
|
994
|
+
assert(tokens[pos + 1].type === 3 /* LITERAL */);
|
|
2145
995
|
assert(tokens[pos + 2].eq(RIGHT_CURLY_BRACKET));
|
|
2146
996
|
const envName = tokens[pos + 1].value;
|
|
2147
997
|
pos += 3;
|
|
2148
998
|
const args = [];
|
|
2149
999
|
if (["array", "subarray"].includes(envName)) {
|
|
2150
|
-
|
|
2151
|
-
throw new LatexParserError(`Missing arg for \\begin{${envName}}`);
|
|
2152
|
-
}
|
|
1000
|
+
pos += eat_whitespaces(tokens, pos).length;
|
|
2153
1001
|
const [arg, newPos] = this.parseNextArg(tokens, pos);
|
|
2154
1002
|
args.push(arg);
|
|
2155
1003
|
pos = newPos;
|
|
@@ -2163,18 +1011,18 @@ var LatexParser = class {
|
|
|
2163
1011
|
const exprInsideEnd = endIdx;
|
|
2164
1012
|
pos = endIdx + 1;
|
|
2165
1013
|
assert(tokens[pos].eq(LEFT_CURLY_BRACKET));
|
|
2166
|
-
assert(tokens[pos + 1].type ===
|
|
1014
|
+
assert(tokens[pos + 1].type === 3 /* LITERAL */);
|
|
2167
1015
|
assert(tokens[pos + 2].eq(RIGHT_CURLY_BRACKET));
|
|
2168
1016
|
if (tokens[pos + 1].value !== envName) {
|
|
2169
1017
|
throw new LatexParserError("Mismatched \\begin and \\end environments");
|
|
2170
1018
|
}
|
|
2171
1019
|
pos += 3;
|
|
2172
1020
|
const exprInside = tokens.slice(exprInsideStart, exprInsideEnd);
|
|
2173
|
-
while (exprInside.length > 0 && [
|
|
1021
|
+
while (exprInside.length > 0 && [5 /* SPACE */, 6 /* NEWLINE */].includes(exprInside[exprInside.length - 1].type)) {
|
|
2174
1022
|
exprInside.pop();
|
|
2175
1023
|
}
|
|
2176
1024
|
const body = this.parseAligned(exprInside);
|
|
2177
|
-
const res = new
|
|
1025
|
+
const res = new TexBeginEnd(new TexToken(3 /* LITERAL */, envName), args, body);
|
|
2178
1026
|
return [res, pos];
|
|
2179
1027
|
}
|
|
2180
1028
|
parseAligned(tokens) {
|
|
@@ -2182,26 +1030,26 @@ var LatexParser = class {
|
|
|
2182
1030
|
const allRows = [];
|
|
2183
1031
|
let row = [];
|
|
2184
1032
|
allRows.push(row);
|
|
2185
|
-
let group = new
|
|
1033
|
+
let group = new TexGroup([]);
|
|
2186
1034
|
row.push(group);
|
|
2187
1035
|
while (pos < tokens.length) {
|
|
2188
1036
|
const [res, newPos] = this.parseNextExpr(tokens, pos);
|
|
2189
1037
|
pos = newPos;
|
|
2190
|
-
if (res.type ===
|
|
2191
|
-
if (!this.space_sensitive && res.
|
|
1038
|
+
if (res.head.type === 5 /* SPACE */ || res.head.type === 6 /* NEWLINE */) {
|
|
1039
|
+
if (!this.space_sensitive && res.head.value.replace(/ /g, "").length === 0) {
|
|
2192
1040
|
continue;
|
|
2193
1041
|
}
|
|
2194
|
-
if (!this.newline_sensitive && res.
|
|
1042
|
+
if (!this.newline_sensitive && res.head.value === "\n") {
|
|
2195
1043
|
continue;
|
|
2196
1044
|
}
|
|
2197
1045
|
}
|
|
2198
|
-
if (res.
|
|
1046
|
+
if (res.head.eq(new TexToken(7 /* CONTROL */, "\\\\"))) {
|
|
2199
1047
|
row = [];
|
|
2200
|
-
group = new
|
|
1048
|
+
group = new TexGroup([]);
|
|
2201
1049
|
row.push(group);
|
|
2202
1050
|
allRows.push(row);
|
|
2203
|
-
} else if (res.
|
|
2204
|
-
group = new
|
|
1051
|
+
} else if (res.head.eq(new TexToken(7 /* CONTROL */, "&"))) {
|
|
1052
|
+
group = new TexGroup([]);
|
|
2205
1053
|
row.push(group);
|
|
2206
1054
|
} else {
|
|
2207
1055
|
group.args.push(res);
|
|
@@ -2214,10 +1062,10 @@ function passIgnoreWhitespaceBeforeScriptMark(tokens) {
|
|
|
2214
1062
|
const is_script_mark = (token) => token.eq(SUB_SYMBOL) || token.eq(SUP_SYMBOL);
|
|
2215
1063
|
let out_tokens = [];
|
|
2216
1064
|
for (let i = 0; i < tokens.length; i++) {
|
|
2217
|
-
if (tokens[i].type ===
|
|
1065
|
+
if (tokens[i].type === 5 /* SPACE */ && i + 1 < tokens.length && is_script_mark(tokens[i + 1])) {
|
|
2218
1066
|
continue;
|
|
2219
1067
|
}
|
|
2220
|
-
if (tokens[i].type ===
|
|
1068
|
+
if (tokens[i].type === 5 /* SPACE */ && i - 1 >= 0 && is_script_mark(tokens[i - 1])) {
|
|
2221
1069
|
continue;
|
|
2222
1070
|
}
|
|
2223
1071
|
out_tokens.push(tokens[i]);
|
|
@@ -2227,7 +1075,7 @@ function passIgnoreWhitespaceBeforeScriptMark(tokens) {
|
|
|
2227
1075
|
function passExpandCustomTexMacros(tokens, customTexMacros) {
|
|
2228
1076
|
let out_tokens = [];
|
|
2229
1077
|
for (const token of tokens) {
|
|
2230
|
-
if (token.type ===
|
|
1078
|
+
if (token.type === 2 /* COMMAND */ && customTexMacros[token.value]) {
|
|
2231
1079
|
const expanded_tokens = tokenize_tex(customTexMacros[token.value]);
|
|
2232
1080
|
out_tokens = out_tokens.concat(expanded_tokens);
|
|
2233
1081
|
} else {
|
|
@@ -2244,6 +1092,139 @@ function parseTex(tex, customTexMacros) {
|
|
|
2244
1092
|
return parser.parse(tokens);
|
|
2245
1093
|
}
|
|
2246
1094
|
|
|
1095
|
+
// src/typst-types.ts
|
|
1096
|
+
var TypstToken = class _TypstToken {
|
|
1097
|
+
constructor(type, content) {
|
|
1098
|
+
this.type = type;
|
|
1099
|
+
this.value = content;
|
|
1100
|
+
}
|
|
1101
|
+
eq(other) {
|
|
1102
|
+
return this.type === other.type && this.value === other.value;
|
|
1103
|
+
}
|
|
1104
|
+
isOneOf(tokens) {
|
|
1105
|
+
return array_includes(tokens, this);
|
|
1106
|
+
}
|
|
1107
|
+
toNode() {
|
|
1108
|
+
return new TypstTerminal(this);
|
|
1109
|
+
}
|
|
1110
|
+
toString() {
|
|
1111
|
+
switch (this.type) {
|
|
1112
|
+
case 4 /* TEXT */:
|
|
1113
|
+
return `"${this.value}"`;
|
|
1114
|
+
case 5 /* COMMENT */:
|
|
1115
|
+
return `//${this.value}`;
|
|
1116
|
+
default:
|
|
1117
|
+
return this.value;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
static {
|
|
1121
|
+
this.NONE = new _TypstToken(0 /* NONE */, "#none");
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
var TypstNode = class {
|
|
1125
|
+
constructor(type, head, args) {
|
|
1126
|
+
this.type = type;
|
|
1127
|
+
this.head = head ? head : TypstToken.NONE;
|
|
1128
|
+
this.args = args;
|
|
1129
|
+
}
|
|
1130
|
+
setOptions(options) {
|
|
1131
|
+
this.options = options;
|
|
1132
|
+
}
|
|
1133
|
+
// Note that this is only shallow equality.
|
|
1134
|
+
eq(other) {
|
|
1135
|
+
return this.type === other.type && this.head.eq(other.head);
|
|
1136
|
+
}
|
|
1137
|
+
toString() {
|
|
1138
|
+
throw new Error(`Unimplemented toString() in base class TypstNode`);
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
var TypstTerminal = class extends TypstNode {
|
|
1142
|
+
constructor(head) {
|
|
1143
|
+
super("terminal", head);
|
|
1144
|
+
}
|
|
1145
|
+
isOverHigh() {
|
|
1146
|
+
return false;
|
|
1147
|
+
}
|
|
1148
|
+
toString() {
|
|
1149
|
+
return this.head.toString();
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var TypstGroup = class extends TypstNode {
|
|
1153
|
+
constructor(args) {
|
|
1154
|
+
super("group", TypstToken.NONE, args);
|
|
1155
|
+
}
|
|
1156
|
+
isOverHigh() {
|
|
1157
|
+
return this.args.some((n) => n.isOverHigh());
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
var TypstSupsub = class extends TypstNode {
|
|
1161
|
+
constructor(data) {
|
|
1162
|
+
super("supsub", TypstToken.NONE, []);
|
|
1163
|
+
this.base = data.base;
|
|
1164
|
+
this.sup = data.sup;
|
|
1165
|
+
this.sub = data.sub;
|
|
1166
|
+
}
|
|
1167
|
+
isOverHigh() {
|
|
1168
|
+
return this.base.isOverHigh();
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
var TypstFuncCall = class extends TypstNode {
|
|
1172
|
+
constructor(head, args) {
|
|
1173
|
+
super("funcCall", head, args);
|
|
1174
|
+
}
|
|
1175
|
+
isOverHigh() {
|
|
1176
|
+
if (this.head.value === "frac") {
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
return this.args.some((n) => n.isOverHigh());
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
var TypstFraction = class extends TypstNode {
|
|
1183
|
+
constructor(args) {
|
|
1184
|
+
super("fraction", TypstToken.NONE, args);
|
|
1185
|
+
}
|
|
1186
|
+
isOverHigh() {
|
|
1187
|
+
return true;
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
var TypstLeftright = class extends TypstNode {
|
|
1191
|
+
constructor(head, args, data) {
|
|
1192
|
+
super("leftright", head, args);
|
|
1193
|
+
this.left = data.left;
|
|
1194
|
+
this.right = data.right;
|
|
1195
|
+
}
|
|
1196
|
+
isOverHigh() {
|
|
1197
|
+
return this.args.some((n) => n.isOverHigh());
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
var TypstAlign = class extends TypstNode {
|
|
1201
|
+
constructor(data) {
|
|
1202
|
+
super("align", TypstToken.NONE, []);
|
|
1203
|
+
this.matrix = data;
|
|
1204
|
+
}
|
|
1205
|
+
isOverHigh() {
|
|
1206
|
+
return true;
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
var TypstMatrix = class extends TypstNode {
|
|
1210
|
+
constructor(data) {
|
|
1211
|
+
super("matrix", TypstToken.NONE, []);
|
|
1212
|
+
this.matrix = data;
|
|
1213
|
+
}
|
|
1214
|
+
isOverHigh() {
|
|
1215
|
+
return true;
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
var TypstCases = class extends TypstNode {
|
|
1219
|
+
constructor(data) {
|
|
1220
|
+
super("cases", TypstToken.NONE, []);
|
|
1221
|
+
this.matrix = data;
|
|
1222
|
+
}
|
|
1223
|
+
isOverHigh() {
|
|
1224
|
+
return true;
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
|
|
2247
1228
|
// src/typst-shorthands.ts
|
|
2248
1229
|
var shorthandMap = /* @__PURE__ */ new Map([
|
|
2249
1230
|
["arrow.l.r.double.long", "<==>"],
|
|
@@ -2294,7 +1275,7 @@ for (const [key, value] of shorthandMap.entries()) {
|
|
|
2294
1275
|
|
|
2295
1276
|
// src/typst-writer.ts
|
|
2296
1277
|
function is_delimiter(c) {
|
|
2297
|
-
return c.type ===
|
|
1278
|
+
return c.head.type === 2 /* ELEMENT */ && ["(", ")", "[", "]", "{", "}", "|", "\u230A", "\u230B", "\u2308", "\u2309"].includes(c.head.value);
|
|
2298
1279
|
}
|
|
2299
1280
|
var TYPST_LEFT_PARENTHESIS = new TypstToken(2 /* ELEMENT */, "(");
|
|
2300
1281
|
var TYPST_RIGHT_PARENTHESIS = new TypstToken(2 /* ELEMENT */, ")");
|
|
@@ -2343,64 +1324,82 @@ var TypstWriter = class {
|
|
|
2343
1324
|
this.buffer += str;
|
|
2344
1325
|
}
|
|
2345
1326
|
// Serialize a tree of TypstNode into a list of TypstToken
|
|
2346
|
-
serialize(
|
|
2347
|
-
switch (
|
|
2348
|
-
case "
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
1327
|
+
serialize(abstractNode) {
|
|
1328
|
+
switch (abstractNode.type) {
|
|
1329
|
+
case "terminal": {
|
|
1330
|
+
const node = abstractNode;
|
|
1331
|
+
if (node.head.type === 2 /* ELEMENT */) {
|
|
1332
|
+
if (node.head.value === "," && this.insideFunctionDepth > 0) {
|
|
1333
|
+
this.queue.push(new TypstToken(1 /* SYMBOL */, "comma"));
|
|
1334
|
+
} else {
|
|
1335
|
+
this.queue.push(node.head);
|
|
1336
|
+
}
|
|
1337
|
+
break;
|
|
1338
|
+
} else if (node.head.type === 1 /* SYMBOL */) {
|
|
1339
|
+
let symbol_name = node.head.value;
|
|
1340
|
+
if (this.preferShorthands) {
|
|
1341
|
+
if (shorthandMap.has(symbol_name)) {
|
|
1342
|
+
symbol_name = shorthandMap.get(symbol_name);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (this.inftyToOo && symbol_name === "infinity") {
|
|
1346
|
+
symbol_name = "oo";
|
|
1347
|
+
}
|
|
1348
|
+
this.queue.push(new TypstToken(1 /* SYMBOL */, symbol_name));
|
|
1349
|
+
break;
|
|
1350
|
+
} else if (node.head.type === 6 /* SPACE */ || node.head.type === 8 /* NEWLINE */) {
|
|
1351
|
+
for (const c of node.head.value) {
|
|
1352
|
+
if (c === " ") {
|
|
1353
|
+
if (this.keepSpaces) {
|
|
1354
|
+
this.queue.push(new TypstToken(6 /* SPACE */, c));
|
|
1355
|
+
}
|
|
1356
|
+
} else if (c === "\n") {
|
|
1357
|
+
this.queue.push(new TypstToken(1 /* SYMBOL */, c));
|
|
1358
|
+
} else {
|
|
1359
|
+
throw new TypstWriterError(`Unexpected whitespace character: ${c}`, node);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
break;
|
|
2354
1363
|
} else {
|
|
2355
|
-
this.queue.push(
|
|
1364
|
+
this.queue.push(node.head);
|
|
1365
|
+
break;
|
|
2356
1366
|
}
|
|
2357
|
-
break;
|
|
2358
1367
|
}
|
|
2359
|
-
case "
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
content = shorthandMap.get(content);
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
if (this.inftyToOo && content === "infinity") {
|
|
2367
|
-
content = "oo";
|
|
1368
|
+
case "group": {
|
|
1369
|
+
const node = abstractNode;
|
|
1370
|
+
for (const item of node.args) {
|
|
1371
|
+
this.serialize(item);
|
|
2368
1372
|
}
|
|
2369
|
-
this.queue.push(new TypstToken(1 /* SYMBOL */, content));
|
|
2370
1373
|
break;
|
|
2371
1374
|
}
|
|
2372
|
-
case "
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
for (const c of node.content) {
|
|
2383
|
-
if (c === " ") {
|
|
2384
|
-
if (this.keepSpaces) {
|
|
2385
|
-
this.queue.push(new TypstToken(6 /* SPACE */, c));
|
|
2386
|
-
}
|
|
2387
|
-
} else if (c === "\n") {
|
|
2388
|
-
this.queue.push(new TypstToken(1 /* SYMBOL */, c));
|
|
2389
|
-
} else {
|
|
2390
|
-
throw new TypstWriterError(`Unexpected whitespace character: ${c}`, node);
|
|
2391
|
-
}
|
|
1375
|
+
case "leftright": {
|
|
1376
|
+
const node = abstractNode;
|
|
1377
|
+
const LR = new TypstToken(1 /* SYMBOL */, "lr");
|
|
1378
|
+
const { left, right } = node;
|
|
1379
|
+
if (node.head.eq(LR)) {
|
|
1380
|
+
this.queue.push(LR);
|
|
1381
|
+
this.queue.push(TYPST_LEFT_PARENTHESIS);
|
|
1382
|
+
}
|
|
1383
|
+
if (left) {
|
|
1384
|
+
this.queue.push(left);
|
|
2392
1385
|
}
|
|
2393
|
-
break;
|
|
2394
|
-
case "group":
|
|
2395
1386
|
for (const item of node.args) {
|
|
2396
1387
|
this.serialize(item);
|
|
2397
1388
|
}
|
|
1389
|
+
if (right) {
|
|
1390
|
+
this.queue.push(right);
|
|
1391
|
+
}
|
|
1392
|
+
if (node.head.eq(LR)) {
|
|
1393
|
+
this.queue.push(TYPST_RIGHT_PARENTHESIS);
|
|
1394
|
+
}
|
|
2398
1395
|
break;
|
|
1396
|
+
}
|
|
2399
1397
|
case "supsub": {
|
|
2400
|
-
|
|
1398
|
+
const node = abstractNode;
|
|
1399
|
+
let { base, sup, sub } = node;
|
|
2401
1400
|
this.appendWithBracketsIfNeeded(base);
|
|
2402
1401
|
let trailing_space_needed = false;
|
|
2403
|
-
const has_prime = sup && sup.
|
|
1402
|
+
const has_prime = sup && sup.head.eq(new TypstToken(2 /* ELEMENT */, "'"));
|
|
2404
1403
|
if (has_prime) {
|
|
2405
1404
|
this.queue.push(new TypstToken(2 /* ELEMENT */, "'"));
|
|
2406
1405
|
trailing_space_needed = false;
|
|
@@ -2419,11 +1418,10 @@ var TypstWriter = class {
|
|
|
2419
1418
|
break;
|
|
2420
1419
|
}
|
|
2421
1420
|
case "funcCall": {
|
|
2422
|
-
const
|
|
1421
|
+
const node = abstractNode;
|
|
1422
|
+
const func_symbol = node.head;
|
|
2423
1423
|
this.queue.push(func_symbol);
|
|
2424
|
-
|
|
2425
|
-
this.insideFunctionDepth++;
|
|
2426
|
-
}
|
|
1424
|
+
this.insideFunctionDepth++;
|
|
2427
1425
|
this.queue.push(TYPST_LEFT_PARENTHESIS);
|
|
2428
1426
|
for (let i = 0; i < node.args.length; i++) {
|
|
2429
1427
|
this.serialize(node.args[i]);
|
|
@@ -2437,12 +1435,11 @@ var TypstWriter = class {
|
|
|
2437
1435
|
}
|
|
2438
1436
|
}
|
|
2439
1437
|
this.queue.push(TYPST_RIGHT_PARENTHESIS);
|
|
2440
|
-
|
|
2441
|
-
this.insideFunctionDepth--;
|
|
2442
|
-
}
|
|
1438
|
+
this.insideFunctionDepth--;
|
|
2443
1439
|
break;
|
|
2444
1440
|
}
|
|
2445
1441
|
case "fraction": {
|
|
1442
|
+
const node = abstractNode;
|
|
2446
1443
|
const [numerator, denominator] = node.args;
|
|
2447
1444
|
const pos = this.queue.length;
|
|
2448
1445
|
const no_wrap = this.appendWithBracketsIfNeeded(numerator);
|
|
@@ -2455,7 +1452,8 @@ var TypstWriter = class {
|
|
|
2455
1452
|
break;
|
|
2456
1453
|
}
|
|
2457
1454
|
case "align": {
|
|
2458
|
-
const
|
|
1455
|
+
const node = abstractNode;
|
|
1456
|
+
const matrix = node.matrix;
|
|
2459
1457
|
matrix.forEach((row, i) => {
|
|
2460
1458
|
row.forEach((cell, j) => {
|
|
2461
1459
|
if (j > 0) {
|
|
@@ -2470,7 +1468,8 @@ var TypstWriter = class {
|
|
|
2470
1468
|
break;
|
|
2471
1469
|
}
|
|
2472
1470
|
case "matrix": {
|
|
2473
|
-
const
|
|
1471
|
+
const node = abstractNode;
|
|
1472
|
+
const matrix = node.matrix;
|
|
2474
1473
|
this.queue.push(new TypstToken(1 /* SYMBOL */, "mat"));
|
|
2475
1474
|
this.insideFunctionDepth++;
|
|
2476
1475
|
this.queue.push(TYPST_LEFT_PARENTHESIS);
|
|
@@ -2496,7 +1495,8 @@ var TypstWriter = class {
|
|
|
2496
1495
|
break;
|
|
2497
1496
|
}
|
|
2498
1497
|
case "cases": {
|
|
2499
|
-
const
|
|
1498
|
+
const node = abstractNode;
|
|
1499
|
+
const cases = node.matrix;
|
|
2500
1500
|
this.queue.push(new TypstToken(1 /* SYMBOL */, "cases"));
|
|
2501
1501
|
this.insideFunctionDepth++;
|
|
2502
1502
|
this.queue.push(TYPST_LEFT_PARENTHESIS);
|
|
@@ -2521,16 +1521,8 @@ var TypstWriter = class {
|
|
|
2521
1521
|
this.insideFunctionDepth--;
|
|
2522
1522
|
break;
|
|
2523
1523
|
}
|
|
2524
|
-
case "unknown": {
|
|
2525
|
-
if (this.nonStrict) {
|
|
2526
|
-
this.queue.push(new TypstToken(1 /* SYMBOL */, node.content));
|
|
2527
|
-
} else {
|
|
2528
|
-
throw new TypstWriterError(`Unknown macro: ${node.content}`, node);
|
|
2529
|
-
}
|
|
2530
|
-
break;
|
|
2531
|
-
}
|
|
2532
1524
|
default:
|
|
2533
|
-
throw new TypstWriterError(`Unimplemented node type to append: ${
|
|
1525
|
+
throw new TypstWriterError(`Unimplemented node type to append: ${abstractNode.type}`, abstractNode);
|
|
2534
1526
|
}
|
|
2535
1527
|
}
|
|
2536
1528
|
appendWithBracketsIfNeeded(node) {
|
|
@@ -2572,34 +1564,1124 @@ var TypstWriter = class {
|
|
|
2572
1564
|
});
|
|
2573
1565
|
this.queue = [];
|
|
2574
1566
|
}
|
|
2575
|
-
finalize() {
|
|
2576
|
-
this.flushQueue();
|
|
2577
|
-
const smartFloorPass = function(input) {
|
|
2578
|
-
let res = input.replace(/floor\.l\s*(.*?)\s*floor\.r/g, "floor($1)");
|
|
2579
|
-
res = res.replace(/floor\(\)/g, 'floor("")');
|
|
2580
|
-
return res;
|
|
2581
|
-
};
|
|
2582
|
-
const smartCeilPass = function(input) {
|
|
2583
|
-
let res = input.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g, "ceil($1)");
|
|
2584
|
-
res = res.replace(/ceil\(\)/g, 'ceil("")');
|
|
2585
|
-
return res;
|
|
2586
|
-
};
|
|
2587
|
-
const smartRoundPass = function(input) {
|
|
2588
|
-
let res = input.replace(/floor\.l\s*(.*?)\s*ceil\.r/g, "round($1)");
|
|
2589
|
-
res = res.replace(/round\(\)/g, 'round("")');
|
|
2590
|
-
return res;
|
|
2591
|
-
};
|
|
2592
|
-
if (this.optimize) {
|
|
2593
|
-
const all_passes = [smartFloorPass, smartCeilPass, smartRoundPass];
|
|
2594
|
-
for (const pass of all_passes) {
|
|
2595
|
-
this.buffer = pass(this.buffer);
|
|
2596
|
-
}
|
|
2597
|
-
}
|
|
2598
|
-
return this.buffer;
|
|
1567
|
+
finalize() {
|
|
1568
|
+
this.flushQueue();
|
|
1569
|
+
const smartFloorPass = function(input) {
|
|
1570
|
+
let res = input.replace(/floor\.l\s*(.*?)\s*floor\.r/g, "floor($1)");
|
|
1571
|
+
res = res.replace(/floor\(\)/g, 'floor("")');
|
|
1572
|
+
return res;
|
|
1573
|
+
};
|
|
1574
|
+
const smartCeilPass = function(input) {
|
|
1575
|
+
let res = input.replace(/ceil\.l\s*(.*?)\s*ceil\.r/g, "ceil($1)");
|
|
1576
|
+
res = res.replace(/ceil\(\)/g, 'ceil("")');
|
|
1577
|
+
return res;
|
|
1578
|
+
};
|
|
1579
|
+
const smartRoundPass = function(input) {
|
|
1580
|
+
let res = input.replace(/floor\.l\s*(.*?)\s*ceil\.r/g, "round($1)");
|
|
1581
|
+
res = res.replace(/round\(\)/g, 'round("")');
|
|
1582
|
+
return res;
|
|
1583
|
+
};
|
|
1584
|
+
if (this.optimize) {
|
|
1585
|
+
const all_passes = [smartFloorPass, smartCeilPass, smartRoundPass];
|
|
1586
|
+
for (const pass of all_passes) {
|
|
1587
|
+
this.buffer = pass(this.buffer);
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
return this.buffer;
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
// src/map.ts
|
|
1595
|
+
var symbolMap = /* @__PURE__ */ new Map([
|
|
1596
|
+
["displaystyle", "display"],
|
|
1597
|
+
["hspace", "#h"],
|
|
1598
|
+
["|", "bar.v.double"],
|
|
1599
|
+
[",", "thin"],
|
|
1600
|
+
[":", "med"],
|
|
1601
|
+
[" ", "med"],
|
|
1602
|
+
[";", "thick"],
|
|
1603
|
+
/* textual operators */
|
|
1604
|
+
["ln", "ln"],
|
|
1605
|
+
["log", "log"],
|
|
1606
|
+
["cos", "cos"],
|
|
1607
|
+
["sin", "sin"],
|
|
1608
|
+
["tan", "tan"],
|
|
1609
|
+
["cot", "cot"],
|
|
1610
|
+
["sec", "sec"],
|
|
1611
|
+
["csc", "csc"],
|
|
1612
|
+
["mod", "mod"],
|
|
1613
|
+
["omicron", "omicron"],
|
|
1614
|
+
["Xi", "Xi"],
|
|
1615
|
+
["Upsilon", "Upsilon"],
|
|
1616
|
+
["lim", "lim"],
|
|
1617
|
+
["binom", "binom"],
|
|
1618
|
+
["tilde", "tilde"],
|
|
1619
|
+
["hat", "hat"],
|
|
1620
|
+
["sqrt", "sqrt"],
|
|
1621
|
+
["nonumber", ""],
|
|
1622
|
+
["vec", "arrow"],
|
|
1623
|
+
["neq", "eq.not"],
|
|
1624
|
+
["dot", "dot"],
|
|
1625
|
+
["ddot", "dot.double"],
|
|
1626
|
+
["doteq", "dot(eq)"],
|
|
1627
|
+
["dots", "dots.h"],
|
|
1628
|
+
["vdots", "dots.v"],
|
|
1629
|
+
["ddots", "dots.down"],
|
|
1630
|
+
["widehat", "hat"],
|
|
1631
|
+
// Ideally, the result of \widehat should be longer than \hat. But it is not implemented now.
|
|
1632
|
+
["widetilde", "tilde"],
|
|
1633
|
+
// Ideally, the result of \widetilde should be longer than \tilde. But it is not implemented now.
|
|
1634
|
+
["quad", "quad"],
|
|
1635
|
+
["qquad", "wide"],
|
|
1636
|
+
["overbrace", "overbrace"],
|
|
1637
|
+
// same
|
|
1638
|
+
["underbrace", "underbrace"],
|
|
1639
|
+
// same
|
|
1640
|
+
["overline", "overline"],
|
|
1641
|
+
// same
|
|
1642
|
+
["underline", "underline"],
|
|
1643
|
+
// same
|
|
1644
|
+
["bar", "macron"],
|
|
1645
|
+
["dbinom", "binom"],
|
|
1646
|
+
["tbinom", "binom"],
|
|
1647
|
+
["dfrac", "frac"],
|
|
1648
|
+
["tfrac", "frac"],
|
|
1649
|
+
["operatorname", "op"],
|
|
1650
|
+
["boldsymbol", "bold"],
|
|
1651
|
+
["mathbb", "bb"],
|
|
1652
|
+
["mathbf", "bold"],
|
|
1653
|
+
["mathcal", "cal"],
|
|
1654
|
+
["mathit", "italic"],
|
|
1655
|
+
["mathfrak", "frak"],
|
|
1656
|
+
["mathrm", "upright"],
|
|
1657
|
+
["mathsf", "sans"],
|
|
1658
|
+
["mathtt", "mono"],
|
|
1659
|
+
["rm", "upright"],
|
|
1660
|
+
// TODO: \pmb need special logic to handle but it is not implemented now. See the commented test case.
|
|
1661
|
+
["pmb", "bold"],
|
|
1662
|
+
["leadsto", "arrow.r.squiggly"],
|
|
1663
|
+
["P", "pilcrow"],
|
|
1664
|
+
["S", "section"],
|
|
1665
|
+
["aleph", "alef"],
|
|
1666
|
+
["infin", "infinity"],
|
|
1667
|
+
["Delta", "Delta"],
|
|
1668
|
+
["Gamma", "Gamma"],
|
|
1669
|
+
["Lambda", "Lambda"],
|
|
1670
|
+
["Omega", "Omega"],
|
|
1671
|
+
["Phi", "Phi"],
|
|
1672
|
+
["Pi", "Pi"],
|
|
1673
|
+
["Psi", "Psi"],
|
|
1674
|
+
["Sigma", "Sigma"],
|
|
1675
|
+
["Theta", "Theta"],
|
|
1676
|
+
["alpha", "alpha"],
|
|
1677
|
+
// ['amalg', 'product.co'],
|
|
1678
|
+
["beta", "beta"],
|
|
1679
|
+
["bigcirc", "circle.big"],
|
|
1680
|
+
// ['bowtie', 'join'],
|
|
1681
|
+
["bullet", "bullet"],
|
|
1682
|
+
["cdot", "dot.op"],
|
|
1683
|
+
// 'dot.op' or 'dot.c'
|
|
1684
|
+
["cdots", "dots.c"],
|
|
1685
|
+
["checkmark", "checkmark"],
|
|
1686
|
+
["chi", "chi"],
|
|
1687
|
+
["circ", "circle.small"],
|
|
1688
|
+
// 'circle.small' or 'compose'
|
|
1689
|
+
["colon", "colon"],
|
|
1690
|
+
["cong", "tilde.equiv"],
|
|
1691
|
+
["coprod", "product.co"],
|
|
1692
|
+
["copyright", "copyright"],
|
|
1693
|
+
["cup", "union"],
|
|
1694
|
+
["curlyvee", "or.curly"],
|
|
1695
|
+
["curlywedge", "and.curly"],
|
|
1696
|
+
["dagger", "dagger"],
|
|
1697
|
+
["dashv", "tack.l"],
|
|
1698
|
+
["ddagger", "dagger.double"],
|
|
1699
|
+
["delta", "delta"],
|
|
1700
|
+
["ddots", "dots.down"],
|
|
1701
|
+
["diamond", "diamond"],
|
|
1702
|
+
["div", "div"],
|
|
1703
|
+
["divideontimes", "times.div"],
|
|
1704
|
+
["dotplus", "plus.dot"],
|
|
1705
|
+
["ell", "ell"],
|
|
1706
|
+
["emptyset", "nothing"],
|
|
1707
|
+
["epsilon", "epsilon.alt"],
|
|
1708
|
+
["equiv", "equiv"],
|
|
1709
|
+
["eta", "eta"],
|
|
1710
|
+
["exists", "exists"],
|
|
1711
|
+
["forall", "forall"],
|
|
1712
|
+
// ['frown', 'paren.t'],
|
|
1713
|
+
["gamma", "gamma"],
|
|
1714
|
+
["ge", "gt.eq"],
|
|
1715
|
+
["geq", "gt.eq"],
|
|
1716
|
+
["geqslant", "gt.eq.slant"],
|
|
1717
|
+
["gg", "gt.double"],
|
|
1718
|
+
["hbar", "planck.reduce"],
|
|
1719
|
+
["imath", "dotless.i"],
|
|
1720
|
+
["iiiint", "integral.quad"],
|
|
1721
|
+
["iiint", "integral.triple"],
|
|
1722
|
+
["iint", "integral.double"],
|
|
1723
|
+
["in", "in"],
|
|
1724
|
+
["infty", "infinity"],
|
|
1725
|
+
["int", "integral"],
|
|
1726
|
+
["intercal", "top"],
|
|
1727
|
+
// 'top' or 'tack.b'
|
|
1728
|
+
["iota", "iota"],
|
|
1729
|
+
["jmath", "dotless.j"],
|
|
1730
|
+
["kappa", "kappa"],
|
|
1731
|
+
["lambda", "lambda"],
|
|
1732
|
+
["land", "and"],
|
|
1733
|
+
["langle", "angle.l"],
|
|
1734
|
+
["lbrace", "brace.l"],
|
|
1735
|
+
["lbrack", "bracket.l"],
|
|
1736
|
+
["ldots", "dots.h"],
|
|
1737
|
+
["le", "lt.eq"],
|
|
1738
|
+
["leftthreetimes", "times.three.l"],
|
|
1739
|
+
["leftrightarrow", "arrow.l.r"],
|
|
1740
|
+
["leq", "lt.eq"],
|
|
1741
|
+
["leqslant", "lt.eq.slant"],
|
|
1742
|
+
["lhd", "triangle.l"],
|
|
1743
|
+
["ll", "lt.double"],
|
|
1744
|
+
// ['longmapsto', 'arrow.bar.long'],
|
|
1745
|
+
// ['longrightarrow', 'arrow.long'],
|
|
1746
|
+
["lor", "or"],
|
|
1747
|
+
["ltimes", "times.l"],
|
|
1748
|
+
// ['mapsto', 'arrow.bar'],
|
|
1749
|
+
["measuredangle", "angle.arc"],
|
|
1750
|
+
["mid", "divides"],
|
|
1751
|
+
["models", "models"],
|
|
1752
|
+
["mp", "minus.plus"],
|
|
1753
|
+
["mu", "mu"],
|
|
1754
|
+
// ['nRightarrow', 'arrow.double.not'],
|
|
1755
|
+
["nabla", "nabla"],
|
|
1756
|
+
["ncong", "tilde.equiv.not"],
|
|
1757
|
+
["ne", "eq.not"],
|
|
1758
|
+
["neg", "not"],
|
|
1759
|
+
["neq", "eq.not"],
|
|
1760
|
+
["nexists", "exists.not"],
|
|
1761
|
+
["ni", "in.rev"],
|
|
1762
|
+
["nleftarrow", "arrow.l.not"],
|
|
1763
|
+
["nleq", "lt.eq.not"],
|
|
1764
|
+
["nparallel", "parallel.not"],
|
|
1765
|
+
["ngeq", "gt.eq.not"],
|
|
1766
|
+
["nmid", "divides.not"],
|
|
1767
|
+
["notin", "in.not"],
|
|
1768
|
+
// ['nrightarrow', 'arrow.not'],
|
|
1769
|
+
["nsim", "tilde.not"],
|
|
1770
|
+
["nsubseteq", "subset.eq.not"],
|
|
1771
|
+
["nu", "nu"],
|
|
1772
|
+
["ntriangleleft", "lt.tri.not"],
|
|
1773
|
+
["ntriangleright", "gt.tri.not"],
|
|
1774
|
+
["odot", "dot.circle"],
|
|
1775
|
+
["oint", "integral.cont"],
|
|
1776
|
+
["oiint", "integral.surf"],
|
|
1777
|
+
["oiiint", "integral.vol"],
|
|
1778
|
+
["omega", "omega"],
|
|
1779
|
+
["ominus", "minus.circle"],
|
|
1780
|
+
// ['oplus', 'xor'], // or 'plus.circle'
|
|
1781
|
+
["otimes", "times.circle"],
|
|
1782
|
+
["parallel", "parallel"],
|
|
1783
|
+
["partial", "diff"],
|
|
1784
|
+
["perp", "perp"],
|
|
1785
|
+
["phi", "phi.alt"],
|
|
1786
|
+
["pi", "pi"],
|
|
1787
|
+
["pm", "plus.minus"],
|
|
1788
|
+
["pounds", "pound"],
|
|
1789
|
+
["prec", "prec"],
|
|
1790
|
+
["preceq", "prec.eq"],
|
|
1791
|
+
["prime", "prime"],
|
|
1792
|
+
["prod", "product"],
|
|
1793
|
+
["propto", "prop"],
|
|
1794
|
+
["psi", "psi"],
|
|
1795
|
+
["rangle", "angle.r"],
|
|
1796
|
+
["rbrace", "brace.r"],
|
|
1797
|
+
["rbrack", "bracket.r"],
|
|
1798
|
+
["rhd", "triangle"],
|
|
1799
|
+
["rho", "rho"],
|
|
1800
|
+
["rightarrow", "arrow.r"],
|
|
1801
|
+
["rightthreetimes", "times.three.r"],
|
|
1802
|
+
["rtimes", "times.r"],
|
|
1803
|
+
["setminus", "without"],
|
|
1804
|
+
["sigma", "sigma"],
|
|
1805
|
+
["sim", "tilde.op"],
|
|
1806
|
+
["simeq", "tilde.eq"],
|
|
1807
|
+
["slash", "slash"],
|
|
1808
|
+
["smallsetminus", "without"],
|
|
1809
|
+
// ['smile', 'paren.b'],
|
|
1810
|
+
["spadesuit", "suit.spade"],
|
|
1811
|
+
["sqsubseteq", "subset.eq.sq"],
|
|
1812
|
+
["sqsupseteq", "supset.eq.sq"],
|
|
1813
|
+
// ['star', 'star'],
|
|
1814
|
+
["subset", "subset"],
|
|
1815
|
+
["subseteq", "subset.eq"],
|
|
1816
|
+
["subsetneq", "subset.neq"],
|
|
1817
|
+
["succ", "succ"],
|
|
1818
|
+
["succeq", "succ.eq"],
|
|
1819
|
+
["sum", "sum"],
|
|
1820
|
+
["supset", "supset"],
|
|
1821
|
+
["supseteq", "supset.eq"],
|
|
1822
|
+
["supsetneq", "supset.neq"],
|
|
1823
|
+
["tau", "tau"],
|
|
1824
|
+
["theta", "theta"],
|
|
1825
|
+
["times", "times"],
|
|
1826
|
+
["to", "arrow.r"],
|
|
1827
|
+
["top", "top"],
|
|
1828
|
+
["triangle", "triangle.t"],
|
|
1829
|
+
// ['triangledown', 'triangle.b.small'],
|
|
1830
|
+
// ['triangleleft', 'triangle.l.small'],
|
|
1831
|
+
// ['triangleright', 'triangle.r.small'],
|
|
1832
|
+
["twoheadrightarrow", "arrow.r.twohead"],
|
|
1833
|
+
["upharpoonright", "harpoon.tr"],
|
|
1834
|
+
["uplus", "union.plus"],
|
|
1835
|
+
["upsilon", "upsilon"],
|
|
1836
|
+
["varepsilon", "epsilon"],
|
|
1837
|
+
["varnothing", "diameter"],
|
|
1838
|
+
// empty set
|
|
1839
|
+
["varphi", "phi"],
|
|
1840
|
+
["varpi", "pi.alt"],
|
|
1841
|
+
["varrho", "rho.alt"],
|
|
1842
|
+
["varsigma", "sigma.alt"],
|
|
1843
|
+
["vartheta", "theta.alt"],
|
|
1844
|
+
["vdash", "tack.r"],
|
|
1845
|
+
["vdots", "dots.v"],
|
|
1846
|
+
["vee", "or"],
|
|
1847
|
+
["wedge", "and"],
|
|
1848
|
+
["wr", "wreath"],
|
|
1849
|
+
["xi", "xi"],
|
|
1850
|
+
["yen", "yen"],
|
|
1851
|
+
["zeta", "zeta"],
|
|
1852
|
+
// extended
|
|
1853
|
+
["mathscr", "scr"],
|
|
1854
|
+
["LaTeX", "#LaTeX"],
|
|
1855
|
+
["TeX", "#TeX"]
|
|
1856
|
+
]);
|
|
1857
|
+
var map_from_official_docs = /* @__PURE__ */ new Map([
|
|
1858
|
+
["acwopencirclearrow", "arrow.ccw"],
|
|
1859
|
+
["adots", "dots.up"],
|
|
1860
|
+
["angdnr", "angle.acute"],
|
|
1861
|
+
["angle", "angle"],
|
|
1862
|
+
["angles", "angle.s"],
|
|
1863
|
+
["approx", "approx"],
|
|
1864
|
+
["approxeq", "approx.eq"],
|
|
1865
|
+
["approxident", "tilde.triple"],
|
|
1866
|
+
["assert", "tack.r.short"],
|
|
1867
|
+
["ast", "ast.op"],
|
|
1868
|
+
["asymp", "asymp"],
|
|
1869
|
+
["awint", "integral.ccw"],
|
|
1870
|
+
["backcong", "tilde.rev.equiv"],
|
|
1871
|
+
["backdprime", "prime.double.rev"],
|
|
1872
|
+
["backprime", "prime.rev"],
|
|
1873
|
+
["backsim", "tilde.rev"],
|
|
1874
|
+
["backsimeq", "tilde.eq.rev"],
|
|
1875
|
+
["backslash", "backslash"],
|
|
1876
|
+
["backtrprime", "prime.triple.rev"],
|
|
1877
|
+
["bardownharpoonleft", "harpoon.bl.bar"],
|
|
1878
|
+
["bardownharpoonright", "harpoon.br.bar"],
|
|
1879
|
+
["barleftarrow", "arrow.l.stop"],
|
|
1880
|
+
["barleftarrowrightarrowbar", "arrows.lr.stop"],
|
|
1881
|
+
["barleftharpoondown", "harpoon.lb.stop"],
|
|
1882
|
+
["barleftharpoonup", "harpoon.lt.stop"],
|
|
1883
|
+
["barrightharpoondown", "harpoon.rb.bar"],
|
|
1884
|
+
["barrightharpoonup", "harpoon.rt.bar"],
|
|
1885
|
+
["baruparrow", "arrow.t.stop"],
|
|
1886
|
+
["barupharpoonleft", "harpoon.tl.stop"],
|
|
1887
|
+
["barupharpoonright", "harpoon.tr.stop"],
|
|
1888
|
+
["barV", "tack.b.double"],
|
|
1889
|
+
["BbbA", "AA"],
|
|
1890
|
+
["BbbB", "BB"],
|
|
1891
|
+
["BbbC", "CC"],
|
|
1892
|
+
["BbbD", "DD"],
|
|
1893
|
+
["BbbE", "EE"],
|
|
1894
|
+
["BbbF", "FF"],
|
|
1895
|
+
["BbbG", "GG"],
|
|
1896
|
+
["BbbH", "HH"],
|
|
1897
|
+
["BbbI", "II"],
|
|
1898
|
+
["BbbJ", "JJ"],
|
|
1899
|
+
["BbbK", "KK"],
|
|
1900
|
+
["BbbL", "LL"],
|
|
1901
|
+
["BbbM", "MM"],
|
|
1902
|
+
["BbbN", "NN"],
|
|
1903
|
+
["BbbO", "OO"],
|
|
1904
|
+
["BbbP", "PP"],
|
|
1905
|
+
["BbbQ", "QQ"],
|
|
1906
|
+
["BbbR", "RR"],
|
|
1907
|
+
["BbbS", "SS"],
|
|
1908
|
+
["BbbT", "TT"],
|
|
1909
|
+
["BbbU", "UU"],
|
|
1910
|
+
["BbbV", "VV"],
|
|
1911
|
+
["BbbW", "WW"],
|
|
1912
|
+
["BbbX", "XX"],
|
|
1913
|
+
["BbbY", "YY"],
|
|
1914
|
+
["BbbZ", "ZZ"],
|
|
1915
|
+
["because", "because"],
|
|
1916
|
+
["bigblacktriangledown", "triangle.filled.b"],
|
|
1917
|
+
["bigblacktriangleup", "triangle.filled.t"],
|
|
1918
|
+
["bigbot", "tack.t.big"],
|
|
1919
|
+
["bigcap", "inter.big"],
|
|
1920
|
+
["bigcup", "union.big"],
|
|
1921
|
+
["bigcupdot", "union.dot.big"],
|
|
1922
|
+
["biginterleave", "interleave.big"],
|
|
1923
|
+
["bigodot", "dot.circle.big"],
|
|
1924
|
+
["bigoplus", "plus.circle.big"],
|
|
1925
|
+
// or 'xor.big'
|
|
1926
|
+
["bigotimes", "times.circle.big"],
|
|
1927
|
+
["bigsqcap", "inter.sq.big"],
|
|
1928
|
+
["bigsqcup", "union.sq.big"],
|
|
1929
|
+
["bigstar", "star.filled"],
|
|
1930
|
+
["bigtimes", "times.big"],
|
|
1931
|
+
["bigtop", "tack.b.big"],
|
|
1932
|
+
["bigtriangledown", "triangle.stroked.b"],
|
|
1933
|
+
// or 'triangle.b'
|
|
1934
|
+
["bigtriangleup", "triangle.stroked.t"],
|
|
1935
|
+
// or 'triangle.t'
|
|
1936
|
+
["biguplus", "union.plus.big"],
|
|
1937
|
+
["bigvee", "or.big"],
|
|
1938
|
+
["bigwedge", "and.big"],
|
|
1939
|
+
["bigwhitestar", "star.stroked"],
|
|
1940
|
+
["blackhourglass", "hourglass.filled"],
|
|
1941
|
+
["blacktriangle", "triangle.filled.small.t"],
|
|
1942
|
+
["blacktriangledown", "triangle.filled.small.b"],
|
|
1943
|
+
["blacktriangleleft", "triangle.filled.l"],
|
|
1944
|
+
["blacktriangleright", "triangle.filled.r"],
|
|
1945
|
+
["blkhorzoval", "ellipse.filled.h"],
|
|
1946
|
+
["blkvertoval", "ellipse.filled.v"],
|
|
1947
|
+
["bot", "bot"],
|
|
1948
|
+
["boxast", "ast.square"],
|
|
1949
|
+
["boxdot", "dot.square"],
|
|
1950
|
+
["boxminus", "minus.square"],
|
|
1951
|
+
["boxplus", "plus.square"],
|
|
1952
|
+
["boxtimes", "times.square"],
|
|
1953
|
+
["cap", "inter"],
|
|
1954
|
+
["Cap", "inter.double"],
|
|
1955
|
+
["capdot", "inter.dot"],
|
|
1956
|
+
["capwedge", "inter.and"],
|
|
1957
|
+
["caretinsert", "caret"],
|
|
1958
|
+
["cdot", "dot.op"],
|
|
1959
|
+
["cdotp", "dot.c"],
|
|
1960
|
+
["checkmark", "checkmark"],
|
|
1961
|
+
["circledast", "ast.circle"],
|
|
1962
|
+
["circledcirc", "circle.nested"],
|
|
1963
|
+
["circleddash", "dash.circle"],
|
|
1964
|
+
["circledequal", "eq.circle"],
|
|
1965
|
+
["circledparallel", "parallel.circle"],
|
|
1966
|
+
["circledvert", "bar.v.circle"],
|
|
1967
|
+
["clubsuit", "suit.club.filled"],
|
|
1968
|
+
["Colon", "colon.double"],
|
|
1969
|
+
["coloneq", "colon.eq"],
|
|
1970
|
+
["Coloneq", "colon.double.eq"],
|
|
1971
|
+
["complement", "complement"],
|
|
1972
|
+
["cong", "tilde.equiv"],
|
|
1973
|
+
["coprod", "product.co"],
|
|
1974
|
+
["cup", "union"],
|
|
1975
|
+
["Cup", "union.double"],
|
|
1976
|
+
["cupdot", "union.dot"],
|
|
1977
|
+
["cupleftarrow", "union.arrow"],
|
|
1978
|
+
["cupvee", "union.or"],
|
|
1979
|
+
["curlyeqprec", "eq.prec"],
|
|
1980
|
+
["curlyeqsucc", "eq.succ"],
|
|
1981
|
+
["curlyvee", "or.curly"],
|
|
1982
|
+
["curlywedge", "and.curly"],
|
|
1983
|
+
["curvearrowleft", "arrow.ccw.half"],
|
|
1984
|
+
["curvearrowright", "arrow.cw.half"],
|
|
1985
|
+
["cwopencirclearrow", "arrow.cw"],
|
|
1986
|
+
["dagger", "dagger"],
|
|
1987
|
+
["dashcolon", "dash.colon"],
|
|
1988
|
+
["dashv", "tack.l"],
|
|
1989
|
+
["Dashv", "tack.l.double"],
|
|
1990
|
+
["dashVdash", "tack.l.r"],
|
|
1991
|
+
["ddagger", "dagger.double"],
|
|
1992
|
+
["ddddot", "dot.quad"],
|
|
1993
|
+
["dddot", "dot.triple"],
|
|
1994
|
+
["ddots", "dots.down"],
|
|
1995
|
+
["DDownarrow", "arrow.b.quad"],
|
|
1996
|
+
["Ddownarrow", "arrow.b.triple"],
|
|
1997
|
+
["diameter", "diameter"],
|
|
1998
|
+
["diamondcdot", "diamond.stroked.dot"],
|
|
1999
|
+
["diamondsuit", "suit.diamond.stroked"],
|
|
2000
|
+
["dicei", "die.one"],
|
|
2001
|
+
["diceii", "die.two"],
|
|
2002
|
+
["diceiii", "die.three"],
|
|
2003
|
+
["diceiv", "die.four"],
|
|
2004
|
+
["dicev", "die.five"],
|
|
2005
|
+
["dicevi", "die.six"],
|
|
2006
|
+
["div", "div"],
|
|
2007
|
+
["divideontimes", "times.div"],
|
|
2008
|
+
["Doteq", "eq.dots"],
|
|
2009
|
+
["dotminus", "minus.dot"],
|
|
2010
|
+
["dotplus", "plus.dot"],
|
|
2011
|
+
["dotsim", "tilde.dot"],
|
|
2012
|
+
["dottedcircle", "circle.dotted"],
|
|
2013
|
+
["dottedsquare", "square.stroked.dotted"],
|
|
2014
|
+
["doubleplus", "plus.double"],
|
|
2015
|
+
["downarrow", "arrow.b"],
|
|
2016
|
+
["Downarrow", "arrow.b.double"],
|
|
2017
|
+
["downarrowbar", "arrow.b.stop"],
|
|
2018
|
+
["downdasharrow", "arrow.b.dashed"],
|
|
2019
|
+
["downdownarrows", "arrows.bb"],
|
|
2020
|
+
["downharpoonleft", "harpoon.bl"],
|
|
2021
|
+
["downharpoonleftbar", "harpoon.bl.stop"],
|
|
2022
|
+
["downharpoonright", "harpoon.br"],
|
|
2023
|
+
["downharpoonrightbar", "harpoon.br.stop"],
|
|
2024
|
+
["downharpoonsleftright", "harpoons.blbr"],
|
|
2025
|
+
["downrightcurvedarrow", "arrow.b.curve"],
|
|
2026
|
+
["downuparrows", "arrows.bt"],
|
|
2027
|
+
["downupharpoonsleftright", "harpoons.bltr"],
|
|
2028
|
+
["downwhitearrow", "arrow.b.stroked"],
|
|
2029
|
+
["downzigzagarrow", "arrow.zigzag"],
|
|
2030
|
+
["dprime", "prime.double"],
|
|
2031
|
+
["dualmap", "multimap.double"],
|
|
2032
|
+
["eighthnote", "note.eighth.alt"],
|
|
2033
|
+
["ell", "ell"],
|
|
2034
|
+
["emptysetoarr", "emptyset.arrow.r"],
|
|
2035
|
+
["emptysetoarrl", "emptyset.arrow.l"],
|
|
2036
|
+
["emptysetobar", "emptyset.bar"],
|
|
2037
|
+
["emptysetocirc", "emptyset.circle"],
|
|
2038
|
+
["eparsl", "parallel.slanted.eq"],
|
|
2039
|
+
["eqcolon", "eq.colon"],
|
|
2040
|
+
["eqdef", "eq.def"],
|
|
2041
|
+
// \usepackage{mathtools} defines \eqdef
|
|
2042
|
+
["eqgtr", "eq.gt"],
|
|
2043
|
+
["eqless", "eq.lt"],
|
|
2044
|
+
["eqsim", "minus.tilde"],
|
|
2045
|
+
["equal", "eq"],
|
|
2046
|
+
["equalparallel", "parallel.eq"],
|
|
2047
|
+
["equiv", "eq.triple"],
|
|
2048
|
+
["Equiv", "eq.quad"],
|
|
2049
|
+
["equivVert", "parallel.equiv"],
|
|
2050
|
+
["eqvparsl", "parallel.slanted.equiv"],
|
|
2051
|
+
["errbarblackcircle", "errorbar.circle.filled"],
|
|
2052
|
+
["errbarblackdiamond", "errorbar.diamond.filled"],
|
|
2053
|
+
["errbarblacksquare", "errorbar.square.filled"],
|
|
2054
|
+
["errbarcircle", "errorbar.circle.stroked"],
|
|
2055
|
+
["errbardiamond", "errorbar.diamond.stroked"],
|
|
2056
|
+
["errbarsquare", "errorbar.square.stroked"],
|
|
2057
|
+
["euro", "euro"],
|
|
2058
|
+
["Exclam", "excl.double"],
|
|
2059
|
+
["exists", "exists"],
|
|
2060
|
+
["fallingdotseq", "eq.dots.down"],
|
|
2061
|
+
["fint", "integral.slash"],
|
|
2062
|
+
["flat", "flat"],
|
|
2063
|
+
["forall", "forall"],
|
|
2064
|
+
["fourvdots", "fence.dotted"],
|
|
2065
|
+
["fullouterjoin", "join.l.r"],
|
|
2066
|
+
["geq", "gt.eq"],
|
|
2067
|
+
["geqq", "gt.equiv"],
|
|
2068
|
+
["geqslant", "gt.eq.slant"],
|
|
2069
|
+
["gg", "gt.double"],
|
|
2070
|
+
["ggg", "gt.triple"],
|
|
2071
|
+
["gggnest", "gt.triple.nested"],
|
|
2072
|
+
["gnapprox", "gt.napprox"],
|
|
2073
|
+
["gneq", "gt.neq"],
|
|
2074
|
+
["gneqq", "gt.nequiv"],
|
|
2075
|
+
["gnsim", "gt.ntilde"],
|
|
2076
|
+
["greater", "gt"],
|
|
2077
|
+
["gtlpar", "angle.spheric.rev"],
|
|
2078
|
+
["gtrapprox", "gt.approx"],
|
|
2079
|
+
["gtrdot", "gt.dot"],
|
|
2080
|
+
["gtreqless", "gt.eq.lt"],
|
|
2081
|
+
["gtrless", "gt.lt"],
|
|
2082
|
+
["gtrsim", "gt.tilde"],
|
|
2083
|
+
["heartsuit", "suit.heart.stroked"],
|
|
2084
|
+
["hknearrow", "arrow.tr.hook"],
|
|
2085
|
+
["hknwarrow", "arrow.tl.hook"],
|
|
2086
|
+
["hksearrow", "arrow.br.hook"],
|
|
2087
|
+
["hkswarrow", "arrow.bl.hook"],
|
|
2088
|
+
["hookleftarrow", "arrow.l.hook"],
|
|
2089
|
+
["hookrightarrow", "arrow.r.hook"],
|
|
2090
|
+
["horizbar", "bar.h"],
|
|
2091
|
+
["hourglass", "hourglass.stroked"],
|
|
2092
|
+
["hrectangle", "rect.stroked.h"],
|
|
2093
|
+
["hrectangleblack", "rect.filled.h"],
|
|
2094
|
+
["hslash", "planck.reduce"],
|
|
2095
|
+
["hzigzag", "dash.wave.double"],
|
|
2096
|
+
["iiiint", "integral.quad"],
|
|
2097
|
+
["iiint", "integral.triple"],
|
|
2098
|
+
["iinfin", "infinity.incomplete"],
|
|
2099
|
+
["iint", "integral.double"],
|
|
2100
|
+
["Im", "Im"],
|
|
2101
|
+
["imageof", "image"],
|
|
2102
|
+
["in", "in"],
|
|
2103
|
+
["increment", "laplace"],
|
|
2104
|
+
["infty", "infinity"],
|
|
2105
|
+
["int", "integral"],
|
|
2106
|
+
["intbar", "integral.dash"],
|
|
2107
|
+
["intBar", "integral.dash.double"],
|
|
2108
|
+
["intcap", "integral.inter"],
|
|
2109
|
+
["intclockwise", "integral.cw"],
|
|
2110
|
+
["intcup", "integral.union"],
|
|
2111
|
+
["interleave", "interleave"],
|
|
2112
|
+
["intlarhk", "integral.arrow.hook"],
|
|
2113
|
+
["intx", "integral.times"],
|
|
2114
|
+
["Join", "join"],
|
|
2115
|
+
["langle", "angle.l"],
|
|
2116
|
+
["lAngle", "angle.l.double"],
|
|
2117
|
+
["langledot", "angle.l.dot"],
|
|
2118
|
+
["lat", "lat"],
|
|
2119
|
+
["late", "lat.eq"],
|
|
2120
|
+
["lbrace", "brace.l"],
|
|
2121
|
+
["lBrace", "brace.l.double"],
|
|
2122
|
+
["lbrack", "bracket.l"],
|
|
2123
|
+
["lBrack", "bracket.l.double"],
|
|
2124
|
+
["lbrbrak", "shell.l"],
|
|
2125
|
+
["Lbrbrak", "shell.l.double"],
|
|
2126
|
+
["lceil", "ceil.l"],
|
|
2127
|
+
["lcurvyangle", "angle.l.curly"],
|
|
2128
|
+
["leftarrow", "arrow.l"],
|
|
2129
|
+
["Leftarrow", "arrow.l.double"],
|
|
2130
|
+
["leftarrowtail", "arrow.l.tail"],
|
|
2131
|
+
["leftdasharrow", "arrow.l.dashed"],
|
|
2132
|
+
["leftdotarrow", "arrow.l.dotted"],
|
|
2133
|
+
["leftdowncurvedarrow", "arrow.l.curve"],
|
|
2134
|
+
["leftharpoondown", "harpoon.lb"],
|
|
2135
|
+
["leftharpoondownbar", "harpoon.lb.bar"],
|
|
2136
|
+
["leftharpoonsupdown", "harpoons.ltlb"],
|
|
2137
|
+
["leftharpoonup", "harpoon.lt"],
|
|
2138
|
+
["leftharpoonupbar", "harpoon.lt.bar"],
|
|
2139
|
+
["leftleftarrows", "arrows.ll"],
|
|
2140
|
+
["leftouterjoin", "join.l"],
|
|
2141
|
+
["leftrightarrow", "arrow.l.r"],
|
|
2142
|
+
["Leftrightarrow", "arrow.l.r.double"],
|
|
2143
|
+
["leftrightarrows", "arrows.lr"],
|
|
2144
|
+
["leftrightharpoondowndown", "harpoon.lb.rb"],
|
|
2145
|
+
["leftrightharpoondownup", "harpoon.lb.rt"],
|
|
2146
|
+
["leftrightharpoons", "harpoons.ltrb"],
|
|
2147
|
+
["leftrightharpoonsdown", "harpoons.lbrb"],
|
|
2148
|
+
["leftrightharpoonsup", "harpoons.ltrt"],
|
|
2149
|
+
["leftrightharpoonupdown", "harpoon.lt.rb"],
|
|
2150
|
+
["leftrightharpoonupup", "harpoon.lt.rt"],
|
|
2151
|
+
["leftrightsquigarrow", "arrow.l.r.wave"],
|
|
2152
|
+
["leftsquigarrow", "arrow.l.squiggly"],
|
|
2153
|
+
["leftthreearrows", "arrows.lll"],
|
|
2154
|
+
["leftthreetimes", "times.three.l"],
|
|
2155
|
+
["leftwavearrow", "arrow.l.wave"],
|
|
2156
|
+
["leftwhitearrow", "arrow.l.stroked"],
|
|
2157
|
+
["leq", "lt.eq"],
|
|
2158
|
+
["leqq", "lt.equiv"],
|
|
2159
|
+
["leqslant", "lt.eq.slant"],
|
|
2160
|
+
["less", "lt"],
|
|
2161
|
+
["lessapprox", "lt.approx"],
|
|
2162
|
+
["lessdot", "lt.dot"],
|
|
2163
|
+
["lesseqgtr", "lt.eq.gt"],
|
|
2164
|
+
["lessgtr", "lt.gt"],
|
|
2165
|
+
["lesssim", "lt.tilde"],
|
|
2166
|
+
["lfloor", "floor.l"],
|
|
2167
|
+
["lgblkcircle", "circle.filled.big"],
|
|
2168
|
+
["lgblksquare", "square.filled.big"],
|
|
2169
|
+
["lgwhtcircle", "circle.stroked.big"],
|
|
2170
|
+
["lgwhtsquare", "square.stroked.big"],
|
|
2171
|
+
["ll", "lt.double"],
|
|
2172
|
+
["llblacktriangle", "triangle.filled.bl"],
|
|
2173
|
+
["LLeftarrow", "arrow.l.quad"],
|
|
2174
|
+
["Lleftarrow", "arrow.l.triple"],
|
|
2175
|
+
["lll", "lt.triple"],
|
|
2176
|
+
["lllnest", "lt.triple.nested"],
|
|
2177
|
+
["lltriangle", "triangle.stroked.bl"],
|
|
2178
|
+
["lnapprox", "lt.napprox"],
|
|
2179
|
+
["lneq", "lt.neq"],
|
|
2180
|
+
["lneqq", "lt.nequiv"],
|
|
2181
|
+
["lnsim", "lt.ntilde"],
|
|
2182
|
+
["longdashv", "tack.l.long"],
|
|
2183
|
+
["Longleftarrow", "arrow.l.double.long"],
|
|
2184
|
+
["longleftarrow", "arrow.l.long"],
|
|
2185
|
+
["Longleftrightarrow", "arrow.l.r.double.long"],
|
|
2186
|
+
["longleftrightarrow", "arrow.l.r.long"],
|
|
2187
|
+
["longleftsquigarrow", "arrow.l.long.squiggly"],
|
|
2188
|
+
["Longmapsfrom", "arrow.l.double.long.bar"],
|
|
2189
|
+
["longmapsfrom", "arrow.l.long.bar"],
|
|
2190
|
+
["longmapsto", "arrow.r.long.bar"],
|
|
2191
|
+
["Longmapsto", "arrow.r.double.long.bar"],
|
|
2192
|
+
["Longrightarrow", "arrow.r.double.long"],
|
|
2193
|
+
["longrightarrow", "arrow.r.long"],
|
|
2194
|
+
["longrightsquigarrow", "arrow.r.long.squiggly"],
|
|
2195
|
+
["looparrowleft", "arrow.l.loop"],
|
|
2196
|
+
["looparrowright", "arrow.r.loop"],
|
|
2197
|
+
["lparen", "paren.l"],
|
|
2198
|
+
["lParen", "paren.l.double"],
|
|
2199
|
+
["lrblacktriangle", "triangle.filled.br"],
|
|
2200
|
+
["lrtriangle", "triangle.stroked.br"],
|
|
2201
|
+
["ltimes", "times.l"],
|
|
2202
|
+
["lvzigzag", "fence.l"],
|
|
2203
|
+
["Lvzigzag", "fence.l.double"],
|
|
2204
|
+
["maltese", "maltese"],
|
|
2205
|
+
["mapsdown", "arrow.b.bar"],
|
|
2206
|
+
["mapsfrom", "arrow.l.bar"],
|
|
2207
|
+
["Mapsfrom", "arrow.l.double.bar"],
|
|
2208
|
+
["mapsto", "arrow.r.bar"],
|
|
2209
|
+
["Mapsto", "arrow.r.double.bar"],
|
|
2210
|
+
["mapsup", "arrow.t.bar"],
|
|
2211
|
+
["mathampersand", "amp"],
|
|
2212
|
+
["mathatsign", "at"],
|
|
2213
|
+
["mathcolon", "colon"],
|
|
2214
|
+
["mathcomma", "comma"],
|
|
2215
|
+
["mathdollar", "dollar"],
|
|
2216
|
+
["mathexclam", "excl"],
|
|
2217
|
+
// ['mathhyphen', 'hyph'], // \mathhyphen is not defined in standard amsmath package
|
|
2218
|
+
["mathoctothorpe", "hash"],
|
|
2219
|
+
["mathparagraph", "pilcrow"],
|
|
2220
|
+
["mathpercent", "percent"],
|
|
2221
|
+
["mathperiod", "dot.basic"],
|
|
2222
|
+
["mathplus", "plus"],
|
|
2223
|
+
["mathquestion", "quest"],
|
|
2224
|
+
["mathratio", "ratio"],
|
|
2225
|
+
["mathsection", "section"],
|
|
2226
|
+
["mathsemicolon", "semi"],
|
|
2227
|
+
["mathslash", "slash"],
|
|
2228
|
+
["mathsterling", "pound"],
|
|
2229
|
+
["mathyen", "yen"],
|
|
2230
|
+
["mdblkdiamond", "diamond.filled.medium"],
|
|
2231
|
+
["mdblklozenge", "lozenge.filled.medium"],
|
|
2232
|
+
["mdblksquare", "square.filled.medium"],
|
|
2233
|
+
["mdlgblkcircle", "circle.filled"],
|
|
2234
|
+
["mdlgblkdiamond", "diamond.filled"],
|
|
2235
|
+
["mdlgblklozenge", "lozenge.filled"],
|
|
2236
|
+
["mdlgblksquare", "square.filled"],
|
|
2237
|
+
["mdlgwhtcircle", "circle.stroked"],
|
|
2238
|
+
["mdlgwhtdiamond", "diamond.stroked"],
|
|
2239
|
+
["mdlgwhtlozenge", "lozenge.stroked"],
|
|
2240
|
+
["mdlgwhtsquare", "square.stroked"],
|
|
2241
|
+
["mdsmblkcircle", "circle.filled.tiny"],
|
|
2242
|
+
["mdsmblksquare", "square.filled.small"],
|
|
2243
|
+
["mdsmwhtcircle", "circle.stroked.small"],
|
|
2244
|
+
["mdsmwhtsquare", "square.stroked.small"],
|
|
2245
|
+
["mdwhtdiamond", "diamond.stroked.medium"],
|
|
2246
|
+
["mdwhtlozenge", "lozenge.stroked.medium"],
|
|
2247
|
+
["mdwhtsquare", "square.stroked.medium"],
|
|
2248
|
+
["measeq", "eq.m"],
|
|
2249
|
+
["measuredangle", "angle.arc"],
|
|
2250
|
+
["measuredangleleft", "angle.arc.rev"],
|
|
2251
|
+
["measuredrightangle", "angle.right.arc"],
|
|
2252
|
+
["mho", "Omega.inv"],
|
|
2253
|
+
["mid", "divides"],
|
|
2254
|
+
["minus", "minus"],
|
|
2255
|
+
["models", "models"],
|
|
2256
|
+
["mp", "minus.plus"],
|
|
2257
|
+
["multimap", "multimap"],
|
|
2258
|
+
/* ['mupAlpha', 'Alpha'],
|
|
2259
|
+
['mupalpha', 'alpha'],
|
|
2260
|
+
['mupBeta', 'Beta'],
|
|
2261
|
+
['mupbeta', 'beta'],
|
|
2262
|
+
['mupChi', 'Chi'],
|
|
2263
|
+
['mupchi', 'chi'],
|
|
2264
|
+
['mupDelta', 'Delta'],
|
|
2265
|
+
['mupdelta', 'delta'],
|
|
2266
|
+
['mupEpsilon', 'Epsilon'],
|
|
2267
|
+
['mupepsilon', 'epsilon.alt'],
|
|
2268
|
+
['mupEta', 'Eta'],
|
|
2269
|
+
['mupeta', 'eta'],
|
|
2270
|
+
['mupGamma', 'Gamma'],
|
|
2271
|
+
['mupgamma', 'gamma'],
|
|
2272
|
+
['mupIota', 'Iota'],
|
|
2273
|
+
['mupiota', 'iota'],
|
|
2274
|
+
['mupKappa', 'Kappa'],
|
|
2275
|
+
['mupkappa', 'kappa'],
|
|
2276
|
+
['mupLambda', 'Lambda'],
|
|
2277
|
+
['muplambda', 'lambda'],
|
|
2278
|
+
['mupMu', 'Mu'],
|
|
2279
|
+
['mupmu', 'mu'],
|
|
2280
|
+
['mupNu', 'Nu'],
|
|
2281
|
+
['mupnu', 'nu'],
|
|
2282
|
+
['mupOmega', 'Omega'],
|
|
2283
|
+
['mupomega', 'omega'],
|
|
2284
|
+
['mupOmicron', 'Omicron'],
|
|
2285
|
+
['mupomicron', 'omicron'],
|
|
2286
|
+
['mupPhi', 'Phi'],
|
|
2287
|
+
['mupphi', 'phi.alt'],
|
|
2288
|
+
['mupPi', 'Pi'],
|
|
2289
|
+
['muppi', 'pi'],
|
|
2290
|
+
['mupPsi', 'Psi'],
|
|
2291
|
+
['muppsi', 'psi'],
|
|
2292
|
+
['mupRho', 'Rho'],
|
|
2293
|
+
['muprho', 'rho'],
|
|
2294
|
+
['mupSigma', 'Sigma'],
|
|
2295
|
+
['mupsigma', 'sigma'],
|
|
2296
|
+
['mupTau', 'Tau'],
|
|
2297
|
+
['muptau', 'tau'],
|
|
2298
|
+
['mupTheta', 'Theta'],
|
|
2299
|
+
['muptheta', 'theta'],
|
|
2300
|
+
['mupUpsilon', 'Upsilon'],
|
|
2301
|
+
['mupupsilon', 'upsilon'],
|
|
2302
|
+
['mupvarepsilon', 'epsilon'],
|
|
2303
|
+
['mupvarkappa', 'kappa.alt'],
|
|
2304
|
+
['mupvarphi', 'phi'],
|
|
2305
|
+
['mupvarpi', 'pi.alt'],
|
|
2306
|
+
['mupvarrho', 'rho.alt'],
|
|
2307
|
+
['mupvarsigma', 'sigma.alt'],
|
|
2308
|
+
['mupvartheta', 'theta.alt'],
|
|
2309
|
+
['mupXi', 'Xi'],
|
|
2310
|
+
['mupxi', 'xi'],
|
|
2311
|
+
['mupZeta', 'Zeta'],
|
|
2312
|
+
['mupzeta', 'zeta'], */
|
|
2313
|
+
["nabla", "gradient"],
|
|
2314
|
+
["napprox", "approx.not"],
|
|
2315
|
+
["nasymp", "asymp.not"],
|
|
2316
|
+
["natural", "natural"],
|
|
2317
|
+
["ncong", "tilde.equiv.not"],
|
|
2318
|
+
["ne", "eq.not"],
|
|
2319
|
+
["nearrow", "arrow.tr"],
|
|
2320
|
+
["Nearrow", "arrow.tr.double"],
|
|
2321
|
+
["neg", "not"],
|
|
2322
|
+
["nequiv", "equiv.not"],
|
|
2323
|
+
// or eq.triple.not
|
|
2324
|
+
["neswarrow", "arrow.tr.bl"],
|
|
2325
|
+
["nexists", "exists.not"],
|
|
2326
|
+
["ngeq", "gt.eq.not"],
|
|
2327
|
+
["ngtr", "gt.not"],
|
|
2328
|
+
["ngtrless", "gt.lt.not"],
|
|
2329
|
+
["ngtrsim", "gt.tilde.not"],
|
|
2330
|
+
["nhpar", "parallel.struck"],
|
|
2331
|
+
["nhVvert", "interleave.struck"],
|
|
2332
|
+
["ni", "in.rev"],
|
|
2333
|
+
["nLeftarrow", "arrow.l.double.not"],
|
|
2334
|
+
["nleftarrow", "arrow.l.not"],
|
|
2335
|
+
["nLeftrightarrow", "arrow.l.r.double.not"],
|
|
2336
|
+
["nleftrightarrow", "arrow.l.r.not"],
|
|
2337
|
+
["nleq", "lt.eq.not"],
|
|
2338
|
+
["nless", "lt.not"],
|
|
2339
|
+
["nlessgtr", "lt.gt.not"],
|
|
2340
|
+
["nlesssim", "lt.tilde.not"],
|
|
2341
|
+
["nmid", "divides.not"],
|
|
2342
|
+
["nni", "in.rev.not"],
|
|
2343
|
+
["notin", "in.not"],
|
|
2344
|
+
["nparallel", "parallel.not"],
|
|
2345
|
+
["nprec", "prec.not"],
|
|
2346
|
+
["npreccurlyeq", "prec.curly.eq.not"],
|
|
2347
|
+
["nRightarrow", "arrow.r.double.not"],
|
|
2348
|
+
["nrightarrow", "arrow.r.not"],
|
|
2349
|
+
["nsim", "tilde.not"],
|
|
2350
|
+
["nsimeq", "tilde.eq.not"],
|
|
2351
|
+
["nsqsubseteq", "subset.eq.sq.not"],
|
|
2352
|
+
["nsqsupseteq", "supset.eq.sq.not"],
|
|
2353
|
+
["nsubset", "subset.not"],
|
|
2354
|
+
["nsubseteq", "subset.eq.not"],
|
|
2355
|
+
["nsucc", "succ.not"],
|
|
2356
|
+
["nsucccurlyeq", "succ.curly.eq.not"],
|
|
2357
|
+
["nsupset", "supset.not"],
|
|
2358
|
+
["nsupseteq", "supset.eq.not"],
|
|
2359
|
+
["ntrianglelefteq", "lt.tri.eq.not"],
|
|
2360
|
+
["ntrianglerighteq", "gt.tri.eq.not"],
|
|
2361
|
+
["nvartriangleleft", "lt.tri.not"],
|
|
2362
|
+
["nvartriangleright", "gt.tri.not"],
|
|
2363
|
+
["nVdash", "forces.not"],
|
|
2364
|
+
["nvdash", "tack.r.not"],
|
|
2365
|
+
["nvDash", "tack.r.double.not"],
|
|
2366
|
+
["nvinfty", "infinity.bar"],
|
|
2367
|
+
["nwarrow", "arrow.tl"],
|
|
2368
|
+
["Nwarrow", "arrow.tl.double"],
|
|
2369
|
+
["nwsearrow", "arrow.tl.br"],
|
|
2370
|
+
["obrbrak", "shell.t"],
|
|
2371
|
+
["obslash", "backslash.circle"],
|
|
2372
|
+
["odiv", "div.circle"],
|
|
2373
|
+
["odot", "dot.circle"],
|
|
2374
|
+
["ogreaterthan", "gt.circle"],
|
|
2375
|
+
["oiiint", "integral.vol"],
|
|
2376
|
+
["oiint", "integral.surf"],
|
|
2377
|
+
["oint", "integral.cont"],
|
|
2378
|
+
["ointctrclockwise", "integral.cont.ccw"],
|
|
2379
|
+
["olessthan", "lt.circle"],
|
|
2380
|
+
["ominus", "minus.circle"],
|
|
2381
|
+
["operp", "perp.circle"],
|
|
2382
|
+
["oplus", "plus.circle"],
|
|
2383
|
+
["origof", "original"],
|
|
2384
|
+
["otimes", "times.circle"],
|
|
2385
|
+
// ['overbrace', 'brace.t'],
|
|
2386
|
+
["overbracket", "bracket.t"],
|
|
2387
|
+
["overparen", "paren.t"],
|
|
2388
|
+
["parallel", "parallel"],
|
|
2389
|
+
["parallelogram", "parallelogram.stroked"],
|
|
2390
|
+
["parallelogramblack", "parallelogram.filled"],
|
|
2391
|
+
["parsim", "parallel.tilde"],
|
|
2392
|
+
["partial", "diff"],
|
|
2393
|
+
["pentagon", "penta.stroked"],
|
|
2394
|
+
["pentagonblack", "penta.filled"],
|
|
2395
|
+
["perp", "perp"],
|
|
2396
|
+
["Planckconst", "planck"],
|
|
2397
|
+
["pm", "plus.minus"],
|
|
2398
|
+
["prec", "prec"],
|
|
2399
|
+
["Prec", "prec.double"],
|
|
2400
|
+
["precapprox", "prec.approx"],
|
|
2401
|
+
["preccurlyeq", "prec.curly.eq"],
|
|
2402
|
+
["preceq", "prec.eq"],
|
|
2403
|
+
["preceqq", "prec.equiv"],
|
|
2404
|
+
["precnapprox", "prec.napprox"],
|
|
2405
|
+
["precneq", "prec.neq"],
|
|
2406
|
+
["precneqq", "prec.nequiv"],
|
|
2407
|
+
["precnsim", "prec.ntilde"],
|
|
2408
|
+
["precsim", "prec.tilde"],
|
|
2409
|
+
["prime", "prime"],
|
|
2410
|
+
["prod", "product"],
|
|
2411
|
+
["propto", "prop"],
|
|
2412
|
+
["QED", "qed"],
|
|
2413
|
+
["qprime", "prime.quad"],
|
|
2414
|
+
["quarternote", "note.quarter.alt"],
|
|
2415
|
+
["questeq", "eq.quest"],
|
|
2416
|
+
["Question", "quest.double"],
|
|
2417
|
+
["rangle", "angle.r"],
|
|
2418
|
+
["rAngle", "angle.r.double"],
|
|
2419
|
+
["rangledot", "angle.r.dot"],
|
|
2420
|
+
["rbrace", "brace.r"],
|
|
2421
|
+
["rBrace", "brace.r.double"],
|
|
2422
|
+
["rbrack", "bracket.r"],
|
|
2423
|
+
["rBrack", "bracket.r.double"],
|
|
2424
|
+
["rbrbrak", "shell.r"],
|
|
2425
|
+
["Rbrbrak", "shell.r.double"],
|
|
2426
|
+
["rceil", "ceil.r"],
|
|
2427
|
+
["rcurvyangle", "angle.r.curly"],
|
|
2428
|
+
["Re", "Re"],
|
|
2429
|
+
["revangle", "angle.rev"],
|
|
2430
|
+
["revemptyset", "emptyset.rev"],
|
|
2431
|
+
["revnmid", "divides.not.rev"],
|
|
2432
|
+
["rfloor", "floor.r"],
|
|
2433
|
+
["rightangle", "angle.right"],
|
|
2434
|
+
["rightanglemdot", "angle.right.dot"],
|
|
2435
|
+
["rightanglesqr", "angle.right.sq"],
|
|
2436
|
+
["rightarrow", "arrow.r"],
|
|
2437
|
+
["Rightarrow", "arrow.r.double"],
|
|
2438
|
+
["rightarrowbar", "arrow.r.stop"],
|
|
2439
|
+
["rightarrowonoplus", "plus.circle.arrow"],
|
|
2440
|
+
["rightarrowtail", "arrow.r.tail"],
|
|
2441
|
+
["rightdasharrow", "arrow.r.dashed"],
|
|
2442
|
+
["rightdotarrow", "arrow.r.dotted"],
|
|
2443
|
+
["rightdowncurvedarrow", "arrow.r.curve"],
|
|
2444
|
+
["rightharpoondown", "harpoon.rb"],
|
|
2445
|
+
["rightharpoondownbar", "harpoon.rb.stop"],
|
|
2446
|
+
["rightharpoonsupdown", "harpoons.rtrb"],
|
|
2447
|
+
["rightharpoonup", "harpoon.rt"],
|
|
2448
|
+
["rightharpoonupbar", "harpoon.rt.stop"],
|
|
2449
|
+
["rightleftarrows", "arrows.rl"],
|
|
2450
|
+
["rightleftharpoons", "harpoons.rtlb"],
|
|
2451
|
+
["rightleftharpoonsdown", "harpoons.rblb"],
|
|
2452
|
+
["rightleftharpoonsup", "harpoons.rtlt"],
|
|
2453
|
+
["rightouterjoin", "join.r"],
|
|
2454
|
+
["rightrightarrows", "arrows.rr"],
|
|
2455
|
+
["rightsquigarrow", "arrow.r.squiggly"],
|
|
2456
|
+
["rightthreearrows", "arrows.rrr"],
|
|
2457
|
+
["rightthreetimes", "times.three.r"],
|
|
2458
|
+
["rightwavearrow", "arrow.r.wave"],
|
|
2459
|
+
["rightwhitearrow", "arrow.r.stroked"],
|
|
2460
|
+
["risingdotseq", "eq.dots.up"],
|
|
2461
|
+
["rparen", "paren.r"],
|
|
2462
|
+
["rParen", "paren.r.double"],
|
|
2463
|
+
["RRightarrow", "arrow.r.quad"],
|
|
2464
|
+
["Rrightarrow", "arrow.r.triple"],
|
|
2465
|
+
["rsolbar", "backslash.not"],
|
|
2466
|
+
["rtimes", "times.r"],
|
|
2467
|
+
["rvzigzag", "fence.r"],
|
|
2468
|
+
["Rvzigzag", "fence.r.double"],
|
|
2469
|
+
["searrow", "arrow.br"],
|
|
2470
|
+
["Searrow", "arrow.br.double"],
|
|
2471
|
+
["setminus", "without"],
|
|
2472
|
+
["sharp", "sharp"],
|
|
2473
|
+
["shortdowntack", "tack.b.short"],
|
|
2474
|
+
["shortlefttack", "tack.l.short"],
|
|
2475
|
+
["shortuptack", "tack.t.short"],
|
|
2476
|
+
["sim", "tilde.op"],
|
|
2477
|
+
["sime", "tilde.eq"],
|
|
2478
|
+
["similarleftarrow", "arrow.l.tilde"],
|
|
2479
|
+
["similarrightarrow", "arrow.r.tilde"],
|
|
2480
|
+
["simneqq", "tilde.nequiv"],
|
|
2481
|
+
["smallblacktriangleleft", "triangle.filled.small.l"],
|
|
2482
|
+
["smallblacktriangleright", "triangle.filled.small.r"],
|
|
2483
|
+
["smallin", "in.small"],
|
|
2484
|
+
["smallni", "in.rev.small"],
|
|
2485
|
+
["smalltriangleleft", "triangle.stroked.small.l"],
|
|
2486
|
+
["smalltriangleright", "triangle.stroked.small.r"],
|
|
2487
|
+
["smashtimes", "smash"],
|
|
2488
|
+
["smblkcircle", "bullet"],
|
|
2489
|
+
["smblkdiamond", "diamond.filled.small"],
|
|
2490
|
+
["smblklozenge", "lozenge.filled.small"],
|
|
2491
|
+
["smblksquare", "square.filled.tiny"],
|
|
2492
|
+
["smeparsl", "parallel.slanted.eq.tilde"],
|
|
2493
|
+
["smt", "smt"],
|
|
2494
|
+
["smte", "smt.eq"],
|
|
2495
|
+
["smwhtdiamond", "diamond.stroked.small"],
|
|
2496
|
+
["smwhtlozenge", "lozenge.stroked.small"],
|
|
2497
|
+
["smwhtsquare", "square.stroked.tiny"],
|
|
2498
|
+
["spadesuit", "suit.spade.filled"],
|
|
2499
|
+
["sphericalangle", "angle.spheric"],
|
|
2500
|
+
["sphericalangleup", "angle.spheric.top"],
|
|
2501
|
+
["sqcap", "inter.sq"],
|
|
2502
|
+
["Sqcap", "inter.sq.double"],
|
|
2503
|
+
["sqcup", "union.sq"],
|
|
2504
|
+
["Sqcup", "union.sq.double"],
|
|
2505
|
+
["sqint", "integral.square"],
|
|
2506
|
+
["sqsubset", "subset.sq"],
|
|
2507
|
+
["sqsubseteq", "subset.eq.sq"],
|
|
2508
|
+
["sqsubsetneq", "subset.sq.neq"],
|
|
2509
|
+
["sqsupset", "supset.sq"],
|
|
2510
|
+
["sqsupseteq", "supset.eq.sq"],
|
|
2511
|
+
["sqsupsetneq", "supset.sq.neq"],
|
|
2512
|
+
["squoval", "square.stroked.rounded"],
|
|
2513
|
+
["sslash", "slash.double"],
|
|
2514
|
+
["star", "star.op"],
|
|
2515
|
+
["stareq", "eq.star"],
|
|
2516
|
+
["subset", "subset"],
|
|
2517
|
+
["Subset", "subset.double"],
|
|
2518
|
+
["subsetdot", "subset.dot"],
|
|
2519
|
+
["subseteq", "subset.eq"],
|
|
2520
|
+
["subsetneq", "subset.neq"],
|
|
2521
|
+
["succ", "succ"],
|
|
2522
|
+
["Succ", "succ.double"],
|
|
2523
|
+
["succapprox", "succ.approx"],
|
|
2524
|
+
["succcurlyeq", "succ.curly.eq"],
|
|
2525
|
+
["succeq", "succ.eq"],
|
|
2526
|
+
["succeqq", "succ.equiv"],
|
|
2527
|
+
["succnapprox", "succ.napprox"],
|
|
2528
|
+
["succneq", "succ.neq"],
|
|
2529
|
+
["succneqq", "succ.nequiv"],
|
|
2530
|
+
["succnsim", "succ.ntilde"],
|
|
2531
|
+
["succsim", "succ.tilde"],
|
|
2532
|
+
["sum", "sum"],
|
|
2533
|
+
["sumint", "sum.integral"],
|
|
2534
|
+
["supset", "supset"],
|
|
2535
|
+
["Supset", "supset.double"],
|
|
2536
|
+
["supsetdot", "supset.dot"],
|
|
2537
|
+
["supseteq", "supset.eq"],
|
|
2538
|
+
["supsetneq", "supset.neq"],
|
|
2539
|
+
["swarrow", "arrow.bl"],
|
|
2540
|
+
["Swarrow", "arrow.bl.double"],
|
|
2541
|
+
["therefore", "therefore"],
|
|
2542
|
+
["threedangle", "angle.spatial"],
|
|
2543
|
+
["threedotcolon", "colon.tri.op"],
|
|
2544
|
+
["tieinfty", "infinity.tie"],
|
|
2545
|
+
["times", "times"],
|
|
2546
|
+
["tminus", "miny"],
|
|
2547
|
+
["top", "tack.b"],
|
|
2548
|
+
["tplus", "tiny"],
|
|
2549
|
+
["trianglecdot", "triangle.stroked.dot"],
|
|
2550
|
+
["triangledown", "triangle.stroked.small.b"],
|
|
2551
|
+
["triangleleft", "triangle.stroked.l"],
|
|
2552
|
+
["trianglelefteq", "lt.tri.eq"],
|
|
2553
|
+
["triangleminus", "minus.triangle"],
|
|
2554
|
+
["triangleplus", "plus.triangle"],
|
|
2555
|
+
["triangleq", "eq.delta"],
|
|
2556
|
+
["triangleright", "triangle.stroked.r"],
|
|
2557
|
+
["trianglerighteq", "gt.tri.eq"],
|
|
2558
|
+
["triangletimes", "times.triangle"],
|
|
2559
|
+
["tripleplus", "plus.triple"],
|
|
2560
|
+
["trprime", "prime.triple"],
|
|
2561
|
+
["trslash", "slash.triple"],
|
|
2562
|
+
["twoheaddownarrow", "arrow.b.twohead"],
|
|
2563
|
+
["twoheadleftarrow", "arrow.l.twohead"],
|
|
2564
|
+
["twoheadmapsfrom", "arrow.l.twohead.bar"],
|
|
2565
|
+
["twoheadmapsto", "arrow.r.twohead.bar"],
|
|
2566
|
+
["twoheadrightarrow", "arrow.r.twohead"],
|
|
2567
|
+
["twoheaduparrow", "arrow.t.twohead"],
|
|
2568
|
+
["twonotes", "note.eighth.beamed"],
|
|
2569
|
+
["ubrbrak", "shell.b"],
|
|
2570
|
+
["ulblacktriangle", "triangle.filled.tl"],
|
|
2571
|
+
["ultriangle", "triangle.stroked.tl"],
|
|
2572
|
+
["uminus", "union.minus"],
|
|
2573
|
+
["underbrace", "brace.b"],
|
|
2574
|
+
["underbracket", "bracket.b"],
|
|
2575
|
+
["underparen", "paren.b"],
|
|
2576
|
+
["unicodecdots", "dots.h.c"],
|
|
2577
|
+
["unicodeellipsis", "dots.h"],
|
|
2578
|
+
["upand", "amp.inv"],
|
|
2579
|
+
["uparrow", "arrow.t"],
|
|
2580
|
+
["Uparrow", "arrow.t.double"],
|
|
2581
|
+
["updasharrow", "arrow.t.dashed"],
|
|
2582
|
+
["updownarrow", "arrow.t.b"],
|
|
2583
|
+
["Updownarrow", "arrow.t.b.double"],
|
|
2584
|
+
["updownarrows", "arrows.tb"],
|
|
2585
|
+
["updownharpoonleftleft", "harpoon.tl.bl"],
|
|
2586
|
+
["updownharpoonleftright", "harpoon.tl.br"],
|
|
2587
|
+
["updownharpoonrightleft", "harpoon.tr.bl"],
|
|
2588
|
+
["updownharpoonrightright", "harpoon.tr.br"],
|
|
2589
|
+
["updownharpoonsleftright", "harpoons.tlbr"],
|
|
2590
|
+
["upharpoonleft", "harpoon.tl"],
|
|
2591
|
+
["upharpoonleftbar", "harpoon.tl.bar"],
|
|
2592
|
+
["upharpoonright", "harpoon.tr"],
|
|
2593
|
+
["upharpoonrightbar", "harpoon.tr.bar"],
|
|
2594
|
+
["upharpoonsleftright", "harpoons.tltr"],
|
|
2595
|
+
["uplus", "union.plus"],
|
|
2596
|
+
["uprightcurvearrow", "arrow.t.curve"],
|
|
2597
|
+
["upuparrows", "arrows.tt"],
|
|
2598
|
+
["upwhitearrow", "arrow.t.stroked"],
|
|
2599
|
+
["urblacktriangle", "triangle.filled.tr"],
|
|
2600
|
+
["urtriangle", "triangle.stroked.tr"],
|
|
2601
|
+
["UUparrow", "arrow.t.quad"],
|
|
2602
|
+
["Uuparrow", "arrow.t.triple"],
|
|
2603
|
+
["varclubsuit", "suit.club.stroked"],
|
|
2604
|
+
["vardiamondsuit", "suit.diamond.filled"],
|
|
2605
|
+
["varheartsuit", "suit.heart.filled"],
|
|
2606
|
+
["varhexagon", "hexa.stroked"],
|
|
2607
|
+
["varhexagonblack", "hexa.filled"],
|
|
2608
|
+
["varnothing", "emptyset"],
|
|
2609
|
+
["varointclockwise", "integral.cont.cw"],
|
|
2610
|
+
["varspadesuit", "suit.spade.stroked"],
|
|
2611
|
+
["vartriangle", "triangle.stroked.small.t"],
|
|
2612
|
+
["vartriangleleft", "lt.tri"],
|
|
2613
|
+
["vartriangleright", "gt.tri"],
|
|
2614
|
+
["Vbar", "tack.t.double"],
|
|
2615
|
+
["Vdash", "forces"],
|
|
2616
|
+
["vdash", "tack.r"],
|
|
2617
|
+
["vDash", "tack.r.double"],
|
|
2618
|
+
["vdots", "dots.v"],
|
|
2619
|
+
["vee", "or"],
|
|
2620
|
+
["Vee", "or.double"],
|
|
2621
|
+
["veedot", "or.dot"],
|
|
2622
|
+
["veeeq", "eq.equi"],
|
|
2623
|
+
["vert", "bar.v"],
|
|
2624
|
+
["Vert", "bar.v.double"],
|
|
2625
|
+
["vlongdash", "tack.r.long"],
|
|
2626
|
+
["vrectangle", "rect.stroked.v"],
|
|
2627
|
+
["vrectangleblack", "rect.filled.v"],
|
|
2628
|
+
["Vvert", "bar.v.triple"],
|
|
2629
|
+
["vysmblkcircle", "circle.filled.small"],
|
|
2630
|
+
["vysmwhtcircle", "circle.stroked.tiny"],
|
|
2631
|
+
// or compose
|
|
2632
|
+
["wedge", "and"],
|
|
2633
|
+
["Wedge", "and.double"],
|
|
2634
|
+
["wedgedot", "and.dot"],
|
|
2635
|
+
["wedgeq", "eq.est"],
|
|
2636
|
+
["whiteinwhitetriangle", "triangle.stroked.nested"],
|
|
2637
|
+
["whthorzoval", "ellipse.stroked.h"],
|
|
2638
|
+
["whtvertoval", "ellipse.stroked.v"],
|
|
2639
|
+
["wideangledown", "angle.oblique"],
|
|
2640
|
+
["wr", "wreath"],
|
|
2641
|
+
["xsol", "slash.big"]
|
|
2642
|
+
]);
|
|
2643
|
+
var texAliasMap = /* @__PURE__ */ new Map([
|
|
2644
|
+
["gets", "leftarrow"],
|
|
2645
|
+
["iff", "Longleftrightarrow"],
|
|
2646
|
+
["implies", "Longrightarrow"]
|
|
2647
|
+
]);
|
|
2648
|
+
for (const [key, value] of map_from_official_docs) {
|
|
2649
|
+
if (!symbolMap.has(key)) {
|
|
2650
|
+
symbolMap.set(key, value);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
var reverseSymbolMap = /* @__PURE__ */ new Map();
|
|
2654
|
+
for (const [key, value] of Array.from(symbolMap.entries()).reverse()) {
|
|
2655
|
+
reverseSymbolMap.set(value, key);
|
|
2656
|
+
}
|
|
2657
|
+
reverseSymbolMap.set("oo", "infty");
|
|
2658
|
+
var typst_to_tex_map = /* @__PURE__ */ new Map([
|
|
2659
|
+
["top", "top"],
|
|
2660
|
+
["frac", "frac"],
|
|
2661
|
+
["tilde", "tilde"],
|
|
2662
|
+
["hat", "hat"],
|
|
2663
|
+
["upright", "mathrm"],
|
|
2664
|
+
["bold", "boldsymbol"],
|
|
2665
|
+
["infinity", "infty"]
|
|
2666
|
+
]);
|
|
2667
|
+
for (const [key, value] of typst_to_tex_map) {
|
|
2668
|
+
reverseSymbolMap.set(key, value);
|
|
2669
|
+
}
|
|
2670
|
+
for (const [key, value] of texAliasMap) {
|
|
2671
|
+
if (!symbolMap.has(key)) {
|
|
2672
|
+
symbolMap.set(key, symbolMap.get(value));
|
|
2599
2673
|
}
|
|
2600
|
-
}
|
|
2674
|
+
}
|
|
2601
2675
|
|
|
2602
2676
|
// src/convert.ts
|
|
2677
|
+
var ConverterError = class extends Error {
|
|
2678
|
+
constructor(message, node = null) {
|
|
2679
|
+
super(message);
|
|
2680
|
+
this.name = "ConverterError";
|
|
2681
|
+
this.node = node;
|
|
2682
|
+
}
|
|
2683
|
+
};
|
|
2684
|
+
var TYPST_NONE = TypstToken.NONE.toNode();
|
|
2603
2685
|
var TYPST_INTRINSIC_OP = [
|
|
2604
2686
|
"dim",
|
|
2605
2687
|
"id",
|
|
@@ -2610,13 +2692,13 @@ var TYPST_INTRINSIC_OP = [
|
|
|
2610
2692
|
"csch"
|
|
2611
2693
|
// 'sgn
|
|
2612
2694
|
];
|
|
2613
|
-
function
|
|
2695
|
+
function _tex_token_str_to_typst(token) {
|
|
2614
2696
|
if (/^[a-zA-Z0-9]$/.test(token)) {
|
|
2615
2697
|
return token;
|
|
2616
2698
|
} else if (token === "/") {
|
|
2617
2699
|
return "\\/";
|
|
2618
|
-
} else if (
|
|
2619
|
-
return
|
|
2700
|
+
} else if (["\\\\", "\\{", "\\}", "\\%"].includes(token)) {
|
|
2701
|
+
return token.substring(1);
|
|
2620
2702
|
} else if (["\\$", "\\#", "\\&", "\\_"].includes(token)) {
|
|
2621
2703
|
return token;
|
|
2622
2704
|
} else if (token.startsWith("\\")) {
|
|
@@ -2624,54 +2706,86 @@ function tex_token_to_typst(token) {
|
|
|
2624
2706
|
if (symbolMap.has(symbol)) {
|
|
2625
2707
|
return symbolMap.get(symbol);
|
|
2626
2708
|
} else {
|
|
2627
|
-
return
|
|
2709
|
+
return null;
|
|
2628
2710
|
}
|
|
2629
2711
|
}
|
|
2630
2712
|
return token;
|
|
2631
2713
|
}
|
|
2714
|
+
function tex_token_to_typst(token, options) {
|
|
2715
|
+
let token_type;
|
|
2716
|
+
switch (token.type) {
|
|
2717
|
+
case 0 /* EMPTY */:
|
|
2718
|
+
return TypstToken.NONE;
|
|
2719
|
+
case 2 /* COMMAND */:
|
|
2720
|
+
token_type = 1 /* SYMBOL */;
|
|
2721
|
+
break;
|
|
2722
|
+
case 1 /* ELEMENT */:
|
|
2723
|
+
token_type = 2 /* ELEMENT */;
|
|
2724
|
+
break;
|
|
2725
|
+
case 3 /* LITERAL */:
|
|
2726
|
+
token_type = 3 /* LITERAL */;
|
|
2727
|
+
break;
|
|
2728
|
+
case 4 /* COMMENT */:
|
|
2729
|
+
token_type = 5 /* COMMENT */;
|
|
2730
|
+
break;
|
|
2731
|
+
case 5 /* SPACE */:
|
|
2732
|
+
token_type = 6 /* SPACE */;
|
|
2733
|
+
break;
|
|
2734
|
+
case 6 /* NEWLINE */:
|
|
2735
|
+
token_type = 8 /* NEWLINE */;
|
|
2736
|
+
break;
|
|
2737
|
+
case 7 /* CONTROL */: {
|
|
2738
|
+
if (token.value === "\\\\") {
|
|
2739
|
+
return new TypstToken(7 /* CONTROL */, "\\");
|
|
2740
|
+
} else if (token.value === "\\!") {
|
|
2741
|
+
return new TypstToken(1 /* SYMBOL */, "#h(-math.thin.amount)");
|
|
2742
|
+
} else if (symbolMap.has(token.value.substring(1))) {
|
|
2743
|
+
const typst_symbol = symbolMap.get(token.value.substring(1));
|
|
2744
|
+
return new TypstToken(1 /* SYMBOL */, typst_symbol);
|
|
2745
|
+
} else {
|
|
2746
|
+
throw new Error(`Unknown control sequence: ${token.value}`);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
default:
|
|
2750
|
+
throw Error(`Unknown token type: ${token.type}`);
|
|
2751
|
+
}
|
|
2752
|
+
const typst_str = _tex_token_str_to_typst(token.value);
|
|
2753
|
+
if (typst_str === null) {
|
|
2754
|
+
if (options.nonStrict) {
|
|
2755
|
+
return new TypstToken(token_type, token.value.substring(1));
|
|
2756
|
+
} else {
|
|
2757
|
+
throw new ConverterError(`Unknown token: ${token.value}`, token);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
return new TypstToken(token_type, typst_str);
|
|
2761
|
+
}
|
|
2632
2762
|
function convert_overset(node, options) {
|
|
2633
2763
|
const [sup, base] = node.args;
|
|
2634
2764
|
if (options.optimize) {
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
return true;
|
|
2638
|
-
}
|
|
2639
|
-
if (n.type === "ordgroup" && n.args.length === 3) {
|
|
2640
|
-
const [a1, a2, a3] = n.args;
|
|
2641
|
-
const d = new TexNode("element", "d");
|
|
2642
|
-
const e = new TexNode("element", "e");
|
|
2643
|
-
const f = new TexNode("element", "f");
|
|
2644
|
-
if (a1.eq(d) && a2.eq(e) && a3.eq(f)) {
|
|
2645
|
-
return true;
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
return false;
|
|
2649
|
-
};
|
|
2650
|
-
const is_eq = (n) => n.eq(new TexNode("element", "="));
|
|
2651
|
-
if (is_def(sup) && is_eq(base)) {
|
|
2652
|
-
return new TypstNode("symbol", "eq.def");
|
|
2765
|
+
if (["\\overset{\\text{def}}{=}", "\\overset{d e f}{=}"].includes(node.toString())) {
|
|
2766
|
+
return new TypstToken(1 /* SYMBOL */, "eq.def").toNode();
|
|
2653
2767
|
}
|
|
2654
2768
|
}
|
|
2655
|
-
const limits_call = new
|
|
2656
|
-
"
|
|
2657
|
-
"limits",
|
|
2769
|
+
const limits_call = new TypstFuncCall(
|
|
2770
|
+
new TypstToken(1 /* SYMBOL */, "limits"),
|
|
2658
2771
|
[convert_tex_node_to_typst(base, options)]
|
|
2659
2772
|
);
|
|
2660
|
-
return new
|
|
2773
|
+
return new TypstSupsub({
|
|
2661
2774
|
base: limits_call,
|
|
2662
|
-
sup: convert_tex_node_to_typst(sup, options)
|
|
2775
|
+
sup: convert_tex_node_to_typst(sup, options),
|
|
2776
|
+
sub: null
|
|
2663
2777
|
});
|
|
2664
2778
|
}
|
|
2665
2779
|
function convert_underset(node, options) {
|
|
2666
2780
|
const [sub, base] = node.args;
|
|
2667
|
-
const limits_call = new
|
|
2668
|
-
"
|
|
2669
|
-
"limits",
|
|
2781
|
+
const limits_call = new TypstFuncCall(
|
|
2782
|
+
new TypstToken(1 /* SYMBOL */, "limits"),
|
|
2670
2783
|
[convert_tex_node_to_typst(base, options)]
|
|
2671
2784
|
);
|
|
2672
|
-
return new
|
|
2785
|
+
return new TypstSupsub({
|
|
2673
2786
|
base: limits_call,
|
|
2674
|
-
sub: convert_tex_node_to_typst(sub, options)
|
|
2787
|
+
sub: convert_tex_node_to_typst(sub, options),
|
|
2788
|
+
sup: null
|
|
2675
2789
|
});
|
|
2676
2790
|
}
|
|
2677
2791
|
function convert_tex_array_align_literal(alignLiteral) {
|
|
@@ -2694,430 +2808,450 @@ function convert_tex_array_align_literal(alignLiteral) {
|
|
|
2694
2808
|
} else {
|
|
2695
2809
|
augment_str = `#(vline: (${vlinePositions.join(", ")}))`;
|
|
2696
2810
|
}
|
|
2697
|
-
np["augment"] = new
|
|
2811
|
+
np["augment"] = new TypstToken(3 /* LITERAL */, augment_str).toNode();
|
|
2698
2812
|
}
|
|
2699
|
-
const alignments = chars.map((c) => alignMap[c]).filter((x) => x !== void 0).map((s) => new
|
|
2813
|
+
const alignments = chars.map((c) => alignMap[c]).filter((x) => x !== void 0).map((s) => new TypstToken(3 /* LITERAL */, s).toNode());
|
|
2700
2814
|
if (alignments.length > 0) {
|
|
2701
2815
|
const all_same = alignments.every((item) => item.eq(alignments[0]));
|
|
2702
|
-
np["align"] = all_same ? alignments[0] : new
|
|
2816
|
+
np["align"] = all_same ? alignments[0] : new TypstToken(3 /* LITERAL */, "#center").toNode();
|
|
2703
2817
|
}
|
|
2704
2818
|
return np;
|
|
2705
2819
|
}
|
|
2706
|
-
function convert_tex_node_to_typst(
|
|
2707
|
-
switch (
|
|
2708
|
-
case "
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
case "ordgroup":
|
|
2713
|
-
return new TypstNode(
|
|
2714
|
-
"group",
|
|
2715
|
-
"",
|
|
2716
|
-
node.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2717
|
-
);
|
|
2718
|
-
case "element":
|
|
2719
|
-
return new TypstNode("atom", tex_token_to_typst(node.content));
|
|
2720
|
-
case "symbol":
|
|
2721
|
-
return new TypstNode("symbol", tex_token_to_typst(node.content));
|
|
2820
|
+
function convert_tex_node_to_typst(abstractNode, options = {}) {
|
|
2821
|
+
switch (abstractNode.type) {
|
|
2822
|
+
case "terminal": {
|
|
2823
|
+
const node2 = abstractNode;
|
|
2824
|
+
return tex_token_to_typst(node2.head, options).toNode();
|
|
2825
|
+
}
|
|
2722
2826
|
case "text": {
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
options.nonAsciiWrapper,
|
|
2727
|
-
[new
|
|
2827
|
+
const node2 = abstractNode;
|
|
2828
|
+
if (/[^\x00-\x7F]+/.test(node2.head.value) && options.nonAsciiWrapper !== "") {
|
|
2829
|
+
return new TypstFuncCall(
|
|
2830
|
+
new TypstToken(1 /* SYMBOL */, options.nonAsciiWrapper),
|
|
2831
|
+
[new TypstToken(4 /* TEXT */, node2.head.value).toNode()]
|
|
2728
2832
|
);
|
|
2729
2833
|
}
|
|
2730
|
-
return new
|
|
2834
|
+
return new TypstToken(4 /* TEXT */, node2.head.value).toNode();
|
|
2731
2835
|
}
|
|
2732
|
-
case "
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2836
|
+
case "ordgroup":
|
|
2837
|
+
const node = abstractNode;
|
|
2838
|
+
return new TypstGroup(
|
|
2839
|
+
node.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2840
|
+
);
|
|
2736
2841
|
case "supsub": {
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
"overbrace",
|
|
2842
|
+
const node2 = abstractNode;
|
|
2843
|
+
let { base, sup, sub } = node2;
|
|
2844
|
+
if (base && base.type === "funcCall" && base.head.value === "\\overbrace" && sup) {
|
|
2845
|
+
return new TypstFuncCall(
|
|
2846
|
+
new TypstToken(1 /* SYMBOL */, "overbrace"),
|
|
2742
2847
|
[convert_tex_node_to_typst(base.args[0], options), convert_tex_node_to_typst(sup, options)]
|
|
2743
2848
|
);
|
|
2744
|
-
} else if (base && base.type === "
|
|
2745
|
-
return new
|
|
2746
|
-
"
|
|
2747
|
-
"underbrace",
|
|
2849
|
+
} else if (base && base.type === "funcCall" && base.head.value === "\\underbrace" && sub) {
|
|
2850
|
+
return new TypstFuncCall(
|
|
2851
|
+
new TypstToken(1 /* SYMBOL */, "underbrace"),
|
|
2748
2852
|
[convert_tex_node_to_typst(base.args[0], options), convert_tex_node_to_typst(sub, options)]
|
|
2749
2853
|
);
|
|
2750
2854
|
}
|
|
2751
2855
|
const data = {
|
|
2752
|
-
base: convert_tex_node_to_typst(base, options)
|
|
2856
|
+
base: convert_tex_node_to_typst(base, options),
|
|
2857
|
+
sup: sup ? convert_tex_node_to_typst(sup, options) : null,
|
|
2858
|
+
sub: sub ? convert_tex_node_to_typst(sub, options) : null
|
|
2753
2859
|
};
|
|
2754
|
-
|
|
2755
|
-
data.base = new TypstNode("none", "");
|
|
2756
|
-
}
|
|
2757
|
-
if (sup) {
|
|
2758
|
-
data.sup = convert_tex_node_to_typst(sup, options);
|
|
2759
|
-
}
|
|
2760
|
-
if (sub) {
|
|
2761
|
-
data.sub = convert_tex_node_to_typst(sub, options);
|
|
2762
|
-
}
|
|
2763
|
-
return new TypstNode("supsub", "", [], data);
|
|
2860
|
+
return new TypstSupsub(data);
|
|
2764
2861
|
}
|
|
2765
2862
|
case "leftright": {
|
|
2766
|
-
const
|
|
2767
|
-
const
|
|
2863
|
+
const node2 = abstractNode;
|
|
2864
|
+
const { left, right } = node2;
|
|
2865
|
+
const [_body] = node2.args;
|
|
2866
|
+
const typ_body = convert_tex_node_to_typst(_body, options);
|
|
2768
2867
|
if (options.optimize) {
|
|
2769
|
-
if (left
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
);
|
|
2868
|
+
if (left !== null && right !== null) {
|
|
2869
|
+
const typ_left2 = tex_token_to_typst(left, options);
|
|
2870
|
+
const typ_right2 = tex_token_to_typst(right, options);
|
|
2871
|
+
if (left.value === "\\|" && right.value === "\\|") {
|
|
2872
|
+
return new TypstFuncCall(new TypstToken(1 /* SYMBOL */, "norm"), [typ_body]);
|
|
2873
|
+
}
|
|
2874
|
+
if ([
|
|
2875
|
+
"[]",
|
|
2876
|
+
"()",
|
|
2877
|
+
"\\{\\}",
|
|
2878
|
+
"\\lfloor\\rfloor",
|
|
2879
|
+
"\\lceil\\rceil",
|
|
2880
|
+
"\\lfloor\\rceil"
|
|
2881
|
+
].includes(left.value + right.value)) {
|
|
2882
|
+
return new TypstGroup([typ_left2.toNode(), typ_body, typ_right2.toNode()]);
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2788
2886
|
const escape_curly_or_paren = function(s) {
|
|
2789
|
-
if (["(", ")", "{", "["].includes(s)) {
|
|
2790
|
-
return "\\" + s;
|
|
2887
|
+
if (["(", ")", "{", "["].includes(s.value)) {
|
|
2888
|
+
return new TypstToken(2 /* ELEMENT */, "\\" + s.value);
|
|
2791
2889
|
} else {
|
|
2792
2890
|
return s;
|
|
2793
2891
|
}
|
|
2794
2892
|
};
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
}
|
|
2808
|
-
if (node.content === "\\underset") {
|
|
2809
|
-
return convert_underset(node, options);
|
|
2810
|
-
}
|
|
2811
|
-
if (node.content === "\\frac") {
|
|
2812
|
-
if (options.fracToSlash) {
|
|
2813
|
-
return new TypstNode(
|
|
2814
|
-
"fraction",
|
|
2815
|
-
"",
|
|
2816
|
-
node.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2817
|
-
);
|
|
2818
|
-
}
|
|
2819
|
-
}
|
|
2820
|
-
return new TypstNode(
|
|
2821
|
-
"funcCall",
|
|
2822
|
-
tex_token_to_typst(node.content),
|
|
2823
|
-
node.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2893
|
+
let typ_left = left ? tex_token_to_typst(left, options) : null;
|
|
2894
|
+
let typ_right = right ? tex_token_to_typst(right, options) : null;
|
|
2895
|
+
if (typ_left === null && typ_right !== null) {
|
|
2896
|
+
typ_right = escape_curly_or_paren(typ_right);
|
|
2897
|
+
}
|
|
2898
|
+
if (typ_right === null && typ_left !== null) {
|
|
2899
|
+
typ_left = escape_curly_or_paren(typ_left);
|
|
2900
|
+
}
|
|
2901
|
+
return new TypstLeftright(
|
|
2902
|
+
new TypstToken(1 /* SYMBOL */, "lr"),
|
|
2903
|
+
[typ_body],
|
|
2904
|
+
{ left: typ_left, right: typ_right }
|
|
2824
2905
|
);
|
|
2825
2906
|
}
|
|
2826
|
-
case "
|
|
2827
|
-
const
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
"root",
|
|
2907
|
+
case "funcCall": {
|
|
2908
|
+
const node2 = abstractNode;
|
|
2909
|
+
const arg0 = convert_tex_node_to_typst(node2.args[0], options);
|
|
2910
|
+
if (node2.head.value === "\\sqrt" && node2.data) {
|
|
2911
|
+
const data = convert_tex_node_to_typst(node2.data, options);
|
|
2912
|
+
return new TypstFuncCall(
|
|
2913
|
+
new TypstToken(1 /* SYMBOL */, "root"),
|
|
2833
2914
|
[data, arg0]
|
|
2834
2915
|
);
|
|
2835
2916
|
}
|
|
2836
|
-
if (
|
|
2837
|
-
const inner = new
|
|
2838
|
-
"
|
|
2839
|
-
"bold",
|
|
2917
|
+
if (node2.head.value === "\\mathbf") {
|
|
2918
|
+
const inner = new TypstFuncCall(
|
|
2919
|
+
new TypstToken(1 /* SYMBOL */, "bold"),
|
|
2840
2920
|
[arg0]
|
|
2841
2921
|
);
|
|
2842
|
-
return new
|
|
2843
|
-
"
|
|
2844
|
-
"upright",
|
|
2922
|
+
return new TypstFuncCall(
|
|
2923
|
+
new TypstToken(1 /* SYMBOL */, "upright"),
|
|
2845
2924
|
[inner]
|
|
2846
2925
|
);
|
|
2847
2926
|
}
|
|
2848
|
-
if (
|
|
2849
|
-
return new
|
|
2850
|
-
"
|
|
2851
|
-
"arrow",
|
|
2927
|
+
if (node2.head.value === "\\overrightarrow") {
|
|
2928
|
+
return new TypstFuncCall(
|
|
2929
|
+
new TypstToken(1 /* SYMBOL */, "arrow"),
|
|
2852
2930
|
[arg0]
|
|
2853
2931
|
);
|
|
2854
2932
|
}
|
|
2855
|
-
if (
|
|
2856
|
-
return new
|
|
2857
|
-
"
|
|
2858
|
-
"
|
|
2859
|
-
[arg0, new TypstNode("symbol", "arrow.l")]
|
|
2933
|
+
if (node2.head.value === "\\overleftarrow") {
|
|
2934
|
+
return new TypstFuncCall(
|
|
2935
|
+
new TypstToken(1 /* SYMBOL */, "accent"),
|
|
2936
|
+
[arg0, new TypstToken(1 /* SYMBOL */, "arrow.l").toNode()]
|
|
2860
2937
|
);
|
|
2861
2938
|
}
|
|
2862
|
-
if (
|
|
2939
|
+
if (node2.head.value === "\\operatorname") {
|
|
2863
2940
|
if (options.optimize) {
|
|
2864
|
-
if (TYPST_INTRINSIC_OP.includes(arg0.
|
|
2865
|
-
return new
|
|
2941
|
+
if (TYPST_INTRINSIC_OP.includes(arg0.head.value)) {
|
|
2942
|
+
return new TypstToken(1 /* SYMBOL */, arg0.head.value).toNode();
|
|
2866
2943
|
}
|
|
2867
2944
|
}
|
|
2868
|
-
return new
|
|
2945
|
+
return new TypstFuncCall(new TypstToken(1 /* SYMBOL */, "op"), [new TypstToken(4 /* TEXT */, arg0.head.value).toNode()]);
|
|
2869
2946
|
}
|
|
2870
|
-
if (
|
|
2947
|
+
if (node2.head.value === "\\substack") {
|
|
2871
2948
|
return arg0;
|
|
2872
2949
|
}
|
|
2950
|
+
if (node2.head.value === "\\overset") {
|
|
2951
|
+
return convert_overset(node2, options);
|
|
2952
|
+
}
|
|
2953
|
+
if (node2.head.value === "\\underset") {
|
|
2954
|
+
return convert_underset(node2, options);
|
|
2955
|
+
}
|
|
2956
|
+
if (node2.head.value === "\\frac") {
|
|
2957
|
+
if (options.fracToSlash) {
|
|
2958
|
+
return new TypstFraction(node2.args.map((n) => convert_tex_node_to_typst(n, options)));
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2873
2961
|
if (options.optimize) {
|
|
2874
|
-
if (
|
|
2875
|
-
return new
|
|
2962
|
+
if (node2.head.value === "\\mathbb" && /^\\mathbb{[A-Z]}$/.test(node2.toString())) {
|
|
2963
|
+
return new TypstToken(1 /* SYMBOL */, arg0.head.value.repeat(2)).toNode();
|
|
2876
2964
|
}
|
|
2877
|
-
if (
|
|
2878
|
-
return new
|
|
2965
|
+
if (node2.head.value === "\\mathrm" && node2.toString() === "\\mathrm{d}") {
|
|
2966
|
+
return new TypstToken(1 /* SYMBOL */, "dif").toNode();
|
|
2879
2967
|
}
|
|
2880
2968
|
}
|
|
2881
|
-
return new
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
node.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2969
|
+
return new TypstFuncCall(
|
|
2970
|
+
tex_token_to_typst(node2.head, options),
|
|
2971
|
+
node2.args.map((n) => convert_tex_node_to_typst(n, options))
|
|
2885
2972
|
);
|
|
2886
2973
|
}
|
|
2887
2974
|
case "beginend": {
|
|
2888
|
-
const
|
|
2889
|
-
const data = matrix.map((row) => row.map((n) => convert_tex_node_to_typst(n, options)));
|
|
2890
|
-
if (
|
|
2891
|
-
return new
|
|
2975
|
+
const node2 = abstractNode;
|
|
2976
|
+
const data = node2.matrix.map((row) => row.map((n) => convert_tex_node_to_typst(n, options)));
|
|
2977
|
+
if (node2.head.value.startsWith("align")) {
|
|
2978
|
+
return new TypstAlign(data);
|
|
2892
2979
|
}
|
|
2893
|
-
if (
|
|
2894
|
-
return new
|
|
2980
|
+
if (node2.head.value === "cases") {
|
|
2981
|
+
return new TypstCases(data);
|
|
2895
2982
|
}
|
|
2896
|
-
if (
|
|
2897
|
-
const align_node =
|
|
2898
|
-
switch (align_node.
|
|
2983
|
+
if (node2.head.value === "subarray") {
|
|
2984
|
+
const align_node = node2.args[0];
|
|
2985
|
+
switch (align_node.head.value) {
|
|
2899
2986
|
case "r":
|
|
2900
|
-
data.forEach((row) => row[0].args.push(new
|
|
2987
|
+
data.forEach((row) => row[0].args.push(new TypstToken(7 /* CONTROL */, "&").toNode()));
|
|
2901
2988
|
break;
|
|
2902
2989
|
case "l":
|
|
2903
|
-
data.forEach((row) => row[0].args.unshift(new
|
|
2990
|
+
data.forEach((row) => row[0].args.unshift(new TypstToken(7 /* CONTROL */, "&").toNode()));
|
|
2904
2991
|
break;
|
|
2905
2992
|
default:
|
|
2906
2993
|
break;
|
|
2907
2994
|
}
|
|
2908
|
-
return new
|
|
2995
|
+
return new TypstAlign(data);
|
|
2909
2996
|
}
|
|
2910
|
-
if (
|
|
2997
|
+
if (node2.head.value === "array") {
|
|
2911
2998
|
const np = { "delim": TYPST_NONE };
|
|
2912
|
-
assert(
|
|
2913
|
-
const np_new = convert_tex_array_align_literal(
|
|
2999
|
+
assert(node2.args.length > 0 && node2.args[0].head.type === 3 /* LITERAL */);
|
|
3000
|
+
const np_new = convert_tex_array_align_literal(node2.args[0].head.value);
|
|
2914
3001
|
Object.assign(np, np_new);
|
|
2915
|
-
const res = new
|
|
3002
|
+
const res = new TypstMatrix(data);
|
|
2916
3003
|
res.setOptions(np);
|
|
2917
3004
|
return res;
|
|
2918
3005
|
}
|
|
2919
|
-
if (
|
|
2920
|
-
const res = new
|
|
3006
|
+
if (node2.head.value.endsWith("matrix")) {
|
|
3007
|
+
const res = new TypstMatrix(data);
|
|
2921
3008
|
let delim;
|
|
2922
|
-
switch (
|
|
3009
|
+
switch (node2.head.value) {
|
|
2923
3010
|
case "matrix":
|
|
2924
|
-
delim =
|
|
3011
|
+
delim = TypstToken.NONE;
|
|
2925
3012
|
break;
|
|
2926
3013
|
case "pmatrix":
|
|
2927
3014
|
return res;
|
|
2928
3015
|
// typst mat use delim:"(" by default
|
|
2929
3016
|
case "bmatrix":
|
|
2930
|
-
delim = new
|
|
3017
|
+
delim = new TypstToken(4 /* TEXT */, "[");
|
|
2931
3018
|
break;
|
|
2932
3019
|
case "Bmatrix":
|
|
2933
|
-
delim = new
|
|
3020
|
+
delim = new TypstToken(4 /* TEXT */, "{");
|
|
2934
3021
|
break;
|
|
2935
3022
|
case "vmatrix":
|
|
2936
|
-
delim = new
|
|
3023
|
+
delim = new TypstToken(4 /* TEXT */, "|");
|
|
2937
3024
|
break;
|
|
2938
3025
|
case "Vmatrix": {
|
|
2939
|
-
delim = new
|
|
3026
|
+
delim = new TypstToken(1 /* SYMBOL */, "bar.v.double");
|
|
2940
3027
|
break;
|
|
2941
3028
|
}
|
|
2942
3029
|
default:
|
|
2943
|
-
throw new
|
|
3030
|
+
throw new ConverterError(`Unimplemented beginend: ${node2.head}`, node2);
|
|
2944
3031
|
}
|
|
2945
|
-
res.setOptions({ "delim": delim });
|
|
3032
|
+
res.setOptions({ "delim": delim.toNode() });
|
|
2946
3033
|
return res;
|
|
2947
3034
|
}
|
|
2948
|
-
throw new
|
|
2949
|
-
}
|
|
2950
|
-
case "unknownMacro":
|
|
2951
|
-
return new TypstNode("unknown", tex_token_to_typst(node.content));
|
|
2952
|
-
case "control":
|
|
2953
|
-
if (node.content === "\\\\") {
|
|
2954
|
-
return new TypstNode("symbol", "\\");
|
|
2955
|
-
} else if (node.content === "\\!") {
|
|
2956
|
-
return new TypstNode("funcCall", "#h", [
|
|
2957
|
-
new TypstNode("literal", "-math.thin.amount")
|
|
2958
|
-
]);
|
|
2959
|
-
} else if (symbolMap.has(node.content.substring(1))) {
|
|
2960
|
-
const typst_symbol = symbolMap.get(node.content.substring(1));
|
|
2961
|
-
return new TypstNode("symbol", typst_symbol);
|
|
2962
|
-
} else {
|
|
2963
|
-
throw new TypstWriterError(`Unknown control sequence: ${node.content}`, node);
|
|
2964
|
-
}
|
|
3035
|
+
throw new ConverterError(`Unimplemented beginend: ${node2.head}`, node2);
|
|
3036
|
+
}
|
|
2965
3037
|
default:
|
|
2966
|
-
throw new
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
function apply_escape_if_needed2(c) {
|
|
2970
|
-
if (["{", "}", "%"].includes(c)) {
|
|
2971
|
-
return "\\" + c;
|
|
3038
|
+
throw new ConverterError(`Unimplemented node type: ${abstractNode.type}`, abstractNode);
|
|
2972
3039
|
}
|
|
2973
|
-
return c;
|
|
2974
3040
|
}
|
|
2975
3041
|
function typst_token_to_tex(token) {
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3042
|
+
switch (token.type) {
|
|
3043
|
+
case 0 /* NONE */:
|
|
3044
|
+
return TexToken.EMPTY;
|
|
3045
|
+
case 1 /* SYMBOL */: {
|
|
3046
|
+
const _typst_symbol_to_tex = function(symbol) {
|
|
3047
|
+
if (reverseSymbolMap.has(symbol)) {
|
|
3048
|
+
return "\\" + reverseSymbolMap.get(symbol);
|
|
3049
|
+
} else {
|
|
3050
|
+
return "\\" + symbol;
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
return new TexToken(2 /* COMMAND */, _typst_symbol_to_tex(token.value));
|
|
3054
|
+
}
|
|
3055
|
+
case 2 /* ELEMENT */: {
|
|
3056
|
+
let value;
|
|
3057
|
+
if (["{", "}", "%"].includes(token.value)) {
|
|
3058
|
+
value = "\\" + token.value;
|
|
3059
|
+
} else {
|
|
3060
|
+
value = token.value;
|
|
3061
|
+
}
|
|
3062
|
+
return new TexToken(1 /* ELEMENT */, value);
|
|
3063
|
+
}
|
|
3064
|
+
case 3 /* LITERAL */:
|
|
3065
|
+
return new TexToken(3 /* LITERAL */, token.value);
|
|
3066
|
+
case 4 /* TEXT */:
|
|
3067
|
+
return new TexToken(3 /* LITERAL */, token.value);
|
|
3068
|
+
case 5 /* COMMENT */:
|
|
3069
|
+
return new TexToken(4 /* COMMENT */, token.value);
|
|
3070
|
+
case 6 /* SPACE */:
|
|
3071
|
+
return new TexToken(5 /* SPACE */, token.value);
|
|
3072
|
+
case 7 /* CONTROL */: {
|
|
3073
|
+
let value;
|
|
3074
|
+
switch (token.value) {
|
|
3075
|
+
case "\\":
|
|
3076
|
+
value = "\\\\";
|
|
3077
|
+
break;
|
|
3078
|
+
case "&":
|
|
3079
|
+
value = "&";
|
|
3080
|
+
break;
|
|
3081
|
+
default:
|
|
3082
|
+
throw new Error(`[typst_token_to_tex]Unimplemented control sequence: ${token.value}`);
|
|
3083
|
+
}
|
|
3084
|
+
return new TexToken(7 /* CONTROL */, value);
|
|
3085
|
+
}
|
|
3086
|
+
case 8 /* NEWLINE */:
|
|
3087
|
+
return new TexToken(6 /* NEWLINE */, token.value);
|
|
3088
|
+
default:
|
|
3089
|
+
throw new Error(`Unimplemented token type: ${token.type}`);
|
|
2980
3090
|
}
|
|
2981
|
-
return "\\" + token;
|
|
2982
3091
|
}
|
|
2983
|
-
var TEX_NODE_COMMA = new
|
|
2984
|
-
function convert_typst_node_to_tex(
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
}
|
|
3013
|
-
return
|
|
3014
|
-
}
|
|
3015
|
-
case "literal":
|
|
3016
|
-
return new TexNode("literal", node.content);
|
|
3017
|
-
case "text":
|
|
3018
|
-
return new TexNode("text", node.content);
|
|
3019
|
-
case "comment":
|
|
3020
|
-
return new TexNode("comment", node.content);
|
|
3092
|
+
var TEX_NODE_COMMA = new TexToken(1 /* ELEMENT */, ",").toNode();
|
|
3093
|
+
function convert_typst_node_to_tex(abstractNode) {
|
|
3094
|
+
switch (abstractNode.type) {
|
|
3095
|
+
case "terminal": {
|
|
3096
|
+
const node = abstractNode;
|
|
3097
|
+
if (node.head.type === 1 /* SYMBOL */) {
|
|
3098
|
+
if (node.head.value === "eq.def") {
|
|
3099
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\overset"), [
|
|
3100
|
+
new TexText(new TexToken(3 /* LITERAL */, "def")),
|
|
3101
|
+
new TexToken(1 /* ELEMENT */, "=").toNode()
|
|
3102
|
+
]);
|
|
3103
|
+
}
|
|
3104
|
+
if (node.head.value === "comma") {
|
|
3105
|
+
return new TexToken(1 /* ELEMENT */, ",").toNode();
|
|
3106
|
+
}
|
|
3107
|
+
if (node.head.value === "dif") {
|
|
3108
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\mathrm"), [new TexToken(1 /* ELEMENT */, "d").toNode()]);
|
|
3109
|
+
}
|
|
3110
|
+
if (node.head.value === "hyph" || node.head.value === "hyph.minus") {
|
|
3111
|
+
return new TexText(new TexToken(3 /* LITERAL */, "-"));
|
|
3112
|
+
}
|
|
3113
|
+
if (/^([A-Z])\1$/.test(node.head.value)) {
|
|
3114
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\mathbb"), [
|
|
3115
|
+
new TexToken(1 /* ELEMENT */, node.head.value[0]).toNode()
|
|
3116
|
+
]);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
if (node.head.type === 4 /* TEXT */) {
|
|
3120
|
+
return new TexText(new TexToken(3 /* LITERAL */, node.head.value));
|
|
3121
|
+
}
|
|
3122
|
+
return typst_token_to_tex(node.head).toNode();
|
|
3123
|
+
}
|
|
3021
3124
|
case "group": {
|
|
3125
|
+
const node = abstractNode;
|
|
3126
|
+
const args = node.args.map(convert_typst_node_to_tex);
|
|
3127
|
+
const alignment_char = new TexToken(7 /* CONTROL */, "&").toNode();
|
|
3128
|
+
const newline_char = new TexToken(7 /* CONTROL */, "\\\\").toNode();
|
|
3129
|
+
if (array_includes(args, alignment_char)) {
|
|
3130
|
+
const rows = array_split(args, newline_char);
|
|
3131
|
+
const data = [];
|
|
3132
|
+
for (const row of rows) {
|
|
3133
|
+
const cells = array_split(row, alignment_char);
|
|
3134
|
+
data.push(cells.map((cell) => new TexGroup(cell)));
|
|
3135
|
+
}
|
|
3136
|
+
return new TexBeginEnd(new TexToken(3 /* LITERAL */, "aligned"), [], data);
|
|
3137
|
+
}
|
|
3138
|
+
return new TexGroup(args);
|
|
3139
|
+
}
|
|
3140
|
+
case "leftright": {
|
|
3141
|
+
const node = abstractNode;
|
|
3022
3142
|
const args = node.args.map(convert_typst_node_to_tex);
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
args.push(new TexNode("element", right_delim));
|
|
3143
|
+
let left = node.left ? typst_token_to_tex(node.left) : new TexToken(1 /* ELEMENT */, ".");
|
|
3144
|
+
let right = node.right ? typst_token_to_tex(node.right) : new TexToken(1 /* ELEMENT */, ".");
|
|
3145
|
+
if (node.isOverHigh()) {
|
|
3146
|
+
left.value = "\\left" + left.value;
|
|
3147
|
+
right.value = "\\right" + right.value;
|
|
3029
3148
|
}
|
|
3030
|
-
|
|
3149
|
+
args.unshift(left.toNode());
|
|
3150
|
+
args.push(right.toNode());
|
|
3151
|
+
return new TexGroup(args);
|
|
3031
3152
|
}
|
|
3032
3153
|
case "funcCall": {
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
new
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
new
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3154
|
+
const node = abstractNode;
|
|
3155
|
+
switch (node.head.value) {
|
|
3156
|
+
// special hook for norm
|
|
3157
|
+
// `\| a \|` <- `norm(a)`
|
|
3158
|
+
// `\left\| a + \frac{1}{3} \right\|` <- `norm(a + 1/3)`
|
|
3159
|
+
case "norm": {
|
|
3160
|
+
const arg0 = node.args[0];
|
|
3161
|
+
const args = [convert_typst_node_to_tex(arg0)];
|
|
3162
|
+
if (node.isOverHigh()) {
|
|
3163
|
+
return new TexLeftRight(args, {
|
|
3164
|
+
left: new TexToken(2 /* COMMAND */, "\\|"),
|
|
3165
|
+
right: new TexToken(2 /* COMMAND */, "\\|")
|
|
3166
|
+
});
|
|
3167
|
+
} else {
|
|
3168
|
+
return new TexGroup(args);
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
// special hook for floor, ceil
|
|
3172
|
+
// `\lfloor a \rfloor` <- `floor(a)`
|
|
3173
|
+
// `\lceil a \rceil` <- `ceil(a)`
|
|
3174
|
+
// `\left\lfloor a \right\rfloor` <- `floor(a)`
|
|
3175
|
+
// `\left\lceil a \right\rceil` <- `ceil(a)`
|
|
3176
|
+
case "floor":
|
|
3177
|
+
case "ceil": {
|
|
3178
|
+
const left = "\\l" + node.head.value;
|
|
3179
|
+
const right = "\\r" + node.head.value;
|
|
3180
|
+
const arg0 = node.args[0];
|
|
3181
|
+
const typ_arg0 = convert_typst_node_to_tex(arg0);
|
|
3182
|
+
const left_node = new TexToken(2 /* COMMAND */, left);
|
|
3183
|
+
const right_node = new TexToken(2 /* COMMAND */, right);
|
|
3184
|
+
if (node.isOverHigh()) {
|
|
3185
|
+
return new TexLeftRight([typ_arg0], {
|
|
3186
|
+
left: left_node,
|
|
3187
|
+
right: right_node
|
|
3188
|
+
});
|
|
3189
|
+
} else {
|
|
3190
|
+
return new TexGroup([left_node.toNode(), typ_arg0, right_node.toNode()]);
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
// special hook for root
|
|
3194
|
+
case "root": {
|
|
3195
|
+
const [degree, radicand] = node.args;
|
|
3196
|
+
const data = convert_typst_node_to_tex(degree);
|
|
3197
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\sqrt"), [convert_typst_node_to_tex(radicand)], data);
|
|
3198
|
+
}
|
|
3199
|
+
// special hook for overbrace and underbrace
|
|
3200
|
+
case "overbrace":
|
|
3201
|
+
case "underbrace": {
|
|
3202
|
+
const [body, label] = node.args;
|
|
3203
|
+
const base = new TexFuncCall(typst_token_to_tex(node.head), [convert_typst_node_to_tex(body)]);
|
|
3204
|
+
const script = convert_typst_node_to_tex(label);
|
|
3205
|
+
const data = node.head.value === "overbrace" ? { base, sup: script, sub: null } : { base, sub: script, sup: null };
|
|
3206
|
+
return new TexSupSub(data);
|
|
3207
|
+
}
|
|
3208
|
+
// special hook for vec
|
|
3209
|
+
// "vec(a, b, c)" -> "\begin{pmatrix}a\\ b\\ c\end{pmatrix}"
|
|
3210
|
+
case "vec": {
|
|
3211
|
+
const tex_data = node.args.map(convert_typst_node_to_tex).map((n) => [n]);
|
|
3212
|
+
return new TexBeginEnd(new TexToken(3 /* LITERAL */, "pmatrix"), [], tex_data);
|
|
3213
|
+
}
|
|
3214
|
+
// special hook for op
|
|
3215
|
+
case "op": {
|
|
3216
|
+
const arg0 = node.args[0];
|
|
3217
|
+
assert(arg0.head.type === 4 /* TEXT */);
|
|
3218
|
+
return new TexFuncCall(typst_token_to_tex(node.head), [new TexToken(3 /* LITERAL */, arg0.head.value).toNode()]);
|
|
3219
|
+
}
|
|
3220
|
+
// general case
|
|
3221
|
+
default: {
|
|
3222
|
+
const func_name_tex = typst_token_to_tex(node.head);
|
|
3223
|
+
const is_known_func = TEX_UNARY_COMMANDS.includes(func_name_tex.value.substring(1)) || TEX_BINARY_COMMANDS.includes(func_name_tex.value.substring(1));
|
|
3224
|
+
if (func_name_tex.value.length > 0 && is_known_func) {
|
|
3225
|
+
return new TexFuncCall(func_name_tex, node.args.map(convert_typst_node_to_tex));
|
|
3226
|
+
} else {
|
|
3227
|
+
return new TexGroup([
|
|
3228
|
+
typst_token_to_tex(node.head).toNode(),
|
|
3229
|
+
new TexToken(1 /* ELEMENT */, "(").toNode(),
|
|
3230
|
+
...array_intersperse(node.args.map(convert_typst_node_to_tex), TEX_NODE_COMMA),
|
|
3231
|
+
new TexToken(1 /* ELEMENT */, ")").toNode()
|
|
3232
|
+
]);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3096
3235
|
}
|
|
3097
3236
|
}
|
|
3098
3237
|
case "supsub": {
|
|
3099
|
-
const
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
}
|
|
3105
|
-
if (sub) {
|
|
3106
|
-
sub_tex = convert_typst_node_to_tex(sub);
|
|
3107
|
-
}
|
|
3108
|
-
if (base.eq(new TypstNode("funcCall", "limits"))) {
|
|
3238
|
+
const node = abstractNode;
|
|
3239
|
+
const { base, sup, sub } = node;
|
|
3240
|
+
const sup_tex = sup ? convert_typst_node_to_tex(sup) : null;
|
|
3241
|
+
const sub_tex = sub ? convert_typst_node_to_tex(sub) : null;
|
|
3242
|
+
if (base.head.eq(new TypstToken(1 /* SYMBOL */, "limits"))) {
|
|
3109
3243
|
const body_in_limits = convert_typst_node_to_tex(base.args[0]);
|
|
3110
|
-
if (sup_tex !==
|
|
3111
|
-
return new
|
|
3112
|
-
} else if (sup_tex ===
|
|
3113
|
-
return new
|
|
3244
|
+
if (sup_tex !== null && sub_tex === null) {
|
|
3245
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\overset"), [sup_tex, body_in_limits]);
|
|
3246
|
+
} else if (sup_tex === null && sub_tex !== null) {
|
|
3247
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\underset"), [sub_tex, body_in_limits]);
|
|
3114
3248
|
} else {
|
|
3115
|
-
const underset_call = new
|
|
3116
|
-
return new
|
|
3249
|
+
const underset_call = new TexFuncCall(new TexToken(2 /* COMMAND */, "\\underset"), [sub_tex, body_in_limits]);
|
|
3250
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\overset"), [sup_tex, underset_call]);
|
|
3117
3251
|
}
|
|
3118
3252
|
}
|
|
3119
3253
|
const base_tex = convert_typst_node_to_tex(base);
|
|
3120
|
-
const res = new
|
|
3254
|
+
const res = new TexSupSub({
|
|
3121
3255
|
base: base_tex,
|
|
3122
3256
|
sup: sup_tex,
|
|
3123
3257
|
sub: sub_tex
|
|
@@ -3125,13 +3259,13 @@ function convert_typst_node_to_tex(node) {
|
|
|
3125
3259
|
return res;
|
|
3126
3260
|
}
|
|
3127
3261
|
case "matrix": {
|
|
3128
|
-
const
|
|
3129
|
-
const tex_data =
|
|
3262
|
+
const node = abstractNode;
|
|
3263
|
+
const tex_data = node.matrix.map((row) => row.map(convert_typst_node_to_tex));
|
|
3130
3264
|
let env_type = "pmatrix";
|
|
3131
3265
|
if (node.options) {
|
|
3132
3266
|
if ("delim" in node.options) {
|
|
3133
3267
|
const delim = node.options.delim;
|
|
3134
|
-
switch (delim.
|
|
3268
|
+
switch (delim.head.value) {
|
|
3135
3269
|
case "#none":
|
|
3136
3270
|
env_type = "matrix";
|
|
3137
3271
|
break;
|
|
@@ -3158,35 +3292,26 @@ function convert_typst_node_to_tex(node) {
|
|
|
3158
3292
|
env_type = "Vmatrix";
|
|
3159
3293
|
break;
|
|
3160
3294
|
default:
|
|
3161
|
-
throw new Error(`Unexpected delimiter ${delim.
|
|
3295
|
+
throw new Error(`Unexpected delimiter ${delim.head}`);
|
|
3162
3296
|
}
|
|
3163
3297
|
}
|
|
3164
3298
|
}
|
|
3165
|
-
return new
|
|
3299
|
+
return new TexBeginEnd(new TexToken(3 /* LITERAL */, env_type), [], tex_data);
|
|
3166
3300
|
}
|
|
3167
3301
|
case "cases": {
|
|
3168
|
-
const
|
|
3169
|
-
const tex_data =
|
|
3170
|
-
return new
|
|
3171
|
-
}
|
|
3172
|
-
case "control": {
|
|
3173
|
-
switch (node.content) {
|
|
3174
|
-
case "\\":
|
|
3175
|
-
return new TexNode("control", "\\\\");
|
|
3176
|
-
case "&":
|
|
3177
|
-
return new TexNode("control", "&");
|
|
3178
|
-
default:
|
|
3179
|
-
throw new Error("[convert_typst_node_to_tex] Unimplemented control: " + node.content);
|
|
3180
|
-
}
|
|
3302
|
+
const node = abstractNode;
|
|
3303
|
+
const tex_data = node.matrix.map((row) => row.map(convert_typst_node_to_tex));
|
|
3304
|
+
return new TexBeginEnd(new TexToken(3 /* LITERAL */, "cases"), [], tex_data);
|
|
3181
3305
|
}
|
|
3182
3306
|
case "fraction": {
|
|
3307
|
+
const node = abstractNode;
|
|
3183
3308
|
const [numerator, denominator] = node.args;
|
|
3184
3309
|
const num_tex = convert_typst_node_to_tex(numerator);
|
|
3185
3310
|
const den_tex = convert_typst_node_to_tex(denominator);
|
|
3186
|
-
return new
|
|
3311
|
+
return new TexFuncCall(new TexToken(2 /* COMMAND */, "\\frac"), [num_tex, den_tex]);
|
|
3187
3312
|
}
|
|
3188
3313
|
default:
|
|
3189
|
-
throw new Error("[convert_typst_node_to_tex] Unimplemented type: " +
|
|
3314
|
+
throw new Error("[convert_typst_node_to_tex] Unimplemented type: " + abstractNode.type);
|
|
3190
3315
|
}
|
|
3191
3316
|
}
|
|
3192
3317
|
|
|
@@ -3279,7 +3404,7 @@ function _find_closing_match(tokens, start, leftBrackets, rightBrackets) {
|
|
|
3279
3404
|
let pos = start + 1;
|
|
3280
3405
|
while (count > 0) {
|
|
3281
3406
|
if (pos >= tokens.length) {
|
|
3282
|
-
throw new Error("Unmatched brackets");
|
|
3407
|
+
throw new Error("Unmatched brackets or parentheses");
|
|
3283
3408
|
}
|
|
3284
3409
|
if (tokens[pos].isOneOf(rightBrackets)) {
|
|
3285
3410
|
count -= 1;
|
|
@@ -3307,14 +3432,14 @@ function find_closing_delim(tokens, start) {
|
|
|
3307
3432
|
);
|
|
3308
3433
|
}
|
|
3309
3434
|
function find_closing_parenthesis(nodes, start) {
|
|
3310
|
-
const left_parenthesis = new
|
|
3311
|
-
const right_parenthesis = new
|
|
3435
|
+
const left_parenthesis = new TypstToken(2 /* ELEMENT */, "(").toNode();
|
|
3436
|
+
const right_parenthesis = new TypstToken(2 /* ELEMENT */, ")").toNode();
|
|
3312
3437
|
assert(nodes[start].eq(left_parenthesis));
|
|
3313
3438
|
let count = 1;
|
|
3314
3439
|
let pos = start + 1;
|
|
3315
3440
|
while (count > 0) {
|
|
3316
3441
|
if (pos >= nodes.length) {
|
|
3317
|
-
throw new Error("Unmatched
|
|
3442
|
+
throw new Error("Unmatched '('");
|
|
3318
3443
|
}
|
|
3319
3444
|
if (nodes[pos].eq(left_parenthesis)) {
|
|
3320
3445
|
count += 1;
|
|
@@ -3328,14 +3453,14 @@ function find_closing_parenthesis(nodes, start) {
|
|
|
3328
3453
|
function primes(num) {
|
|
3329
3454
|
const res = [];
|
|
3330
3455
|
for (let i = 0; i < num; i++) {
|
|
3331
|
-
res.push(new
|
|
3456
|
+
res.push(new TypstToken(2 /* ELEMENT */, "'").toNode());
|
|
3332
3457
|
}
|
|
3333
3458
|
return res;
|
|
3334
3459
|
}
|
|
3335
|
-
var DIV = new
|
|
3460
|
+
var DIV = new TypstToken(2 /* ELEMENT */, "/").toNode();
|
|
3336
3461
|
function next_non_whitespace(nodes, start) {
|
|
3337
3462
|
let pos = start;
|
|
3338
|
-
while (pos < nodes.length && nodes[pos].type ===
|
|
3463
|
+
while (pos < nodes.length && (nodes[pos].head.type === 6 /* SPACE */ || nodes[pos].head.type === 8 /* NEWLINE */)) {
|
|
3339
3464
|
pos++;
|
|
3340
3465
|
}
|
|
3341
3466
|
return pos === nodes.length ? null : nodes[pos];
|
|
@@ -3345,7 +3470,7 @@ function trim_whitespace_around_operators(nodes) {
|
|
|
3345
3470
|
const res = [];
|
|
3346
3471
|
for (let i = 0; i < nodes.length; i++) {
|
|
3347
3472
|
const current = nodes[i];
|
|
3348
|
-
if (current.type ===
|
|
3473
|
+
if (current.head.type === 6 /* SPACE */ || current.head.type === 8 /* NEWLINE */) {
|
|
3349
3474
|
if (after_operator) {
|
|
3350
3475
|
continue;
|
|
3351
3476
|
}
|
|
@@ -3364,8 +3489,8 @@ function trim_whitespace_around_operators(nodes) {
|
|
|
3364
3489
|
}
|
|
3365
3490
|
function process_operators(nodes, parenthesis = false) {
|
|
3366
3491
|
nodes = trim_whitespace_around_operators(nodes);
|
|
3367
|
-
const opening_bracket =
|
|
3368
|
-
const closing_bracket =
|
|
3492
|
+
const opening_bracket = LEFT_PARENTHESES.toNode();
|
|
3493
|
+
const closing_bracket = RIGHT_PARENTHESES.toNode();
|
|
3369
3494
|
const stack = [];
|
|
3370
3495
|
const args = [];
|
|
3371
3496
|
let pos = 0;
|
|
@@ -3387,18 +3512,18 @@ function process_operators(nodes, parenthesis = false) {
|
|
|
3387
3512
|
pos++;
|
|
3388
3513
|
}
|
|
3389
3514
|
if (stack.length > 0 && stack[stack.length - 1].eq(DIV)) {
|
|
3390
|
-
|
|
3515
|
+
let denominator = current_tree;
|
|
3391
3516
|
if (args.length === 0) {
|
|
3392
3517
|
throw new TypstParserError("Unexpected '/' operator, no numerator before it");
|
|
3393
3518
|
}
|
|
3394
|
-
|
|
3395
|
-
if (denominator.type === "
|
|
3396
|
-
denominator
|
|
3519
|
+
let numerator = args.pop();
|
|
3520
|
+
if (denominator.type === "leftright") {
|
|
3521
|
+
denominator = new TypstGroup(denominator.args);
|
|
3397
3522
|
}
|
|
3398
|
-
if (numerator.type === "
|
|
3399
|
-
numerator
|
|
3523
|
+
if (numerator.type === "leftright") {
|
|
3524
|
+
numerator = new TypstGroup(numerator.args);
|
|
3400
3525
|
}
|
|
3401
|
-
args.push(new
|
|
3526
|
+
args.push(new TypstFraction([numerator, denominator]));
|
|
3402
3527
|
stack.pop();
|
|
3403
3528
|
} else {
|
|
3404
3529
|
args.push(current_tree);
|
|
@@ -3406,12 +3531,12 @@ function process_operators(nodes, parenthesis = false) {
|
|
|
3406
3531
|
}
|
|
3407
3532
|
}
|
|
3408
3533
|
if (parenthesis) {
|
|
3409
|
-
return new
|
|
3534
|
+
return new TypstLeftright(null, args, { left: LEFT_PARENTHESES, right: RIGHT_PARENTHESES });
|
|
3410
3535
|
} else {
|
|
3411
3536
|
if (args.length === 1) {
|
|
3412
3537
|
return args[0];
|
|
3413
3538
|
} else {
|
|
3414
|
-
return new
|
|
3539
|
+
return new TypstGroup(args);
|
|
3415
3540
|
}
|
|
3416
3541
|
}
|
|
3417
3542
|
}
|
|
@@ -3433,6 +3558,7 @@ var VERTICAL_BAR = new TypstToken(2 /* ELEMENT */, "|");
|
|
|
3433
3558
|
var COMMA = new TypstToken(2 /* ELEMENT */, ",");
|
|
3434
3559
|
var SEMICOLON = new TypstToken(2 /* ELEMENT */, ";");
|
|
3435
3560
|
var SINGLE_SPACE = new TypstToken(6 /* SPACE */, " ");
|
|
3561
|
+
var CONTROL_AND = new TypstToken(7 /* CONTROL */, "&");
|
|
3436
3562
|
var TypstParser = class {
|
|
3437
3563
|
constructor(space_sensitive = true, newline_sensitive = true) {
|
|
3438
3564
|
this.space_sensitive = space_sensitive;
|
|
@@ -3448,11 +3574,11 @@ var TypstParser = class {
|
|
|
3448
3574
|
while (pos < end) {
|
|
3449
3575
|
const [res, newPos] = this.parseNextExpr(tokens, pos);
|
|
3450
3576
|
pos = newPos;
|
|
3451
|
-
if (res.type ===
|
|
3452
|
-
if (!this.space_sensitive && res.
|
|
3577
|
+
if (res.head.type === 6 /* SPACE */ || res.head.type === 8 /* NEWLINE */) {
|
|
3578
|
+
if (!this.space_sensitive && res.head.value.replace(/ /g, "").length === 0) {
|
|
3453
3579
|
continue;
|
|
3454
3580
|
}
|
|
3455
|
-
if (!this.newline_sensitive && res.
|
|
3581
|
+
if (!this.newline_sensitive && res.head.value === "\n") {
|
|
3456
3582
|
continue;
|
|
3457
3583
|
}
|
|
3458
3584
|
}
|
|
@@ -3476,7 +3602,7 @@ var TypstParser = class {
|
|
|
3476
3602
|
let sup = null;
|
|
3477
3603
|
const num_base_prime = eat_primes2(tokens, pos);
|
|
3478
3604
|
if (num_base_prime > 0) {
|
|
3479
|
-
base = new
|
|
3605
|
+
base = new TypstGroup([base].concat(primes(num_base_prime)));
|
|
3480
3606
|
pos += num_base_prime;
|
|
3481
3607
|
}
|
|
3482
3608
|
if (pos < tokens.length && tokens[pos].eq(SUB_SYMBOL2)) {
|
|
@@ -3491,14 +3617,8 @@ var TypstParser = class {
|
|
|
3491
3617
|
}
|
|
3492
3618
|
}
|
|
3493
3619
|
if (sub !== null || sup !== null) {
|
|
3494
|
-
const res = { base };
|
|
3495
|
-
|
|
3496
|
-
res.sub = sub;
|
|
3497
|
-
}
|
|
3498
|
-
if (sup) {
|
|
3499
|
-
res.sup = sup;
|
|
3500
|
-
}
|
|
3501
|
-
return [new TypstNode("supsub", "", [], res), pos];
|
|
3620
|
+
const res = { base, sup, sub };
|
|
3621
|
+
return [new TypstSupsub(res), pos];
|
|
3502
3622
|
} else {
|
|
3503
3623
|
return [base, pos];
|
|
3504
3624
|
}
|
|
@@ -3514,7 +3634,7 @@ var TypstParser = class {
|
|
|
3514
3634
|
}
|
|
3515
3635
|
const num_prime = eat_primes2(tokens, end);
|
|
3516
3636
|
if (num_prime > 0) {
|
|
3517
|
-
node = new
|
|
3637
|
+
node = new TypstGroup([node].concat(primes(num_prime)));
|
|
3518
3638
|
end += num_prime;
|
|
3519
3639
|
}
|
|
3520
3640
|
return [node, end];
|
|
@@ -3532,24 +3652,22 @@ var TypstParser = class {
|
|
|
3532
3652
|
if ([2 /* ELEMENT */, 1 /* SYMBOL */].includes(firstToken.type)) {
|
|
3533
3653
|
if (start + 1 < tokens.length && tokens[start + 1].eq(LEFT_PARENTHESES)) {
|
|
3534
3654
|
if (firstToken.value === "mat") {
|
|
3535
|
-
const [matrix, named_params, newPos2] = this.
|
|
3536
|
-
const mat = new
|
|
3655
|
+
const [matrix, named_params, newPos2] = this.parseMatrix(tokens, start + 1, SEMICOLON, COMMA);
|
|
3656
|
+
const mat = new TypstMatrix(matrix);
|
|
3537
3657
|
mat.setOptions(named_params);
|
|
3538
3658
|
return [mat, newPos2];
|
|
3539
3659
|
}
|
|
3540
3660
|
if (firstToken.value === "cases") {
|
|
3541
|
-
const [cases, named_params, newPos2] = this.
|
|
3542
|
-
const casesNode = new
|
|
3661
|
+
const [cases, named_params, newPos2] = this.parseMatrix(tokens, start + 1, COMMA, CONTROL_AND);
|
|
3662
|
+
const casesNode = new TypstCases(cases);
|
|
3543
3663
|
casesNode.setOptions(named_params);
|
|
3544
3664
|
return [casesNode, newPos2];
|
|
3545
3665
|
}
|
|
3546
3666
|
if (firstToken.value === "lr") {
|
|
3547
|
-
|
|
3548
|
-
const func_call2 = new TypstNode("funcCall", firstToken.value, args2, lrData);
|
|
3549
|
-
return [func_call2, newPos2];
|
|
3667
|
+
return this.parseLrArguments(tokens, start + 1);
|
|
3550
3668
|
}
|
|
3551
3669
|
const [args, newPos] = this.parseArguments(tokens, start + 1);
|
|
3552
|
-
const func_call = new
|
|
3670
|
+
const func_call = new TypstFuncCall(firstToken, args);
|
|
3553
3671
|
return [func_call, newPos];
|
|
3554
3672
|
}
|
|
3555
3673
|
}
|
|
@@ -3558,31 +3676,30 @@ var TypstParser = class {
|
|
|
3558
3676
|
// start: the position of the left parentheses
|
|
3559
3677
|
parseArguments(tokens, start) {
|
|
3560
3678
|
const end = find_closing_match2(tokens, start);
|
|
3561
|
-
return [this.
|
|
3679
|
+
return [this.parseArgumentsWithSeparator(tokens, start + 1, end, COMMA), end + 1];
|
|
3562
3680
|
}
|
|
3563
3681
|
// start: the position of the left parentheses
|
|
3564
3682
|
parseLrArguments(tokens, start) {
|
|
3683
|
+
const lr_token = tokens[start];
|
|
3565
3684
|
if (tokens[start + 1].isOneOf([LEFT_PARENTHESES, LEFT_BRACKET, LEFT_CURLY_BRACKET2, VERTICAL_BAR])) {
|
|
3566
3685
|
const end = find_closing_match2(tokens, start);
|
|
3567
3686
|
const inner_start = start + 1;
|
|
3568
3687
|
const inner_end = find_closing_delim(tokens, inner_start);
|
|
3569
|
-
const inner_args = this.
|
|
3688
|
+
const inner_args = this.parseArgumentsWithSeparator(tokens, inner_start + 1, inner_end, COMMA);
|
|
3570
3689
|
return [
|
|
3571
|
-
inner_args,
|
|
3572
|
-
end + 1
|
|
3573
|
-
{ leftDelim: tokens[inner_start].value, rightDelim: tokens[inner_end].value }
|
|
3690
|
+
new TypstLeftright(lr_token, inner_args, { left: tokens[inner_start], right: tokens[inner_end] }),
|
|
3691
|
+
end + 1
|
|
3574
3692
|
];
|
|
3575
3693
|
} else {
|
|
3576
3694
|
const [args, end] = this.parseArguments(tokens, start);
|
|
3577
3695
|
return [
|
|
3578
|
-
args,
|
|
3579
|
-
end
|
|
3580
|
-
{ leftDelim: null, rightDelim: null }
|
|
3696
|
+
new TypstLeftright(lr_token, args, { left: null, right: null }),
|
|
3697
|
+
end
|
|
3581
3698
|
];
|
|
3582
3699
|
}
|
|
3583
3700
|
}
|
|
3584
3701
|
// start: the position of the left parentheses
|
|
3585
|
-
|
|
3702
|
+
parseMatrix(tokens, start, rowSepToken, cellSepToken) {
|
|
3586
3703
|
const end = find_closing_match2(tokens, start);
|
|
3587
3704
|
tokens = tokens.slice(0, end);
|
|
3588
3705
|
const matrix = [];
|
|
@@ -3591,7 +3708,7 @@ var TypstParser = class {
|
|
|
3591
3708
|
while (pos < end) {
|
|
3592
3709
|
while (pos < end) {
|
|
3593
3710
|
let extract_named_params2 = function(arr) {
|
|
3594
|
-
const COLON = new
|
|
3711
|
+
const COLON = new TypstToken(2 /* ELEMENT */, ":").toNode();
|
|
3595
3712
|
const np2 = {};
|
|
3596
3713
|
const to_delete = [];
|
|
3597
3714
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -3605,7 +3722,7 @@ var TypstParser = class {
|
|
|
3605
3722
|
}
|
|
3606
3723
|
to_delete.push(i);
|
|
3607
3724
|
const param_name = g.args[pos_colon - 1];
|
|
3608
|
-
if (param_name.eq(new
|
|
3725
|
+
if (param_name.eq(new TypstToken(1 /* SYMBOL */, "delim").toNode())) {
|
|
3609
3726
|
if (g.args.length !== 3) {
|
|
3610
3727
|
throw new TypstParserError("Invalid number of arguments for delim");
|
|
3611
3728
|
}
|
|
@@ -3620,11 +3737,11 @@ var TypstParser = class {
|
|
|
3620
3737
|
return [arr, np2];
|
|
3621
3738
|
};
|
|
3622
3739
|
var extract_named_params = extract_named_params2;
|
|
3623
|
-
let next_stop = array_find(tokens,
|
|
3740
|
+
let next_stop = array_find(tokens, rowSepToken, pos);
|
|
3624
3741
|
if (next_stop === -1) {
|
|
3625
3742
|
next_stop = end;
|
|
3626
3743
|
}
|
|
3627
|
-
let row = this.
|
|
3744
|
+
let row = this.parseArgumentsWithSeparator(tokens, pos, next_stop, cellSepToken);
|
|
3628
3745
|
let np = {};
|
|
3629
3746
|
[row, np] = extract_named_params2(row);
|
|
3630
3747
|
matrix.push(row);
|
|
@@ -3635,13 +3752,13 @@ var TypstParser = class {
|
|
|
3635
3752
|
return [matrix, named_params, end + 1];
|
|
3636
3753
|
}
|
|
3637
3754
|
// start: the position of the first token of arguments
|
|
3638
|
-
|
|
3755
|
+
parseArgumentsWithSeparator(tokens, start, end, sepToken) {
|
|
3639
3756
|
const args = [];
|
|
3640
3757
|
let pos = start;
|
|
3641
3758
|
while (pos < end) {
|
|
3642
3759
|
let nodes = [];
|
|
3643
3760
|
while (pos < end) {
|
|
3644
|
-
if (tokens[pos].eq(
|
|
3761
|
+
if (tokens[pos].eq(sepToken)) {
|
|
3645
3762
|
pos += 1;
|
|
3646
3763
|
break;
|
|
3647
3764
|
} else if (tokens[pos].eq(SINGLE_SPACE)) {
|
|
@@ -3675,46 +3792,12 @@ var TexWriter = class {
|
|
|
3675
3792
|
this.buffer = "";
|
|
3676
3793
|
this.queue = [];
|
|
3677
3794
|
}
|
|
3678
|
-
writeBuffer(token) {
|
|
3679
|
-
const str = token.toString();
|
|
3680
|
-
let no_need_space = false;
|
|
3681
|
-
if (token.type === 4 /* SPACE */) {
|
|
3682
|
-
no_need_space = true;
|
|
3683
|
-
} else {
|
|
3684
|
-
no_need_space ||= /[{\(\[\|]$/.test(this.buffer);
|
|
3685
|
-
no_need_space ||= /\\\w+$/.test(this.buffer) && str === "[";
|
|
3686
|
-
no_need_space ||= /^[\.,;:!\?\(\)\]{}_^]$/.test(str);
|
|
3687
|
-
no_need_space ||= ["\\{", "\\}"].includes(str);
|
|
3688
|
-
no_need_space ||= str === "'";
|
|
3689
|
-
no_need_space ||= this.buffer.endsWith("_") || this.buffer.endsWith("^");
|
|
3690
|
-
no_need_space ||= /\s$/.test(this.buffer);
|
|
3691
|
-
no_need_space ||= /^\s/.test(str);
|
|
3692
|
-
no_need_space ||= this.buffer === "";
|
|
3693
|
-
no_need_space ||= /[\(\[{]\s*(-|\+)$/.test(this.buffer) || this.buffer === "-" || this.buffer === "+";
|
|
3694
|
-
no_need_space ||= this.buffer.endsWith("&") && str === "=";
|
|
3695
|
-
}
|
|
3696
|
-
if (!no_need_space) {
|
|
3697
|
-
this.buffer += " ";
|
|
3698
|
-
}
|
|
3699
|
-
this.buffer += str;
|
|
3700
|
-
}
|
|
3701
3795
|
append(node) {
|
|
3702
|
-
const alignment_char = new TexNode("control", "&");
|
|
3703
|
-
const newline_char = new TexNode("control", "\\\\");
|
|
3704
|
-
if (node.type === "ordgroup" && array_includes(node.args, alignment_char)) {
|
|
3705
|
-
const rows = array_split(node.args, newline_char);
|
|
3706
|
-
const data = [];
|
|
3707
|
-
for (const row of rows) {
|
|
3708
|
-
const cells = array_split(row, alignment_char);
|
|
3709
|
-
data.push(cells.map((cell) => new TexNode("ordgroup", "", cell)));
|
|
3710
|
-
}
|
|
3711
|
-
node = new TexNode("beginend", "aligned", [], data);
|
|
3712
|
-
}
|
|
3713
3796
|
this.queue = this.queue.concat(node.serialize());
|
|
3714
3797
|
}
|
|
3715
3798
|
flushQueue() {
|
|
3716
3799
|
for (let i = 0; i < this.queue.length; i++) {
|
|
3717
|
-
this.
|
|
3800
|
+
this.buffer = writeTexTokenBuffer(this.buffer, this.queue[i]);
|
|
3718
3801
|
}
|
|
3719
3802
|
this.queue = [];
|
|
3720
3803
|
}
|