JavaScript library for converting TeX code to Typst
npm install tex2typstJavaScript library for conversion between TeX/LaTeX and Typst math code.
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.
A Web UI wrapper is available at https://qwinsi.github.io/tex2typst-webapp/.
``bash`
npm install tex2typst
`html`
Replace 0.3.0 with the latest version number in case this README is outdated.
`javascript
import { tex2typst, typst2tex } from 'tex2typst';
let tex = "e \\overset{\\text{def}}{=} \\lim_{{n \\to \\infty}} \left(1 + \\frac{1}{n}\\right)^n";
let typst = tex2typst(tex);
console.log(typst);
// e eq.def lim_(n -> infinity) (1 + 1/n)^n
let tex_recovered = typst2tex(typst);
console.log(tex_recovered);
// e \overset{\text{def}}{=} \lim_{n \rightarrow \infty} \left(1 + \frac{1}{n} \right)^n
`
If you are using the library in a web page via a