1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import type { ASTNodeTypes } from "./ASTNodeTypes";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export type TxtNodeType = keyof typeof ASTNodeTypes;
|
12 |
|
13 |
|
14 |
|
15 | export type AnyTxtNode = TxtNode | TxtTextNode | TxtParentNode;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export type TxtNodePosition = {
|
23 | line: number;
|
24 | column: number;
|
25 | };
|
26 |
|
27 |
|
28 |
|
29 | export type TxtNodeLocation = {
|
30 | start: TxtNodePosition;
|
31 | end: TxtNodePosition;
|
32 | };
|
33 |
|
34 |
|
35 |
|
36 | export type TxtNodeRange = readonly [startIndex: number, endIndex: number];
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | export interface TxtNode {
|
42 | type: TxtNodeType;
|
43 | raw: string;
|
44 | range: TxtNodeRange;
|
45 | loc: TxtNodeLocation;
|
46 | parent?: TxtParentNode;
|
47 | [index: string]: any;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export interface TxtTextNode extends TxtNode {
|
55 | value: string;
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | export interface TxtParentNode extends TxtNode {
|
62 | children: Content[];
|
63 | }
|
64 | export type AlignType = "left" | "right" | "center" | null;
|
65 | export type ReferenceType = "shortcut" | "collapsed" | "full";
|
66 | export type Content = TopLevelContent | ListContent | TableContent | RowContent | PhrasingContent;
|
67 |
|
68 |
|
69 |
|
70 | export type TopLevelContent = BlockContent;
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | export type BlockContent = TxtParagraphNode | TxtHeaderNode | TxtHorizontalRuleNode | TxtBlockQuoteNode | TxtListNode | TxtTableNode | TxtHtmlNode | TxtCodeBlockNode;
|
76 |
|
77 |
|
78 |
|
79 | export type ListContent = TxtListItemNode;
|
80 |
|
81 |
|
82 |
|
83 | export type TableContent = TxtTableRowNode;
|
84 |
|
85 |
|
86 |
|
87 | export type RowContent = TxtTableCellNode;
|
88 |
|
89 |
|
90 |
|
91 | export type PhrasingContent = TxtLinkNode | StaticPhrasingContent;
|
92 |
|
93 |
|
94 |
|
95 | export type StaticPhrasingContent = TxtStrNode | TxtEmphasisNode | TxtStrongNode | TxtDeleteNode | TxtHtmlNode | TxtCodeNode | TxtBreakNode | TxtImageNode;
|
96 | export interface TxtDocumentNode extends TxtParentNode {
|
97 | type: "Document";
|
98 | }
|
99 | export interface TxtParagraphNode extends TxtParentNode {
|
100 | type: "Paragraph";
|
101 | children: PhrasingContent[];
|
102 | }
|
103 | export interface TxtHeaderNode extends TxtParentNode {
|
104 | type: "Header";
|
105 | depth: 1 | 2 | 3 | 4 | 5 | 6;
|
106 | children: PhrasingContent[];
|
107 | }
|
108 | export interface TxtHorizontalRuleNode extends TxtNode {
|
109 | type: "HorizontalRule";
|
110 | }
|
111 | export interface TxtBlockQuoteNode extends TxtParentNode {
|
112 | type: "BlockQuote";
|
113 | children: BlockContent[];
|
114 | }
|
115 | export interface TxtListNode extends TxtParentNode {
|
116 | type: "List";
|
117 | ordered?: boolean | null | undefined;
|
118 | start?: number | null | undefined;
|
119 | spread?: boolean | null | undefined;
|
120 | children: ListContent[];
|
121 | }
|
122 | export interface TxtListItemNode extends TxtParentNode {
|
123 | type: "ListItem";
|
124 | checked?: boolean | null | undefined;
|
125 | spread?: boolean | null | undefined;
|
126 | children: BlockContent[];
|
127 | }
|
128 | export interface TxtTableNode extends TxtParentNode {
|
129 | type: "Table";
|
130 | align?: AlignType[] | null | undefined;
|
131 | children: TableContent[];
|
132 | }
|
133 | export interface TxtTableRowNode extends TxtParentNode {
|
134 | type: "TableRow";
|
135 | children: RowContent[];
|
136 | }
|
137 | export interface TxtTableCellNode extends TxtParentNode {
|
138 | type: "TableCell";
|
139 | children: PhrasingContent[];
|
140 | }
|
141 | export interface TxtHtmlNode extends TxtTextNode {
|
142 | type: "Html";
|
143 | }
|
144 | export interface TxtCommentNode extends TxtTextNode {
|
145 | type: "Comment";
|
146 | }
|
147 | export interface TxtCodeBlockNode extends TxtTextNode {
|
148 | type: "CodeBlock";
|
149 | lang?: string | null | undefined;
|
150 | meta?: string | null | undefined;
|
151 | }
|
152 | export interface TxtStrNode extends TxtTextNode {
|
153 | type: "Str";
|
154 | }
|
155 | export interface TxtEmphasisNode extends TxtParentNode {
|
156 | type: "Emphasis";
|
157 | children: PhrasingContent[];
|
158 | }
|
159 | export interface TxtStrongNode extends TxtParentNode {
|
160 | type: "Strong";
|
161 | children: PhrasingContent[];
|
162 | }
|
163 | export interface TxtDeleteNode extends TxtParentNode {
|
164 | type: "Delete";
|
165 | children: PhrasingContent[];
|
166 | }
|
167 | export interface TxtCodeNode extends TxtTextNode {
|
168 | type: "Code";
|
169 | }
|
170 | export interface TxtBreakNode extends TxtNode {
|
171 | type: "Break";
|
172 | }
|
173 | export interface TxtLinkNode extends TxtParentNode, TxtResource {
|
174 | type: "Link";
|
175 | children: StaticPhrasingContent[];
|
176 | }
|
177 | export interface TxtImageNode extends TxtNode, TxtResource, TxtAlternative {
|
178 | type: "Image";
|
179 | }
|
180 | export interface TxtResource {
|
181 | url: string;
|
182 | title?: string | null | undefined;
|
183 | }
|
184 | export interface TxtAlternative {
|
185 | alt?: string | null | undefined;
|
186 | }
|
187 |
|
\ | No newline at end of file |