tex2typst 0.2.2 → 0.2.3
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/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/map.ts +43 -17
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseTex } from "./parser";
|
|
2
2
|
import { Tex2TypstOptions } from "./types";
|
|
3
3
|
import { TypstWriter } from "./writer";
|
|
4
|
+
import { symbolMap } from "./map";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export function tex2typst(tex: string, options?: Tex2TypstOptions): string {
|
|
@@ -26,4 +27,4 @@ export function tex2typst(tex: string, options?: Tex2TypstOptions): string {
|
|
|
26
27
|
return writer.finalize();
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export { Tex2TypstOptions };
|
|
30
|
+
export { symbolMap, Tex2TypstOptions };
|
package/src/map.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export const symbolMap = new Map<string, string>([
|
|
2
|
-
['gets', 'arrow.l'],
|
|
3
2
|
['nonumber', ''],
|
|
4
3
|
['vec', 'arrow'],
|
|
5
4
|
['neq', 'eq.not'],
|
|
@@ -25,14 +24,15 @@ export const symbolMap = new Map<string, string>([
|
|
|
25
24
|
['tfrac', 'frac'],
|
|
26
25
|
|
|
27
26
|
['boldsymbol', 'bold'],
|
|
28
|
-
['mathbf', 'bold'],
|
|
29
27
|
['mathbb', 'bb'],
|
|
28
|
+
['mathbf', 'bold'],
|
|
30
29
|
['mathcal', 'cal'],
|
|
30
|
+
['mathit', 'italic'],
|
|
31
31
|
['mathfrak', 'frak'],
|
|
32
|
+
['mathrm', 'upright'],
|
|
32
33
|
['mathsf', 'sans'],
|
|
33
34
|
['mathtt', 'mono'],
|
|
34
35
|
|
|
35
|
-
['mathrm', 'upright'],
|
|
36
36
|
['rm', 'upright'],
|
|
37
37
|
|
|
38
38
|
// TODO: \pmb need special logic to handle but it is not implemented now. See the commented test case.
|
|
@@ -58,18 +58,6 @@ export const symbolMap = new Map<string, string>([
|
|
|
58
58
|
['equiv', 'equiv'],
|
|
59
59
|
['propto', 'prop'],
|
|
60
60
|
|
|
61
|
-
/* arrows used in proofs */
|
|
62
|
-
// tex: \implies \iff \leftrightarrow \longleftrightarrow \rightrightarrows
|
|
63
|
-
// typst: arrow.r.double.long arrow.l.r.double.long arrow.l.r arrow.l.r.long arrows.rr
|
|
64
|
-
['implies', 'arrow.r.double.long'],
|
|
65
|
-
['Longrightarrow', 'arrow.r.double.long'], // Note: This macro is not supported by KaTeX
|
|
66
|
-
['iff', 'arrow.l.r.double.long'],
|
|
67
|
-
['Longleftrightarrow', 'arrow.l.r.double.long'], // Note: This macro is not supported by KaTeX
|
|
68
|
-
['leftrightarrow', 'arrow.l.r'],
|
|
69
|
-
['longleftrightarrow', 'arrow.l.r.long'],
|
|
70
|
-
['rightrightarrows', 'arrows.rr'],
|
|
71
|
-
|
|
72
|
-
|
|
73
61
|
/* left and right floor,ceil */
|
|
74
62
|
// tex: \lfloor \rfloor \lceil \rceil
|
|
75
63
|
// typst: ⌊ ⌋ ⌈ ⌉
|
|
@@ -80,6 +68,39 @@ export const symbolMap = new Map<string, string>([
|
|
|
80
68
|
['lceil', '⌈'],
|
|
81
69
|
['rceil', '⌉'],
|
|
82
70
|
|
|
71
|
+
/* arrows */
|
|
72
|
+
['gets', 'arrow.l'],
|
|
73
|
+
['hookleftarrow', 'arrow.l.hook'],
|
|
74
|
+
['leftharpoonup', 'harpoon.lt'],
|
|
75
|
+
['leftharpoondown', 'harpoon.lb'],
|
|
76
|
+
['rightleftharpoons', 'harpoons.rtlb'],
|
|
77
|
+
['longleftarrow', 'arrow.l.long'],
|
|
78
|
+
['longrightarrow', 'arrow.r.long'],
|
|
79
|
+
['longleftrightarrow', 'arrow.l.r.long'],
|
|
80
|
+
['Longleftarrow', 'arrow.l.double.long'],
|
|
81
|
+
['Longrightarrow', 'arrow.r.double.long'],
|
|
82
|
+
['Longleftrightarrow', 'arrow.l.r.double.long'],
|
|
83
|
+
['longmapsto', 'arrow.r.bar'],
|
|
84
|
+
['hookrightarrow', 'arrow.r.hook'],
|
|
85
|
+
['rightharpoonup', 'harpoon.rt'],
|
|
86
|
+
['rightharpoondown', 'harpoon.rb'],
|
|
87
|
+
['iff', 'arrow.l.r.double.long'],
|
|
88
|
+
['implies', 'arrow.r.double.long'],
|
|
89
|
+
['uparrow', 'arrow.t'],
|
|
90
|
+
['downarrow', 'arrow.b'],
|
|
91
|
+
['updownarrow', 'arrow.t.b'],
|
|
92
|
+
['Uparrow', 'arrow.t.double'],
|
|
93
|
+
['Downarrow', 'arrow.b.double'],
|
|
94
|
+
['Updownarrow', 'arrow.t.b.double'],
|
|
95
|
+
['nearrow', 'arrow.tr'],
|
|
96
|
+
['searrow', 'arrow.br'],
|
|
97
|
+
['swarrow', 'arrow.bl'],
|
|
98
|
+
['nwarrow', 'arrow.tl'],
|
|
99
|
+
['leadsto', 'arrow.squiggly'],
|
|
100
|
+
|
|
101
|
+
['leftleftarrows', 'arrows.ll'],
|
|
102
|
+
['rightrightarrows', 'arrows.rr'],
|
|
103
|
+
|
|
83
104
|
|
|
84
105
|
['Cap', 'sect.double'],
|
|
85
106
|
['Cup', 'union.double'],
|
|
@@ -87,12 +108,16 @@ export const symbolMap = new Map<string, string>([
|
|
|
87
108
|
['Gamma', 'Gamma'],
|
|
88
109
|
['Join', 'join'],
|
|
89
110
|
['Lambda', 'Lambda'],
|
|
111
|
+
['Leftarrow', 'arrow.l.double'],
|
|
112
|
+
['Leftrightarrow', 'arrow.l.r.double'],
|
|
90
113
|
['Longrightarrow', 'arrow.r.double.long'],
|
|
91
114
|
['Omega', 'Omega'],
|
|
115
|
+
['P', 'pilcrow'],
|
|
92
116
|
['Phi', 'Phi'],
|
|
93
117
|
['Pi', 'Pi'],
|
|
94
118
|
['Psi', 'Psi'],
|
|
95
|
-
['Rightarrow', 'arrow.double'],
|
|
119
|
+
['Rightarrow', 'arrow.r.double'],
|
|
120
|
+
['S', 'section'],
|
|
96
121
|
['Sigma', 'Sigma'],
|
|
97
122
|
['Theta', 'Theta'],
|
|
98
123
|
['aleph', 'alef'],
|
|
@@ -126,6 +151,7 @@ export const symbolMap = new Map<string, string>([
|
|
|
126
151
|
['colon', 'colon'],
|
|
127
152
|
['cong', 'tilde.equiv'],
|
|
128
153
|
['coprod', 'product.co'],
|
|
154
|
+
['copyright', 'copyright'],
|
|
129
155
|
['cup', 'union'],
|
|
130
156
|
['curlyvee', 'or.curly'],
|
|
131
157
|
['curlywedge', 'and.curly'],
|
|
@@ -179,7 +205,7 @@ export const symbolMap = new Map<string, string>([
|
|
|
179
205
|
['leqslant', 'lt.eq.slant'],
|
|
180
206
|
['lhd', 'triangle.l'],
|
|
181
207
|
['ll', 'lt.double'],
|
|
182
|
-
['longmapsto', 'arrow.long
|
|
208
|
+
['longmapsto', 'arrow.bar.long'],
|
|
183
209
|
['longrightarrow', 'arrow.long'],
|
|
184
210
|
['lor', 'or'],
|
|
185
211
|
['ltimes', 'times.l'],
|