-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdast.d.ts
337 lines (284 loc) · 7.45 KB
/
mdast.d.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
import { Literal as UnistLiteral, Node, Parent as UnistParent } from "unist"
export type AlignType = "left" | "right" | "center" | null
export type ReferenceType = "shortcut" | "collapsed" | "full"
/**
* This map registers all node types that may be used where markdown block content is accepted.
*
* These types are accepted inside block quotes, list items, footnotes, and roots.
*
* This interface can be augmented to register custom node types.
*
* @example
* declare module 'mdast' {
* interface BlockContentMap {
* // Allow using math nodes defined by `remark-math`.
* math: Math;
* }
* }
*/
export interface BlockContentMap {
paragraph: Paragraph
heading: Heading
thematicBreak: ThematicBreak
blockquote: Blockquote
list: List
table: Table
html: HTML
code: Code
}
/**
* This map registers all frontmatter node types.
*
* This interface can be augmented to register custom node types.
*
* @example
* declare module 'mdast' {
* interface FrontmatterContentMap {
* // Allow using toml nodes defined by `remark-frontmatter`.
* toml: TOML;
* }
* }
*/
export interface FrontmatterContentMap {
yaml: YAML
}
/**
* This map registers all node definition types.
*
* This interface can be augmented to register custom node types.
*
* @example
* declare module 'mdast' {
* interface DefinitionContentMap {
* custom: Custom;
* }
* }
*/
export interface DefinitionContentMap {
definition: Definition
footnoteDefinition: FootnoteDefinition
}
/**
* This map registers all node types that are acceptable in a static phrasing context.
*
* This interface can be augmented to register custom node types in a phrasing context, including links and link
* references.
*
* @example
* declare module 'mdast' {
* interface StaticPhrasingContentMap {
* mdxJsxTextElement: MDXJSXTextElement;
* }
* }
*/
export interface StaticPhrasingContentMap {
text: Text
emphasis: Emphasis
strong: Strong
delete: Delete
html: HTML
inlineCode: InlineCode
break: Break
image: Image
imageReference: ImageReference
footnote: Footnote
footnoteReference: FootnoteReference
}
/**
* This map registers all node types that are acceptable in a (interactive) phrasing context (so not in links).
*
* This interface can be augmented to register custom node types in a phrasing context, excluding links and link
* references.
*
* @example
* declare module 'mdast' {
* interface PhrasingContentMap {
* custom: Custom;
* }
* }
*/
export interface PhrasingContentMap extends StaticPhrasingContentMap {
link: Link
linkReference: LinkReference
}
/**
* This map registers all node types that are acceptable inside lists.
*
* This interface can be augmented to register custom node types that are acceptable inside lists.
*
* @example
* declare module 'mdast' {
* interface ListContentMap {
* custom: Custom;
* }
* }
*/
export interface ListContentMap {
listItem: ListItem
}
/**
* This map registers all node types that are acceptable inside tables (not table cells).
*
* This interface can be augmented to register custom node types that are acceptable inside tables.
*
* @example
* declare module 'mdast' {
* interface TableContentMap {
* custom: Custom;
* }
* }
*/
export interface TableContentMap {
tableRow: TableRow
}
/**
* This map registers all node types that are acceptable inside tables rows (not table cells).
*
* This interface can be augmented to register custom node types that are acceptable inside table rows.
*
* @example
* declare module 'mdast' {
* interface RowContentMap {
* custom: Custom;
* }
* }
*/
export interface RowContentMap {
tableCell: TableCell
}
export type Content = TopLevelContent | ListContent | TableContent | RowContent | PhrasingContent
export type TopLevelContent = BlockContent | FrontmatterContent | DefinitionContent
export type BlockContent = BlockContentMap[keyof BlockContentMap]
export type FrontmatterContent = FrontmatterContentMap[keyof FrontmatterContentMap]
export type DefinitionContent = DefinitionContentMap[keyof DefinitionContentMap]
export type ListContent = ListContentMap[keyof ListContentMap]
export type TableContent = TableContentMap[keyof TableContentMap]
export type RowContent = RowContentMap[keyof RowContentMap]
export type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap]
export type StaticPhrasingContent = StaticPhrasingContentMap[keyof StaticPhrasingContentMap]
export interface Parent extends UnistParent {
children: Content[]
}
export interface Literal extends UnistLiteral {
value: string
}
export interface Root extends Parent {
type: "root"
}
export interface Paragraph extends Parent {
type: "paragraph"
children: PhrasingContent[]
}
export interface Heading extends Parent {
type: "heading"
depth: 1 | 2 | 3 | 4 | 5 | 6
children: PhrasingContent[]
}
export interface ThematicBreak extends Node {
type: "thematicBreak"
}
export interface Blockquote extends Parent {
type: "blockquote"
children: Array<BlockContent | DefinitionContent>
}
export interface List extends Parent {
type: "list"
ordered?: boolean | null | undefined
start?: number | null | undefined
spread?: boolean | null | undefined
children: ListContent[]
}
export interface ListItem extends Parent {
type: "listItem"
checked?: boolean | null | undefined
spread?: boolean | null | undefined
children: Array<BlockContent | DefinitionContent>
}
export interface Table extends Parent {
type: "table"
align?: AlignType[] | null | undefined
children: TableContent[]
}
export interface TableRow extends Parent {
type: "tableRow"
children: RowContent[]
}
export interface TableCell extends Parent {
type: "tableCell"
children: PhrasingContent[]
}
export interface HTML extends Literal {
type: "html"
}
export interface Code extends Literal {
type: "code"
lang?: string | null | undefined
meta?: string | null | undefined
}
export interface YAML extends Literal {
type: "yaml"
}
export interface Definition extends Node, Association, Resource {
type: "definition"
}
export interface FootnoteDefinition extends Parent, Association {
type: "footnoteDefinition"
children: Array<BlockContent | DefinitionContent>
}
export interface Text extends Literal {
type: "text"
}
export interface Emphasis extends Parent {
type: "emphasis"
children: PhrasingContent[]
}
export interface Strong extends Parent {
type: "strong"
children: PhrasingContent[]
}
export interface Delete extends Parent {
type: "delete"
children: PhrasingContent[]
}
export interface InlineCode extends Literal {
type: "inlineCode"
}
export interface Break extends Node {
type: "break"
}
export interface Link extends Parent, Resource {
type: "link"
children: StaticPhrasingContent[]
}
export interface Image extends Node, Resource, Alternative {
type: "image"
}
export interface LinkReference extends Parent, Reference {
type: "linkReference"
children: StaticPhrasingContent[]
}
export interface ImageReference extends Node, Reference, Alternative {
type: "imageReference"
}
export interface Footnote extends Parent {
type: "footnote"
children: PhrasingContent[]
}
export interface FootnoteReference extends Node, Association {
type: "footnoteReference"
}
// Mixin
export interface Resource {
url: string
title?: string | null | undefined
}
export interface Association {
identifier: string
label?: string | null | undefined
}
export interface Reference extends Association {
referenceType: ReferenceType
}
export interface Alternative {
alt?: string | null | undefined
}