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/README.md
CHANGED
|
@@ -7,23 +7,38 @@ A Web UI wrapper is available at [https://qwinsi.github.io/tex2typst-webapp/](ht
|
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
+
## Installing it in a Node.js project
|
|
11
|
+
|
|
10
12
|
```bash
|
|
11
13
|
npm install tex2typst
|
|
12
14
|
```
|
|
13
15
|
|
|
16
|
+
## Or just loading it in a web page
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.0.19/dist/tex2typst.min.js"></script>
|
|
20
|
+
<!-- or -->
|
|
21
|
+
<script src="https://unpkg.com/tex2typst@0.0.19/dist/tex2typst.min.js"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Replace `0.0.19` with the latest version number in case this README is outdated.
|
|
25
|
+
|
|
14
26
|
## Usage
|
|
15
27
|
|
|
16
28
|
### Basic usage
|
|
17
29
|
|
|
18
30
|
```javascript
|
|
19
|
-
import {
|
|
31
|
+
import { tex2typst } from 'tex2typst';
|
|
20
32
|
|
|
21
33
|
let output = tex2typst("\\zeta(s) = \\sum_{n=1}^{\\infty}\\frac{1}{n^s}");
|
|
22
34
|
console.log(output);
|
|
23
35
|
// zeta(s) = sum_(n = 1)^infinity frac(1, n^s)
|
|
24
36
|
```
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
If you are using the library in a web page via a `<script>` tag, you don't need the line of `import`, function `tex2typst` should be available in the global scope.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Advanced options
|
|
27
42
|
|
|
28
43
|
- custom TeX macros/commands
|
|
29
44
|
|
|
@@ -33,7 +48,7 @@ let macros = {
|
|
|
33
48
|
"\\sgn": "\\operatorname{sgn}"
|
|
34
49
|
};
|
|
35
50
|
let input = "y = \\sgn(x)";
|
|
36
|
-
|
|
51
|
+
let output = tex2typst(input, {customTexMacros: macros});
|
|
37
52
|
console.log(output);
|
|
38
53
|
// y = op("sgn")(x)
|
|
39
54
|
```
|
package/dist/index.js
CHANGED
|
@@ -246,9 +246,6 @@ var symbolMap = new Map([
|
|
|
246
246
|
["gets", "arrow.l"],
|
|
247
247
|
["nonumber", ""],
|
|
248
248
|
["vec", "arrow"],
|
|
249
|
-
["mathbf", "bold"],
|
|
250
|
-
["boldsymbol", "bold"],
|
|
251
|
-
["mathfrak", "frak"],
|
|
252
249
|
["neq", "eq.not"],
|
|
253
250
|
["dot", "dot"],
|
|
254
251
|
["ddot", "dot.double"],
|
|
@@ -266,8 +263,13 @@ var symbolMap = new Map([
|
|
|
266
263
|
["overline", "overline"],
|
|
267
264
|
["underline", "underline"],
|
|
268
265
|
["bar", "macron"],
|
|
266
|
+
["boldsymbol", "bold"],
|
|
267
|
+
["mathbf", "bold"],
|
|
269
268
|
["mathbb", "bb"],
|
|
270
269
|
["mathcal", "cal"],
|
|
270
|
+
["mathfrak", "frak"],
|
|
271
|
+
["mathsf", "sans"],
|
|
272
|
+
["mathtt", "mono"],
|
|
271
273
|
["mathrm", "upright"],
|
|
272
274
|
["rm", "upright"],
|
|
273
275
|
["pmb", "bold"],
|
|
@@ -664,6 +666,19 @@ class TypstWriter {
|
|
|
664
666
|
this.queue.push({ type: "atom", content: ")" });
|
|
665
667
|
this.insideFunctionDepth--;
|
|
666
668
|
return;
|
|
669
|
+
} else if (node.content === "\\mathbf") {
|
|
670
|
+
this.append({ type: "symbol", content: "upright" });
|
|
671
|
+
this.insideFunctionDepth++;
|
|
672
|
+
this.queue.push({ type: "atom", content: "(" });
|
|
673
|
+
this.queue.push(func_symbol);
|
|
674
|
+
this.insideFunctionDepth++;
|
|
675
|
+
this.queue.push({ type: "atom", content: "(" });
|
|
676
|
+
this.append(arg0);
|
|
677
|
+
this.queue.push({ type: "atom", content: ")" });
|
|
678
|
+
this.insideFunctionDepth--;
|
|
679
|
+
this.queue.push({ type: "atom", content: ")" });
|
|
680
|
+
this.insideFunctionDepth--;
|
|
681
|
+
return;
|
|
667
682
|
} else if (node.content === "\\mathbb") {
|
|
668
683
|
const body = node.args[0];
|
|
669
684
|
if (body.type === "symbol" && /^[A-Z]$/.test(body.content)) {
|
|
@@ -829,9 +844,6 @@ function tex2typst(tex, options) {
|
|
|
829
844
|
writer2.append(t);
|
|
830
845
|
return writer2.finalize();
|
|
831
846
|
}
|
|
832
|
-
if (typeof window !== "undefined") {
|
|
833
|
-
window.tex2typst = tex2typst;
|
|
834
|
-
}
|
|
835
847
|
export {
|
|
836
848
|
tex2typst
|
|
837
849
|
};
|