Skip to content

Commit 2393c20

Browse files
committed
update README
1 parent 666820d commit 2393c20

File tree

1 file changed

+17
-35
lines changed

1 file changed

+17
-35
lines changed

README.md

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# tex2typst
2-
JavaScript library for converting TeX / LaTeX math formula code to Typst
2+
JavaScript library for conversion between TeX/LaTeX and Typst math formula code.
3+
4+
Despite the name `tex2typst` due to the initial goal of converting TeX to Typst, the library can also convert Typst to TeX since version 0.3.0.
35

46
## Try it online
57

@@ -16,55 +18,35 @@ npm install tex2typst
1618
## Or just loading it in a web page
1719

1820
```html
19-
<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.2.7/dist/tex2typst.min.js"></script>
21+
<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.3.0-beta-5/dist/tex2typst.min.js"></script>
2022
<!-- or -->
21-
<script src="https://unpkg.com/tex2typst@0.2.7/dist/tex2typst.min.js"></script>
23+
<script src="https://unpkg.com/tex2typst@0.3.0-beta-5/dist/tex2typst.min.js"></script>
2224
```
2325

24-
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.
2527

26-
The size of minimized library `tex2typst.min.js` is about 23 KB.
2728

2829
## Usage
2930

30-
### Basic usage
3131

3232
```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';
4134

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
4239

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
5643
```
5744

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.
5946

60-
```mermaid
61-
graph LR
62-
tex[TeX code] --parser--> tex_ast[TeX AST] --converter--> typst_ast[Typst AST] --writer--> typst[Typst code]
63-
```
47+
## Open-source license
6448

65-
- parser: Implemented in class `LatexParser`.
66-
- converter: Implemented in function `convertTree`.
67-
- writer: Implemented in class `TypstWriter`.
49+
GPL v3. See [LICENSE](LICENSE) for details.
6850

6951
## Contributing
7052

0 commit comments

Comments
 (0)