tex2typst 0.3.25 → 0.3.27-beta.1
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/index.d.ts +24 -6
- package/dist/index.js +88 -35
- package/dist/tex2typst.min.js +9 -9
- package/package.json +6 -7
- package/src/convert.ts +5 -6
- package/src/exposed-types.ts +24 -0
- package/src/index.ts +2 -2
- package/src/map.ts +4 -2
- package/src/tex-parser.ts +4 -4
- package/src/tex-types.ts +1 -17
- package/src/typst-types.ts +1 -0
- package/tsconfig.json +7 -12
- package/dist/convert.d.ts +0 -9
- package/dist/generic.d.ts +0 -9
- package/dist/jslex.d.ts +0 -107
- package/dist/map.d.ts +0 -5
- package/dist/tex-parser.d.ts +0 -23
- package/dist/tex-tokenizer.d.ts +0 -4
- package/dist/tex-types.d.ts +0 -107
- package/dist/tex-writer.d.ts +0 -8
- package/dist/typst-parser.d.ts +0 -23
- package/dist/typst-shorthands.d.ts +0 -3
- package/dist/typst-tokenizer.d.ts +0 -2
- package/dist/typst-types.d.ts +0 -97
- package/dist/typst-writer.d.ts +0 -30
- package/dist/util.d.ts +0 -3
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
/*
|
|
3
|
+
/* This is not the full list because some meaningless options are not listed. */
|
|
4
4
|
|
|
5
5
|
/* Projects */
|
|
6
6
|
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
@@ -20,12 +20,10 @@
|
|
|
20
20
|
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
21
|
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
22
|
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
23
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
24
|
|
|
27
25
|
/* Modules */
|
|
28
|
-
"module": "
|
|
26
|
+
// "module": "es6", /* Specify what module code is generated. */
|
|
29
27
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
28
|
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
29
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
@@ -35,7 +33,7 @@
|
|
|
35
33
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
34
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
35
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
"allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
36
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
37
|
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
38
|
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
39
|
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
@@ -49,12 +47,11 @@
|
|
|
49
47
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
48
|
|
|
51
49
|
/* Emit */
|
|
52
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
50
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
51
|
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
52
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
53
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
54
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
55
|
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
56
|
// "removeComments": true, /* Disable emitting comments. */
|
|
60
57
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
@@ -63,13 +60,11 @@
|
|
|
63
60
|
// "sourceRoot": "./", /* Specify the root path for debuggers to find the reference source code. */
|
|
64
61
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
65
62
|
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
66
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
67
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
68
63
|
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
69
64
|
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
70
65
|
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
71
66
|
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
72
|
-
"declarationDir": "./dist", /* Specify the output directory for generated declaration files. */
|
|
67
|
+
// "declarationDir": "./dist", /* Specify the output directory for generated declaration files. */
|
|
73
68
|
|
|
74
69
|
/* Interop Constraints */
|
|
75
70
|
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
package/dist/convert.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TexNode, Tex2TypstOptions, TexToken } from "./tex-types";
|
|
2
|
-
import { TypstNode } from "./typst-types";
|
|
3
|
-
import { TypstToken } from "./typst-types";
|
|
4
|
-
export declare class ConverterError extends Error {
|
|
5
|
-
node: TexNode | TypstNode | TexToken | TypstToken | null;
|
|
6
|
-
constructor(message: string, node?: TexNode | TypstNode | TexToken | TypstToken | null);
|
|
7
|
-
}
|
|
8
|
-
export declare function convert_tex_node_to_typst(abstractNode: TexNode, options?: Tex2TypstOptions): TypstNode;
|
|
9
|
-
export declare function convert_typst_node_to_tex(abstractNode: TypstNode): TexNode;
|
package/dist/generic.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface IEquatable {
|
|
2
|
-
eq(other: IEquatable): boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare function array_equal<T extends IEquatable>(a: T[], b: T[]): boolean;
|
|
5
|
-
export declare function array_find<T extends IEquatable>(array: T[], item: T, start?: number): number;
|
|
6
|
-
export declare function array_includes<T extends IEquatable>(array: T[], item: T): boolean;
|
|
7
|
-
export declare function array_split<T extends IEquatable>(array: T[], sep: T): T[][];
|
|
8
|
-
export declare function array_intersperse<T>(array: T[], sep: T): T[];
|
|
9
|
-
export {};
|
package/dist/jslex.d.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapted from jslex - A lexer in JavaScript. https://github.com/jimbojw/jslex
|
|
3
|
-
* Licensed under MIT license
|
|
4
|
-
*/
|
|
5
|
-
interface ILexSpec<T> {
|
|
6
|
-
start: Map<string, (arg0: Scanner<T>) => T | T[]>;
|
|
7
|
-
}
|
|
8
|
-
interface IRule<T> {
|
|
9
|
-
re: RegExp;
|
|
10
|
-
action: (a: Scanner<T>) => T | T[];
|
|
11
|
-
}
|
|
12
|
-
export declare class Scanner<T> {
|
|
13
|
-
private _input;
|
|
14
|
-
private _lexer;
|
|
15
|
-
private _pos;
|
|
16
|
-
private _line;
|
|
17
|
-
private _col;
|
|
18
|
-
private _offset;
|
|
19
|
-
private _less;
|
|
20
|
-
private _go;
|
|
21
|
-
private _newstate;
|
|
22
|
-
private _state;
|
|
23
|
-
private _text;
|
|
24
|
-
private _leng;
|
|
25
|
-
private _reMatchArray;
|
|
26
|
-
constructor(input: string, lexer: JSLex<T>);
|
|
27
|
-
/**
|
|
28
|
-
* Analogous to yytext and yyleng in lex - will be set during scan.
|
|
29
|
-
*/
|
|
30
|
-
text(): string | null;
|
|
31
|
-
leng(): number | null;
|
|
32
|
-
reMatchArray(): RegExpMatchArray | null;
|
|
33
|
-
/**
|
|
34
|
-
* Position of in stream, line number and column number of match.
|
|
35
|
-
*/
|
|
36
|
-
pos(): number;
|
|
37
|
-
line(): number;
|
|
38
|
-
column(): number;
|
|
39
|
-
/**
|
|
40
|
-
* Analogous to input() in lex.
|
|
41
|
-
* @return {string} The next character in the stream.
|
|
42
|
-
*/
|
|
43
|
-
input(): string;
|
|
44
|
-
/**
|
|
45
|
-
* Similar to unput() in lex, but does not allow modifying the stream.
|
|
46
|
-
* @return {int} The offset position after the operation.
|
|
47
|
-
*/
|
|
48
|
-
unput(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Analogous to yyless(n) in lex - retains the first n characters from this pattern, and returns
|
|
51
|
-
* the rest to the input stream, such that they will be used in the next pattern-matching operation.
|
|
52
|
-
* @param {int} n Number of characters to retain.
|
|
53
|
-
* @return {int} Length of the stream after the operation has completed.
|
|
54
|
-
*/
|
|
55
|
-
less(n: number): number;
|
|
56
|
-
/**
|
|
57
|
-
* Like less(), but instead of retaining the first n characters, it chops off the last n.
|
|
58
|
-
* @param {int} n Number of characters to chop.
|
|
59
|
-
* @return {int} Length of the stream after the operation has completed.
|
|
60
|
-
*/
|
|
61
|
-
pushback(n: number): number;
|
|
62
|
-
/**
|
|
63
|
-
* Similar to REJECT in lex, except it doesn't break the current execution context.
|
|
64
|
-
* TIP: reject() should be the last instruction in a spec callback.
|
|
65
|
-
*/
|
|
66
|
-
reject(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Analogous to BEGIN in lex - sets the named state (start condition).
|
|
69
|
-
* @param {string|int} state Name of state to switch to, or ordinal number (0 is first, etc).
|
|
70
|
-
* @return {string} The new state on successful switch, throws exception on failure.
|
|
71
|
-
*/
|
|
72
|
-
begin(state: string | number): string;
|
|
73
|
-
/**
|
|
74
|
-
* Simple accessor for reading in the current state.
|
|
75
|
-
* @return {string} The current state.
|
|
76
|
-
*/
|
|
77
|
-
state(): string;
|
|
78
|
-
/**
|
|
79
|
-
* Scan method to be returned to caller - grabs the next token and fires appropriate calback.
|
|
80
|
-
* @return {T} The next token extracted from the stream.
|
|
81
|
-
*/
|
|
82
|
-
scan(): T | T[];
|
|
83
|
-
}
|
|
84
|
-
export declare class JSLex<T> {
|
|
85
|
-
states: string[];
|
|
86
|
-
specification: Record<string, IRule<T>[]>;
|
|
87
|
-
constructor(spec: ILexSpec<T>);
|
|
88
|
-
/**
|
|
89
|
-
* Scanner function - makes a new scanner object which is used to get tokens one at a time.
|
|
90
|
-
* @param {string} input Input text to tokenize.
|
|
91
|
-
* @return {function} Scanner function.
|
|
92
|
-
*/
|
|
93
|
-
scanner(input: string): Scanner<T>;
|
|
94
|
-
/**
|
|
95
|
-
* Similar to lex's yylex() function, consumes all input, calling calback for each token.
|
|
96
|
-
* @param {string} input Text to lex.
|
|
97
|
-
* @param {function} callback Function to execute for each token.
|
|
98
|
-
*/
|
|
99
|
-
lex(input: string, callback: (arg0: T | T[]) => void): void;
|
|
100
|
-
/**
|
|
101
|
-
* Consumes all input, collecting tokens along the way.
|
|
102
|
-
* @param {string} input Text to lex.
|
|
103
|
-
* @return {array} List of tokens, may contain an Error at the end.
|
|
104
|
-
*/
|
|
105
|
-
collect(input: string): T[];
|
|
106
|
-
}
|
|
107
|
-
export {};
|
package/dist/map.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const symbolMap: Map<string, string>;
|
|
2
|
-
declare const texAliasMap: Map<string, string>;
|
|
3
|
-
declare const typstAliasMap: Map<string, string>;
|
|
4
|
-
declare const reverseSymbolMap: Map<string, string>;
|
|
5
|
-
export { symbolMap, reverseSymbolMap, texAliasMap, typstAliasMap };
|
package/dist/tex-parser.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TexNode, TexToken } from "./tex-types";
|
|
2
|
-
export declare class LatexParserError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
type ParseResult = [TexNode, number];
|
|
6
|
-
export declare class LatexParser {
|
|
7
|
-
space_sensitive: boolean;
|
|
8
|
-
newline_sensitive: boolean;
|
|
9
|
-
constructor(space_sensitive?: boolean, newline_sensitive?: boolean);
|
|
10
|
-
parse(tokens: TexToken[]): TexNode;
|
|
11
|
-
parseGroup(tokens: TexToken[], start: number, end: number): ParseResult;
|
|
12
|
-
parseNextExpr(tokens: TexToken[], start: number): ParseResult;
|
|
13
|
-
parseNextExprWithoutSupSub(tokens: TexToken[], start: number): ParseResult;
|
|
14
|
-
parseCommandExpr(tokens: TexToken[], start: number): ParseResult;
|
|
15
|
-
parseNextArg(tokens: TexToken[], start: number): ParseResult;
|
|
16
|
-
parseLeftRightExpr(tokens: TexToken[], start: number): ParseResult;
|
|
17
|
-
parseBeginEndExpr(tokens: TexToken[], start: number): ParseResult;
|
|
18
|
-
parseAligned(tokens: TexToken[]): TexNode[][];
|
|
19
|
-
}
|
|
20
|
-
export declare function parseTex(tex: string, customTexMacros: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
}): TexNode;
|
|
23
|
-
export {};
|
package/dist/tex-tokenizer.d.ts
DELETED
package/dist/tex-types.d.ts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ELEMENT: 0-9, a-z, A-Z, punctuations such as +-/*,:; etc.
|
|
3
|
-
* COMMAND: LaTeX macro with no parameter. e.g. \sin \cos \int \sum
|
|
4
|
-
* EMPTY: special type when something is empty. e.g. the base of _{a} or ^{a}
|
|
5
|
-
*/
|
|
6
|
-
export declare enum TexTokenType {
|
|
7
|
-
EMPTY = 0,
|
|
8
|
-
ELEMENT = 1,
|
|
9
|
-
COMMAND = 2,
|
|
10
|
-
LITERAL = 3,
|
|
11
|
-
COMMENT = 4,
|
|
12
|
-
SPACE = 5,
|
|
13
|
-
NEWLINE = 6,
|
|
14
|
-
CONTROL = 7,
|
|
15
|
-
UNKNOWN = 8
|
|
16
|
-
}
|
|
17
|
-
export declare class TexToken {
|
|
18
|
-
readonly type: TexTokenType;
|
|
19
|
-
value: string;
|
|
20
|
-
constructor(type: TexTokenType, value: string);
|
|
21
|
-
eq(token: TexToken): boolean;
|
|
22
|
-
toString(): string;
|
|
23
|
-
toNode(): TexNode;
|
|
24
|
-
static readonly EMPTY: TexToken;
|
|
25
|
-
}
|
|
26
|
-
export interface TexSupsubData {
|
|
27
|
-
base: TexNode;
|
|
28
|
-
sup: TexNode | null;
|
|
29
|
-
sub: TexNode | null;
|
|
30
|
-
}
|
|
31
|
-
export interface TexLeftRightData {
|
|
32
|
-
body: TexNode;
|
|
33
|
-
left: TexToken | null;
|
|
34
|
-
right: TexToken | null;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* funcCall: LaTeX macro with 1 or more parameters. e.g. \sqrt{3} \log{x} \exp{x} \frac{1}{2}
|
|
38
|
-
* text: text enclosed by braces. e.g. \text{hello world}
|
|
39
|
-
*/
|
|
40
|
-
type TexNodeType = 'terminal' | 'text' | 'ordgroup' | 'supsub' | 'funcCall' | 'leftright' | 'beginend';
|
|
41
|
-
export declare abstract class TexNode {
|
|
42
|
-
readonly type: TexNodeType;
|
|
43
|
-
head: TexToken;
|
|
44
|
-
constructor(type: TexNodeType, head: TexToken | null);
|
|
45
|
-
eq(other: TexNode): boolean;
|
|
46
|
-
abstract serialize(): TexToken[];
|
|
47
|
-
toString(): string;
|
|
48
|
-
}
|
|
49
|
-
export declare class TexTerminal extends TexNode {
|
|
50
|
-
constructor(head: TexToken);
|
|
51
|
-
serialize(): TexToken[];
|
|
52
|
-
}
|
|
53
|
-
export declare class TexText extends TexNode {
|
|
54
|
-
constructor(head: TexToken);
|
|
55
|
-
serialize(): TexToken[];
|
|
56
|
-
}
|
|
57
|
-
export declare class TexGroup extends TexNode {
|
|
58
|
-
items: TexNode[];
|
|
59
|
-
constructor(items: TexNode[]);
|
|
60
|
-
serialize(): TexToken[];
|
|
61
|
-
}
|
|
62
|
-
export declare class TexSupSub extends TexNode {
|
|
63
|
-
base: TexNode;
|
|
64
|
-
sup: TexNode | null;
|
|
65
|
-
sub: TexNode | null;
|
|
66
|
-
constructor(data: TexSupsubData);
|
|
67
|
-
serialize(): TexToken[];
|
|
68
|
-
}
|
|
69
|
-
export declare class TexFuncCall extends TexNode {
|
|
70
|
-
args: TexNode[];
|
|
71
|
-
data: TexNode | null;
|
|
72
|
-
constructor(head: TexToken, args: TexNode[], data?: TexNode | null);
|
|
73
|
-
serialize(): TexToken[];
|
|
74
|
-
}
|
|
75
|
-
export declare class TexLeftRight extends TexNode {
|
|
76
|
-
body: TexNode;
|
|
77
|
-
left: TexToken | null;
|
|
78
|
-
right: TexToken | null;
|
|
79
|
-
constructor(data: TexLeftRightData);
|
|
80
|
-
serialize(): TexToken[];
|
|
81
|
-
}
|
|
82
|
-
export declare class TexBeginEnd extends TexNode {
|
|
83
|
-
matrix: TexNode[][];
|
|
84
|
-
data: TexNode | null;
|
|
85
|
-
constructor(head: TexToken, matrix: TexNode[][], data?: TexNode | null);
|
|
86
|
-
serialize(): TexToken[];
|
|
87
|
-
}
|
|
88
|
-
export declare function writeTexTokenBuffer(buffer: string, token: TexToken): string;
|
|
89
|
-
/**
|
|
90
|
-
* ATTENTION:
|
|
91
|
-
* Don't use any options except those explicitly documented in
|
|
92
|
-
* https://github.com/qwinsi/tex2typst/blob/main/docs/api-reference.md
|
|
93
|
-
* Any undocumented options may be not working at present or break in the future!
|
|
94
|
-
*/
|
|
95
|
-
export interface Tex2TypstOptions {
|
|
96
|
-
nonStrict?: boolean; /** default is true */
|
|
97
|
-
preferShorthands?: boolean; /** default is true */
|
|
98
|
-
keepSpaces?: boolean; /** default is false */
|
|
99
|
-
fracToSlash?: boolean; /** default is true */
|
|
100
|
-
inftyToOo?: boolean; /** default is false */
|
|
101
|
-
optimize?: boolean; /** default is true */
|
|
102
|
-
nonAsciiWrapper?: string; /** default is "" */
|
|
103
|
-
customTexMacros?: {
|
|
104
|
-
[key: string]: string;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export {};
|
package/dist/tex-writer.d.ts
DELETED
package/dist/typst-parser.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { TypstNode } from "./typst-types";
|
|
2
|
-
import { TypstNamedParams } from "./typst-types";
|
|
3
|
-
import { TypstToken } from "./typst-types";
|
|
4
|
-
export declare class TypstParserError extends Error {
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
}
|
|
7
|
-
type TypstParseResult = [TypstNode, number];
|
|
8
|
-
export declare class TypstParser {
|
|
9
|
-
space_sensitive: boolean;
|
|
10
|
-
newline_sensitive: boolean;
|
|
11
|
-
constructor(space_sensitive?: boolean, newline_sensitive?: boolean);
|
|
12
|
-
parse(tokens: TypstToken[]): TypstNode;
|
|
13
|
-
parseGroup(tokens: TypstToken[], start: number, end: number, parentheses?: boolean): TypstParseResult;
|
|
14
|
-
parseNextExpr(tokens: TypstToken[], start: number): TypstParseResult;
|
|
15
|
-
parseSupOrSub(tokens: TypstToken[], start: number): TypstParseResult;
|
|
16
|
-
parseNextExprWithoutSupSub(tokens: TypstToken[], start: number): TypstParseResult;
|
|
17
|
-
parseArguments(tokens: TypstToken[], start: number): [TypstNode[], number];
|
|
18
|
-
parseLrArguments(tokens: TypstToken[], start: number): [TypstNode, number];
|
|
19
|
-
parseMatrix(tokens: TypstToken[], start: number, rowSepToken: TypstToken, cellSepToken: TypstToken): [TypstNode[][], TypstNamedParams, number];
|
|
20
|
-
parseArgumentsWithSeparator(tokens: TypstToken[], start: number, end: number, sepToken: TypstToken): TypstNode[];
|
|
21
|
-
}
|
|
22
|
-
export declare function parseTypst(typst: string): TypstNode;
|
|
23
|
-
export {};
|
package/dist/typst-types.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
readonly 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
|
-
body: TypstNode;
|
|
29
|
-
left: TypstToken | null;
|
|
30
|
-
right: TypstToken | null;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* fraction: `1/2`, `(x + y)/2`, `(1+x)/(1-x)`
|
|
34
|
-
* group: `a + 1/3`
|
|
35
|
-
* leftright: `(a + 1/3)`, `[a + 1/3)`, `lr(]sum_(x=1)^n])`
|
|
36
|
-
* markupFunc: `#heading(level: 2)[something]`, `#text(fill: red)[some text and math $x + y$]`
|
|
37
|
-
*/
|
|
38
|
-
export type TypstNodeType = 'terminal' | 'group' | 'supsub' | 'funcCall' | 'fraction' | 'leftright' | 'matrixLike' | 'markupFunc';
|
|
39
|
-
export type TypstNamedParams = {
|
|
40
|
-
[key: string]: TypstNode;
|
|
41
|
-
};
|
|
42
|
-
export declare abstract class TypstNode {
|
|
43
|
-
readonly type: TypstNodeType;
|
|
44
|
-
head: TypstToken;
|
|
45
|
-
options?: TypstNamedParams;
|
|
46
|
-
constructor(type: TypstNodeType, head: TypstToken | null);
|
|
47
|
-
abstract isOverHigh(): boolean;
|
|
48
|
-
setOptions(options: TypstNamedParams): void;
|
|
49
|
-
eq(other: TypstNode): boolean;
|
|
50
|
-
toString(): string;
|
|
51
|
-
}
|
|
52
|
-
export declare class TypstTerminal extends TypstNode {
|
|
53
|
-
constructor(head: TypstToken);
|
|
54
|
-
isOverHigh(): boolean;
|
|
55
|
-
toString(): string;
|
|
56
|
-
}
|
|
57
|
-
export declare class TypstGroup extends TypstNode {
|
|
58
|
-
items: TypstNode[];
|
|
59
|
-
constructor(items: TypstNode[]);
|
|
60
|
-
isOverHigh(): boolean;
|
|
61
|
-
}
|
|
62
|
-
export declare class TypstSupsub extends TypstNode {
|
|
63
|
-
base: TypstNode;
|
|
64
|
-
sup: TypstNode | null;
|
|
65
|
-
sub: TypstNode | null;
|
|
66
|
-
constructor(data: TypstSupsubData);
|
|
67
|
-
isOverHigh(): boolean;
|
|
68
|
-
}
|
|
69
|
-
export declare class TypstFuncCall extends TypstNode {
|
|
70
|
-
args: TypstNode[];
|
|
71
|
-
constructor(head: TypstToken, args: TypstNode[]);
|
|
72
|
-
isOverHigh(): boolean;
|
|
73
|
-
}
|
|
74
|
-
export declare class TypstFraction extends TypstNode {
|
|
75
|
-
args: TypstNode[];
|
|
76
|
-
constructor(args: TypstNode[]);
|
|
77
|
-
isOverHigh(): boolean;
|
|
78
|
-
}
|
|
79
|
-
export declare class TypstLeftright extends TypstNode {
|
|
80
|
-
body: TypstNode;
|
|
81
|
-
left: TypstToken | null;
|
|
82
|
-
right: TypstToken | null;
|
|
83
|
-
constructor(head: TypstToken | null, data: TypstLeftRightData);
|
|
84
|
-
isOverHigh(): boolean;
|
|
85
|
-
}
|
|
86
|
-
export declare class TypstMatrixLike extends TypstNode {
|
|
87
|
-
matrix: TypstNode[][];
|
|
88
|
-
constructor(head: TypstToken | null, data: TypstNode[][]);
|
|
89
|
-
isOverHigh(): boolean;
|
|
90
|
-
static readonly MAT: TypstToken;
|
|
91
|
-
static readonly CASES: TypstToken;
|
|
92
|
-
}
|
|
93
|
-
export declare class TypstMarkupFunc extends TypstNode {
|
|
94
|
-
fragments: TypstNode[];
|
|
95
|
-
constructor(head: TypstToken, fragments: TypstNode[]);
|
|
96
|
-
isOverHigh(): boolean;
|
|
97
|
-
}
|
package/dist/typst-writer.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { TexNode } from "./tex-types";
|
|
2
|
-
import { TypstNode } from "./typst-types";
|
|
3
|
-
import { TypstToken } from "./typst-types";
|
|
4
|
-
export declare class TypstWriterError extends Error {
|
|
5
|
-
node: TexNode | TypstNode | TypstToken;
|
|
6
|
-
constructor(message: string, node: TexNode | TypstNode | TypstToken);
|
|
7
|
-
}
|
|
8
|
-
export interface TypstWriterOptions {
|
|
9
|
-
nonStrict: boolean;
|
|
10
|
-
preferShorthands: boolean;
|
|
11
|
-
keepSpaces: boolean;
|
|
12
|
-
inftyToOo: boolean;
|
|
13
|
-
optimize: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare class TypstWriter {
|
|
16
|
-
private nonStrict;
|
|
17
|
-
private preferShorthands;
|
|
18
|
-
private keepSpaces;
|
|
19
|
-
private inftyToOo;
|
|
20
|
-
private optimize;
|
|
21
|
-
protected buffer: string;
|
|
22
|
-
protected queue: TypstToken[];
|
|
23
|
-
private insideFunctionDepth;
|
|
24
|
-
constructor(options: TypstWriterOptions);
|
|
25
|
-
private writeBuffer;
|
|
26
|
-
serialize(abstractNode: TypstNode): void;
|
|
27
|
-
private appendWithBracketsIfNeeded;
|
|
28
|
-
protected flushQueue(): void;
|
|
29
|
-
finalize(): string;
|
|
30
|
-
}
|
package/dist/util.d.ts
DELETED