tex2typst 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/index.js +18 -6
- package/dist/tex2typst.min.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -5
- package/src/map.ts +5 -3
- package/src/tex2typst.ts +9 -0
- package/src/writer.ts +13 -0
- package/tool/dist/dist/ka.js +13654 -0
- package/tool/dist/ka.js +13634 -0
- package/tsconfig.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tex2typst",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "JavaScript library for converting TeX code to Typst",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"prebuild": "rimraf dist/",
|
|
18
18
|
"build:node": "bun build --entrypoints src/index.ts --outdir ./dist --target node --external katex",
|
|
19
|
-
"build:browser": "bun build --entrypoints src/
|
|
19
|
+
"build:browser": "bun build --entrypoints src/tex2typst.ts --outdir ./dist --target browser --entry-naming [dir]/[name].min.[ext] --minify",
|
|
20
20
|
"build:types": "tsc --project ./tsconfig.json",
|
|
21
21
|
"build": "npm run build:node && npm run build:browser && npm run build:types",
|
|
22
22
|
"test": "vitest run"
|
package/src/index.ts
CHANGED
package/src/map.ts
CHANGED
|
@@ -2,9 +2,6 @@ export const symbolMap = new Map<string, string>([
|
|
|
2
2
|
['gets', 'arrow.l'],
|
|
3
3
|
['nonumber', ''],
|
|
4
4
|
['vec', 'arrow'],
|
|
5
|
-
['mathbf', 'bold'],
|
|
6
|
-
['boldsymbol', 'bold'],
|
|
7
|
-
['mathfrak', 'frak'],
|
|
8
5
|
['neq', 'eq.not'],
|
|
9
6
|
['dot', 'dot'],
|
|
10
7
|
['ddot', 'dot.double'],
|
|
@@ -23,8 +20,13 @@ export const symbolMap = new Map<string, string>([
|
|
|
23
20
|
['underline', 'underline'], // same
|
|
24
21
|
['bar', 'macron'],
|
|
25
22
|
|
|
23
|
+
['boldsymbol', 'bold'],
|
|
24
|
+
['mathbf', 'bold'],
|
|
26
25
|
['mathbb', 'bb'],
|
|
27
26
|
['mathcal', 'cal'],
|
|
27
|
+
['mathfrak', 'frak'],
|
|
28
|
+
['mathsf', 'sans'],
|
|
29
|
+
['mathtt', 'mono'],
|
|
28
30
|
|
|
29
31
|
['mathrm', 'upright'],
|
|
30
32
|
['rm', 'upright'],
|
package/src/tex2typst.ts
ADDED
package/src/writer.ts
CHANGED
|
@@ -172,6 +172,19 @@ export class TypstWriter {
|
|
|
172
172
|
this.queue.push({ type: 'atom', content: ')'});
|
|
173
173
|
this.insideFunctionDepth --;
|
|
174
174
|
return;
|
|
175
|
+
} else if (node.content === '\\mathbf') {
|
|
176
|
+
this.append({ type: 'symbol', content: 'upright' });
|
|
177
|
+
this.insideFunctionDepth ++;
|
|
178
|
+
this.queue.push({ type: 'atom', content: '('});
|
|
179
|
+
this.queue.push(func_symbol);
|
|
180
|
+
this.insideFunctionDepth ++;
|
|
181
|
+
this.queue.push({ type: 'atom', content: '('});
|
|
182
|
+
this.append(arg0);
|
|
183
|
+
this.queue.push({ type: 'atom', content: ')'});
|
|
184
|
+
this.insideFunctionDepth --;
|
|
185
|
+
this.queue.push({ type: 'atom', content: ')'});
|
|
186
|
+
this.insideFunctionDepth --;
|
|
187
|
+
return;
|
|
175
188
|
} else if (node.content === '\\mathbb') {
|
|
176
189
|
const body = node.args![0];
|
|
177
190
|
if (body.type === 'symbol' && /^[A-Z]$/.test(body.content)) {
|