@isdk/mdast-plus 0.1.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/README.cn.md +109 -0
- package/README.md +109 -0
- package/dist/index.d.mts +1363 -0
- package/dist/index.d.ts +1363 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/docs/README.md +113 -0
- package/docs/_media/CONTRIBUTING.md +108 -0
- package/docs/_media/LICENSE-MIT +22 -0
- package/docs/_media/README.cn.md +109 -0
- package/docs/classes/FluentProcessor.md +194 -0
- package/docs/functions/htmlFormat.md +24 -0
- package/docs/functions/markdownFormat.md +24 -0
- package/docs/functions/mdast.md +27 -0
- package/docs/globals.md +33 -0
- package/docs/interfaces/ConvertResult.md +39 -0
- package/docs/interfaces/MdastAsset.md +41 -0
- package/docs/interfaces/MdastDataOrigin.md +45 -0
- package/docs/interfaces/MdastFormatDefinition.md +51 -0
- package/docs/interfaces/MdastMark.md +74 -0
- package/docs/interfaces/MdastPlugin.md +65 -0
- package/docs/interfaces/MdastReader.md +41 -0
- package/docs/interfaces/MdastSub.md +74 -0
- package/docs/interfaces/MdastSup.md +74 -0
- package/docs/interfaces/MdastTransformer.md +33 -0
- package/docs/interfaces/MdastWriter.md +47 -0
- package/docs/type-aliases/Stage.md +13 -0
- package/package.json +112 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1363 @@
|
|
|
1
|
+
// ## Interfaces
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Info associated with nodes by the ecosystem.
|
|
5
|
+
*
|
|
6
|
+
* This space is guaranteed to never be specified by unist or specifications
|
|
7
|
+
* implementing unist.
|
|
8
|
+
* But you can use it in utilities and plugins to store data.
|
|
9
|
+
*
|
|
10
|
+
* This type can be augmented to register custom data.
|
|
11
|
+
* For example:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* declare module 'unist' {
|
|
15
|
+
* interface Data {
|
|
16
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
17
|
+
* myId?: number | undefined
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface Data$1 {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One place in a source file.
|
|
26
|
+
*/
|
|
27
|
+
interface Point {
|
|
28
|
+
/**
|
|
29
|
+
* Line in a source file (1-indexed integer).
|
|
30
|
+
*/
|
|
31
|
+
line: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Column in a source file (1-indexed integer).
|
|
35
|
+
*/
|
|
36
|
+
column: number;
|
|
37
|
+
/**
|
|
38
|
+
* Character in a source file (0-indexed integer).
|
|
39
|
+
*/
|
|
40
|
+
offset?: number | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Position of a node in a source document.
|
|
45
|
+
*
|
|
46
|
+
* A position is a range between two points.
|
|
47
|
+
*/
|
|
48
|
+
interface Position {
|
|
49
|
+
/**
|
|
50
|
+
* Place of the first character of the parsed source region.
|
|
51
|
+
*/
|
|
52
|
+
start: Point;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Place of the first character after the parsed source region.
|
|
56
|
+
*/
|
|
57
|
+
end: Point;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Abstract unist node.
|
|
62
|
+
*
|
|
63
|
+
* The syntactic unit in unist syntax trees are called nodes.
|
|
64
|
+
*
|
|
65
|
+
* This interface is supposed to be extended.
|
|
66
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
67
|
+
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
68
|
+
* nor parent, but still a node.
|
|
69
|
+
*/
|
|
70
|
+
interface Node$1 {
|
|
71
|
+
/**
|
|
72
|
+
* Node type.
|
|
73
|
+
*/
|
|
74
|
+
type: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Info from the ecosystem.
|
|
78
|
+
*/
|
|
79
|
+
data?: Data$1 | undefined;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Position of a node in a source document.
|
|
83
|
+
*
|
|
84
|
+
* Nodes that are generated (not in the original source document) must not
|
|
85
|
+
* have a position.
|
|
86
|
+
*/
|
|
87
|
+
position?: Position | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Abstract unist node that contains other nodes (*children*).
|
|
92
|
+
*
|
|
93
|
+
* This interface is supposed to be extended.
|
|
94
|
+
*
|
|
95
|
+
* For example, in XML, an element is a parent of different things, such as
|
|
96
|
+
* comments, text, and further elements.
|
|
97
|
+
*/
|
|
98
|
+
interface Parent$1 extends Node$1 {
|
|
99
|
+
/**
|
|
100
|
+
* List of children.
|
|
101
|
+
*/
|
|
102
|
+
children: Node$1[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ## Enumeration
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* How phrasing content is aligned
|
|
109
|
+
* ({@link https://drafts.csswg.org/css-text/ | [CSSTEXT]}).
|
|
110
|
+
*
|
|
111
|
+
* * `'left'`: See the
|
|
112
|
+
* {@link https://drafts.csswg.org/css-text/#valdef-text-align-left | left}
|
|
113
|
+
* value of the `text-align` CSS property
|
|
114
|
+
* * `'right'`: See the
|
|
115
|
+
* {@link https://drafts.csswg.org/css-text/#valdef-text-align-right | right}
|
|
116
|
+
* value of the `text-align` CSS property
|
|
117
|
+
* * `'center'`: See the
|
|
118
|
+
* {@link https://drafts.csswg.org/css-text/#valdef-text-align-center | center}
|
|
119
|
+
* value of the `text-align` CSS property
|
|
120
|
+
* * `null`: phrasing content is aligned as defined by the host environment
|
|
121
|
+
*
|
|
122
|
+
* Used in GFM tables.
|
|
123
|
+
*/
|
|
124
|
+
type AlignType = "center" | "left" | "right" | null;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Explicitness of a reference.
|
|
128
|
+
*
|
|
129
|
+
* `'shortcut'`: the reference is implicit, its identifier inferred from its
|
|
130
|
+
* content
|
|
131
|
+
* `'collapsed'`: the reference is explicit, its identifier inferred from its
|
|
132
|
+
* content
|
|
133
|
+
* `'full'`: the reference is explicit, its identifier explicitly set
|
|
134
|
+
*/
|
|
135
|
+
type ReferenceType = "shortcut" | "collapsed" | "full";
|
|
136
|
+
|
|
137
|
+
// ## Mixin
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Node with a fallback.
|
|
141
|
+
*/
|
|
142
|
+
interface Alternative {
|
|
143
|
+
/**
|
|
144
|
+
* Equivalent content for environments that cannot represent the node as
|
|
145
|
+
* intended.
|
|
146
|
+
*/
|
|
147
|
+
alt?: string | null | undefined;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Internal relation from one node to another.
|
|
152
|
+
*
|
|
153
|
+
* Whether the value of `identifier` is expected to be a unique identifier or
|
|
154
|
+
* not depends on the type of node including the Association.
|
|
155
|
+
* An example of this is that they should be unique on {@link Definition},
|
|
156
|
+
* whereas multiple {@link LinkReference}s can be non-unique to be associated
|
|
157
|
+
* with one definition.
|
|
158
|
+
*/
|
|
159
|
+
interface Association {
|
|
160
|
+
/**
|
|
161
|
+
* Relation of association.
|
|
162
|
+
*
|
|
163
|
+
* `identifier` is a source value: character escapes and character
|
|
164
|
+
* references are not parsed.
|
|
165
|
+
*
|
|
166
|
+
* It can match another node.
|
|
167
|
+
*
|
|
168
|
+
* Its value must be normalized.
|
|
169
|
+
* To normalize a value, collapse markdown whitespace (`[\t\n\r ]+`) to a space,
|
|
170
|
+
* trim the optional initial and/or final space, and perform Unicode-aware
|
|
171
|
+
* case-folding.
|
|
172
|
+
*/
|
|
173
|
+
identifier: string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Relation of association, in parsed form.
|
|
177
|
+
*
|
|
178
|
+
* `label` is a `string` value: it works just like `title` on {@link Link}
|
|
179
|
+
* or a `lang` on {@link Code}: character escapes and character references
|
|
180
|
+
* are parsed.
|
|
181
|
+
*
|
|
182
|
+
* It can match another node.
|
|
183
|
+
*/
|
|
184
|
+
label?: string | null | undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Marker that is associated to another node.
|
|
189
|
+
*/
|
|
190
|
+
interface Reference extends Association {
|
|
191
|
+
/**
|
|
192
|
+
* Explicitness of the reference.
|
|
193
|
+
*/
|
|
194
|
+
referenceType: ReferenceType;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Reference to resource.
|
|
199
|
+
*/
|
|
200
|
+
interface Resource {
|
|
201
|
+
/**
|
|
202
|
+
* URL to the referenced resource.
|
|
203
|
+
*/
|
|
204
|
+
url: string;
|
|
205
|
+
/**
|
|
206
|
+
* Advisory information for the resource, such as would be appropriate for
|
|
207
|
+
* a tooltip.
|
|
208
|
+
*/
|
|
209
|
+
title?: string | null | undefined;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ## Interfaces
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Info associated with mdast nodes by the ecosystem.
|
|
216
|
+
*
|
|
217
|
+
* This space is guaranteed to never be specified by unist or mdast.
|
|
218
|
+
* But you can use it in utilities and plugins to store data.
|
|
219
|
+
*
|
|
220
|
+
* This type can be augmented to register custom data.
|
|
221
|
+
* For example:
|
|
222
|
+
*
|
|
223
|
+
* ```ts
|
|
224
|
+
* declare module 'mdast' {
|
|
225
|
+
* interface Data {
|
|
226
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
227
|
+
* myId?: number | undefined
|
|
228
|
+
* }
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
interface Data extends Data$1 {}
|
|
233
|
+
|
|
234
|
+
// ## Content maps
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Union of registered mdast nodes that can occur where block content is
|
|
238
|
+
* expected.
|
|
239
|
+
*
|
|
240
|
+
* To register custom mdast nodes, add them to {@link BlockContentMap}.
|
|
241
|
+
* They will be automatically added here.
|
|
242
|
+
*/
|
|
243
|
+
type BlockContent = BlockContentMap[keyof BlockContentMap];
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Registry of all mdast nodes that can occur where {@link BlockContent} is
|
|
247
|
+
* expected.
|
|
248
|
+
*
|
|
249
|
+
* This interface can be augmented to register custom node types:
|
|
250
|
+
*
|
|
251
|
+
* ```ts
|
|
252
|
+
* declare module 'mdast' {
|
|
253
|
+
* interface BlockContentMap {
|
|
254
|
+
* // Allow using MDX ESM nodes defined by `remark-mdx`.
|
|
255
|
+
* mdxjsEsm: MdxjsEsm;
|
|
256
|
+
* }
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* For a union of all block content, see {@link RootContent}.
|
|
261
|
+
*/
|
|
262
|
+
interface BlockContentMap {
|
|
263
|
+
blockquote: Blockquote;
|
|
264
|
+
code: Code;
|
|
265
|
+
heading: Heading;
|
|
266
|
+
html: Html;
|
|
267
|
+
list: List;
|
|
268
|
+
paragraph: Paragraph;
|
|
269
|
+
table: Table;
|
|
270
|
+
thematicBreak: ThematicBreak;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Union of registered mdast nodes that can occur where definition content is
|
|
275
|
+
* expected.
|
|
276
|
+
*
|
|
277
|
+
* To register custom mdast nodes, add them to {@link DefinitionContentMap}.
|
|
278
|
+
* They will be automatically added here.
|
|
279
|
+
*/
|
|
280
|
+
type DefinitionContent = DefinitionContentMap[keyof DefinitionContentMap];
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Registry of all mdast nodes that can occur where {@link DefinitionContent}
|
|
284
|
+
* is expected.
|
|
285
|
+
*
|
|
286
|
+
* This interface can be augmented to register custom node types:
|
|
287
|
+
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* declare module 'mdast' {
|
|
290
|
+
* interface DefinitionContentMap {
|
|
291
|
+
* custom: Custom;
|
|
292
|
+
* }
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* For a union of all definition content, see {@link RootContent}.
|
|
297
|
+
*/
|
|
298
|
+
interface DefinitionContentMap {
|
|
299
|
+
definition: Definition;
|
|
300
|
+
footnoteDefinition: FootnoteDefinition;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Union of registered mdast nodes that can occur where list content is
|
|
305
|
+
* expected.
|
|
306
|
+
*
|
|
307
|
+
* To register custom mdast nodes, add them to {@link ListContentMap}.
|
|
308
|
+
* They will be automatically added here.
|
|
309
|
+
*/
|
|
310
|
+
type ListContent = ListContentMap[keyof ListContentMap];
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Registry of all mdast nodes that can occur where {@link ListContent}
|
|
314
|
+
* is expected.
|
|
315
|
+
*
|
|
316
|
+
* This interface can be augmented to register custom node types:
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* declare module 'mdast' {
|
|
320
|
+
* interface ListContentMap {
|
|
321
|
+
* custom: Custom;
|
|
322
|
+
* }
|
|
323
|
+
* }
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* For a union of all list content, see {@link RootContent}.
|
|
327
|
+
*/
|
|
328
|
+
interface ListContentMap {
|
|
329
|
+
listItem: ListItem;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Union of registered mdast nodes that can occur where phrasing content is
|
|
334
|
+
* expected.
|
|
335
|
+
*
|
|
336
|
+
* To register custom mdast nodes, add them to {@link PhrasingContentMap}.
|
|
337
|
+
* They will be automatically added here.
|
|
338
|
+
*/
|
|
339
|
+
type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap];
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Registry of all mdast nodes that can occur where {@link PhrasingContent}
|
|
343
|
+
* is expected.
|
|
344
|
+
*
|
|
345
|
+
* This interface can be augmented to register custom node types:
|
|
346
|
+
*
|
|
347
|
+
* ```ts
|
|
348
|
+
* declare module 'mdast' {
|
|
349
|
+
* interface PhrasingContentMap {
|
|
350
|
+
* // Allow using MDX JSX (text) nodes defined by `remark-mdx`.
|
|
351
|
+
* mdxJsxTextElement: MDXJSXTextElement;
|
|
352
|
+
* }
|
|
353
|
+
* }
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* For a union of all phrasing content, see {@link RootContent}.
|
|
357
|
+
*/
|
|
358
|
+
interface PhrasingContentMap {
|
|
359
|
+
break: Break;
|
|
360
|
+
delete: Delete;
|
|
361
|
+
emphasis: Emphasis;
|
|
362
|
+
footnoteReference: FootnoteReference;
|
|
363
|
+
html: Html;
|
|
364
|
+
image: Image;
|
|
365
|
+
imageReference: ImageReference;
|
|
366
|
+
inlineCode: InlineCode;
|
|
367
|
+
link: Link;
|
|
368
|
+
linkReference: LinkReference;
|
|
369
|
+
strong: Strong;
|
|
370
|
+
text: Text;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Union of registered mdast nodes that can occur in {@link Root}.
|
|
375
|
+
*
|
|
376
|
+
* To register custom mdast nodes, add them to {@link RootContentMap}.
|
|
377
|
+
* They will be automatically added here.
|
|
378
|
+
*/
|
|
379
|
+
type RootContent = RootContentMap[keyof RootContentMap];
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Registry of all mdast nodes that can occur as children of {@link Root}.
|
|
383
|
+
*
|
|
384
|
+
* > **Note**: {@link Root} does not need to be an entire document.
|
|
385
|
+
* > it can also be a fragment.
|
|
386
|
+
*
|
|
387
|
+
* This interface can be augmented to register custom node types:
|
|
388
|
+
*
|
|
389
|
+
* ```ts
|
|
390
|
+
* declare module 'mdast' {
|
|
391
|
+
* interface RootContentMap {
|
|
392
|
+
* // Allow using toml nodes defined by `remark-frontmatter`.
|
|
393
|
+
* toml: TOML;
|
|
394
|
+
* }
|
|
395
|
+
* }
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
399
|
+
*/
|
|
400
|
+
interface RootContentMap {
|
|
401
|
+
blockquote: Blockquote;
|
|
402
|
+
break: Break;
|
|
403
|
+
code: Code;
|
|
404
|
+
definition: Definition;
|
|
405
|
+
delete: Delete;
|
|
406
|
+
emphasis: Emphasis;
|
|
407
|
+
footnoteDefinition: FootnoteDefinition;
|
|
408
|
+
footnoteReference: FootnoteReference;
|
|
409
|
+
heading: Heading;
|
|
410
|
+
html: Html;
|
|
411
|
+
image: Image;
|
|
412
|
+
imageReference: ImageReference;
|
|
413
|
+
inlineCode: InlineCode;
|
|
414
|
+
link: Link;
|
|
415
|
+
linkReference: LinkReference;
|
|
416
|
+
list: List;
|
|
417
|
+
listItem: ListItem;
|
|
418
|
+
paragraph: Paragraph;
|
|
419
|
+
strong: Strong;
|
|
420
|
+
table: Table;
|
|
421
|
+
tableCell: TableCell;
|
|
422
|
+
tableRow: TableRow;
|
|
423
|
+
text: Text;
|
|
424
|
+
thematicBreak: ThematicBreak;
|
|
425
|
+
yaml: Yaml;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Union of registered mdast nodes that can occur where row content is
|
|
430
|
+
* expected.
|
|
431
|
+
*
|
|
432
|
+
* To register custom mdast nodes, add them to {@link RowContentMap}.
|
|
433
|
+
* They will be automatically added here.
|
|
434
|
+
*/
|
|
435
|
+
type RowContent = RowContentMap[keyof RowContentMap];
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Registry of all mdast nodes that can occur where {@link RowContent}
|
|
439
|
+
* is expected.
|
|
440
|
+
*
|
|
441
|
+
* This interface can be augmented to register custom node types:
|
|
442
|
+
*
|
|
443
|
+
* ```ts
|
|
444
|
+
* declare module 'mdast' {
|
|
445
|
+
* interface RowContentMap {
|
|
446
|
+
* custom: Custom;
|
|
447
|
+
* }
|
|
448
|
+
* }
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* For a union of all row content, see {@link RootContent}.
|
|
452
|
+
*/
|
|
453
|
+
interface RowContentMap {
|
|
454
|
+
tableCell: TableCell;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Union of registered mdast nodes that can occur where table content is
|
|
459
|
+
* expected.
|
|
460
|
+
*
|
|
461
|
+
* To register custom mdast nodes, add them to {@link TableContentMap}.
|
|
462
|
+
* They will be automatically added here.
|
|
463
|
+
*/
|
|
464
|
+
type TableContent = TableContentMap[keyof TableContentMap];
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Registry of all mdast nodes that can occur where {@link TableContent}
|
|
468
|
+
* is expected.
|
|
469
|
+
*
|
|
470
|
+
* This interface can be augmented to register custom node types:
|
|
471
|
+
*
|
|
472
|
+
* ```ts
|
|
473
|
+
* declare module 'mdast' {
|
|
474
|
+
* interface TableContentMap {
|
|
475
|
+
* custom: Custom;
|
|
476
|
+
* }
|
|
477
|
+
* }
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* For a union of all table content, see {@link RootContent}.
|
|
481
|
+
*/
|
|
482
|
+
interface TableContentMap {
|
|
483
|
+
tableRow: TableRow;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ## Abstract nodes
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Abstract mdast node that contains the smallest possible value.
|
|
490
|
+
*
|
|
491
|
+
* This interface is supposed to be extended if you make custom mdast nodes.
|
|
492
|
+
*
|
|
493
|
+
* For a union of all registered mdast literals, see {@link Literals}.
|
|
494
|
+
*/
|
|
495
|
+
interface Literal extends Node {
|
|
496
|
+
/**
|
|
497
|
+
* Plain-text value.
|
|
498
|
+
*/
|
|
499
|
+
value: string;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Abstract mdast node.
|
|
504
|
+
*
|
|
505
|
+
* This interface is supposed to be extended.
|
|
506
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
507
|
+
* But for example in markdown, a thematic break (`***`) is neither literal nor
|
|
508
|
+
* parent, but still a node.
|
|
509
|
+
*
|
|
510
|
+
* To register custom mdast nodes, add them to {@link RootContentMap} and other
|
|
511
|
+
* places where relevant (such as {@link ElementContentMap}).
|
|
512
|
+
*
|
|
513
|
+
* For a union of all registered mdast nodes, see {@link Nodes}.
|
|
514
|
+
*/
|
|
515
|
+
interface Node extends Node$1 {
|
|
516
|
+
/**
|
|
517
|
+
* Info from the ecosystem.
|
|
518
|
+
*/
|
|
519
|
+
data?: Data | undefined;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Abstract mdast node that contains other mdast nodes (*children*).
|
|
524
|
+
*
|
|
525
|
+
* This interface is supposed to be extended if you make custom mdast nodes.
|
|
526
|
+
*
|
|
527
|
+
* For a union of all registered mdast parents, see {@link Parents}.
|
|
528
|
+
*/
|
|
529
|
+
interface Parent extends Node {
|
|
530
|
+
/**
|
|
531
|
+
* List of children.
|
|
532
|
+
*/
|
|
533
|
+
children: RootContent[];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// ## Concrete nodes
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Markdown block quote.
|
|
540
|
+
*/
|
|
541
|
+
interface Blockquote extends Parent {
|
|
542
|
+
/**
|
|
543
|
+
* Node type of mdast block quote.
|
|
544
|
+
*/
|
|
545
|
+
type: "blockquote";
|
|
546
|
+
/**
|
|
547
|
+
* Children of block quote.
|
|
548
|
+
*/
|
|
549
|
+
children: Array<BlockContent | DefinitionContent>;
|
|
550
|
+
/**
|
|
551
|
+
* Data associated with the mdast block quote.
|
|
552
|
+
*/
|
|
553
|
+
data?: BlockquoteData | undefined;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Info associated with mdast block quote nodes by the ecosystem.
|
|
558
|
+
*/
|
|
559
|
+
interface BlockquoteData extends Data {}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Markdown break.
|
|
563
|
+
*/
|
|
564
|
+
interface Break extends Node {
|
|
565
|
+
/**
|
|
566
|
+
* Node type of mdast break.
|
|
567
|
+
*/
|
|
568
|
+
type: "break";
|
|
569
|
+
/**
|
|
570
|
+
* Data associated with the mdast break.
|
|
571
|
+
*/
|
|
572
|
+
data?: BreakData | undefined;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Info associated with mdast break nodes by the ecosystem.
|
|
577
|
+
*/
|
|
578
|
+
interface BreakData extends Data {}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Markdown code (flow) (block).
|
|
582
|
+
*/
|
|
583
|
+
interface Code extends Literal {
|
|
584
|
+
/**
|
|
585
|
+
* Node type of mdast code (flow).
|
|
586
|
+
*/
|
|
587
|
+
type: "code";
|
|
588
|
+
/**
|
|
589
|
+
* Language of computer code being marked up.
|
|
590
|
+
*/
|
|
591
|
+
lang?: string | null | undefined;
|
|
592
|
+
/**
|
|
593
|
+
* Custom information relating to the node.
|
|
594
|
+
*
|
|
595
|
+
* If the lang field is present, a meta field can be present.
|
|
596
|
+
*/
|
|
597
|
+
meta?: string | null | undefined;
|
|
598
|
+
/**
|
|
599
|
+
* Data associated with the mdast code (flow).
|
|
600
|
+
*/
|
|
601
|
+
data?: CodeData | undefined;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Info associated with mdast code (flow) (block) nodes by the ecosystem.
|
|
606
|
+
*/
|
|
607
|
+
interface CodeData extends Data {}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Markdown definition.
|
|
611
|
+
*/
|
|
612
|
+
interface Definition extends Node, Association, Resource {
|
|
613
|
+
/**
|
|
614
|
+
* Node type of mdast definition.
|
|
615
|
+
*/
|
|
616
|
+
type: "definition";
|
|
617
|
+
/**
|
|
618
|
+
* Data associated with the mdast definition.
|
|
619
|
+
*/
|
|
620
|
+
data?: DefinitionData | undefined;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Info associated with mdast definition nodes by the ecosystem.
|
|
625
|
+
*/
|
|
626
|
+
interface DefinitionData extends Data {}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Markdown GFM delete (strikethrough).
|
|
630
|
+
*/
|
|
631
|
+
interface Delete extends Parent {
|
|
632
|
+
/**
|
|
633
|
+
* Node type of mdast GFM delete.
|
|
634
|
+
*/
|
|
635
|
+
type: "delete";
|
|
636
|
+
/**
|
|
637
|
+
* Children of GFM delete.
|
|
638
|
+
*/
|
|
639
|
+
children: PhrasingContent[];
|
|
640
|
+
/**
|
|
641
|
+
* Data associated with the mdast GFM delete.
|
|
642
|
+
*/
|
|
643
|
+
data?: DeleteData | undefined;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Info associated with mdast GFM delete nodes by the ecosystem.
|
|
648
|
+
*/
|
|
649
|
+
interface DeleteData extends Data {}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Markdown emphasis.
|
|
653
|
+
*/
|
|
654
|
+
interface Emphasis extends Parent {
|
|
655
|
+
/**
|
|
656
|
+
* Node type of mdast emphasis.
|
|
657
|
+
*/
|
|
658
|
+
type: "emphasis";
|
|
659
|
+
/**
|
|
660
|
+
* Children of emphasis.
|
|
661
|
+
*/
|
|
662
|
+
children: PhrasingContent[];
|
|
663
|
+
/**
|
|
664
|
+
* Data associated with the mdast emphasis.
|
|
665
|
+
*/
|
|
666
|
+
data?: EmphasisData | undefined;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Info associated with mdast emphasis nodes by the ecosystem.
|
|
671
|
+
*/
|
|
672
|
+
interface EmphasisData extends Data {}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Markdown GFM footnote definition.
|
|
676
|
+
*/
|
|
677
|
+
interface FootnoteDefinition extends Parent, Association {
|
|
678
|
+
/**
|
|
679
|
+
* Node type of mdast GFM footnote definition.
|
|
680
|
+
*/
|
|
681
|
+
type: "footnoteDefinition";
|
|
682
|
+
/**
|
|
683
|
+
* Children of GFM footnote definition.
|
|
684
|
+
*/
|
|
685
|
+
children: Array<BlockContent | DefinitionContent>;
|
|
686
|
+
/**
|
|
687
|
+
* Data associated with the mdast GFM footnote definition.
|
|
688
|
+
*/
|
|
689
|
+
data?: FootnoteDefinitionData | undefined;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Info associated with mdast GFM footnote definition nodes by the ecosystem.
|
|
694
|
+
*/
|
|
695
|
+
interface FootnoteDefinitionData extends Data {}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Markdown GFM footnote reference.
|
|
699
|
+
*/
|
|
700
|
+
interface FootnoteReference extends Association, Node {
|
|
701
|
+
/**
|
|
702
|
+
* Node type of mdast GFM footnote reference.
|
|
703
|
+
*/
|
|
704
|
+
type: "footnoteReference";
|
|
705
|
+
/**
|
|
706
|
+
* Data associated with the mdast GFM footnote reference.
|
|
707
|
+
*/
|
|
708
|
+
data?: FootnoteReferenceData | undefined;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Info associated with mdast GFM footnote reference nodes by the ecosystem.
|
|
713
|
+
*/
|
|
714
|
+
interface FootnoteReferenceData extends Data {}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Markdown heading.
|
|
718
|
+
*/
|
|
719
|
+
interface Heading extends Parent {
|
|
720
|
+
/**
|
|
721
|
+
* Node type of mdast heading.
|
|
722
|
+
*/
|
|
723
|
+
type: "heading";
|
|
724
|
+
/**
|
|
725
|
+
* Heading rank.
|
|
726
|
+
*
|
|
727
|
+
* A value of `1` is said to be the highest rank and `6` the lowest.
|
|
728
|
+
*/
|
|
729
|
+
depth: 1 | 2 | 3 | 4 | 5 | 6;
|
|
730
|
+
/**
|
|
731
|
+
* Children of heading.
|
|
732
|
+
*/
|
|
733
|
+
children: PhrasingContent[];
|
|
734
|
+
/**
|
|
735
|
+
* Data associated with the mdast heading.
|
|
736
|
+
*/
|
|
737
|
+
data?: HeadingData | undefined;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Info associated with mdast heading nodes by the ecosystem.
|
|
742
|
+
*/
|
|
743
|
+
interface HeadingData extends Data {}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Markdown HTML.
|
|
747
|
+
*/
|
|
748
|
+
interface Html extends Literal {
|
|
749
|
+
/**
|
|
750
|
+
* Node type of mdast HTML.
|
|
751
|
+
*/
|
|
752
|
+
type: "html";
|
|
753
|
+
/**
|
|
754
|
+
* Data associated with the mdast HTML.
|
|
755
|
+
*/
|
|
756
|
+
data?: HtmlData | undefined;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Info associated with mdast HTML nodes by the ecosystem.
|
|
761
|
+
*/
|
|
762
|
+
interface HtmlData extends Data {}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Markdown image.
|
|
766
|
+
*/
|
|
767
|
+
interface Image extends Alternative, Node, Resource {
|
|
768
|
+
/**
|
|
769
|
+
* Node type of mdast image.
|
|
770
|
+
*/
|
|
771
|
+
type: "image";
|
|
772
|
+
/**
|
|
773
|
+
* Data associated with the mdast image.
|
|
774
|
+
*/
|
|
775
|
+
data?: ImageData | undefined;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Info associated with mdast image nodes by the ecosystem.
|
|
780
|
+
*/
|
|
781
|
+
interface ImageData extends Data {}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Markdown image reference.
|
|
785
|
+
*/
|
|
786
|
+
interface ImageReference extends Alternative, Node, Reference {
|
|
787
|
+
/**
|
|
788
|
+
* Node type of mdast image reference.
|
|
789
|
+
*/
|
|
790
|
+
type: "imageReference";
|
|
791
|
+
/**
|
|
792
|
+
* Data associated with the mdast image reference.
|
|
793
|
+
*/
|
|
794
|
+
data?: ImageReferenceData | undefined;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Info associated with mdast image reference nodes by the ecosystem.
|
|
799
|
+
*/
|
|
800
|
+
interface ImageReferenceData extends Data {}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Markdown code (text) (inline).
|
|
804
|
+
*/
|
|
805
|
+
interface InlineCode extends Literal {
|
|
806
|
+
/**
|
|
807
|
+
* Node type of mdast code (text).
|
|
808
|
+
*/
|
|
809
|
+
type: "inlineCode";
|
|
810
|
+
/**
|
|
811
|
+
* Data associated with the mdast code (text).
|
|
812
|
+
*/
|
|
813
|
+
data?: InlineCodeData | undefined;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Info associated with mdast code (text) (inline) nodes by the ecosystem.
|
|
818
|
+
*/
|
|
819
|
+
interface InlineCodeData extends Data {}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Markdown link.
|
|
823
|
+
*/
|
|
824
|
+
interface Link extends Parent, Resource {
|
|
825
|
+
/**
|
|
826
|
+
* Node type of mdast link.
|
|
827
|
+
*/
|
|
828
|
+
type: "link";
|
|
829
|
+
/**
|
|
830
|
+
* Children of link.
|
|
831
|
+
*/
|
|
832
|
+
children: PhrasingContent[];
|
|
833
|
+
/**
|
|
834
|
+
* Data associated with the mdast link.
|
|
835
|
+
*/
|
|
836
|
+
data?: LinkData | undefined;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Info associated with mdast link nodes by the ecosystem.
|
|
841
|
+
*/
|
|
842
|
+
interface LinkData extends Data {}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Markdown link reference.
|
|
846
|
+
*/
|
|
847
|
+
interface LinkReference extends Parent, Reference {
|
|
848
|
+
/**
|
|
849
|
+
* Node type of mdast link reference.
|
|
850
|
+
*/
|
|
851
|
+
type: "linkReference";
|
|
852
|
+
/**
|
|
853
|
+
* Children of link reference.
|
|
854
|
+
*/
|
|
855
|
+
children: PhrasingContent[];
|
|
856
|
+
/**
|
|
857
|
+
* Data associated with the mdast link reference.
|
|
858
|
+
*/
|
|
859
|
+
data?: LinkReferenceData | undefined;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Info associated with mdast link reference nodes by the ecosystem.
|
|
864
|
+
*/
|
|
865
|
+
interface LinkReferenceData extends Data {}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Markdown list.
|
|
869
|
+
*/
|
|
870
|
+
interface List extends Parent {
|
|
871
|
+
/**
|
|
872
|
+
* Node type of mdast list.
|
|
873
|
+
*/
|
|
874
|
+
type: "list";
|
|
875
|
+
/**
|
|
876
|
+
* Whether the items have been intentionally ordered (when `true`), or that
|
|
877
|
+
* the order of items is not important (when `false` or not present).
|
|
878
|
+
*/
|
|
879
|
+
ordered?: boolean | null | undefined;
|
|
880
|
+
/**
|
|
881
|
+
* The starting number of the list, when the `ordered` field is `true`.
|
|
882
|
+
*/
|
|
883
|
+
start?: number | null | undefined;
|
|
884
|
+
/**
|
|
885
|
+
* Whether one or more of the children are separated with a blank line from
|
|
886
|
+
* its siblings (when `true`), or not (when `false` or not present).
|
|
887
|
+
*/
|
|
888
|
+
spread?: boolean | null | undefined;
|
|
889
|
+
/**
|
|
890
|
+
* Children of list.
|
|
891
|
+
*/
|
|
892
|
+
children: ListContent[];
|
|
893
|
+
/**
|
|
894
|
+
* Data associated with the mdast list.
|
|
895
|
+
*/
|
|
896
|
+
data?: ListData | undefined;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Info associated with mdast list nodes by the ecosystem.
|
|
901
|
+
*/
|
|
902
|
+
interface ListData extends Data {}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Markdown list item.
|
|
906
|
+
*/
|
|
907
|
+
interface ListItem extends Parent {
|
|
908
|
+
/**
|
|
909
|
+
* Node type of mdast list item.
|
|
910
|
+
*/
|
|
911
|
+
type: "listItem";
|
|
912
|
+
/**
|
|
913
|
+
* Whether the item is a tasklist item (when `boolean`).
|
|
914
|
+
*
|
|
915
|
+
* When `true`, the item is complete.
|
|
916
|
+
* When `false`, the item is incomplete.
|
|
917
|
+
*/
|
|
918
|
+
checked?: boolean | null | undefined;
|
|
919
|
+
/**
|
|
920
|
+
* Whether one or more of the children are separated with a blank line from
|
|
921
|
+
* its siblings (when `true`), or not (when `false` or not present).
|
|
922
|
+
*/
|
|
923
|
+
spread?: boolean | null | undefined;
|
|
924
|
+
/**
|
|
925
|
+
* Children of list item.
|
|
926
|
+
*/
|
|
927
|
+
children: Array<BlockContent | DefinitionContent>;
|
|
928
|
+
/**
|
|
929
|
+
* Data associated with the mdast list item.
|
|
930
|
+
*/
|
|
931
|
+
data?: ListItemData | undefined;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Info associated with mdast list item nodes by the ecosystem.
|
|
936
|
+
*/
|
|
937
|
+
interface ListItemData extends Data {}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Markdown paragraph.
|
|
941
|
+
*/
|
|
942
|
+
interface Paragraph extends Parent {
|
|
943
|
+
/**
|
|
944
|
+
* Node type of mdast paragraph.
|
|
945
|
+
*/
|
|
946
|
+
type: "paragraph";
|
|
947
|
+
/**
|
|
948
|
+
* Children of paragraph.
|
|
949
|
+
*/
|
|
950
|
+
children: PhrasingContent[];
|
|
951
|
+
/**
|
|
952
|
+
* Data associated with the mdast paragraph.
|
|
953
|
+
*/
|
|
954
|
+
data?: ParagraphData | undefined;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Info associated with mdast paragraph nodes by the ecosystem.
|
|
959
|
+
*/
|
|
960
|
+
interface ParagraphData extends Data {}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Document fragment or a whole document.
|
|
964
|
+
*
|
|
965
|
+
* Should be used as the root of a tree and must not be used as a child.
|
|
966
|
+
*/
|
|
967
|
+
interface Root extends Parent {
|
|
968
|
+
/**
|
|
969
|
+
* Node type of mdast root.
|
|
970
|
+
*/
|
|
971
|
+
type: "root";
|
|
972
|
+
/**
|
|
973
|
+
* Data associated with the mdast root.
|
|
974
|
+
*/
|
|
975
|
+
data?: RootData | undefined;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Info associated with mdast root nodes by the ecosystem.
|
|
980
|
+
*/
|
|
981
|
+
interface RootData extends Data {}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* Markdown strong.
|
|
985
|
+
*/
|
|
986
|
+
interface Strong extends Parent {
|
|
987
|
+
/**
|
|
988
|
+
* Node type of mdast strong.
|
|
989
|
+
*/
|
|
990
|
+
type: "strong";
|
|
991
|
+
/**
|
|
992
|
+
* Children of strong.
|
|
993
|
+
*/
|
|
994
|
+
children: PhrasingContent[];
|
|
995
|
+
/**
|
|
996
|
+
* Data associated with the mdast strong.
|
|
997
|
+
*/
|
|
998
|
+
data?: StrongData | undefined;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Info associated with mdast strong nodes by the ecosystem.
|
|
1003
|
+
*/
|
|
1004
|
+
interface StrongData extends Data {}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Markdown GFM table.
|
|
1008
|
+
*/
|
|
1009
|
+
interface Table extends Parent {
|
|
1010
|
+
/**
|
|
1011
|
+
* Node type of mdast GFM table.
|
|
1012
|
+
*/
|
|
1013
|
+
type: "table";
|
|
1014
|
+
/**
|
|
1015
|
+
* How cells in columns are aligned.
|
|
1016
|
+
*/
|
|
1017
|
+
align?: AlignType[] | null | undefined;
|
|
1018
|
+
/**
|
|
1019
|
+
* Children of GFM table.
|
|
1020
|
+
*/
|
|
1021
|
+
children: TableContent[];
|
|
1022
|
+
/**
|
|
1023
|
+
* Data associated with the mdast GFM table.
|
|
1024
|
+
*/
|
|
1025
|
+
data?: TableData | undefined;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Info associated with mdast GFM table nodes by the ecosystem.
|
|
1030
|
+
*/
|
|
1031
|
+
interface TableData extends Data {}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Markdown GFM table row.
|
|
1035
|
+
*/
|
|
1036
|
+
interface TableRow extends Parent {
|
|
1037
|
+
/**
|
|
1038
|
+
* Node type of mdast GFM table row.
|
|
1039
|
+
*/
|
|
1040
|
+
type: "tableRow";
|
|
1041
|
+
/**
|
|
1042
|
+
* Children of GFM table row.
|
|
1043
|
+
*/
|
|
1044
|
+
children: RowContent[];
|
|
1045
|
+
/**
|
|
1046
|
+
* Data associated with the mdast GFM table row.
|
|
1047
|
+
*/
|
|
1048
|
+
data?: TableRowData | undefined;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Info associated with mdast GFM table row nodes by the ecosystem.
|
|
1053
|
+
*/
|
|
1054
|
+
interface TableRowData extends Data {}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Markdown GFM table cell.
|
|
1058
|
+
*/
|
|
1059
|
+
interface TableCell extends Parent {
|
|
1060
|
+
/**
|
|
1061
|
+
* Node type of mdast GFM table cell.
|
|
1062
|
+
*/
|
|
1063
|
+
type: "tableCell";
|
|
1064
|
+
/**
|
|
1065
|
+
* Children of GFM table cell.
|
|
1066
|
+
*/
|
|
1067
|
+
children: PhrasingContent[];
|
|
1068
|
+
/**
|
|
1069
|
+
* Data associated with the mdast GFM table cell.
|
|
1070
|
+
*/
|
|
1071
|
+
data?: TableCellData | undefined;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Info associated with mdast GFM table cell nodes by the ecosystem.
|
|
1076
|
+
*/
|
|
1077
|
+
interface TableCellData extends Data {}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Markdown text.
|
|
1081
|
+
*/
|
|
1082
|
+
interface Text extends Literal {
|
|
1083
|
+
/**
|
|
1084
|
+
* Node type of mdast text.
|
|
1085
|
+
*/
|
|
1086
|
+
type: "text";
|
|
1087
|
+
/**
|
|
1088
|
+
* Data associated with the mdast text.
|
|
1089
|
+
*/
|
|
1090
|
+
data?: TextData | undefined;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* Info associated with mdast text nodes by the ecosystem.
|
|
1095
|
+
*/
|
|
1096
|
+
interface TextData extends Data {}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Markdown thematic break (horizontal rule).
|
|
1100
|
+
*/
|
|
1101
|
+
interface ThematicBreak extends Node {
|
|
1102
|
+
/**
|
|
1103
|
+
* Node type of mdast thematic break.
|
|
1104
|
+
*/
|
|
1105
|
+
type: "thematicBreak";
|
|
1106
|
+
/**
|
|
1107
|
+
* Data associated with the mdast thematic break.
|
|
1108
|
+
*/
|
|
1109
|
+
data?: ThematicBreakData | undefined;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* Info associated with mdast thematic break nodes by the ecosystem.
|
|
1114
|
+
*/
|
|
1115
|
+
interface ThematicBreakData extends Data {}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Markdown YAML.
|
|
1119
|
+
*/
|
|
1120
|
+
interface Yaml extends Literal {
|
|
1121
|
+
/**
|
|
1122
|
+
* Node type of mdast YAML.
|
|
1123
|
+
*/
|
|
1124
|
+
type: "yaml";
|
|
1125
|
+
/**
|
|
1126
|
+
* Data associated with the mdast YAML.
|
|
1127
|
+
*/
|
|
1128
|
+
data?: YamlData | undefined;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Info associated with mdast YAML nodes by the ecosystem.
|
|
1133
|
+
*/
|
|
1134
|
+
interface YamlData extends Data {}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Info associated with an element.
|
|
1138
|
+
*/
|
|
1139
|
+
interface Properties {
|
|
1140
|
+
[PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Stages for mdast-plus pipeline processing.
|
|
1145
|
+
*/
|
|
1146
|
+
type Stage = 'normalize' | 'compile' | 'finalize';
|
|
1147
|
+
/**
|
|
1148
|
+
* Definition for an mdast plugin.
|
|
1149
|
+
*/
|
|
1150
|
+
interface MdastPlugin {
|
|
1151
|
+
/** Plugin name */
|
|
1152
|
+
name: string;
|
|
1153
|
+
/** Processing stage the plugin belongs to */
|
|
1154
|
+
stage?: Stage;
|
|
1155
|
+
/** Execution order within the stage (lower numbers run first) */
|
|
1156
|
+
order?: number;
|
|
1157
|
+
/** Transformation function */
|
|
1158
|
+
transform: (tree: Root, ctx: any) => Promise<void> | void;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Definition for an mdast format (parser/stringifier).
|
|
1162
|
+
*/
|
|
1163
|
+
interface MdastFormatDefinition {
|
|
1164
|
+
/** Function to register parser plugins */
|
|
1165
|
+
parse?: (processor: any) => void;
|
|
1166
|
+
/** Function to register stringifier plugins */
|
|
1167
|
+
stringify?: (processor: any) => void;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Represents an asset (e.g., image) extracted during processing.
|
|
1171
|
+
*/
|
|
1172
|
+
interface MdastAsset {
|
|
1173
|
+
/** Relative path or identifier for the asset */
|
|
1174
|
+
path: string;
|
|
1175
|
+
/** MIME type of the asset */
|
|
1176
|
+
contentType: string;
|
|
1177
|
+
/** Raw content as bytes */
|
|
1178
|
+
bytes: Uint8Array;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Result of a conversion process.
|
|
1182
|
+
* @template T - The type of the main content (default: string)
|
|
1183
|
+
*/
|
|
1184
|
+
interface ConvertResult<T = string> {
|
|
1185
|
+
/** The converted content */
|
|
1186
|
+
content: T;
|
|
1187
|
+
/** Extracted assets */
|
|
1188
|
+
assets: MdastAsset[];
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Original metadata for a node.
|
|
1192
|
+
*/
|
|
1193
|
+
interface MdastDataOrigin {
|
|
1194
|
+
/** Source format */
|
|
1195
|
+
format: 'docx' | 'notion' | 'html' | 'markdown' | 'latex' | string;
|
|
1196
|
+
/** Raw data from the source */
|
|
1197
|
+
raw?: unknown;
|
|
1198
|
+
/** Hash of the source content */
|
|
1199
|
+
hash?: string;
|
|
1200
|
+
[k: string]: unknown;
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* mdast node for highlighted text (mark).
|
|
1204
|
+
*/
|
|
1205
|
+
interface MdastMark extends Parent$1 {
|
|
1206
|
+
type: 'mark';
|
|
1207
|
+
children: PhrasingContent[];
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* mdast node for subscript text.
|
|
1211
|
+
*/
|
|
1212
|
+
interface MdastSub extends Parent$1 {
|
|
1213
|
+
type: 'sub';
|
|
1214
|
+
children: PhrasingContent[];
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* mdast node for superscript text.
|
|
1218
|
+
*/
|
|
1219
|
+
interface MdastSup extends Parent$1 {
|
|
1220
|
+
type: 'sup';
|
|
1221
|
+
children: PhrasingContent[];
|
|
1222
|
+
}
|
|
1223
|
+
declare module 'mdast' {
|
|
1224
|
+
interface Data {
|
|
1225
|
+
/** Target HTML tag name */
|
|
1226
|
+
hName?: string;
|
|
1227
|
+
/** Target HTML properties */
|
|
1228
|
+
hProperties?: Properties;
|
|
1229
|
+
/** Source origin information */
|
|
1230
|
+
_origin?: MdastDataOrigin;
|
|
1231
|
+
}
|
|
1232
|
+
interface CodeData extends Data {
|
|
1233
|
+
/** Title of the code block */
|
|
1234
|
+
title?: string;
|
|
1235
|
+
/** Path to the code file */
|
|
1236
|
+
filename?: string;
|
|
1237
|
+
/** Extra key-value metadata */
|
|
1238
|
+
kv?: Record<string, any>;
|
|
1239
|
+
}
|
|
1240
|
+
interface TableCellData extends Data {
|
|
1241
|
+
/** Table cell row span */
|
|
1242
|
+
rowspan?: number;
|
|
1243
|
+
/** Table cell column span */
|
|
1244
|
+
colspan?: number;
|
|
1245
|
+
}
|
|
1246
|
+
interface PhrasingContentMap {
|
|
1247
|
+
mark: MdastMark;
|
|
1248
|
+
sub: MdastSub;
|
|
1249
|
+
sup: MdastSup;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Interface for reading input into an mdast tree.
|
|
1254
|
+
* @template I - Input type
|
|
1255
|
+
*/
|
|
1256
|
+
interface MdastReader<I> {
|
|
1257
|
+
/**
|
|
1258
|
+
* Reads input and returns an mdast Root node.
|
|
1259
|
+
* @param input - The input to read
|
|
1260
|
+
*/
|
|
1261
|
+
read(input: I): Promise<Root>;
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Interface for transforming an mdast tree.
|
|
1265
|
+
*/
|
|
1266
|
+
interface MdastTransformer {
|
|
1267
|
+
/**
|
|
1268
|
+
* Transforms the given mdast tree.
|
|
1269
|
+
* @param tree - The Root node to transform
|
|
1270
|
+
*/
|
|
1271
|
+
transform(tree: Root): Promise<{
|
|
1272
|
+
tree: Root;
|
|
1273
|
+
assets?: MdastAsset[];
|
|
1274
|
+
}>;
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Interface for writing an mdast tree to an output format.
|
|
1278
|
+
* @template Output - Output type (default: string)
|
|
1279
|
+
*/
|
|
1280
|
+
interface MdastWriter<Output = string> {
|
|
1281
|
+
/**
|
|
1282
|
+
* Writes the mdast tree to the target output.
|
|
1283
|
+
* @param tree - The Root node to write
|
|
1284
|
+
* @param assets - Optional assets to include
|
|
1285
|
+
*/
|
|
1286
|
+
write(tree: Root, assets?: MdastAsset[]): Promise<ConvertResult<Output>>;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Fluent processor for mdast transformations.
|
|
1291
|
+
* Allows chaining configuration and finally converting to a target format.
|
|
1292
|
+
*/
|
|
1293
|
+
declare class FluentProcessor {
|
|
1294
|
+
/** Map of registered format definitions */
|
|
1295
|
+
static formats: Record<string, MdastFormatDefinition>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Registers a new format definition.
|
|
1298
|
+
* @param name - The name of the format (e.g., 'docx')
|
|
1299
|
+
* @param definition - The format definition containing parse/stringify logic
|
|
1300
|
+
*/
|
|
1301
|
+
static registerFormat(name: string, definition: MdastFormatDefinition): void;
|
|
1302
|
+
private processor;
|
|
1303
|
+
private input;
|
|
1304
|
+
private inputFormat;
|
|
1305
|
+
private plugins;
|
|
1306
|
+
private globalData;
|
|
1307
|
+
/**
|
|
1308
|
+
* Creates a new FluentProcessor instance.
|
|
1309
|
+
* @param input - The input content (string or mdast tree)
|
|
1310
|
+
*/
|
|
1311
|
+
constructor(input: any);
|
|
1312
|
+
/**
|
|
1313
|
+
* Specifies the input format.
|
|
1314
|
+
* @param format - The input format name (default: 'markdown')
|
|
1315
|
+
*/
|
|
1316
|
+
from(format: string): this;
|
|
1317
|
+
/**
|
|
1318
|
+
* Adds a plugin to the processing pipeline.
|
|
1319
|
+
* @param plugin - The mdast plugin to use
|
|
1320
|
+
*/
|
|
1321
|
+
use(plugin: MdastPlugin): this;
|
|
1322
|
+
/**
|
|
1323
|
+
* Merges global data into the processor.
|
|
1324
|
+
* @param data - Key-value pairs to store in global data
|
|
1325
|
+
*/
|
|
1326
|
+
data(data: Record<string, any>): this;
|
|
1327
|
+
/**
|
|
1328
|
+
* Converts the input content to the specified format.
|
|
1329
|
+
* @param format - The output format name
|
|
1330
|
+
* @returns A promise resolving to the conversion result (content and assets)
|
|
1331
|
+
*/
|
|
1332
|
+
to(format: string): Promise<ConvertResult>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Helper to convert content to Markdown.
|
|
1335
|
+
* @returns A promise resolving to the Markdown string
|
|
1336
|
+
*/
|
|
1337
|
+
toMarkdown(): Promise<string>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Helper to convert content to HTML.
|
|
1340
|
+
* @returns A promise resolving to the HTML string
|
|
1341
|
+
*/
|
|
1342
|
+
toHTML(): Promise<string>;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Entry point for the fluent mdast-plus API.
|
|
1346
|
+
* @param input - The input content (string or mdast tree)
|
|
1347
|
+
* @returns A FluentProcessor instance
|
|
1348
|
+
*/
|
|
1349
|
+
declare function mdast(input: any): FluentProcessor;
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* Unified plugin/configuration for Markdown format.
|
|
1353
|
+
* Includes GFM, directives, math, and frontmatter.
|
|
1354
|
+
*/
|
|
1355
|
+
declare function markdownFormat(this: any): void;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Unified plugin/configuration for HTML format.
|
|
1359
|
+
* Includes mdast-to-hast conversion, sanitization (with table span support), and stringification.
|
|
1360
|
+
*/
|
|
1361
|
+
declare function htmlFormat(this: any): void;
|
|
1362
|
+
|
|
1363
|
+
export { type ConvertResult, FluentProcessor, type MdastAsset, type MdastDataOrigin, type MdastFormatDefinition, type MdastMark, type MdastPlugin, type MdastReader, type MdastSub, type MdastSup, type MdastTransformer, type MdastWriter, type Stage, htmlFormat, markdownFormat, mdast };
|