tex2typst 0.3.22 → 0.3.24
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/dist/convert.d.ts +9 -3
- package/dist/generic.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2219 -2181
- package/dist/jslex.d.ts +2 -0
- package/dist/tex-parser.d.ts +1 -1
- package/dist/tex-tokenizer.d.ts +1 -1
- package/dist/tex-types.d.ts +103 -0
- package/dist/tex-writer.d.ts +1 -2
- package/dist/tex2typst.min.js +13 -13
- package/dist/typst-parser.d.ts +6 -4
- package/dist/typst-tokenizer.d.ts +1 -1
- package/dist/typst-types.d.ts +95 -0
- package/dist/typst-writer.d.ts +4 -2
- package/package.json +1 -1
- package/src/convert.ts +515 -457
- package/src/generic.ts +29 -3
- package/src/index.ts +1 -1
- package/src/jslex.ts +19 -12
- package/src/map.ts +6 -4
- package/src/tex-parser.ts +54 -62
- package/src/tex-tokenizer.ts +27 -24
- package/src/tex-types.ts +358 -0
- package/src/tex-writer.ts +3 -51
- package/src/typst-parser.ts +54 -71
- package/src/typst-tokenizer.ts +86 -76
- package/src/typst-types.ts +221 -0
- package/src/typst-writer.ts +83 -84
- package/src/util.ts +1 -1
- package/dist/types.d.ts +0 -111
- package/src/types.ts +0 -408
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export declare enum TypstTokenType {
|
|
2
|
+
NONE = 0,
|
|
3
|
+
SYMBOL = 1,
|
|
4
|
+
ELEMENT = 2,
|
|
5
|
+
LITERAL = 3,
|
|
6
|
+
TEXT = 4,
|
|
7
|
+
COMMENT = 5,
|
|
8
|
+
SPACE = 6,
|
|
9
|
+
CONTROL = 7,
|
|
10
|
+
NEWLINE = 8
|
|
11
|
+
}
|
|
12
|
+
export declare class TypstToken {
|
|
13
|
+
type: TypstTokenType;
|
|
14
|
+
value: string;
|
|
15
|
+
constructor(type: TypstTokenType, content: string);
|
|
16
|
+
eq(other: TypstToken): boolean;
|
|
17
|
+
isOneOf(tokens: TypstToken[]): boolean;
|
|
18
|
+
toNode(): TypstNode;
|
|
19
|
+
toString(): string;
|
|
20
|
+
static readonly NONE: TypstToken;
|
|
21
|
+
}
|
|
22
|
+
export interface TypstSupsubData {
|
|
23
|
+
base: TypstNode;
|
|
24
|
+
sup: TypstNode | null;
|
|
25
|
+
sub: TypstNode | null;
|
|
26
|
+
}
|
|
27
|
+
export interface TypstLeftRightData {
|
|
28
|
+
left: TypstToken | null;
|
|
29
|
+
right: TypstToken | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* fraction: `1/2`, `(x + y)/2`, `(1+x)/(1-x)`
|
|
33
|
+
* group: `a + 1/3`
|
|
34
|
+
* leftright: `(a + 1/3)`, `[a + 1/3)`, `lr(]sum_(x=1)^n])`
|
|
35
|
+
*/
|
|
36
|
+
export type TypstNodeType = 'terminal' | 'group' | 'supsub' | 'funcCall' | 'fraction' | 'leftright' | 'align' | 'matrix' | 'cases';
|
|
37
|
+
export type TypstNamedParams = {
|
|
38
|
+
[key: string]: TypstNode;
|
|
39
|
+
};
|
|
40
|
+
export declare abstract class TypstNode {
|
|
41
|
+
readonly type: TypstNodeType;
|
|
42
|
+
head: TypstToken;
|
|
43
|
+
args?: TypstNode[];
|
|
44
|
+
options?: TypstNamedParams;
|
|
45
|
+
constructor(type: TypstNodeType, head: TypstToken | null, args?: TypstNode[]);
|
|
46
|
+
abstract isOverHigh(): boolean;
|
|
47
|
+
setOptions(options: TypstNamedParams): void;
|
|
48
|
+
eq(other: TypstNode): boolean;
|
|
49
|
+
toString(): string;
|
|
50
|
+
}
|
|
51
|
+
export declare class TypstTerminal extends TypstNode {
|
|
52
|
+
constructor(head: TypstToken);
|
|
53
|
+
isOverHigh(): boolean;
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
export declare class TypstGroup extends TypstNode {
|
|
57
|
+
constructor(args: TypstNode[]);
|
|
58
|
+
isOverHigh(): boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare class TypstSupsub extends TypstNode {
|
|
61
|
+
base: TypstNode;
|
|
62
|
+
sup: TypstNode | null;
|
|
63
|
+
sub: TypstNode | null;
|
|
64
|
+
constructor(data: TypstSupsubData);
|
|
65
|
+
isOverHigh(): boolean;
|
|
66
|
+
}
|
|
67
|
+
export declare class TypstFuncCall extends TypstNode {
|
|
68
|
+
constructor(head: TypstToken, args: TypstNode[]);
|
|
69
|
+
isOverHigh(): boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare class TypstFraction extends TypstNode {
|
|
72
|
+
constructor(args: TypstNode[]);
|
|
73
|
+
isOverHigh(): boolean;
|
|
74
|
+
}
|
|
75
|
+
export declare class TypstLeftright extends TypstNode {
|
|
76
|
+
left: TypstToken | null;
|
|
77
|
+
right: TypstToken | null;
|
|
78
|
+
constructor(head: TypstToken | null, args: TypstNode[], data: TypstLeftRightData);
|
|
79
|
+
isOverHigh(): boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare class TypstAlign extends TypstNode {
|
|
82
|
+
matrix: TypstNode[][];
|
|
83
|
+
constructor(data: TypstNode[][]);
|
|
84
|
+
isOverHigh(): boolean;
|
|
85
|
+
}
|
|
86
|
+
export declare class TypstMatrix extends TypstNode {
|
|
87
|
+
matrix: TypstNode[][];
|
|
88
|
+
constructor(data: TypstNode[][]);
|
|
89
|
+
isOverHigh(): boolean;
|
|
90
|
+
}
|
|
91
|
+
export declare class TypstCases extends TypstNode {
|
|
92
|
+
matrix: TypstNode[][];
|
|
93
|
+
constructor(data: TypstNode[][]);
|
|
94
|
+
isOverHigh(): boolean;
|
|
95
|
+
}
|
package/dist/typst-writer.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { TexNode
|
|
1
|
+
import { TexNode } from "./tex-types";
|
|
2
|
+
import { TypstNode } from "./typst-types";
|
|
3
|
+
import { TypstToken } from "./typst-types";
|
|
2
4
|
export declare class TypstWriterError extends Error {
|
|
3
5
|
node: TexNode | TypstNode | TypstToken;
|
|
4
6
|
constructor(message: string, node: TexNode | TypstNode | TypstToken);
|
|
@@ -21,7 +23,7 @@ export declare class TypstWriter {
|
|
|
21
23
|
private insideFunctionDepth;
|
|
22
24
|
constructor(options: TypstWriterOptions);
|
|
23
25
|
private writeBuffer;
|
|
24
|
-
serialize(
|
|
26
|
+
serialize(abstractNode: TypstNode): void;
|
|
25
27
|
private appendWithBracketsIfNeeded;
|
|
26
28
|
protected flushQueue(): void;
|
|
27
29
|
finalize(): string;
|