tex2typst 0.3.26 → 0.3.27

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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +21 -4
  3. package/dist/index.js +409 -340
  4. package/dist/parser.js +23 -0
  5. package/dist/tex2typst.min.js +12 -12
  6. package/package.json +6 -7
  7. package/src/convert.ts +56 -6
  8. package/src/exposed-types.ts +23 -0
  9. package/src/index.ts +9 -5
  10. package/src/jslex.ts +1 -1
  11. package/src/tex-tokenizer.ts +1 -0
  12. package/src/tex-types.ts +1 -17
  13. package/src/tex2typst.ts +2 -4
  14. package/src/typst-parser.ts +9 -10
  15. package/src/typst-types.ts +484 -230
  16. package/src/typst-writer.ts +28 -274
  17. package/tests/cheat-sheet.test.ts +42 -0
  18. package/tests/cheat-sheet.toml +304 -0
  19. package/tests/example.ts +15 -0
  20. package/tests/general-symbols.test.ts +22 -0
  21. package/tests/general-symbols.toml +755 -0
  22. package/tests/integration-tex2typst.yaml +89 -0
  23. package/tests/struct-bidirection.yaml +179 -0
  24. package/tests/struct-tex2typst.yaml +443 -0
  25. package/tests/struct-typst2tex.yaml +412 -0
  26. package/tests/symbol.yml +123 -0
  27. package/tests/test-common.ts +26 -0
  28. package/tests/tex-parser.test.ts +57 -0
  29. package/tests/tex-to-typst.test.ts +143 -0
  30. package/tests/typst-parser.test.ts +134 -0
  31. package/tests/typst-to-tex.test.ts +76 -0
  32. package/tsconfig.json +11 -16
  33. package/dist/convert.d.ts +0 -9
  34. package/dist/generic.d.ts +0 -9
  35. package/dist/jslex.d.ts +0 -107
  36. package/dist/map.d.ts +0 -5
  37. package/dist/tex-parser.d.ts +0 -23
  38. package/dist/tex-tokenizer.d.ts +0 -4
  39. package/dist/tex-types.d.ts +0 -107
  40. package/dist/tex-writer.d.ts +0 -8
  41. package/dist/typst-parser.d.ts +0 -23
  42. package/dist/typst-shorthands.d.ts +0 -3
  43. package/dist/typst-tokenizer.d.ts +0 -2
  44. package/dist/typst-types.d.ts +0 -98
  45. package/dist/typst-writer.d.ts +0 -30
  46. package/dist/util.d.ts +0 -3
package/README.md CHANGED
@@ -35,7 +35,7 @@ import { tex2typst, typst2tex } from 'tex2typst';
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 -> infinity)(1 + 1/n)^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);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,23 @@
1
- import type { Tex2TypstOptions } from "./tex-types";
2
- import { symbolMap } from "./map";
3
- import { shorthandMap } from "./typst-shorthands";
1
+
2
+ /**
3
+ * ATTENTION:
4
+ * Don't use any options except those explicitly documented in
5
+ * https://github.com/qwinsi/tex2typst/blob/main/docs/api-reference.md
6
+ * Any undocumented options may be not working at present or break in the future!
7
+ */
8
+ export interface Tex2TypstOptions {
9
+ nonStrict?: boolean; /** default is true */
10
+ preferShorthands?: boolean; /** default is true */
11
+ keepSpaces?: boolean; /** default is false */
12
+ fracToSlash?: boolean; /** default is true */
13
+ inftyToOo?: boolean; /** default is false */
14
+ optimize?: boolean; /** default is true */
15
+ nonAsciiWrapper?: string; /** default is "" */
16
+ customTexMacros?: { [key: string]: string; };
17
+ }
18
+
4
19
  export declare function tex2typst(tex: string, options?: Tex2TypstOptions): string;
5
20
  export declare function typst2tex(typst: string): string;
6
- export { Tex2TypstOptions, symbolMap, shorthandMap };
21
+
22
+ export declare const symbolMap: Map<string, string>;
23
+ export declare const shorthandMap: Map<string, string>;