-
Notifications
You must be signed in to change notification settings - Fork 48
/
types.ts
59 lines (51 loc) · 1.67 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import type { PageFrontmatter } from 'myst-frontmatter';
import type { FootnoteDefinition } from 'myst-spec-ext';
import type { VFile } from 'vfile';
export const DEFAULT_IMAGE_WIDTH = 0.7;
export const DEFAULT_PAGE_WIDTH_PIXELS = 800;
export type Handler = (node: any, state: ITypstSerializer, parent: any) => void;
export type TypstResult = {
value: string;
macros: string[];
commands: Record<string, string>;
};
export type MathPlugins = Required<PageFrontmatter>['math'];
export type Options = {
handlers?: Record<string, Handler>;
math?: MathPlugins;
};
export type StateData = {
tableColumns?: number;
isInFigure?: boolean;
isInTable?: boolean;
longFigure?: boolean;
definitionIndent?: number;
nextCaptionNumbered?: boolean;
nextHeadingIsFrameTitle?: boolean;
nextCaptionId?: string;
mathPlugins: Required<PageFrontmatter>['math'];
macros: Set<string>;
list?: {
env: string[];
};
};
export type RenderChildrenOptions = { delim?: string; trimEnd?: boolean };
export interface ITypstSerializer<D extends Record<string, any> = StateData> {
file: VFile;
data: D;
options: Options;
footnotes: Record<string, FootnoteDefinition>;
useMacro: (macro: string) => void;
write: (value: string) => void;
text: (value: string, mathMode?: boolean) => void;
trimEnd: () => void;
ensureNewLine: (trim?: boolean) => void;
addNewLine: () => void;
renderChildren: (node: any, trailingNewLines?: number, opts?: RenderChildrenOptions) => void;
renderInlineEnvironment: (node: any, env: string, opts?: { after?: string }) => void;
renderEnvironment: (
node: any,
env: string,
opts?: { parameters?: string; arguments?: string[] },
) => void;
}