tex2typst 0.3.1 → 0.3.3
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 +5 -3
- package/dist/index.js +454 -322
- package/dist/jslex.d.ts +105 -0
- package/dist/tex-parser.d.ts +1 -1
- package/dist/tex2typst.min.js +13 -20
- package/dist/types.d.ts +3 -1
- package/dist/typst-parser.d.ts +1 -1
- package/dist/typst-shorthands.d.ts +3 -0
- package/dist/typst-writer.d.ts +9 -3
- package/docs/api-reference.md +64 -0
- package/package.json +1 -1
- package/src/convert.ts +31 -18
- package/src/index.ts +11 -14
- package/src/jslex.ts +304 -0
- package/src/map.ts +13 -36
- package/src/tex-parser.ts +44 -137
- package/src/types.ts +3 -1
- package/src/typst-parser.ts +72 -126
- package/src/typst-shorthands.ts +51 -0
- package/src/typst-writer.ts +29 -22
- package/tools/make-shorthand-map.py +33 -0
- package/tools/make-symbol-map.py +4 -3
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# tex2typst
|
|
1
|
+
# tex2typst.js
|
|
2
|
+
|
|
2
3
|
JavaScript library for conversion between TeX/LaTeX and Typst math formula code.
|
|
3
4
|
|
|
4
5
|
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.
|
|
@@ -28,14 +29,13 @@ Replace `0.3.0` with the latest version number in case this README is outdated.
|
|
|
28
29
|
|
|
29
30
|
## Usage
|
|
30
31
|
|
|
31
|
-
|
|
32
32
|
```javascript
|
|
33
33
|
import { tex2typst, typst2tex } from 'tex2typst';
|
|
34
34
|
|
|
35
35
|
let tex = "e \overset{\text{def}}{=} \lim_{{n \to \infty}} \left(1 + \frac{1}{n}\right)^n";
|
|
36
36
|
let typst = tex2typst(tex);
|
|
37
37
|
console.log(typst);
|
|
38
|
-
// e eq.def lim_(n
|
|
38
|
+
// e eq.def lim_(n -> infinity)(1 + 1/n)^n
|
|
39
39
|
|
|
40
40
|
let tex_recovered = typst2tex(typst);
|
|
41
41
|
console.log(tex_recovered);
|
|
@@ -44,6 +44,8 @@ console.log(tex_recovered);
|
|
|
44
44
|
|
|
45
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.
|
|
46
46
|
|
|
47
|
+
tex2typst.js supports some advanced options to customize the conversion. For more details, please refer to the [API Reference](docs/api-reference.md).
|
|
48
|
+
|
|
47
49
|
## Open-source license
|
|
48
50
|
|
|
49
51
|
GPL v3. See [LICENSE](LICENSE) for details.
|