tex2typst 0.3.27-beta.1 → 0.3.28

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.
@@ -0,0 +1,304 @@
1
+ # ref https://ctan.org/tex-archive/info/typstfun
2
+
3
+ [math_commands]
4
+ arccos = "arccos"
5
+ arcsin = "arcsin"
6
+ arctan = "arctan"
7
+ arg = "arg"
8
+ bar = "macron"
9
+ binom = "binom"
10
+ boldsymbol = "bold"
11
+ cos = "cos"
12
+ cosh = "cosh"
13
+ cot = "cot"
14
+ coth = "coth"
15
+ csc = "csc"
16
+ dbinom = "binom"
17
+ ddot = "dot.double" # 'dot.double' or 'diaer'
18
+ deg = "deg"
19
+ det = "det"
20
+ dfrac = "frac"
21
+ dim = "dim"
22
+ dot = "dot"
23
+ exp = "exp"
24
+ # frac = "frac"
25
+ gcd = "gcd"
26
+ hat = "hat"
27
+ # hspace = "h"
28
+ inf = "inf"
29
+ ker = "ker"
30
+ # left = "lr"
31
+ lg = "lg"
32
+ lim = "lim"
33
+ liminf = "liminf"
34
+ limsup = "limsup"
35
+ ln = "ln"
36
+ log = "log"
37
+ mathbb = "bb"
38
+ mathcal = "cal"
39
+ mathit = "italic"
40
+ mathsf = "sans"
41
+ mathrm = "upright"
42
+ mathtt = "mono"
43
+ max = "max"
44
+ min = "min"
45
+ mod = "mod"
46
+ overbrace = "overbrace"
47
+ overline = "overline"
48
+ qquad = "wide"
49
+ quad = "quad"
50
+ # right = "lr"
51
+ sec = "sec"
52
+ sin = "sin"
53
+ sinh = "sinh"
54
+ sqrt = "sqrt" # 'sqrt' or 'root'
55
+ sup = "sup"
56
+ tan = "tan"
57
+ tanh = "tanh"
58
+ tbinom = "binom"
59
+ tfrac = "frac"
60
+ tilde = "tilde"
61
+ underbrace = "underbrace"
62
+ vec = "arrow"
63
+ widehat = "hat"
64
+
65
+ [math_symbols]
66
+ gets = "arrow.l"
67
+ hookleftarrow = "arrow.l.hook"
68
+ leftharpoonup = "harpoon.lt"
69
+ leftharpoondown = "harpoon.lb"
70
+ rightleftharpoons = "harpoons.rtlb"
71
+ longleftarrow = "arrow.l.long"
72
+ hookrightarrow = "arrow.r.hook"
73
+ rightharpoonup = "harpoon.rt"
74
+ rightharpoondown = "harpoon.rb"
75
+ iff = "arrow.l.r.double.long"
76
+ Uparrow = "arrow.t.double"
77
+ Downarrow = "arrow.b.double"
78
+ Updownarrow = "arrow.t.b.double"
79
+ nearrow = "arrow.tr"
80
+ searrow = "arrow.br"
81
+
82
+
83
+ Cap = "inter.double"
84
+ Cup = "union.double"
85
+ Delta = "Delta"
86
+ Gamma = "Gamma"
87
+ Join = "join"
88
+ Lambda = "Lambda"
89
+ Leftarrow = "arrow.l.double"
90
+ Leftrightarrow = "arrow.l.r.double"
91
+ Longleftarrow = "arrow.l.double.long"
92
+ Longleftrightarrow = "arrow.l.r.double.long"
93
+ Longrightarrow = "arrow.r.double.long"
94
+ Omega = "Omega"
95
+ P = "pilcrow"
96
+ Phi = "Phi"
97
+ Pi = "Pi"
98
+ Psi = "Psi"
99
+ Rightarrow = "arrow.r.double"
100
+ S = "section"
101
+ Sigma = "Sigma"
102
+ Theta = "Theta"
103
+ aleph = "alef"
104
+ alpha = "alpha"
105
+ # amalg = "product.co"
106
+ angle = "angle"
107
+ approx = "approx"
108
+ approxeq = "approx.eq"
109
+ # ast = "ast"
110
+ beta = "beta"
111
+ bigcap = "inter.big"
112
+ bigcirc = "circle.big"
113
+ bigcup = "union.big"
114
+ bigodot = "dot.circle.big"
115
+ # bigoplus = "xor.big" # or "plus.circle.big"
116
+ bigotimes = "times.circle.big"
117
+ bigsqcup = "union.sq.big"
118
+ # bigtriangledown = "triangle.b"
119
+ # bigtriangleup = "triangle.t"
120
+ biguplus = "union.plus.big"
121
+ bigvee = "or.big"
122
+ bigwedge = "and.big"
123
+ # bowtie = "join"
124
+ bullet = "bullet"
125
+ cap = "inter"
126
+ cdot = "dot.op" # 'dot.op' or 'dot.c'
127
+ cdots = "dots.c"
128
+ checkmark = "checkmark"
129
+ chi = "chi"
130
+ circ = "circle.small" # 'circle.small' or 'compose'
131
+ # colon = "colon"
132
+ cong = "tilde.equiv"
133
+ coprod = "product.co"
134
+ copyright = "copyright"
135
+ cup = "union"
136
+ curlyvee = "or.curly"
137
+ curlywedge = "and.curly"
138
+ dagger = "dagger"
139
+ dashv = "tack.l"
140
+ ddagger = "dagger.double"
141
+ delta = "delta"
142
+ ddots = "dots.down"
143
+ diamond = "diamond"
144
+ div = "div"
145
+ divideontimes = "times.div"
146
+ dotplus = "plus.dot"
147
+ downarrow = "arrow.b"
148
+ ell = "ell"
149
+ emptyset = "nothing"
150
+ epsilon = "epsilon.alt"
151
+ equiv = "equiv"
152
+ eta = "eta"
153
+ exists = "exists"
154
+ forall = "forall"
155
+ # frown = "paren.t"
156
+ gamma = "gamma"
157
+ ge = "gt.eq"
158
+ geq = "gt.eq"
159
+ geqslant = "gt.eq.slant"
160
+ gg = "gt.double"
161
+ hbar = "planck.reduce"
162
+ imath = "dotless.i"
163
+ iiiint = "integral.quad"
164
+ iiint = "integral.triple"
165
+ iint = "integral.double"
166
+ in = "in"
167
+ infty = "infinity"
168
+ int = "integral"
169
+ intercal = "top" # 'top' or 'tack.b'
170
+ iota = "iota"
171
+ jmath = "dotless.j"
172
+ kappa = "kappa"
173
+ lambda = "lambda"
174
+ land = "and"
175
+ langle = "angle.l"
176
+ lbrace = "brace.l"
177
+ lbrack = "bracket.l"
178
+ ldots = "dots.h"
179
+ le = "lt.eq"
180
+ leadsto = "arrow.r.squiggly"
181
+ leftarrow = "arrow.l"
182
+ leftleftarrows = "arrows.ll"
183
+ leftthreetimes = "times.three.l"
184
+ leftrightarrow = "arrow.l.r"
185
+ leq = "lt.eq"
186
+ leqslant = "lt.eq.slant"
187
+ lhd = "triangle.l"
188
+ ll = "lt.double"
189
+ # longmapsto = "arrow.bar.long"
190
+ # longrightarrow = "arrow.long"
191
+ ltimes = "times.l"
192
+ # mapsto = "arrow.bar"
193
+ measuredangle = "angle.arc"
194
+ mid = "divides"
195
+ models = "models"
196
+ mp = "minus.plus"
197
+ mu = "mu"
198
+ # nRightarrow = "arrow.double.not"
199
+ nabla = "nabla"
200
+ # natural = # Typst does not have a symbol for this
201
+ ncong = "tilde.equiv.not"
202
+ ne = "eq.not"
203
+ neg = "not"
204
+ neq = "eq.not"
205
+ nexists = "exists.not"
206
+ ngeq = "gt.eq.not"
207
+ ni = "in.rev"
208
+ nleftarrow = "arrow.l.not"
209
+ nleq = "lt.eq.not"
210
+ nparallel = "parallel.not"
211
+ nmid = "divides.not"
212
+ notin = "in.not"
213
+ # nrightarrow = "arrow.not"
214
+ nsim = "tilde.not"
215
+ nsubseteq = "subset.eq.not"
216
+ nu = "nu"
217
+ ntriangleleft = "lt.tri.not"
218
+ ntriangleright = "gt.tri.not"
219
+ nwarrow = "arrow.tl"
220
+ odot = "dot.circle"
221
+ oint = "integral.cont"
222
+ omega = "omega"
223
+ # omicron = "omicron"
224
+ ominus = "minus.circle"
225
+ # oplus = "xor" # or "plus.circle"
226
+ # oslash = # Unfortunately Typst does not have a symbol for this
227
+ otimes = "times.circle"
228
+ parallel = "parallel"
229
+ partial = "diff"
230
+ perp = "perp"
231
+ phi = "phi.alt"
232
+ pi = "pi"
233
+ pm = "plus.minus"
234
+ pounds = "pound"
235
+ prec = "prec"
236
+ preceq = "prec.eq"
237
+ prime = "prime"
238
+ prod = "product"
239
+ propto = "prop"
240
+ psi = "psi"
241
+ rangle = "angle.r"
242
+ rbrace = "brace.r"
243
+ rbrack = "bracket.r"
244
+ # rceil = "ceil.r" # Unfortunately Typst does not have a symbol for this
245
+ # rfloor = "floor.r" # Unfortunately Typst does not have a symbol for this
246
+ rhd = "triangle"
247
+ rho = "rho"
248
+ rightarrow = "arrow.r"
249
+ rightthreetimes = "times.three.r"
250
+ rtimes = "times.r"
251
+ setminus = "without" # Not exactly. Ideally this should be something like "withoug.big"
252
+ sigma = "sigma"
253
+ # sim = "tilde"
254
+ simeq = "tilde.eq"
255
+ slash = "slash" # or "\\/" # This symbol is not supported by Typst but supported by LaTeX
256
+ smallsetminus = "without"
257
+ # smile = "paren.b" # Typst does not have a symbol for this. "paren.b" just look like it but has different size.
258
+ spadesuit = "suit.spade"
259
+ sqcap = "inter.sq"
260
+ sqcup = "union.sq"
261
+ sqsubseteq = "subset.eq.sq"
262
+ sqsupseteq = "supset.eq.sq"
263
+ # star = "star"
264
+ subset = "subset"
265
+ subseteq = "subset.eq"
266
+ subsetneq = "subset.neq"
267
+ succ = "succ"
268
+ succeq = "succ.eq"
269
+ sum = "sum"
270
+ supset = "supset"
271
+ supseteq = "supset.eq"
272
+ supsetneq = "supset.neq"
273
+ # surd = # not supported by Typst
274
+ swarrow = "arrow.bl"
275
+ tau = "tau"
276
+ theta = "theta"
277
+ times = "times"
278
+ to = "arrow.r"
279
+ top = "top"
280
+ # triangle = "triangle.t"
281
+ # triangledown = "triangle.b.small"
282
+ # triangleleft = "triangle.l.small"
283
+ # triangleright = "triangle.r.small"
284
+ twoheadrightarrow = "arrow.r.twohead"
285
+ uparrow = "arrow.t"
286
+ updownarrow = "arrow.t.b"
287
+ upharpoonright = "harpoon.tr"
288
+ uplus = "union.plus"
289
+ upsilon = "upsilon"
290
+ varepsilon = "epsilon"
291
+ varphi = "phi"
292
+ varpi = "pi.alt"
293
+ varrho = "rho.alt"
294
+ varsigma = "sigma.alt"
295
+ vartheta = "theta.alt"
296
+ vdash = "tack.r"
297
+ vdots = "dots.v"
298
+ vee = "or"
299
+ wedge = "and"
300
+ # wp = # not supported by Typst
301
+ wr = "wreath"
302
+ xi = "xi"
303
+ yen = "yen"
304
+ zeta = "zeta"
@@ -0,0 +1,15 @@
1
+ import { tex2typst, typst2tex } from "../src/index";
2
+
3
+ function example_tex2typst(text: string) {
4
+ const res = tex2typst(text);
5
+ console.log(res);
6
+ }
7
+
8
+ function example_typst2tex(text: string) {
9
+ const res = typst2tex(text);
10
+ console.log(res);
11
+ }
12
+
13
+ example_tex2typst("a + \\frac{1}{2}");
14
+
15
+ example_typst2tex("a + 1/2");
@@ -0,0 +1,22 @@
1
+ import path from 'path';
2
+ import toml from 'toml';
3
+ import fs from 'node:fs';
4
+ import { describe, it, test, expect } from 'vitest';
5
+ import { symbolMap } from '../src';
6
+
7
+
8
+ describe('general symbols', () => {
9
+ const cheatSheetFile = path.join(__dirname, 'general-symbols.toml');
10
+ const text_content = fs.readFileSync(cheatSheetFile, { encoding: 'utf-8' });
11
+ const data = toml.parse(text_content);
12
+
13
+ expect(data.symbols_in_official_doc).toBeDefined();
14
+
15
+ test('symbols_in_official_doc', () => {
16
+ expect(data.symbols_in_official_doc).toBeDefined();
17
+
18
+ for (const [key, value] of Object.entries(data.symbols_in_official_doc)) {
19
+ expect(symbolMap.get(key)).toBe(value);
20
+ }
21
+ });
22
+ });