You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace `0.2.7` with the latest version number in case this README is outdated.
26
+
Replace `0.3.0-beta-5` with the latest version number in case this README is outdated.
25
27
26
-
The size of minimized library `tex2typst.min.js` is about 23 KB.
27
28
28
29
## Usage
29
30
30
-
### Basic usage
31
31
32
32
```javascript
33
-
import { tex2typst } from'tex2typst';
34
-
35
-
let output =tex2typst("\\zeta(s) = \\sum_{n=1}^{\\infty}\\frac{1}{n^s}");
36
-
console.log(output);
37
-
// zeta(s) = sum_(n = 1)^infinity frac(1, n^s)
38
-
```
39
-
40
-
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.
33
+
import { tex2typst, typst2tex } from'tex2typst';
41
34
35
+
let tex ="e \overset{\text{def}}{=} \lim_{{n \to \infty}} \left(1 + \frac{1}{n}\right)^n";
36
+
let typst =tex2typst(tex);
37
+
console.log(typst);
38
+
// e eq.def lim_(n arrow.r infinity)(1 + frac(1, n))^n
42
39
43
-
### Advanced options
44
-
45
-
- custom TeX macros/commands
46
-
47
-
For example,
48
-
```javascript
49
-
let macros = {
50
-
"\\sgn":"\\operatorname{sgn}"
51
-
};
52
-
let input ="y = \\sgn(x)";
53
-
let output =tex2typst(input, {customTexMacros: macros});
54
-
console.log(output);
55
-
// y = op("sgn")(x)
40
+
let tex_recovered =typst2tex(typst);
41
+
console.log(tex_recovered);
42
+
// e \overset{\text{def}}{=} \lim_{n \rightarrow \infty} \left(1 + \frac{1}{n} \right)^n
56
43
```
57
44
58
-
## How it works
45
+
If you are using the library in a web page via a `<script>` tag, you don't need the line of `import`, function `tex2typst` and `typst2tex` should be available in the global scope.
0 commit comments