@storybook/addon-docs 8.0.0-alpha.1 → 8.0.0-alpha.11
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.md +0 -17
- package/dist/{DocsRenderer-NNNQARDV.mjs → DocsRenderer-56ZJCE2Q.mjs} +1 -0
- package/dist/chunk-FG2YIYKM.mjs +3 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/dist/mdx-loader.d.ts +4776 -0
- package/dist/mdx-loader.js +50 -0
- package/dist/mdx-loader.mjs +53 -0
- package/dist/preset.d.ts +14 -4
- package/dist/preset.js +47 -41
- package/dist/preview.js +1 -1
- package/dist/preview.mjs +4 -1
- package/ember/README.md +1 -1
- package/package.json +22 -28
- package/preview.js +0 -1
- package/jest-transform-mdx.js +0 -22
- package/jest.config.js +0 -7
- package/postinstall/presets.js +0 -36
- package/template/stories/stories-mdx/csf-in-mdx.non-stories.js +0 -19
|
@@ -0,0 +1,4776 @@
|
|
|
1
|
+
import { transformAsync } from '@babel/core';
|
|
2
|
+
import * as unist from 'unist';
|
|
3
|
+
import { Node as Node$3, Data as Data$7 } from 'unist';
|
|
4
|
+
import * as hast from 'hast';
|
|
5
|
+
import { ElementContent as ElementContent$1, Properties, Literal, Data as Data$5, Parent as Parent$1 } from 'hast';
|
|
6
|
+
import * as mdast from 'mdast';
|
|
7
|
+
import { Parent, BlockContent, DefinitionContent, Data as Data$6, PhrasingContent, Literal as Literal$1 } from 'mdast';
|
|
8
|
+
import { Program } from 'estree-jsx';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Contents of the file.
|
|
12
|
+
*
|
|
13
|
+
* Can either be text or a `Uint8Array` structure.
|
|
14
|
+
*/
|
|
15
|
+
type Value$3 = Uint8Array | string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This map registers the type of the `data` key of a `VFile`.
|
|
19
|
+
*
|
|
20
|
+
* This type can be augmented to register custom `data` types.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* declare module 'vfile' {
|
|
24
|
+
* interface DataMap {
|
|
25
|
+
* // `file.data.name` is typed as `string`
|
|
26
|
+
* name: string
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-interface
|
|
32
|
+
interface DataMap {}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Custom information.
|
|
36
|
+
*
|
|
37
|
+
* Known attributes can be added to @see {@link DataMap}
|
|
38
|
+
*/
|
|
39
|
+
type Data$4 = Record<string, unknown> & Partial<DataMap>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Message.
|
|
43
|
+
*/
|
|
44
|
+
declare class VFileMessage extends Error {
|
|
45
|
+
constructor(reason: string, options?: Options$5 | null | undefined)
|
|
46
|
+
constructor(
|
|
47
|
+
reason: string,
|
|
48
|
+
parent: Node$2 | NodeLike$1 | null | undefined,
|
|
49
|
+
origin?: string | null | undefined
|
|
50
|
+
)
|
|
51
|
+
constructor(
|
|
52
|
+
reason: string,
|
|
53
|
+
place: Point$2 | Position$2 | null | undefined,
|
|
54
|
+
origin?: string | null | undefined
|
|
55
|
+
)
|
|
56
|
+
constructor(reason: string, origin?: string | null | undefined)
|
|
57
|
+
constructor(
|
|
58
|
+
cause: Error | VFileMessage,
|
|
59
|
+
parent: Node$2 | NodeLike$1 | null | undefined,
|
|
60
|
+
origin?: string | null | undefined
|
|
61
|
+
)
|
|
62
|
+
constructor(
|
|
63
|
+
cause: Error | VFileMessage,
|
|
64
|
+
place: Point$2 | Position$2 | null | undefined,
|
|
65
|
+
origin?: string | null | undefined
|
|
66
|
+
)
|
|
67
|
+
constructor(cause: Error | VFileMessage, origin?: string | null | undefined)
|
|
68
|
+
/**
|
|
69
|
+
* Stack of ancestor nodes surrounding the message.
|
|
70
|
+
*
|
|
71
|
+
* @type {Array<Node> | undefined}
|
|
72
|
+
*/
|
|
73
|
+
ancestors: Array<Node$2> | undefined
|
|
74
|
+
/**
|
|
75
|
+
* Starting column of message.
|
|
76
|
+
*
|
|
77
|
+
* @type {number | undefined}
|
|
78
|
+
*/
|
|
79
|
+
column: number | undefined
|
|
80
|
+
/**
|
|
81
|
+
* State of problem.
|
|
82
|
+
*
|
|
83
|
+
* * `true` — error, file not usable
|
|
84
|
+
* * `false` — warning, change may be needed
|
|
85
|
+
* * `undefined` — change likely not needed
|
|
86
|
+
*
|
|
87
|
+
* @type {boolean | null | undefined}
|
|
88
|
+
*/
|
|
89
|
+
fatal: boolean | null | undefined
|
|
90
|
+
/**
|
|
91
|
+
* Path of a file (used throughout the `VFile` ecosystem).
|
|
92
|
+
*
|
|
93
|
+
* @type {string | undefined}
|
|
94
|
+
*/
|
|
95
|
+
file: string | undefined
|
|
96
|
+
/**
|
|
97
|
+
* Starting line of error.
|
|
98
|
+
*
|
|
99
|
+
* @type {number | undefined}
|
|
100
|
+
*/
|
|
101
|
+
line: number | undefined
|
|
102
|
+
/**
|
|
103
|
+
* Place of message.
|
|
104
|
+
*
|
|
105
|
+
* @type {Point | Position | undefined}
|
|
106
|
+
*/
|
|
107
|
+
place: Point$2 | Position$2 | undefined
|
|
108
|
+
/**
|
|
109
|
+
* Reason for message, should use markdown.
|
|
110
|
+
*
|
|
111
|
+
* @type {string}
|
|
112
|
+
*/
|
|
113
|
+
reason: string
|
|
114
|
+
/**
|
|
115
|
+
* Category of message (example: `'my-rule'`).
|
|
116
|
+
*
|
|
117
|
+
* @type {string | undefined}
|
|
118
|
+
*/
|
|
119
|
+
ruleId: string | undefined
|
|
120
|
+
/**
|
|
121
|
+
* Namespace of message (example: `'my-package'`).
|
|
122
|
+
*
|
|
123
|
+
* @type {string | undefined}
|
|
124
|
+
*/
|
|
125
|
+
source: string | undefined
|
|
126
|
+
/**
|
|
127
|
+
* Specify the source value that’s being reported, which is deemed
|
|
128
|
+
* incorrect.
|
|
129
|
+
*
|
|
130
|
+
* @type {string | undefined}
|
|
131
|
+
*/
|
|
132
|
+
actual: string | undefined
|
|
133
|
+
/**
|
|
134
|
+
* Suggest acceptable values that can be used instead of `actual`.
|
|
135
|
+
*
|
|
136
|
+
* @type {Array<string> | undefined}
|
|
137
|
+
*/
|
|
138
|
+
expected: Array<string> | undefined
|
|
139
|
+
/**
|
|
140
|
+
* Long form description of the message (you should use markdown).
|
|
141
|
+
*
|
|
142
|
+
* @type {string | undefined}
|
|
143
|
+
*/
|
|
144
|
+
note: string | undefined
|
|
145
|
+
/**
|
|
146
|
+
* Link to docs for the message.
|
|
147
|
+
*
|
|
148
|
+
* > 👉 **Note**: this must be an absolute URL that can be passed as `x`
|
|
149
|
+
* > to `new URL(x)`.
|
|
150
|
+
*
|
|
151
|
+
* @type {string | undefined}
|
|
152
|
+
*/
|
|
153
|
+
url: string | undefined
|
|
154
|
+
}
|
|
155
|
+
type Node$2 = unist.Node
|
|
156
|
+
type Point$2 = unist.Point
|
|
157
|
+
type Position$2 = unist.Position
|
|
158
|
+
type NodeLike$1 = object & {
|
|
159
|
+
type: string
|
|
160
|
+
position?: Position$2 | undefined
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Configuration.
|
|
164
|
+
*/
|
|
165
|
+
type Options$5 = {
|
|
166
|
+
/**
|
|
167
|
+
* Stack of (inclusive) ancestor nodes surrounding the message (optional).
|
|
168
|
+
*/
|
|
169
|
+
ancestors?: Array<Node$2> | null | undefined
|
|
170
|
+
/**
|
|
171
|
+
* Original error cause of the message (optional).
|
|
172
|
+
*/
|
|
173
|
+
cause?: Error | null | undefined
|
|
174
|
+
/**
|
|
175
|
+
* Place of message (optional).
|
|
176
|
+
*/
|
|
177
|
+
place?: Point$2 | Position$2 | null | undefined
|
|
178
|
+
/**
|
|
179
|
+
* Category of message (optional, example: `'my-rule'`).
|
|
180
|
+
*/
|
|
181
|
+
ruleId?: string | null | undefined
|
|
182
|
+
/**
|
|
183
|
+
* Namespace of who sent the message (optional, example: `'my-package'`).
|
|
184
|
+
*/
|
|
185
|
+
source?: string | null | undefined
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type Options$4 = Options$5
|
|
189
|
+
|
|
190
|
+
declare class VFile$1 {
|
|
191
|
+
/**
|
|
192
|
+
* Create a new virtual file.
|
|
193
|
+
*
|
|
194
|
+
* `options` is treated as:
|
|
195
|
+
*
|
|
196
|
+
* * `string` or `Uint8Array` — `{value: options}`
|
|
197
|
+
* * `URL` — `{path: options}`
|
|
198
|
+
* * `VFile` — shallow copies its data over to the new file
|
|
199
|
+
* * `object` — all fields are shallow copied over to the new file
|
|
200
|
+
*
|
|
201
|
+
* Path related fields are set in the following order (least specific to
|
|
202
|
+
* most specific): `history`, `path`, `basename`, `stem`, `extname`,
|
|
203
|
+
* `dirname`.
|
|
204
|
+
*
|
|
205
|
+
* You cannot set `dirname` or `extname` without setting either `history`,
|
|
206
|
+
* `path`, `basename`, or `stem` too.
|
|
207
|
+
*
|
|
208
|
+
* @param {Compatible | null | undefined} [value]
|
|
209
|
+
* File value.
|
|
210
|
+
* @returns
|
|
211
|
+
* New instance.
|
|
212
|
+
*/
|
|
213
|
+
constructor(value?: Compatible$2 | null | undefined)
|
|
214
|
+
/**
|
|
215
|
+
* Base of `path` (default: `process.cwd()` or `'/'` in browsers).
|
|
216
|
+
*
|
|
217
|
+
* @type {string}
|
|
218
|
+
*/
|
|
219
|
+
cwd: string
|
|
220
|
+
/**
|
|
221
|
+
* Place to store custom info (default: `{}`).
|
|
222
|
+
*
|
|
223
|
+
* It’s OK to store custom data directly on the file but moving it to
|
|
224
|
+
* `data` is recommended.
|
|
225
|
+
*
|
|
226
|
+
* @type {Data}
|
|
227
|
+
*/
|
|
228
|
+
data: Data$3
|
|
229
|
+
/**
|
|
230
|
+
* List of file paths the file moved between.
|
|
231
|
+
*
|
|
232
|
+
* The first is the original path and the last is the current path.
|
|
233
|
+
*
|
|
234
|
+
* @type {Array<string>}
|
|
235
|
+
*/
|
|
236
|
+
history: Array<string>
|
|
237
|
+
/**
|
|
238
|
+
* List of messages associated with the file.
|
|
239
|
+
*
|
|
240
|
+
* @type {Array<VFileMessage>}
|
|
241
|
+
*/
|
|
242
|
+
messages: Array<VFileMessage>
|
|
243
|
+
/**
|
|
244
|
+
* Raw value.
|
|
245
|
+
*
|
|
246
|
+
* @type {Value}
|
|
247
|
+
*/
|
|
248
|
+
value: Value$2
|
|
249
|
+
/**
|
|
250
|
+
* Source map.
|
|
251
|
+
*
|
|
252
|
+
* This type is equivalent to the `RawSourceMap` type from the `source-map`
|
|
253
|
+
* module.
|
|
254
|
+
*
|
|
255
|
+
* @type {Map | null | undefined}
|
|
256
|
+
*/
|
|
257
|
+
map: Map$1 | null | undefined
|
|
258
|
+
/**
|
|
259
|
+
* Custom, non-string, compiled, representation.
|
|
260
|
+
*
|
|
261
|
+
* This is used by unified to store non-string results.
|
|
262
|
+
* One example is when turning markdown into React nodes.
|
|
263
|
+
*
|
|
264
|
+
* @type {unknown}
|
|
265
|
+
*/
|
|
266
|
+
result: unknown
|
|
267
|
+
/**
|
|
268
|
+
* Whether a file was saved to disk.
|
|
269
|
+
*
|
|
270
|
+
* This is used by vfile reporters.
|
|
271
|
+
*
|
|
272
|
+
* @type {boolean}
|
|
273
|
+
*/
|
|
274
|
+
stored: boolean
|
|
275
|
+
/**
|
|
276
|
+
* Set basename (including extname) (`'index.min.js'`).
|
|
277
|
+
*
|
|
278
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
279
|
+
* on windows).
|
|
280
|
+
* Cannot be nullified (use `file.path = file.dirname` instead).
|
|
281
|
+
*
|
|
282
|
+
* @param {string} basename
|
|
283
|
+
* Basename.
|
|
284
|
+
* @returns {undefined}
|
|
285
|
+
* Nothing.
|
|
286
|
+
*/
|
|
287
|
+
set basename(arg: string | undefined)
|
|
288
|
+
/**
|
|
289
|
+
* Get the basename (including extname) (example: `'index.min.js'`).
|
|
290
|
+
*
|
|
291
|
+
* @returns {string | undefined}
|
|
292
|
+
* Basename.
|
|
293
|
+
*/
|
|
294
|
+
get basename(): string | undefined
|
|
295
|
+
/**
|
|
296
|
+
* Set the full path (example: `'~/index.min.js'`).
|
|
297
|
+
*
|
|
298
|
+
* Cannot be nullified.
|
|
299
|
+
* You can set a file URL (a `URL` object with a `file:` protocol) which will
|
|
300
|
+
* be turned into a path with `url.fileURLToPath`.
|
|
301
|
+
*
|
|
302
|
+
* @param {URL | string} path
|
|
303
|
+
* Path.
|
|
304
|
+
* @returns {undefined}
|
|
305
|
+
* Nothing.
|
|
306
|
+
*/
|
|
307
|
+
set path(arg: string)
|
|
308
|
+
/**
|
|
309
|
+
* Get the full path (example: `'~/index.min.js'`).
|
|
310
|
+
*
|
|
311
|
+
* @returns {string}
|
|
312
|
+
* Path.
|
|
313
|
+
*/
|
|
314
|
+
get path(): string
|
|
315
|
+
/**
|
|
316
|
+
* Set the parent path (example: `'~'`).
|
|
317
|
+
*
|
|
318
|
+
* Cannot be set if there’s no `path` yet.
|
|
319
|
+
*
|
|
320
|
+
* @param {string | undefined} dirname
|
|
321
|
+
* Dirname.
|
|
322
|
+
* @returns {undefined}
|
|
323
|
+
* Nothing.
|
|
324
|
+
*/
|
|
325
|
+
set dirname(arg: string | undefined)
|
|
326
|
+
/**
|
|
327
|
+
* Get the parent path (example: `'~'`).
|
|
328
|
+
*
|
|
329
|
+
* @returns {string | undefined}
|
|
330
|
+
* Dirname.
|
|
331
|
+
*/
|
|
332
|
+
get dirname(): string | undefined
|
|
333
|
+
/**
|
|
334
|
+
* Set the extname (including dot) (example: `'.js'`).
|
|
335
|
+
*
|
|
336
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
337
|
+
* on windows).
|
|
338
|
+
* Cannot be set if there’s no `path` yet.
|
|
339
|
+
*
|
|
340
|
+
* @param {string | undefined} extname
|
|
341
|
+
* Extname.
|
|
342
|
+
* @returns {undefined}
|
|
343
|
+
* Nothing.
|
|
344
|
+
*/
|
|
345
|
+
set extname(arg: string | undefined)
|
|
346
|
+
/**
|
|
347
|
+
* Get the extname (including dot) (example: `'.js'`).
|
|
348
|
+
*
|
|
349
|
+
* @returns {string | undefined}
|
|
350
|
+
* Extname.
|
|
351
|
+
*/
|
|
352
|
+
get extname(): string | undefined
|
|
353
|
+
/**
|
|
354
|
+
* Set the stem (basename w/o extname) (example: `'index.min'`).
|
|
355
|
+
*
|
|
356
|
+
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
|
|
357
|
+
* on windows).
|
|
358
|
+
* Cannot be nullified (use `file.path = file.dirname` instead).
|
|
359
|
+
*
|
|
360
|
+
* @param {string} stem
|
|
361
|
+
* Stem.
|
|
362
|
+
* @returns {undefined}
|
|
363
|
+
* Nothing.
|
|
364
|
+
*/
|
|
365
|
+
set stem(arg: string | undefined)
|
|
366
|
+
/**
|
|
367
|
+
* Get the stem (basename w/o extname) (example: `'index.min'`).
|
|
368
|
+
*
|
|
369
|
+
* @returns {string | undefined}
|
|
370
|
+
* Stem.
|
|
371
|
+
*/
|
|
372
|
+
get stem(): string | undefined
|
|
373
|
+
fail(reason: string, options?: MessageOptions | null | undefined): never
|
|
374
|
+
fail(
|
|
375
|
+
reason: string,
|
|
376
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
377
|
+
origin?: string | null | undefined
|
|
378
|
+
): never
|
|
379
|
+
fail(
|
|
380
|
+
reason: string,
|
|
381
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
382
|
+
origin?: string | null | undefined
|
|
383
|
+
): never
|
|
384
|
+
fail(reason: string, origin?: string | null | undefined): never
|
|
385
|
+
fail(
|
|
386
|
+
cause: Error | VFileMessage,
|
|
387
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
388
|
+
origin?: string | null | undefined
|
|
389
|
+
): never
|
|
390
|
+
fail(
|
|
391
|
+
cause: Error | VFileMessage,
|
|
392
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
393
|
+
origin?: string | null | undefined
|
|
394
|
+
): never
|
|
395
|
+
fail(cause: Error | VFileMessage, origin?: string | null | undefined): never
|
|
396
|
+
info(
|
|
397
|
+
reason: string,
|
|
398
|
+
options?: MessageOptions | null | undefined
|
|
399
|
+
): VFileMessage
|
|
400
|
+
info(
|
|
401
|
+
reason: string,
|
|
402
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
403
|
+
origin?: string | null | undefined
|
|
404
|
+
): VFileMessage
|
|
405
|
+
info(
|
|
406
|
+
reason: string,
|
|
407
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
408
|
+
origin?: string | null | undefined
|
|
409
|
+
): VFileMessage
|
|
410
|
+
info(reason: string, origin?: string | null | undefined): VFileMessage
|
|
411
|
+
info(
|
|
412
|
+
cause: Error | VFileMessage,
|
|
413
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
414
|
+
origin?: string | null | undefined
|
|
415
|
+
): VFileMessage
|
|
416
|
+
info(
|
|
417
|
+
cause: Error | VFileMessage,
|
|
418
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
419
|
+
origin?: string | null | undefined
|
|
420
|
+
): VFileMessage
|
|
421
|
+
info(
|
|
422
|
+
cause: Error | VFileMessage,
|
|
423
|
+
origin?: string | null | undefined
|
|
424
|
+
): VFileMessage
|
|
425
|
+
message(
|
|
426
|
+
reason: string,
|
|
427
|
+
options?: MessageOptions | null | undefined
|
|
428
|
+
): VFileMessage
|
|
429
|
+
message(
|
|
430
|
+
reason: string,
|
|
431
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
432
|
+
origin?: string | null | undefined
|
|
433
|
+
): VFileMessage
|
|
434
|
+
message(
|
|
435
|
+
reason: string,
|
|
436
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
437
|
+
origin?: string | null | undefined
|
|
438
|
+
): VFileMessage
|
|
439
|
+
message(reason: string, origin?: string | null | undefined): VFileMessage
|
|
440
|
+
message(
|
|
441
|
+
cause: Error | VFileMessage,
|
|
442
|
+
parent: Node$1 | NodeLike | null | undefined,
|
|
443
|
+
origin?: string | null | undefined
|
|
444
|
+
): VFileMessage
|
|
445
|
+
message(
|
|
446
|
+
cause: Error | VFileMessage,
|
|
447
|
+
place: Point$1 | Position$1 | null | undefined,
|
|
448
|
+
origin?: string | null | undefined
|
|
449
|
+
): VFileMessage
|
|
450
|
+
message(
|
|
451
|
+
cause: Error | VFileMessage,
|
|
452
|
+
origin?: string | null | undefined
|
|
453
|
+
): VFileMessage
|
|
454
|
+
/**
|
|
455
|
+
* Serialize the file.
|
|
456
|
+
*
|
|
457
|
+
* > **Note**: which encodings are supported depends on the engine.
|
|
458
|
+
* > For info on Node.js, see:
|
|
459
|
+
* > <https://nodejs.org/api/util.html#whatwg-supported-encodings>.
|
|
460
|
+
*
|
|
461
|
+
* @param {string | null | undefined} [encoding='utf8']
|
|
462
|
+
* Character encoding to understand `value` as when it’s a `Uint8Array`
|
|
463
|
+
* (default: `'utf-8'`).
|
|
464
|
+
* @returns {string}
|
|
465
|
+
* Serialized file.
|
|
466
|
+
*/
|
|
467
|
+
toString(encoding?: string | null | undefined): string
|
|
468
|
+
}
|
|
469
|
+
type Node$1 = unist.Node
|
|
470
|
+
type Point$1 = unist.Point
|
|
471
|
+
type Position$1 = unist.Position
|
|
472
|
+
type MessageOptions = Options$4
|
|
473
|
+
type Data$3 = Data$4
|
|
474
|
+
type Value$2 = Value$3
|
|
475
|
+
type NodeLike = object & {
|
|
476
|
+
type: string
|
|
477
|
+
position?: Position$1 | undefined
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Things that can be passed to the constructor.
|
|
481
|
+
*/
|
|
482
|
+
type Compatible$2 = Options$3 | URL | VFile$1 | Value$2
|
|
483
|
+
/**
|
|
484
|
+
* Set multiple values.
|
|
485
|
+
*/
|
|
486
|
+
type VFileCoreOptions = {
|
|
487
|
+
/**
|
|
488
|
+
* Set `basename` (name).
|
|
489
|
+
*/
|
|
490
|
+
basename?: string | null | undefined
|
|
491
|
+
/**
|
|
492
|
+
* Set `cwd` (working directory).
|
|
493
|
+
*/
|
|
494
|
+
cwd?: string | null | undefined
|
|
495
|
+
/**
|
|
496
|
+
* Set `data` (associated info).
|
|
497
|
+
*/
|
|
498
|
+
data?: Data$3 | null | undefined
|
|
499
|
+
/**
|
|
500
|
+
* Set `dirname` (path w/o basename).
|
|
501
|
+
*/
|
|
502
|
+
dirname?: string | null | undefined
|
|
503
|
+
/**
|
|
504
|
+
* Set `extname` (extension with dot).
|
|
505
|
+
*/
|
|
506
|
+
extname?: string | null | undefined
|
|
507
|
+
/**
|
|
508
|
+
* Set `history` (paths the file moved between).
|
|
509
|
+
*/
|
|
510
|
+
history?: Array<string> | null | undefined
|
|
511
|
+
/**
|
|
512
|
+
* Set `path` (current path).
|
|
513
|
+
*/
|
|
514
|
+
path?: URL | string | null | undefined
|
|
515
|
+
/**
|
|
516
|
+
* Set `stem` (name without extension).
|
|
517
|
+
*/
|
|
518
|
+
stem?: string | null | undefined
|
|
519
|
+
/**
|
|
520
|
+
* Set `value` (the contents of the file).
|
|
521
|
+
*/
|
|
522
|
+
value?: Value$2 | null | undefined
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Raw source map.
|
|
526
|
+
*
|
|
527
|
+
* See:
|
|
528
|
+
* <https://github.com/mozilla/source-map/blob/60adcb0/source-map.d.ts#L15-L23>.
|
|
529
|
+
*/
|
|
530
|
+
type Map$1 = {
|
|
531
|
+
/**
|
|
532
|
+
* Which version of the source map spec this map is following.
|
|
533
|
+
*/
|
|
534
|
+
version: number
|
|
535
|
+
/**
|
|
536
|
+
* An array of URLs to the original source files.
|
|
537
|
+
*/
|
|
538
|
+
sources: Array<string>
|
|
539
|
+
/**
|
|
540
|
+
* An array of identifiers which can be referenced by individual mappings.
|
|
541
|
+
*/
|
|
542
|
+
names: Array<string>
|
|
543
|
+
/**
|
|
544
|
+
* The URL root from which all sources are relative.
|
|
545
|
+
*/
|
|
546
|
+
sourceRoot?: string | undefined
|
|
547
|
+
/**
|
|
548
|
+
* An array of contents of the original source files.
|
|
549
|
+
*/
|
|
550
|
+
sourcesContent?: Array<string> | undefined
|
|
551
|
+
/**
|
|
552
|
+
* A string of base64 VLQs which contain the actual mappings.
|
|
553
|
+
*/
|
|
554
|
+
mappings: string
|
|
555
|
+
/**
|
|
556
|
+
* The generated file this source map is associated with.
|
|
557
|
+
*/
|
|
558
|
+
file: string
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Configuration.
|
|
562
|
+
*
|
|
563
|
+
* A bunch of keys that will be shallow copied over to the new file.
|
|
564
|
+
*/
|
|
565
|
+
type Options$3 = Record<string, unknown> & VFileCoreOptions
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Contents of the file.
|
|
569
|
+
*
|
|
570
|
+
* Can either be text or a `Uint8Array` structure.
|
|
571
|
+
*/
|
|
572
|
+
type Value$1 = Uint8Array | string
|
|
573
|
+
|
|
574
|
+
// See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts>
|
|
575
|
+
declare const emptyObjectSymbol$1: unique symbol
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Interface of known results from compilers.
|
|
579
|
+
*
|
|
580
|
+
* Normally, compilers result in text ({@link Value `Value`} of `vfile`).
|
|
581
|
+
* When you compile to something else, such as a React node (as in,
|
|
582
|
+
* `rehype-react`), you can augment this interface to include that type.
|
|
583
|
+
*
|
|
584
|
+
* ```ts
|
|
585
|
+
* import type {ReactNode} from 'somewhere'
|
|
586
|
+
*
|
|
587
|
+
* declare module 'unified' {
|
|
588
|
+
* interface CompileResultMap {
|
|
589
|
+
* // Register a new result (value is used, key should match it).
|
|
590
|
+
* ReactNode: ReactNode
|
|
591
|
+
* }
|
|
592
|
+
* }
|
|
593
|
+
*
|
|
594
|
+
* export {} // You may not need this, but it makes sure the file is a module.
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* Use {@link CompileResults `CompileResults`} to access the values.
|
|
598
|
+
*/
|
|
599
|
+
interface CompileResultMap$1 {
|
|
600
|
+
// Note: if `Value` from `VFile` is changed, this should too.
|
|
601
|
+
Uint8Array: Uint8Array
|
|
602
|
+
string: string
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Interface of known data that can be supported by all plugins.
|
|
607
|
+
*
|
|
608
|
+
* Typically, options can be given to a specific plugin, but sometimes it makes
|
|
609
|
+
* sense to have information shared with several plugins.
|
|
610
|
+
* For example, a list of HTML elements that are self-closing, which is needed
|
|
611
|
+
* during all phases.
|
|
612
|
+
*
|
|
613
|
+
* To type this, do something like:
|
|
614
|
+
*
|
|
615
|
+
* ```ts
|
|
616
|
+
* declare module 'unified' {
|
|
617
|
+
* interface Data {
|
|
618
|
+
* htmlVoidElements?: Array<string> | undefined
|
|
619
|
+
* }
|
|
620
|
+
* }
|
|
621
|
+
*
|
|
622
|
+
* export {} // You may not need this, but it makes sure the file is a module.
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
interface Data$2 {
|
|
626
|
+
settings?: Settings$2 | undefined
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Interface of known extra options, that can be supported by parser and
|
|
631
|
+
* compilers.
|
|
632
|
+
*
|
|
633
|
+
* This exists so that users can use packages such as `remark`, which configure
|
|
634
|
+
* both parsers and compilers (in this case `remark-parse` and
|
|
635
|
+
* `remark-stringify`), and still provide options for them.
|
|
636
|
+
*
|
|
637
|
+
* When you make parsers or compilers, that could be packaged up together,
|
|
638
|
+
* you should support `this.data('settings')` as input and merge it with
|
|
639
|
+
* explicitly passed `options`.
|
|
640
|
+
* Then, to type it, using `remark-stringify` as an example, do something like:
|
|
641
|
+
*
|
|
642
|
+
* ```ts
|
|
643
|
+
* declare module 'unified' {
|
|
644
|
+
* interface Settings {
|
|
645
|
+
* bullet: '*' | '+' | '-'
|
|
646
|
+
* // …
|
|
647
|
+
* }
|
|
648
|
+
* }
|
|
649
|
+
*
|
|
650
|
+
* export {} // You may not need this, but it makes sure the file is a module.
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
interface Settings$2 {
|
|
654
|
+
[emptyObjectSymbol$1]?: never
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
type Middleware = (...input: Array<any>) => any
|
|
658
|
+
/**
|
|
659
|
+
* Call all middleware.
|
|
660
|
+
*/
|
|
661
|
+
type Run = (...input: Array<any>) => void
|
|
662
|
+
/**
|
|
663
|
+
* Add `fn` (middleware) to the list.
|
|
664
|
+
*/
|
|
665
|
+
type Use = (fn: Middleware) => Pipeline$1
|
|
666
|
+
/**
|
|
667
|
+
* Middleware.
|
|
668
|
+
*/
|
|
669
|
+
type Pipeline$1 = {
|
|
670
|
+
run: Run
|
|
671
|
+
use: Use
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
declare const CallableInstance: new <Parameters_1 extends unknown[], Result>(property: string | symbol) => (...parameters: Parameters_1) => Result;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @template {Node | undefined} [ParseTree=undefined]
|
|
678
|
+
* Output of `parse` (optional).
|
|
679
|
+
* @template {Node | undefined} [HeadTree=undefined]
|
|
680
|
+
* Input for `run` (optional).
|
|
681
|
+
* @template {Node | undefined} [TailTree=undefined]
|
|
682
|
+
* Output for `run` (optional).
|
|
683
|
+
* @template {Node | undefined} [CompileTree=undefined]
|
|
684
|
+
* Input of `stringify` (optional).
|
|
685
|
+
* @template {CompileResults | undefined} [CompileResult=undefined]
|
|
686
|
+
* Output of `stringify` (optional).
|
|
687
|
+
* @extends {CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>>}
|
|
688
|
+
*/
|
|
689
|
+
declare class Processor<ParseTree extends unist.Node | undefined = undefined, HeadTree extends unist.Node | undefined = undefined, TailTree extends unist.Node | undefined = undefined, CompileTree extends unist.Node | undefined = undefined, CompileResult extends CompileResults | undefined = undefined> extends CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>> {
|
|
690
|
+
/**
|
|
691
|
+
* Create a processor.
|
|
692
|
+
*/
|
|
693
|
+
constructor();
|
|
694
|
+
/**
|
|
695
|
+
* Compiler to use (deprecated).
|
|
696
|
+
*
|
|
697
|
+
* @deprecated
|
|
698
|
+
* Use `compiler` instead.
|
|
699
|
+
* @type {(
|
|
700
|
+
* Compiler<
|
|
701
|
+
* CompileTree extends undefined ? Node : CompileTree,
|
|
702
|
+
* CompileResult extends undefined ? CompileResults : CompileResult
|
|
703
|
+
* > |
|
|
704
|
+
* undefined
|
|
705
|
+
* )}
|
|
706
|
+
*/
|
|
707
|
+
Compiler: (Compiler<CompileTree extends undefined ? Node : CompileTree, CompileResult extends undefined ? CompileResults : CompileResult> | undefined);
|
|
708
|
+
/**
|
|
709
|
+
* Parser to use (deprecated).
|
|
710
|
+
*
|
|
711
|
+
* @deprecated
|
|
712
|
+
* Use `parser` instead.
|
|
713
|
+
* @type {(
|
|
714
|
+
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
|
715
|
+
* undefined
|
|
716
|
+
* )}
|
|
717
|
+
*/
|
|
718
|
+
Parser: (Parser<ParseTree extends undefined ? Node : ParseTree> | undefined);
|
|
719
|
+
/**
|
|
720
|
+
* Internal list of configured plugins.
|
|
721
|
+
*
|
|
722
|
+
* @deprecated
|
|
723
|
+
* This is a private internal property and should not be used.
|
|
724
|
+
* @type {Array<PluginTuple<Array<unknown>>>}
|
|
725
|
+
*/
|
|
726
|
+
attachers: Array<[plugin: Plugin<unknown[], undefined, undefined>, ...parameters: unknown[]]>;
|
|
727
|
+
/**
|
|
728
|
+
* Compiler to use.
|
|
729
|
+
*
|
|
730
|
+
* @type {(
|
|
731
|
+
* Compiler<
|
|
732
|
+
* CompileTree extends undefined ? Node : CompileTree,
|
|
733
|
+
* CompileResult extends undefined ? CompileResults : CompileResult
|
|
734
|
+
* > |
|
|
735
|
+
* undefined
|
|
736
|
+
* )}
|
|
737
|
+
*/
|
|
738
|
+
compiler: (Compiler<CompileTree extends undefined ? Node : CompileTree, CompileResult extends undefined ? CompileResults : CompileResult> | undefined);
|
|
739
|
+
/**
|
|
740
|
+
* Internal state to track where we are while freezing.
|
|
741
|
+
*
|
|
742
|
+
* @deprecated
|
|
743
|
+
* This is a private internal property and should not be used.
|
|
744
|
+
* @type {number}
|
|
745
|
+
*/
|
|
746
|
+
freezeIndex: number;
|
|
747
|
+
/**
|
|
748
|
+
* Internal state to track whether we’re frozen.
|
|
749
|
+
*
|
|
750
|
+
* @deprecated
|
|
751
|
+
* This is a private internal property and should not be used.
|
|
752
|
+
* @type {boolean | undefined}
|
|
753
|
+
*/
|
|
754
|
+
frozen: boolean | undefined;
|
|
755
|
+
/**
|
|
756
|
+
* Internal state.
|
|
757
|
+
*
|
|
758
|
+
* @deprecated
|
|
759
|
+
* This is a private internal property and should not be used.
|
|
760
|
+
* @type {Data}
|
|
761
|
+
*/
|
|
762
|
+
namespace: Data$1;
|
|
763
|
+
/**
|
|
764
|
+
* Parser to use.
|
|
765
|
+
*
|
|
766
|
+
* @type {(
|
|
767
|
+
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
|
768
|
+
* undefined
|
|
769
|
+
* )}
|
|
770
|
+
*/
|
|
771
|
+
parser: (Parser<ParseTree extends undefined ? Node : ParseTree> | undefined);
|
|
772
|
+
/**
|
|
773
|
+
* Internal list of configured transformers.
|
|
774
|
+
*
|
|
775
|
+
* @deprecated
|
|
776
|
+
* This is a private internal property and should not be used.
|
|
777
|
+
* @type {Pipeline}
|
|
778
|
+
*/
|
|
779
|
+
transformers: Pipeline;
|
|
780
|
+
/**
|
|
781
|
+
* Copy a processor.
|
|
782
|
+
*
|
|
783
|
+
* @deprecated
|
|
784
|
+
* This is a private internal method and should not be used.
|
|
785
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
786
|
+
* New *unfrozen* processor ({@link Processor `Processor`}) that is
|
|
787
|
+
* configured to work the same as its ancestor.
|
|
788
|
+
* When the descendant processor is configured in the future it does not
|
|
789
|
+
* affect the ancestral processor.
|
|
790
|
+
*/
|
|
791
|
+
copy(): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
792
|
+
/**
|
|
793
|
+
* Configure the processor with info available to all plugins.
|
|
794
|
+
* Information is stored in an object.
|
|
795
|
+
*
|
|
796
|
+
* Typically, options can be given to a specific plugin, but sometimes it
|
|
797
|
+
* makes sense to have information shared with several plugins.
|
|
798
|
+
* For example, a list of HTML elements that are self-closing, which is
|
|
799
|
+
* needed during all phases.
|
|
800
|
+
*
|
|
801
|
+
* > 👉 **Note**: setting information cannot occur on *frozen* processors.
|
|
802
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
803
|
+
*
|
|
804
|
+
* > 👉 **Note**: to register custom data in TypeScript, augment the
|
|
805
|
+
* > {@link Data `Data`} interface.
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* This example show how to get and set info:
|
|
809
|
+
*
|
|
810
|
+
* ```js
|
|
811
|
+
* import {unified} from 'unified'
|
|
812
|
+
*
|
|
813
|
+
* const processor = unified().data('alpha', 'bravo')
|
|
814
|
+
*
|
|
815
|
+
* processor.data('alpha') // => 'bravo'
|
|
816
|
+
*
|
|
817
|
+
* processor.data() // => {alpha: 'bravo'}
|
|
818
|
+
*
|
|
819
|
+
* processor.data({charlie: 'delta'})
|
|
820
|
+
*
|
|
821
|
+
* processor.data() // => {charlie: 'delta'}
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @template {keyof Data} Key
|
|
825
|
+
*
|
|
826
|
+
* @overload
|
|
827
|
+
* @returns {Data}
|
|
828
|
+
*
|
|
829
|
+
* @overload
|
|
830
|
+
* @param {Data} dataset
|
|
831
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
832
|
+
*
|
|
833
|
+
* @overload
|
|
834
|
+
* @param {Key} key
|
|
835
|
+
* @returns {Data[Key]}
|
|
836
|
+
*
|
|
837
|
+
* @overload
|
|
838
|
+
* @param {Key} key
|
|
839
|
+
* @param {Data[Key]} value
|
|
840
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
841
|
+
*
|
|
842
|
+
* @param {Data | Key} [key]
|
|
843
|
+
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
844
|
+
* entire dataset (optional).
|
|
845
|
+
* @param {Data[Key]} [value]
|
|
846
|
+
* Value to set (optional).
|
|
847
|
+
* @returns {unknown}
|
|
848
|
+
* The current processor when setting, the value at `key` when getting, or
|
|
849
|
+
* the entire dataset when getting without key.
|
|
850
|
+
*/
|
|
851
|
+
data<Key extends keyof Data>(): Data$1;
|
|
852
|
+
/**
|
|
853
|
+
* Configure the processor with info available to all plugins.
|
|
854
|
+
* Information is stored in an object.
|
|
855
|
+
*
|
|
856
|
+
* Typically, options can be given to a specific plugin, but sometimes it
|
|
857
|
+
* makes sense to have information shared with several plugins.
|
|
858
|
+
* For example, a list of HTML elements that are self-closing, which is
|
|
859
|
+
* needed during all phases.
|
|
860
|
+
*
|
|
861
|
+
* > 👉 **Note**: setting information cannot occur on *frozen* processors.
|
|
862
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
863
|
+
*
|
|
864
|
+
* > 👉 **Note**: to register custom data in TypeScript, augment the
|
|
865
|
+
* > {@link Data `Data`} interface.
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
* This example show how to get and set info:
|
|
869
|
+
*
|
|
870
|
+
* ```js
|
|
871
|
+
* import {unified} from 'unified'
|
|
872
|
+
*
|
|
873
|
+
* const processor = unified().data('alpha', 'bravo')
|
|
874
|
+
*
|
|
875
|
+
* processor.data('alpha') // => 'bravo'
|
|
876
|
+
*
|
|
877
|
+
* processor.data() // => {alpha: 'bravo'}
|
|
878
|
+
*
|
|
879
|
+
* processor.data({charlie: 'delta'})
|
|
880
|
+
*
|
|
881
|
+
* processor.data() // => {charlie: 'delta'}
|
|
882
|
+
* ```
|
|
883
|
+
*
|
|
884
|
+
* @template {keyof Data} Key
|
|
885
|
+
*
|
|
886
|
+
* @overload
|
|
887
|
+
* @returns {Data}
|
|
888
|
+
*
|
|
889
|
+
* @overload
|
|
890
|
+
* @param {Data} dataset
|
|
891
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
892
|
+
*
|
|
893
|
+
* @overload
|
|
894
|
+
* @param {Key} key
|
|
895
|
+
* @returns {Data[Key]}
|
|
896
|
+
*
|
|
897
|
+
* @overload
|
|
898
|
+
* @param {Key} key
|
|
899
|
+
* @param {Data[Key]} value
|
|
900
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
901
|
+
*
|
|
902
|
+
* @param {Data | Key} [key]
|
|
903
|
+
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
904
|
+
* entire dataset (optional).
|
|
905
|
+
* @param {Data[Key]} [value]
|
|
906
|
+
* Value to set (optional).
|
|
907
|
+
* @returns {unknown}
|
|
908
|
+
* The current processor when setting, the value at `key` when getting, or
|
|
909
|
+
* the entire dataset when getting without key.
|
|
910
|
+
*/
|
|
911
|
+
data<Key extends keyof Data>(dataset: Data$1): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
912
|
+
/**
|
|
913
|
+
* Configure the processor with info available to all plugins.
|
|
914
|
+
* Information is stored in an object.
|
|
915
|
+
*
|
|
916
|
+
* Typically, options can be given to a specific plugin, but sometimes it
|
|
917
|
+
* makes sense to have information shared with several plugins.
|
|
918
|
+
* For example, a list of HTML elements that are self-closing, which is
|
|
919
|
+
* needed during all phases.
|
|
920
|
+
*
|
|
921
|
+
* > 👉 **Note**: setting information cannot occur on *frozen* processors.
|
|
922
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
923
|
+
*
|
|
924
|
+
* > 👉 **Note**: to register custom data in TypeScript, augment the
|
|
925
|
+
* > {@link Data `Data`} interface.
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* This example show how to get and set info:
|
|
929
|
+
*
|
|
930
|
+
* ```js
|
|
931
|
+
* import {unified} from 'unified'
|
|
932
|
+
*
|
|
933
|
+
* const processor = unified().data('alpha', 'bravo')
|
|
934
|
+
*
|
|
935
|
+
* processor.data('alpha') // => 'bravo'
|
|
936
|
+
*
|
|
937
|
+
* processor.data() // => {alpha: 'bravo'}
|
|
938
|
+
*
|
|
939
|
+
* processor.data({charlie: 'delta'})
|
|
940
|
+
*
|
|
941
|
+
* processor.data() // => {charlie: 'delta'}
|
|
942
|
+
* ```
|
|
943
|
+
*
|
|
944
|
+
* @template {keyof Data} Key
|
|
945
|
+
*
|
|
946
|
+
* @overload
|
|
947
|
+
* @returns {Data}
|
|
948
|
+
*
|
|
949
|
+
* @overload
|
|
950
|
+
* @param {Data} dataset
|
|
951
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
952
|
+
*
|
|
953
|
+
* @overload
|
|
954
|
+
* @param {Key} key
|
|
955
|
+
* @returns {Data[Key]}
|
|
956
|
+
*
|
|
957
|
+
* @overload
|
|
958
|
+
* @param {Key} key
|
|
959
|
+
* @param {Data[Key]} value
|
|
960
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
961
|
+
*
|
|
962
|
+
* @param {Data | Key} [key]
|
|
963
|
+
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
964
|
+
* entire dataset (optional).
|
|
965
|
+
* @param {Data[Key]} [value]
|
|
966
|
+
* Value to set (optional).
|
|
967
|
+
* @returns {unknown}
|
|
968
|
+
* The current processor when setting, the value at `key` when getting, or
|
|
969
|
+
* the entire dataset when getting without key.
|
|
970
|
+
*/
|
|
971
|
+
data<Key extends keyof Data>(key: Key): Data[Key];
|
|
972
|
+
/**
|
|
973
|
+
* Configure the processor with info available to all plugins.
|
|
974
|
+
* Information is stored in an object.
|
|
975
|
+
*
|
|
976
|
+
* Typically, options can be given to a specific plugin, but sometimes it
|
|
977
|
+
* makes sense to have information shared with several plugins.
|
|
978
|
+
* For example, a list of HTML elements that are self-closing, which is
|
|
979
|
+
* needed during all phases.
|
|
980
|
+
*
|
|
981
|
+
* > 👉 **Note**: setting information cannot occur on *frozen* processors.
|
|
982
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
983
|
+
*
|
|
984
|
+
* > 👉 **Note**: to register custom data in TypeScript, augment the
|
|
985
|
+
* > {@link Data `Data`} interface.
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* This example show how to get and set info:
|
|
989
|
+
*
|
|
990
|
+
* ```js
|
|
991
|
+
* import {unified} from 'unified'
|
|
992
|
+
*
|
|
993
|
+
* const processor = unified().data('alpha', 'bravo')
|
|
994
|
+
*
|
|
995
|
+
* processor.data('alpha') // => 'bravo'
|
|
996
|
+
*
|
|
997
|
+
* processor.data() // => {alpha: 'bravo'}
|
|
998
|
+
*
|
|
999
|
+
* processor.data({charlie: 'delta'})
|
|
1000
|
+
*
|
|
1001
|
+
* processor.data() // => {charlie: 'delta'}
|
|
1002
|
+
* ```
|
|
1003
|
+
*
|
|
1004
|
+
* @template {keyof Data} Key
|
|
1005
|
+
*
|
|
1006
|
+
* @overload
|
|
1007
|
+
* @returns {Data}
|
|
1008
|
+
*
|
|
1009
|
+
* @overload
|
|
1010
|
+
* @param {Data} dataset
|
|
1011
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1012
|
+
*
|
|
1013
|
+
* @overload
|
|
1014
|
+
* @param {Key} key
|
|
1015
|
+
* @returns {Data[Key]}
|
|
1016
|
+
*
|
|
1017
|
+
* @overload
|
|
1018
|
+
* @param {Key} key
|
|
1019
|
+
* @param {Data[Key]} value
|
|
1020
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1021
|
+
*
|
|
1022
|
+
* @param {Data | Key} [key]
|
|
1023
|
+
* Key to get or set, or entire dataset to set, or nothing to get the
|
|
1024
|
+
* entire dataset (optional).
|
|
1025
|
+
* @param {Data[Key]} [value]
|
|
1026
|
+
* Value to set (optional).
|
|
1027
|
+
* @returns {unknown}
|
|
1028
|
+
* The current processor when setting, the value at `key` when getting, or
|
|
1029
|
+
* the entire dataset when getting without key.
|
|
1030
|
+
*/
|
|
1031
|
+
data<Key extends keyof Data>(key: Key, value: Data[Key]): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Freeze a processor.
|
|
1034
|
+
*
|
|
1035
|
+
* Frozen processors are meant to be extended and not to be configured
|
|
1036
|
+
* directly.
|
|
1037
|
+
*
|
|
1038
|
+
* When a processor is frozen it cannot be unfrozen.
|
|
1039
|
+
* New processors working the same way can be created by calling the
|
|
1040
|
+
* processor.
|
|
1041
|
+
*
|
|
1042
|
+
* It’s possible to freeze processors explicitly by calling `.freeze()`.
|
|
1043
|
+
* Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
|
|
1044
|
+
* `.stringify()`, `.process()`, or `.processSync()` are called.
|
|
1045
|
+
*
|
|
1046
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1047
|
+
* The current processor.
|
|
1048
|
+
*/
|
|
1049
|
+
freeze(): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Parse text to a syntax tree.
|
|
1052
|
+
*
|
|
1053
|
+
* > 👉 **Note**: `parse` freezes the processor if not already *frozen*.
|
|
1054
|
+
*
|
|
1055
|
+
* > 👉 **Note**: `parse` performs the parse phase, not the run phase or other
|
|
1056
|
+
* > phases.
|
|
1057
|
+
*
|
|
1058
|
+
* @param {Compatible | undefined} [file]
|
|
1059
|
+
* file to parse (optional); typically `string` or `VFile`; any value
|
|
1060
|
+
* accepted as `x` in `new VFile(x)`.
|
|
1061
|
+
* @returns {ParseTree extends undefined ? Node : ParseTree}
|
|
1062
|
+
* Syntax tree representing `file`.
|
|
1063
|
+
*/
|
|
1064
|
+
parse(file?: Compatible$1 | undefined): ParseTree extends undefined ? Node : ParseTree;
|
|
1065
|
+
/**
|
|
1066
|
+
* Process the given file as configured on the processor.
|
|
1067
|
+
*
|
|
1068
|
+
* > 👉 **Note**: `process` freezes the processor if not already *frozen*.
|
|
1069
|
+
*
|
|
1070
|
+
* > 👉 **Note**: `process` performs the parse, run, and stringify phases.
|
|
1071
|
+
*
|
|
1072
|
+
* @overload
|
|
1073
|
+
* @param {Compatible | undefined} file
|
|
1074
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
|
1075
|
+
* @returns {undefined}
|
|
1076
|
+
*
|
|
1077
|
+
* @overload
|
|
1078
|
+
* @param {Compatible | undefined} [file]
|
|
1079
|
+
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
|
1080
|
+
*
|
|
1081
|
+
* @param {Compatible | undefined} [file]
|
|
1082
|
+
* File (optional); typically `string` or `VFile`]; any value accepted as
|
|
1083
|
+
* `x` in `new VFile(x)`.
|
|
1084
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
|
1085
|
+
* Callback (optional).
|
|
1086
|
+
* @returns {Promise<VFile> | undefined}
|
|
1087
|
+
* Nothing if `done` is given.
|
|
1088
|
+
* Otherwise a promise, rejected with a fatal error or resolved with the
|
|
1089
|
+
* processed file.
|
|
1090
|
+
*
|
|
1091
|
+
* The parsed, transformed, and compiled value is available at
|
|
1092
|
+
* `file.value` (see note).
|
|
1093
|
+
*
|
|
1094
|
+
* > 👉 **Note**: unified typically compiles by serializing: most
|
|
1095
|
+
* > compilers return `string` (or `Uint8Array`).
|
|
1096
|
+
* > Some compilers, such as the one configured with
|
|
1097
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
1098
|
+
* > React tree).
|
|
1099
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
1100
|
+
* > result values.
|
|
1101
|
+
* >
|
|
1102
|
+
* > To register custom results in TypeScript, add them to
|
|
1103
|
+
* > {@link CompileResultMap `CompileResultMap`}.
|
|
1104
|
+
*
|
|
1105
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
1106
|
+
*/
|
|
1107
|
+
process(file: Compatible$1 | undefined, done: ProcessCallback<VFileWithOutput<CompileResult>>): undefined;
|
|
1108
|
+
/**
|
|
1109
|
+
* Process the given file as configured on the processor.
|
|
1110
|
+
*
|
|
1111
|
+
* > 👉 **Note**: `process` freezes the processor if not already *frozen*.
|
|
1112
|
+
*
|
|
1113
|
+
* > 👉 **Note**: `process` performs the parse, run, and stringify phases.
|
|
1114
|
+
*
|
|
1115
|
+
* @overload
|
|
1116
|
+
* @param {Compatible | undefined} file
|
|
1117
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
|
1118
|
+
* @returns {undefined}
|
|
1119
|
+
*
|
|
1120
|
+
* @overload
|
|
1121
|
+
* @param {Compatible | undefined} [file]
|
|
1122
|
+
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
|
1123
|
+
*
|
|
1124
|
+
* @param {Compatible | undefined} [file]
|
|
1125
|
+
* File (optional); typically `string` or `VFile`]; any value accepted as
|
|
1126
|
+
* `x` in `new VFile(x)`.
|
|
1127
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
|
1128
|
+
* Callback (optional).
|
|
1129
|
+
* @returns {Promise<VFile> | undefined}
|
|
1130
|
+
* Nothing if `done` is given.
|
|
1131
|
+
* Otherwise a promise, rejected with a fatal error or resolved with the
|
|
1132
|
+
* processed file.
|
|
1133
|
+
*
|
|
1134
|
+
* The parsed, transformed, and compiled value is available at
|
|
1135
|
+
* `file.value` (see note).
|
|
1136
|
+
*
|
|
1137
|
+
* > 👉 **Note**: unified typically compiles by serializing: most
|
|
1138
|
+
* > compilers return `string` (or `Uint8Array`).
|
|
1139
|
+
* > Some compilers, such as the one configured with
|
|
1140
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
1141
|
+
* > React tree).
|
|
1142
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
1143
|
+
* > result values.
|
|
1144
|
+
* >
|
|
1145
|
+
* > To register custom results in TypeScript, add them to
|
|
1146
|
+
* > {@link CompileResultMap `CompileResultMap`}.
|
|
1147
|
+
*
|
|
1148
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
1149
|
+
*/
|
|
1150
|
+
process(file?: Compatible$1 | undefined): Promise<VFileWithOutput<CompileResult>>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Process the given file as configured on the processor.
|
|
1153
|
+
*
|
|
1154
|
+
* An error is thrown if asynchronous transforms are configured.
|
|
1155
|
+
*
|
|
1156
|
+
* > 👉 **Note**: `processSync` freezes the processor if not already *frozen*.
|
|
1157
|
+
*
|
|
1158
|
+
* > 👉 **Note**: `processSync` performs the parse, run, and stringify phases.
|
|
1159
|
+
*
|
|
1160
|
+
* @param {Compatible | undefined} [file]
|
|
1161
|
+
* File (optional); typically `string` or `VFile`; any value accepted as
|
|
1162
|
+
* `x` in `new VFile(x)`.
|
|
1163
|
+
* @returns {VFileWithOutput<CompileResult>}
|
|
1164
|
+
* The processed file.
|
|
1165
|
+
*
|
|
1166
|
+
* The parsed, transformed, and compiled value is available at
|
|
1167
|
+
* `file.value` (see note).
|
|
1168
|
+
*
|
|
1169
|
+
* > 👉 **Note**: unified typically compiles by serializing: most
|
|
1170
|
+
* > compilers return `string` (or `Uint8Array`).
|
|
1171
|
+
* > Some compilers, such as the one configured with
|
|
1172
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
1173
|
+
* > React tree).
|
|
1174
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
1175
|
+
* > result values.
|
|
1176
|
+
* >
|
|
1177
|
+
* > To register custom results in TypeScript, add them to
|
|
1178
|
+
* > {@link CompileResultMap `CompileResultMap`}.
|
|
1179
|
+
*
|
|
1180
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
1181
|
+
*/
|
|
1182
|
+
processSync(file?: Compatible$1 | undefined): VFileWithOutput<CompileResult>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Run *transformers* on a syntax tree.
|
|
1185
|
+
*
|
|
1186
|
+
* > 👉 **Note**: `run` freezes the processor if not already *frozen*.
|
|
1187
|
+
*
|
|
1188
|
+
* > 👉 **Note**: `run` performs the run phase, not other phases.
|
|
1189
|
+
*
|
|
1190
|
+
* @overload
|
|
1191
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1192
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1193
|
+
* @returns {undefined}
|
|
1194
|
+
*
|
|
1195
|
+
* @overload
|
|
1196
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1197
|
+
* @param {Compatible | undefined} file
|
|
1198
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1199
|
+
* @returns {undefined}
|
|
1200
|
+
*
|
|
1201
|
+
* @overload
|
|
1202
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1203
|
+
* @param {Compatible | undefined} [file]
|
|
1204
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
1205
|
+
*
|
|
1206
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1207
|
+
* Tree to transform and inspect.
|
|
1208
|
+
* @param {(
|
|
1209
|
+
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
1210
|
+
* Compatible
|
|
1211
|
+
* )} [file]
|
|
1212
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
|
1213
|
+
* `new VFile(x)`.
|
|
1214
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
1215
|
+
* Callback (optional).
|
|
1216
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
1217
|
+
* Nothing if `done` is given.
|
|
1218
|
+
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
1219
|
+
* transformed tree.
|
|
1220
|
+
*/
|
|
1221
|
+
run(tree: HeadTree extends undefined ? Node : HeadTree, done: RunCallback<TailTree extends undefined ? Node : TailTree>): undefined;
|
|
1222
|
+
/**
|
|
1223
|
+
* Run *transformers* on a syntax tree.
|
|
1224
|
+
*
|
|
1225
|
+
* > 👉 **Note**: `run` freezes the processor if not already *frozen*.
|
|
1226
|
+
*
|
|
1227
|
+
* > 👉 **Note**: `run` performs the run phase, not other phases.
|
|
1228
|
+
*
|
|
1229
|
+
* @overload
|
|
1230
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1231
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1232
|
+
* @returns {undefined}
|
|
1233
|
+
*
|
|
1234
|
+
* @overload
|
|
1235
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1236
|
+
* @param {Compatible | undefined} file
|
|
1237
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1238
|
+
* @returns {undefined}
|
|
1239
|
+
*
|
|
1240
|
+
* @overload
|
|
1241
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1242
|
+
* @param {Compatible | undefined} [file]
|
|
1243
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
1244
|
+
*
|
|
1245
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1246
|
+
* Tree to transform and inspect.
|
|
1247
|
+
* @param {(
|
|
1248
|
+
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
1249
|
+
* Compatible
|
|
1250
|
+
* )} [file]
|
|
1251
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
|
1252
|
+
* `new VFile(x)`.
|
|
1253
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
1254
|
+
* Callback (optional).
|
|
1255
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
1256
|
+
* Nothing if `done` is given.
|
|
1257
|
+
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
1258
|
+
* transformed tree.
|
|
1259
|
+
*/
|
|
1260
|
+
run(tree: HeadTree extends undefined ? Node : HeadTree, file: Compatible$1 | undefined, done: RunCallback<TailTree extends undefined ? Node : TailTree>): undefined;
|
|
1261
|
+
/**
|
|
1262
|
+
* Run *transformers* on a syntax tree.
|
|
1263
|
+
*
|
|
1264
|
+
* > 👉 **Note**: `run` freezes the processor if not already *frozen*.
|
|
1265
|
+
*
|
|
1266
|
+
* > 👉 **Note**: `run` performs the run phase, not other phases.
|
|
1267
|
+
*
|
|
1268
|
+
* @overload
|
|
1269
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1270
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1271
|
+
* @returns {undefined}
|
|
1272
|
+
*
|
|
1273
|
+
* @overload
|
|
1274
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1275
|
+
* @param {Compatible | undefined} file
|
|
1276
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
|
1277
|
+
* @returns {undefined}
|
|
1278
|
+
*
|
|
1279
|
+
* @overload
|
|
1280
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1281
|
+
* @param {Compatible | undefined} [file]
|
|
1282
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
|
1283
|
+
*
|
|
1284
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1285
|
+
* Tree to transform and inspect.
|
|
1286
|
+
* @param {(
|
|
1287
|
+
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
|
1288
|
+
* Compatible
|
|
1289
|
+
* )} [file]
|
|
1290
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
|
1291
|
+
* `new VFile(x)`.
|
|
1292
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
|
1293
|
+
* Callback (optional).
|
|
1294
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
|
1295
|
+
* Nothing if `done` is given.
|
|
1296
|
+
* Otherwise, a promise rejected with a fatal error or resolved with the
|
|
1297
|
+
* transformed tree.
|
|
1298
|
+
*/
|
|
1299
|
+
run(tree: HeadTree extends undefined ? Node : HeadTree, file?: Compatible$1 | undefined): Promise<TailTree extends undefined ? Node : TailTree>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Run *transformers* on a syntax tree.
|
|
1302
|
+
*
|
|
1303
|
+
* An error is thrown if asynchronous transforms are configured.
|
|
1304
|
+
*
|
|
1305
|
+
* > 👉 **Note**: `runSync` freezes the processor if not already *frozen*.
|
|
1306
|
+
*
|
|
1307
|
+
* > 👉 **Note**: `runSync` performs the run phase, not other phases.
|
|
1308
|
+
*
|
|
1309
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
|
1310
|
+
* Tree to transform and inspect.
|
|
1311
|
+
* @param {Compatible | undefined} [file]
|
|
1312
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
|
1313
|
+
* `new VFile(x)`.
|
|
1314
|
+
* @returns {TailTree extends undefined ? Node : TailTree}
|
|
1315
|
+
* Transformed tree.
|
|
1316
|
+
*/
|
|
1317
|
+
runSync(tree: HeadTree extends undefined ? Node : HeadTree, file?: Compatible$1 | undefined): TailTree extends undefined ? Node : TailTree;
|
|
1318
|
+
/**
|
|
1319
|
+
* Compile a syntax tree.
|
|
1320
|
+
*
|
|
1321
|
+
* > 👉 **Note**: `stringify` freezes the processor if not already *frozen*.
|
|
1322
|
+
*
|
|
1323
|
+
* > 👉 **Note**: `stringify` performs the stringify phase, not the run phase
|
|
1324
|
+
* > or other phases.
|
|
1325
|
+
*
|
|
1326
|
+
* @param {CompileTree extends undefined ? Node : CompileTree} tree
|
|
1327
|
+
* Tree to compile.
|
|
1328
|
+
* @param {Compatible | undefined} [file]
|
|
1329
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
|
1330
|
+
* `new VFile(x)`.
|
|
1331
|
+
* @returns {CompileResult extends undefined ? Value : CompileResult}
|
|
1332
|
+
* Textual representation of the tree (see note).
|
|
1333
|
+
*
|
|
1334
|
+
* > 👉 **Note**: unified typically compiles by serializing: most compilers
|
|
1335
|
+
* > return `string` (or `Uint8Array`).
|
|
1336
|
+
* > Some compilers, such as the one configured with
|
|
1337
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
1338
|
+
* > React tree).
|
|
1339
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
1340
|
+
* > result values.
|
|
1341
|
+
* >
|
|
1342
|
+
* > To register custom results in TypeScript, add them to
|
|
1343
|
+
* > {@link CompileResultMap `CompileResultMap`}.
|
|
1344
|
+
*
|
|
1345
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
1346
|
+
*/
|
|
1347
|
+
stringify(tree: CompileTree extends undefined ? Node : CompileTree, file?: Compatible$1 | undefined): CompileResult extends undefined ? Value : CompileResult;
|
|
1348
|
+
/**
|
|
1349
|
+
* Configure the processor to use a plugin, a list of usable values, or a
|
|
1350
|
+
* preset.
|
|
1351
|
+
*
|
|
1352
|
+
* If the processor is already using a plugin, the previous plugin
|
|
1353
|
+
* configuration is changed based on the options that are passed in.
|
|
1354
|
+
* In other words, the plugin is not added a second time.
|
|
1355
|
+
*
|
|
1356
|
+
* > 👉 **Note**: `use` cannot be called on *frozen* processors.
|
|
1357
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* There are many ways to pass plugins to `.use()`.
|
|
1361
|
+
* This example gives an overview:
|
|
1362
|
+
*
|
|
1363
|
+
* ```js
|
|
1364
|
+
* import {unified} from 'unified'
|
|
1365
|
+
*
|
|
1366
|
+
* unified()
|
|
1367
|
+
* // Plugin with options:
|
|
1368
|
+
* .use(pluginA, {x: true, y: true})
|
|
1369
|
+
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
1370
|
+
* .use(pluginA, {y: false, z: true})
|
|
1371
|
+
* // Plugins:
|
|
1372
|
+
* .use([pluginB, pluginC])
|
|
1373
|
+
* // Two plugins, the second with options:
|
|
1374
|
+
* .use([pluginD, [pluginE, {}]])
|
|
1375
|
+
* // Preset with plugins and settings:
|
|
1376
|
+
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
1377
|
+
* // Settings only:
|
|
1378
|
+
* .use({settings: {position: false}})
|
|
1379
|
+
* ```
|
|
1380
|
+
*
|
|
1381
|
+
* @template {Array<unknown>} [Parameters=[]]
|
|
1382
|
+
* @template {Node | string | undefined} [Input=undefined]
|
|
1383
|
+
* @template [Output=Input]
|
|
1384
|
+
*
|
|
1385
|
+
* @overload
|
|
1386
|
+
* @param {Preset | null | undefined} [preset]
|
|
1387
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1388
|
+
*
|
|
1389
|
+
* @overload
|
|
1390
|
+
* @param {PluggableList} list
|
|
1391
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1392
|
+
*
|
|
1393
|
+
* @overload
|
|
1394
|
+
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
1395
|
+
* @param {...(Parameters | [boolean])} parameters
|
|
1396
|
+
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
1397
|
+
*
|
|
1398
|
+
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
1399
|
+
* Usable value.
|
|
1400
|
+
* @param {...unknown} parameters
|
|
1401
|
+
* Parameters, when a plugin is given as a usable value.
|
|
1402
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1403
|
+
* Current processor.
|
|
1404
|
+
*/
|
|
1405
|
+
use<Parameters_2 extends unknown[] = [], Input extends string | unist.Node | undefined = undefined, Output = Input>(preset?: Preset | null | undefined): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
1406
|
+
/**
|
|
1407
|
+
* Configure the processor to use a plugin, a list of usable values, or a
|
|
1408
|
+
* preset.
|
|
1409
|
+
*
|
|
1410
|
+
* If the processor is already using a plugin, the previous plugin
|
|
1411
|
+
* configuration is changed based on the options that are passed in.
|
|
1412
|
+
* In other words, the plugin is not added a second time.
|
|
1413
|
+
*
|
|
1414
|
+
* > 👉 **Note**: `use` cannot be called on *frozen* processors.
|
|
1415
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* There are many ways to pass plugins to `.use()`.
|
|
1419
|
+
* This example gives an overview:
|
|
1420
|
+
*
|
|
1421
|
+
* ```js
|
|
1422
|
+
* import {unified} from 'unified'
|
|
1423
|
+
*
|
|
1424
|
+
* unified()
|
|
1425
|
+
* // Plugin with options:
|
|
1426
|
+
* .use(pluginA, {x: true, y: true})
|
|
1427
|
+
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
1428
|
+
* .use(pluginA, {y: false, z: true})
|
|
1429
|
+
* // Plugins:
|
|
1430
|
+
* .use([pluginB, pluginC])
|
|
1431
|
+
* // Two plugins, the second with options:
|
|
1432
|
+
* .use([pluginD, [pluginE, {}]])
|
|
1433
|
+
* // Preset with plugins and settings:
|
|
1434
|
+
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
1435
|
+
* // Settings only:
|
|
1436
|
+
* .use({settings: {position: false}})
|
|
1437
|
+
* ```
|
|
1438
|
+
*
|
|
1439
|
+
* @template {Array<unknown>} [Parameters=[]]
|
|
1440
|
+
* @template {Node | string | undefined} [Input=undefined]
|
|
1441
|
+
* @template [Output=Input]
|
|
1442
|
+
*
|
|
1443
|
+
* @overload
|
|
1444
|
+
* @param {Preset | null | undefined} [preset]
|
|
1445
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1446
|
+
*
|
|
1447
|
+
* @overload
|
|
1448
|
+
* @param {PluggableList} list
|
|
1449
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1450
|
+
*
|
|
1451
|
+
* @overload
|
|
1452
|
+
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
1453
|
+
* @param {...(Parameters | [boolean])} parameters
|
|
1454
|
+
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
1455
|
+
*
|
|
1456
|
+
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
1457
|
+
* Usable value.
|
|
1458
|
+
* @param {...unknown} parameters
|
|
1459
|
+
* Parameters, when a plugin is given as a usable value.
|
|
1460
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1461
|
+
* Current processor.
|
|
1462
|
+
*/
|
|
1463
|
+
use<Parameters_2 extends unknown[] = [], Input extends string | unist.Node | undefined = undefined, Output = Input>(list: PluggableList): Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>;
|
|
1464
|
+
/**
|
|
1465
|
+
* Configure the processor to use a plugin, a list of usable values, or a
|
|
1466
|
+
* preset.
|
|
1467
|
+
*
|
|
1468
|
+
* If the processor is already using a plugin, the previous plugin
|
|
1469
|
+
* configuration is changed based on the options that are passed in.
|
|
1470
|
+
* In other words, the plugin is not added a second time.
|
|
1471
|
+
*
|
|
1472
|
+
* > 👉 **Note**: `use` cannot be called on *frozen* processors.
|
|
1473
|
+
* > Call the processor first to create a new unfrozen processor.
|
|
1474
|
+
*
|
|
1475
|
+
* @example
|
|
1476
|
+
* There are many ways to pass plugins to `.use()`.
|
|
1477
|
+
* This example gives an overview:
|
|
1478
|
+
*
|
|
1479
|
+
* ```js
|
|
1480
|
+
* import {unified} from 'unified'
|
|
1481
|
+
*
|
|
1482
|
+
* unified()
|
|
1483
|
+
* // Plugin with options:
|
|
1484
|
+
* .use(pluginA, {x: true, y: true})
|
|
1485
|
+
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
|
1486
|
+
* .use(pluginA, {y: false, z: true})
|
|
1487
|
+
* // Plugins:
|
|
1488
|
+
* .use([pluginB, pluginC])
|
|
1489
|
+
* // Two plugins, the second with options:
|
|
1490
|
+
* .use([pluginD, [pluginE, {}]])
|
|
1491
|
+
* // Preset with plugins and settings:
|
|
1492
|
+
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
|
1493
|
+
* // Settings only:
|
|
1494
|
+
* .use({settings: {position: false}})
|
|
1495
|
+
* ```
|
|
1496
|
+
*
|
|
1497
|
+
* @template {Array<unknown>} [Parameters=[]]
|
|
1498
|
+
* @template {Node | string | undefined} [Input=undefined]
|
|
1499
|
+
* @template [Output=Input]
|
|
1500
|
+
*
|
|
1501
|
+
* @overload
|
|
1502
|
+
* @param {Preset | null | undefined} [preset]
|
|
1503
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1504
|
+
*
|
|
1505
|
+
* @overload
|
|
1506
|
+
* @param {PluggableList} list
|
|
1507
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1508
|
+
*
|
|
1509
|
+
* @overload
|
|
1510
|
+
* @param {Plugin<Parameters, Input, Output>} plugin
|
|
1511
|
+
* @param {...(Parameters | [boolean])} parameters
|
|
1512
|
+
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
|
1513
|
+
*
|
|
1514
|
+
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
|
1515
|
+
* Usable value.
|
|
1516
|
+
* @param {...unknown} parameters
|
|
1517
|
+
* Parameters, when a plugin is given as a usable value.
|
|
1518
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
|
1519
|
+
* Current processor.
|
|
1520
|
+
*/
|
|
1521
|
+
use<Parameters_2 extends unknown[] = [], Input extends string | unist.Node | undefined = undefined, Output = Input>(plugin: Plugin<Parameters_2, Input, Output>, ...parameters: Parameters_2 | [boolean]): UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>;
|
|
1522
|
+
}
|
|
1523
|
+
type Pipeline = Pipeline$1;
|
|
1524
|
+
type Node = unist.Node;
|
|
1525
|
+
type Compatible$1 = Compatible$2;
|
|
1526
|
+
type Value = Value$1;
|
|
1527
|
+
type CompileResultMap = CompileResultMap$1;
|
|
1528
|
+
type Data$1 = Data$2;
|
|
1529
|
+
type Settings$1 = Settings$2;
|
|
1530
|
+
/**
|
|
1531
|
+
* Acceptable results from compilers.
|
|
1532
|
+
*
|
|
1533
|
+
* To register custom results, add them to
|
|
1534
|
+
* {@link CompileResultMap `CompileResultMap`}.
|
|
1535
|
+
*/
|
|
1536
|
+
type CompileResults = CompileResultMap[keyof CompileResultMap];
|
|
1537
|
+
/**
|
|
1538
|
+
* A **compiler** handles the compiling of a syntax tree to something else
|
|
1539
|
+
* (in most cases, text) (TypeScript type).
|
|
1540
|
+
*
|
|
1541
|
+
* It is used in the stringify phase and called with a {@link Node `Node`}
|
|
1542
|
+
* and {@link VFile `VFile`} representation of the document to compile.
|
|
1543
|
+
* It should return the textual representation of the given tree (typically
|
|
1544
|
+
* `string`).
|
|
1545
|
+
*
|
|
1546
|
+
* > 👉 **Note**: unified typically compiles by serializing: most compilers
|
|
1547
|
+
* > return `string` (or `Uint8Array`).
|
|
1548
|
+
* > Some compilers, such as the one configured with
|
|
1549
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
|
1550
|
+
* > React tree).
|
|
1551
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
|
1552
|
+
* > result values.
|
|
1553
|
+
* >
|
|
1554
|
+
* > To register custom results in TypeScript, add them to
|
|
1555
|
+
* > {@link CompileResultMap `CompileResultMap`}.
|
|
1556
|
+
*
|
|
1557
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
|
1558
|
+
*/
|
|
1559
|
+
type Compiler<Tree extends unist.Node = unist.Node, Result extends CompileResults = CompileResults> = (tree: Tree, file: VFile$1) => Result;
|
|
1560
|
+
/**
|
|
1561
|
+
* A **parser** handles the parsing of text to a syntax tree.
|
|
1562
|
+
*
|
|
1563
|
+
* It is used in the parse phase and is called with a `string` and
|
|
1564
|
+
* {@link VFile `VFile`} of the document to parse.
|
|
1565
|
+
* It must return the syntax tree representation of the given file
|
|
1566
|
+
* ({@link Node `Node`}).
|
|
1567
|
+
*/
|
|
1568
|
+
type Parser<Tree extends unist.Node = unist.Node> = (document: string, file: VFile$1) => Tree;
|
|
1569
|
+
/**
|
|
1570
|
+
* Union of the different ways to add plugins and settings.
|
|
1571
|
+
*/
|
|
1572
|
+
type Pluggable = (Plugin<Array<any>, any, any> | PluginTuple<Array<any>, any, any> | Preset);
|
|
1573
|
+
/**
|
|
1574
|
+
* List of plugins and presets.
|
|
1575
|
+
*/
|
|
1576
|
+
type PluggableList = Array<Pluggable>;
|
|
1577
|
+
/**
|
|
1578
|
+
* Single plugin.
|
|
1579
|
+
*
|
|
1580
|
+
* Plugins configure the processors they are applied on in the following
|
|
1581
|
+
* ways:
|
|
1582
|
+
*
|
|
1583
|
+
* * they change the processor, such as the parser, the compiler, or by
|
|
1584
|
+
* configuring data
|
|
1585
|
+
* * they specify how to handle trees and files
|
|
1586
|
+
*
|
|
1587
|
+
* In practice, they are functions that can receive options and configure the
|
|
1588
|
+
* processor (`this`).
|
|
1589
|
+
*
|
|
1590
|
+
* > 👉 **Note**: plugins are called when the processor is *frozen*, not when
|
|
1591
|
+
* > they are applied.
|
|
1592
|
+
*/
|
|
1593
|
+
type Plugin<PluginParameters extends unknown[] = [], Input extends string | unist.Node | undefined = unist.Node, Output = Input> = (this: Processor, ...parameters: PluginParameters) => Input extends string ? Output extends Node | undefined ? undefined | void : never : Output extends CompileResults ? Input extends Node | undefined ? undefined | void : never : Transformer<Input extends Node ? Input : Node, Output extends Node ? Output : Node> | undefined | void;
|
|
1594
|
+
/**
|
|
1595
|
+
* Tuple of a plugin and its configuration.
|
|
1596
|
+
*
|
|
1597
|
+
* The first item is a plugin, the rest are its parameters.
|
|
1598
|
+
*/
|
|
1599
|
+
type PluginTuple<TupleParameters extends unknown[] = [], Input extends string | unist.Node | undefined = undefined, Output = undefined> = ([
|
|
1600
|
+
plugin: Plugin<TupleParameters, Input, Output>,
|
|
1601
|
+
...parameters: TupleParameters
|
|
1602
|
+
]);
|
|
1603
|
+
/**
|
|
1604
|
+
* Sharable configuration.
|
|
1605
|
+
*
|
|
1606
|
+
* They can contain plugins and settings.
|
|
1607
|
+
*/
|
|
1608
|
+
type Preset = {
|
|
1609
|
+
/**
|
|
1610
|
+
* List of plugins and presets (optional).
|
|
1611
|
+
*/
|
|
1612
|
+
plugins?: PluggableList | undefined;
|
|
1613
|
+
/**
|
|
1614
|
+
* Shared settings for parsers and compilers (optional).
|
|
1615
|
+
*/
|
|
1616
|
+
settings?: Settings$1 | undefined;
|
|
1617
|
+
};
|
|
1618
|
+
/**
|
|
1619
|
+
* Callback called when the process is done.
|
|
1620
|
+
*
|
|
1621
|
+
* Called with either an error or a result.
|
|
1622
|
+
*/
|
|
1623
|
+
type ProcessCallback<File extends VFile$1 = VFile$1> = (error?: Error | undefined, file?: File | undefined) => undefined;
|
|
1624
|
+
/**
|
|
1625
|
+
* Callback called when transformers are done.
|
|
1626
|
+
*
|
|
1627
|
+
* Called with either an error or results.
|
|
1628
|
+
*/
|
|
1629
|
+
type RunCallback<Tree extends unist.Node = unist.Node> = (error?: Error | undefined, tree?: Tree | undefined, file?: VFile$1 | undefined) => undefined;
|
|
1630
|
+
/**
|
|
1631
|
+
* Callback passed to transforms.
|
|
1632
|
+
*
|
|
1633
|
+
* If the signature of a `transformer` accepts a third argument, the
|
|
1634
|
+
* transformer may perform asynchronous operations, and must call it.
|
|
1635
|
+
*/
|
|
1636
|
+
type TransformCallback<Output extends unist.Node = unist.Node> = (error?: Error | undefined, tree?: Output | undefined, file?: VFile$1 | undefined) => undefined;
|
|
1637
|
+
/**
|
|
1638
|
+
* Transformers handle syntax trees and files.
|
|
1639
|
+
*
|
|
1640
|
+
* They are functions that are called each time a syntax tree and file are
|
|
1641
|
+
* passed through the run phase.
|
|
1642
|
+
* When an error occurs in them (either because it’s thrown, returned,
|
|
1643
|
+
* rejected, or passed to `next`), the process stops.
|
|
1644
|
+
*
|
|
1645
|
+
* The run phase is handled by [`trough`][trough], see its documentation for
|
|
1646
|
+
* the exact semantics of these functions.
|
|
1647
|
+
*
|
|
1648
|
+
* > 👉 **Note**: you should likely ignore `next`: don’t accept it.
|
|
1649
|
+
* > it supports callback-style async work.
|
|
1650
|
+
* > But promises are likely easier to reason about.
|
|
1651
|
+
*
|
|
1652
|
+
* [trough]: https://github.com/wooorm/trough#function-fninput-next
|
|
1653
|
+
*/
|
|
1654
|
+
type Transformer<Input extends unist.Node = unist.Node, Output extends unist.Node = Input> = (tree: Input, file: VFile$1, next: TransformCallback<Output>) => (Promise<Output | undefined | void> | Promise<never> | // For some reason this is needed separately.
|
|
1655
|
+
Output | Error | undefined | void);
|
|
1656
|
+
/**
|
|
1657
|
+
* Create a processor based on the input/output of a {@link Plugin plugin}.
|
|
1658
|
+
*/
|
|
1659
|
+
type UsePlugin<ParseTree extends unist.Node | undefined, HeadTree extends unist.Node | undefined, TailTree extends unist.Node | undefined, CompileTree extends unist.Node | undefined, CompileResult extends CompileResults | undefined, Input extends string | unist.Node | undefined, Output> = (Input extends string ? Output extends Node | undefined ? Processor<Output extends undefined ? ParseTree : Output, HeadTree, TailTree, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Output extends CompileResults ? Input extends Node | undefined ? Processor<ParseTree, HeadTree, TailTree, Input extends undefined ? CompileTree : Input, Output extends undefined ? CompileResult : Output> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Input extends Node | undefined ? Output extends Node | undefined ? Processor<ParseTree, HeadTree extends undefined ? Input : HeadTree, Output extends undefined ? TailTree : Output, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult> : Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>);
|
|
1660
|
+
/**
|
|
1661
|
+
* Type to generate a {@link VFile `VFile`} corresponding to a compiler result.
|
|
1662
|
+
*
|
|
1663
|
+
* If a result that is not acceptable on a `VFile` is used, that will
|
|
1664
|
+
* be stored on the `result` field of {@link VFile `VFile`}.
|
|
1665
|
+
*/
|
|
1666
|
+
type VFileWithOutput<Result extends CompileResults | undefined> = (Result extends Value | undefined ? VFile$1 : VFile$1 & {
|
|
1667
|
+
result: Result;
|
|
1668
|
+
});
|
|
1669
|
+
|
|
1670
|
+
// See: <https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts>
|
|
1671
|
+
declare const emptyObjectSymbol: unique symbol
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1674
|
+
* Interface of known data that can be supported by all plugins.
|
|
1675
|
+
*
|
|
1676
|
+
* Typically, options can be given to a specific plugin, but sometimes it makes
|
|
1677
|
+
* sense to have information shared with several plugins.
|
|
1678
|
+
* For example, a list of HTML elements that are self-closing, which is needed
|
|
1679
|
+
* during all phases.
|
|
1680
|
+
*
|
|
1681
|
+
* To type this, do something like:
|
|
1682
|
+
*
|
|
1683
|
+
* ```ts
|
|
1684
|
+
* declare module 'unified' {
|
|
1685
|
+
* interface Data {
|
|
1686
|
+
* htmlVoidElements?: Array<string> | undefined
|
|
1687
|
+
* }
|
|
1688
|
+
* }
|
|
1689
|
+
*
|
|
1690
|
+
* export {} // You may not need this, but it makes sure the file is a module.
|
|
1691
|
+
* ```
|
|
1692
|
+
*/
|
|
1693
|
+
interface Data {
|
|
1694
|
+
settings?: Settings | undefined
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
/**
|
|
1698
|
+
* Interface of known extra options, that can be supported by parser and
|
|
1699
|
+
* compilers.
|
|
1700
|
+
*
|
|
1701
|
+
* This exists so that users can use packages such as `remark`, which configure
|
|
1702
|
+
* both parsers and compilers (in this case `remark-parse` and
|
|
1703
|
+
* `remark-stringify`), and still provide options for them.
|
|
1704
|
+
*
|
|
1705
|
+
* When you make parsers or compilers, that could be packaged up together,
|
|
1706
|
+
* you should support `this.data('settings')` as input and merge it with
|
|
1707
|
+
* explicitly passed `options`.
|
|
1708
|
+
* Then, to type it, using `remark-stringify` as an example, do something like:
|
|
1709
|
+
*
|
|
1710
|
+
* ```ts
|
|
1711
|
+
* declare module 'unified' {
|
|
1712
|
+
* interface Settings {
|
|
1713
|
+
* bullet: '*' | '+' | '-'
|
|
1714
|
+
* // …
|
|
1715
|
+
* }
|
|
1716
|
+
* }
|
|
1717
|
+
*
|
|
1718
|
+
* export {} // You may not need this, but it makes sure the file is a module.
|
|
1719
|
+
* ```
|
|
1720
|
+
*/
|
|
1721
|
+
interface Settings {
|
|
1722
|
+
[emptyObjectSymbol]?: never
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// Type definitions for source-map 0.7
|
|
1726
|
+
// Project: https://github.com/mozilla/source-map
|
|
1727
|
+
// Definitions by: Morten Houston Ludvigsen <https://github.com/MortenHoustonLudvigsen>,
|
|
1728
|
+
// Ron Buckton <https://github.com/rbuckton>,
|
|
1729
|
+
// John Vilk <https://github.com/jvilk>
|
|
1730
|
+
// Definitions: https://github.com/mozilla/source-map
|
|
1731
|
+
type SourceMapUrl = string;
|
|
1732
|
+
|
|
1733
|
+
interface StartOfSourceMap {
|
|
1734
|
+
file?: string;
|
|
1735
|
+
sourceRoot?: string;
|
|
1736
|
+
skipValidation?: boolean;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
interface RawSourceMap {
|
|
1740
|
+
version: number;
|
|
1741
|
+
sources: string[];
|
|
1742
|
+
names: string[];
|
|
1743
|
+
sourceRoot?: string;
|
|
1744
|
+
sourcesContent?: string[];
|
|
1745
|
+
mappings: string;
|
|
1746
|
+
file: string;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
interface RawIndexMap extends StartOfSourceMap {
|
|
1750
|
+
version: number;
|
|
1751
|
+
sections: RawSection[];
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
interface RawSection {
|
|
1755
|
+
offset: Position;
|
|
1756
|
+
map: RawSourceMap;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
interface Position {
|
|
1760
|
+
line: number;
|
|
1761
|
+
column: number;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
interface NullablePosition {
|
|
1765
|
+
line: number | null;
|
|
1766
|
+
column: number | null;
|
|
1767
|
+
lastColumn: number | null;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
interface MappedPosition {
|
|
1771
|
+
source: string;
|
|
1772
|
+
line: number;
|
|
1773
|
+
column: number;
|
|
1774
|
+
name?: string;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
interface NullableMappedPosition {
|
|
1778
|
+
source: string | null;
|
|
1779
|
+
line: number | null;
|
|
1780
|
+
column: number | null;
|
|
1781
|
+
name: string | null;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
interface MappingItem {
|
|
1785
|
+
source: string;
|
|
1786
|
+
generatedLine: number;
|
|
1787
|
+
generatedColumn: number;
|
|
1788
|
+
originalLine: number;
|
|
1789
|
+
originalColumn: number;
|
|
1790
|
+
name: string;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
interface Mapping {
|
|
1794
|
+
generated: Position;
|
|
1795
|
+
original: Position;
|
|
1796
|
+
source: string;
|
|
1797
|
+
name?: string;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
interface SourceMapConsumerConstructor {
|
|
1801
|
+
prototype: SourceMapConsumer;
|
|
1802
|
+
|
|
1803
|
+
GENERATED_ORDER: number;
|
|
1804
|
+
ORIGINAL_ORDER: number;
|
|
1805
|
+
GREATEST_LOWER_BOUND: number;
|
|
1806
|
+
LEAST_UPPER_BOUND: number;
|
|
1807
|
+
|
|
1808
|
+
new (rawSourceMap: RawSourceMap, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
|
|
1809
|
+
new (rawSourceMap: RawIndexMap, sourceMapUrl?: SourceMapUrl): Promise<IndexedSourceMapConsumer>;
|
|
1810
|
+
new (rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer | IndexedSourceMapConsumer>;
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
|
1814
|
+
*
|
|
1815
|
+
* @param sourceMap
|
|
1816
|
+
* The source map that will be consumed.
|
|
1817
|
+
*/
|
|
1818
|
+
fromSourceMap(sourceMap: SourceMapGenerator$1, sourceMapUrl?: SourceMapUrl): Promise<BasicSourceMapConsumer>;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`
|
|
1822
|
+
* (see the `SourceMapConsumer` constructor for details. Then, invoke the `async
|
|
1823
|
+
* function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait
|
|
1824
|
+
* for `f` to complete, call `destroy` on the consumer, and return `f`'s return
|
|
1825
|
+
* value.
|
|
1826
|
+
*
|
|
1827
|
+
* You must not use the consumer after `f` completes!
|
|
1828
|
+
*
|
|
1829
|
+
* By using `with`, you do not have to remember to manually call `destroy` on
|
|
1830
|
+
* the consumer, since it will be called automatically once `f` completes.
|
|
1831
|
+
*
|
|
1832
|
+
* ```js
|
|
1833
|
+
* const xSquared = await SourceMapConsumer.with(
|
|
1834
|
+
* myRawSourceMap,
|
|
1835
|
+
* null,
|
|
1836
|
+
* async function (consumer) {
|
|
1837
|
+
* // Use `consumer` inside here and don't worry about remembering
|
|
1838
|
+
* // to call `destroy`.
|
|
1839
|
+
*
|
|
1840
|
+
* const x = await whatever(consumer);
|
|
1841
|
+
* return x * x;
|
|
1842
|
+
* }
|
|
1843
|
+
* );
|
|
1844
|
+
*
|
|
1845
|
+
* // You may not use that `consumer` anymore out here; it has
|
|
1846
|
+
* // been destroyed. But you can use `xSquared`.
|
|
1847
|
+
* console.log(xSquared);
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
with<T>(rawSourceMap: RawSourceMap | RawIndexMap | string, sourceMapUrl: SourceMapUrl | null | undefined, callback: (consumer: BasicSourceMapConsumer | IndexedSourceMapConsumer) => Promise<T> | T): Promise<T>;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
interface SourceMapConsumer {
|
|
1854
|
+
/**
|
|
1855
|
+
* Compute the last column for each generated mapping. The last column is
|
|
1856
|
+
* inclusive.
|
|
1857
|
+
*/
|
|
1858
|
+
computeColumnSpans(): void;
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* Returns the original source, line, and column information for the generated
|
|
1862
|
+
* source's line and column positions provided. The only argument is an object
|
|
1863
|
+
* with the following properties:
|
|
1864
|
+
*
|
|
1865
|
+
* - line: The line number in the generated source.
|
|
1866
|
+
* - column: The column number in the generated source.
|
|
1867
|
+
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
|
1868
|
+
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
|
1869
|
+
* closest element that is smaller than or greater than the one we are
|
|
1870
|
+
* searching for, respectively, if the exact element cannot be found.
|
|
1871
|
+
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
|
1872
|
+
*
|
|
1873
|
+
* and an object is returned with the following properties:
|
|
1874
|
+
*
|
|
1875
|
+
* - source: The original source file, or null.
|
|
1876
|
+
* - line: The line number in the original source, or null.
|
|
1877
|
+
* - column: The column number in the original source, or null.
|
|
1878
|
+
* - name: The original identifier, or null.
|
|
1879
|
+
*/
|
|
1880
|
+
originalPositionFor(generatedPosition: Position & { bias?: number }): NullableMappedPosition;
|
|
1881
|
+
|
|
1882
|
+
/**
|
|
1883
|
+
* Returns the generated line and column information for the original source,
|
|
1884
|
+
* line, and column positions provided. The only argument is an object with
|
|
1885
|
+
* the following properties:
|
|
1886
|
+
*
|
|
1887
|
+
* - source: The filename of the original source.
|
|
1888
|
+
* - line: The line number in the original source.
|
|
1889
|
+
* - column: The column number in the original source.
|
|
1890
|
+
* - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
|
|
1891
|
+
* 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
|
|
1892
|
+
* closest element that is smaller than or greater than the one we are
|
|
1893
|
+
* searching for, respectively, if the exact element cannot be found.
|
|
1894
|
+
* Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
|
|
1895
|
+
*
|
|
1896
|
+
* and an object is returned with the following properties:
|
|
1897
|
+
*
|
|
1898
|
+
* - line: The line number in the generated source, or null.
|
|
1899
|
+
* - column: The column number in the generated source, or null.
|
|
1900
|
+
*/
|
|
1901
|
+
generatedPositionFor(originalPosition: MappedPosition & { bias?: number }): NullablePosition;
|
|
1902
|
+
|
|
1903
|
+
/**
|
|
1904
|
+
* Returns all generated line and column information for the original source,
|
|
1905
|
+
* line, and column provided. If no column is provided, returns all mappings
|
|
1906
|
+
* corresponding to a either the line we are searching for or the next
|
|
1907
|
+
* closest line that has any mappings. Otherwise, returns all mappings
|
|
1908
|
+
* corresponding to the given line and either the column we are searching for
|
|
1909
|
+
* or the next closest column that has any offsets.
|
|
1910
|
+
*
|
|
1911
|
+
* The only argument is an object with the following properties:
|
|
1912
|
+
*
|
|
1913
|
+
* - source: The filename of the original source.
|
|
1914
|
+
* - line: The line number in the original source.
|
|
1915
|
+
* - column: Optional. the column number in the original source.
|
|
1916
|
+
*
|
|
1917
|
+
* and an array of objects is returned, each with the following properties:
|
|
1918
|
+
*
|
|
1919
|
+
* - line: The line number in the generated source, or null.
|
|
1920
|
+
* - column: The column number in the generated source, or null.
|
|
1921
|
+
*/
|
|
1922
|
+
allGeneratedPositionsFor(originalPosition: MappedPosition): NullablePosition[];
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Return true if we have the source content for every source in the source
|
|
1926
|
+
* map, false otherwise.
|
|
1927
|
+
*/
|
|
1928
|
+
hasContentsOfAllSources(): boolean;
|
|
1929
|
+
|
|
1930
|
+
/**
|
|
1931
|
+
* Returns the original source content. The only argument is the url of the
|
|
1932
|
+
* original source file. Returns null if no original source content is
|
|
1933
|
+
* available.
|
|
1934
|
+
*/
|
|
1935
|
+
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
|
|
1936
|
+
|
|
1937
|
+
/**
|
|
1938
|
+
* Iterate over each mapping between an original source/line/column and a
|
|
1939
|
+
* generated line/column in this source map.
|
|
1940
|
+
*
|
|
1941
|
+
* @param callback
|
|
1942
|
+
* The function that is called with each mapping.
|
|
1943
|
+
* @param context
|
|
1944
|
+
* Optional. If specified, this object will be the value of `this` every
|
|
1945
|
+
* time that `aCallback` is called.
|
|
1946
|
+
* @param order
|
|
1947
|
+
* Either `SourceMapConsumer.GENERATED_ORDER` or
|
|
1948
|
+
* `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
|
|
1949
|
+
* iterate over the mappings sorted by the generated file's line/column
|
|
1950
|
+
* order or the original's source/line/column order, respectively. Defaults to
|
|
1951
|
+
* `SourceMapConsumer.GENERATED_ORDER`.
|
|
1952
|
+
*/
|
|
1953
|
+
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
|
|
1954
|
+
/**
|
|
1955
|
+
* Free this source map consumer's associated wasm data that is manually-managed.
|
|
1956
|
+
* Alternatively, you can use SourceMapConsumer.with to avoid needing to remember to call destroy.
|
|
1957
|
+
*/
|
|
1958
|
+
destroy(): void;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
declare const SourceMapConsumer: SourceMapConsumerConstructor;
|
|
1962
|
+
|
|
1963
|
+
interface BasicSourceMapConsumerConstructor {
|
|
1964
|
+
prototype: BasicSourceMapConsumer;
|
|
1965
|
+
|
|
1966
|
+
new (rawSourceMap: RawSourceMap | string): Promise<BasicSourceMapConsumer>;
|
|
1967
|
+
|
|
1968
|
+
/**
|
|
1969
|
+
* Create a BasicSourceMapConsumer from a SourceMapGenerator.
|
|
1970
|
+
*
|
|
1971
|
+
* @param sourceMap
|
|
1972
|
+
* The source map that will be consumed.
|
|
1973
|
+
*/
|
|
1974
|
+
fromSourceMap(sourceMap: SourceMapGenerator$1): Promise<BasicSourceMapConsumer>;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
interface BasicSourceMapConsumer extends SourceMapConsumer {
|
|
1978
|
+
file: string;
|
|
1979
|
+
sourceRoot: string;
|
|
1980
|
+
sources: string[];
|
|
1981
|
+
sourcesContent: string[];
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
declare const BasicSourceMapConsumer: BasicSourceMapConsumerConstructor;
|
|
1985
|
+
|
|
1986
|
+
interface IndexedSourceMapConsumerConstructor {
|
|
1987
|
+
prototype: IndexedSourceMapConsumer;
|
|
1988
|
+
|
|
1989
|
+
new (rawSourceMap: RawIndexMap | string): Promise<IndexedSourceMapConsumer>;
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
interface IndexedSourceMapConsumer extends SourceMapConsumer {
|
|
1993
|
+
sources: string[];
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
declare const IndexedSourceMapConsumer: IndexedSourceMapConsumerConstructor;
|
|
1997
|
+
|
|
1998
|
+
declare class SourceMapGenerator$1 {
|
|
1999
|
+
constructor(startOfSourceMap?: StartOfSourceMap);
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
|
2003
|
+
*
|
|
2004
|
+
* @param sourceMapConsumer The SourceMap.
|
|
2005
|
+
*/
|
|
2006
|
+
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator$1;
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* Add a single mapping from original source line and column to the generated
|
|
2010
|
+
* source's line and column for this source map being created. The mapping
|
|
2011
|
+
* object should have the following properties:
|
|
2012
|
+
*
|
|
2013
|
+
* - generated: An object with the generated line and column positions.
|
|
2014
|
+
* - original: An object with the original line and column positions.
|
|
2015
|
+
* - source: The original source file (relative to the sourceRoot).
|
|
2016
|
+
* - name: An optional original token name for this mapping.
|
|
2017
|
+
*/
|
|
2018
|
+
addMapping(mapping: Mapping): void;
|
|
2019
|
+
|
|
2020
|
+
/**
|
|
2021
|
+
* Set the source content for a source file.
|
|
2022
|
+
*/
|
|
2023
|
+
setSourceContent(sourceFile: string, sourceContent: string): void;
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Applies the mappings of a sub-source-map for a specific source file to the
|
|
2027
|
+
* source map being generated. Each mapping to the supplied source file is
|
|
2028
|
+
* rewritten using the supplied source map. Note: The resolution for the
|
|
2029
|
+
* resulting mappings is the minimium of this map and the supplied map.
|
|
2030
|
+
*
|
|
2031
|
+
* @param sourceMapConsumer The source map to be applied.
|
|
2032
|
+
* @param sourceFile Optional. The filename of the source file.
|
|
2033
|
+
* If omitted, SourceMapConsumer's file property will be used.
|
|
2034
|
+
* @param sourceMapPath Optional. The dirname of the path to the source map
|
|
2035
|
+
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
|
2036
|
+
* This parameter is needed when the two source maps aren't in the same
|
|
2037
|
+
* directory, and the source map to be applied contains relative source
|
|
2038
|
+
* paths. If so, those relative source paths need to be rewritten
|
|
2039
|
+
* relative to the SourceMapGenerator.
|
|
2040
|
+
*/
|
|
2041
|
+
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
|
2042
|
+
|
|
2043
|
+
toString(): string;
|
|
2044
|
+
|
|
2045
|
+
toJSON(): RawSourceMap;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
type HastElementContent = hast.ElementContent;
|
|
2049
|
+
type HastNodes = hast.Nodes;
|
|
2050
|
+
type HastProperties = hast.Properties;
|
|
2051
|
+
type MdastDefinition = mdast.Definition;
|
|
2052
|
+
type MdastFootnoteDefinition = mdast.FootnoteDefinition;
|
|
2053
|
+
type MdastNodes = mdast.Nodes;
|
|
2054
|
+
type MdastParents = mdast.Parents;
|
|
2055
|
+
type FootnoteBackContentTemplate$1 = FootnoteBackContentTemplate;
|
|
2056
|
+
type FootnoteBackLabelTemplate$1 = FootnoteBackLabelTemplate;
|
|
2057
|
+
/**
|
|
2058
|
+
* Handle a node.
|
|
2059
|
+
*/
|
|
2060
|
+
type Handler = (state: State$1, node: any, parent: MdastParents | undefined) => Array<HastElementContent> | HastElementContent | undefined;
|
|
2061
|
+
/**
|
|
2062
|
+
* Handle nodes.
|
|
2063
|
+
*/
|
|
2064
|
+
type Handlers = Partial<Record<MdastNodes['type'], Handler>>;
|
|
2065
|
+
/**
|
|
2066
|
+
* Configuration (optional).
|
|
2067
|
+
*/
|
|
2068
|
+
type Options$2 = {
|
|
2069
|
+
/**
|
|
2070
|
+
* Whether to persist raw HTML in markdown in the hast tree (default:
|
|
2071
|
+
* `false`).
|
|
2072
|
+
*/
|
|
2073
|
+
allowDangerousHtml?: boolean | null | undefined;
|
|
2074
|
+
/**
|
|
2075
|
+
* Prefix to use before the `id` property on footnotes to prevent them from
|
|
2076
|
+
* *clobbering* (default: `'user-content-'`).
|
|
2077
|
+
*
|
|
2078
|
+
* Pass `''` for trusted markdown and when you are careful with
|
|
2079
|
+
* polyfilling.
|
|
2080
|
+
* You could pass a different prefix.
|
|
2081
|
+
*
|
|
2082
|
+
* DOM clobbering is this:
|
|
2083
|
+
*
|
|
2084
|
+
* ```html
|
|
2085
|
+
* <p id="x"></p>
|
|
2086
|
+
* <script>alert(x) // `x` now refers to the `p#x` DOM element</script>
|
|
2087
|
+
* ```
|
|
2088
|
+
*
|
|
2089
|
+
* The above example shows that elements are made available by browsers, by
|
|
2090
|
+
* their ID, on the `window` object.
|
|
2091
|
+
* This is a security risk because you might be expecting some other variable
|
|
2092
|
+
* at that place.
|
|
2093
|
+
* It can also break polyfills.
|
|
2094
|
+
* Using a prefix solves these problems.
|
|
2095
|
+
*/
|
|
2096
|
+
clobberPrefix?: string | null | undefined;
|
|
2097
|
+
/**
|
|
2098
|
+
* Content of the backreference back to references (default: `defaultFootnoteBackContent`).
|
|
2099
|
+
*
|
|
2100
|
+
* The default value is:
|
|
2101
|
+
*
|
|
2102
|
+
* ```js
|
|
2103
|
+
* function defaultFootnoteBackContent(_, rereferenceIndex) {
|
|
2104
|
+
* const result = [{type: 'text', value: '↩'}]
|
|
2105
|
+
*
|
|
2106
|
+
* if (rereferenceIndex > 1) {
|
|
2107
|
+
* result.push({
|
|
2108
|
+
* type: 'element',
|
|
2109
|
+
* tagName: 'sup',
|
|
2110
|
+
* properties: {},
|
|
2111
|
+
* children: [{type: 'text', value: String(rereferenceIndex)}]
|
|
2112
|
+
* })
|
|
2113
|
+
* }
|
|
2114
|
+
*
|
|
2115
|
+
* return result
|
|
2116
|
+
* }
|
|
2117
|
+
* ```
|
|
2118
|
+
*
|
|
2119
|
+
* This content is used in the `a` element of each backreference (the `↩`
|
|
2120
|
+
* links).
|
|
2121
|
+
*/
|
|
2122
|
+
footnoteBackContent?: FootnoteBackContentTemplate$1 | string | null | undefined;
|
|
2123
|
+
/**
|
|
2124
|
+
* Label to describe the backreference back to references (default:
|
|
2125
|
+
* `defaultFootnoteBackLabel`).
|
|
2126
|
+
*
|
|
2127
|
+
* The default value is:
|
|
2128
|
+
*
|
|
2129
|
+
* ```js
|
|
2130
|
+
* function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
|
|
2131
|
+
* return (
|
|
2132
|
+
* 'Back to reference ' +
|
|
2133
|
+
* (referenceIndex + 1) +
|
|
2134
|
+
* (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')
|
|
2135
|
+
* )
|
|
2136
|
+
* }
|
|
2137
|
+
* ```
|
|
2138
|
+
*
|
|
2139
|
+
* Change it when the markdown is not in English.
|
|
2140
|
+
*
|
|
2141
|
+
* This label is used in the `ariaLabel` property on each backreference
|
|
2142
|
+
* (the `↩` links).
|
|
2143
|
+
* It affects users of assistive technology.
|
|
2144
|
+
*/
|
|
2145
|
+
footnoteBackLabel?: FootnoteBackLabelTemplate$1 | string | null | undefined;
|
|
2146
|
+
/**
|
|
2147
|
+
* Textual label to use for the footnotes section (default: `'Footnotes'`).
|
|
2148
|
+
*
|
|
2149
|
+
* Change it when the markdown is not in English.
|
|
2150
|
+
*
|
|
2151
|
+
* This label is typically hidden visually (assuming a `sr-only` CSS class
|
|
2152
|
+
* is defined that does that) and so affects screen readers only.
|
|
2153
|
+
* If you do have such a class, but want to show this section to everyone,
|
|
2154
|
+
* pass different properties with the `footnoteLabelProperties` option.
|
|
2155
|
+
*/
|
|
2156
|
+
footnoteLabel?: string | null | undefined;
|
|
2157
|
+
/**
|
|
2158
|
+
* Properties to use on the footnote label (default: `{className:
|
|
2159
|
+
* ['sr-only']}`).
|
|
2160
|
+
*
|
|
2161
|
+
* Change it to show the label and add other properties.
|
|
2162
|
+
*
|
|
2163
|
+
* This label is typically hidden visually (assuming an `sr-only` CSS class
|
|
2164
|
+
* is defined that does that) and so affects screen readers only.
|
|
2165
|
+
* If you do have such a class, but want to show this section to everyone,
|
|
2166
|
+
* pass an empty string.
|
|
2167
|
+
* You can also add different properties.
|
|
2168
|
+
*
|
|
2169
|
+
* > 👉 **Note**: `id: 'footnote-label'` is always added, because footnote
|
|
2170
|
+
* > calls use it with `aria-describedby` to provide an accessible label.
|
|
2171
|
+
*/
|
|
2172
|
+
footnoteLabelProperties?: HastProperties | null | undefined;
|
|
2173
|
+
/**
|
|
2174
|
+
* HTML tag name to use for the footnote label element (default: `'h2'`).
|
|
2175
|
+
*
|
|
2176
|
+
* Change it to match your document structure.
|
|
2177
|
+
*
|
|
2178
|
+
* This label is typically hidden visually (assuming a `sr-only` CSS class
|
|
2179
|
+
* is defined that does that) and so affects screen readers only.
|
|
2180
|
+
* If you do have such a class, but want to show this section to everyone,
|
|
2181
|
+
* pass different properties with the `footnoteLabelProperties` option.
|
|
2182
|
+
*/
|
|
2183
|
+
footnoteLabelTagName?: string | null | undefined;
|
|
2184
|
+
/**
|
|
2185
|
+
* Extra handlers for nodes (optional).
|
|
2186
|
+
*/
|
|
2187
|
+
handlers?: Handlers | null | undefined;
|
|
2188
|
+
/**
|
|
2189
|
+
* List of custom mdast node types to pass through (keep) in hast (note that
|
|
2190
|
+
* the node itself is passed, but eventual children are transformed)
|
|
2191
|
+
* (optional).
|
|
2192
|
+
*/
|
|
2193
|
+
passThrough?: Array<MdastNodes['type']> | null | undefined;
|
|
2194
|
+
/**
|
|
2195
|
+
* Handler for all unknown nodes (optional).
|
|
2196
|
+
*/
|
|
2197
|
+
unknownHandler?: Handler | null | undefined;
|
|
2198
|
+
};
|
|
2199
|
+
/**
|
|
2200
|
+
* Info passed around.
|
|
2201
|
+
*/
|
|
2202
|
+
type State$1 = {
|
|
2203
|
+
/**
|
|
2204
|
+
* Transform the children of an mdast parent to hast.
|
|
2205
|
+
*/
|
|
2206
|
+
all: (node: MdastNodes) => Array<HastElementContent>;
|
|
2207
|
+
/**
|
|
2208
|
+
* Honor the `data` of `from`, and generate an element instead of `node`.
|
|
2209
|
+
*/
|
|
2210
|
+
applyData: <Type extends hast.Nodes>(from: MdastNodes, to: Type) => hast.Element | Type;
|
|
2211
|
+
/**
|
|
2212
|
+
* Definitions by their identifier.
|
|
2213
|
+
*/
|
|
2214
|
+
definitionById: Map<string, MdastDefinition>;
|
|
2215
|
+
/**
|
|
2216
|
+
* Footnote definitions by their identifier.
|
|
2217
|
+
*/
|
|
2218
|
+
footnoteById: Map<string, MdastFootnoteDefinition>;
|
|
2219
|
+
/**
|
|
2220
|
+
* Counts for how often the same footnote was called.
|
|
2221
|
+
*/
|
|
2222
|
+
footnoteCounts: Map<string, number>;
|
|
2223
|
+
/**
|
|
2224
|
+
* Identifiers of order when footnote calls first appear in tree order.
|
|
2225
|
+
*/
|
|
2226
|
+
footnoteOrder: Array<string>;
|
|
2227
|
+
/**
|
|
2228
|
+
* Applied handlers.
|
|
2229
|
+
*/
|
|
2230
|
+
handlers: Handlers;
|
|
2231
|
+
/**
|
|
2232
|
+
* Transform an mdast node to hast.
|
|
2233
|
+
*/
|
|
2234
|
+
one: (node: MdastNodes, parent: MdastParents | undefined) => Array<HastElementContent> | HastElementContent | undefined;
|
|
2235
|
+
/**
|
|
2236
|
+
* Configuration.
|
|
2237
|
+
*/
|
|
2238
|
+
options: Options$2;
|
|
2239
|
+
/**
|
|
2240
|
+
* Copy a node’s positional info.
|
|
2241
|
+
*/
|
|
2242
|
+
patch: (from: MdastNodes, node: HastNodes) => undefined;
|
|
2243
|
+
/**
|
|
2244
|
+
* Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`.
|
|
2245
|
+
*/
|
|
2246
|
+
wrap: <Type_1 extends hast.RootContent>(nodes: Type_1[], loose?: boolean | undefined) => (hast.Text | Type_1)[];
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
type ElementContent = hast.ElementContent;
|
|
2250
|
+
/**
|
|
2251
|
+
* Generate content for the backreference dynamically.
|
|
2252
|
+
*
|
|
2253
|
+
* For the following markdown:
|
|
2254
|
+
*
|
|
2255
|
+
* ```markdown
|
|
2256
|
+
* Alpha[^micromark], bravo[^micromark], and charlie[^remark].
|
|
2257
|
+
*
|
|
2258
|
+
* [^remark]: things about remark
|
|
2259
|
+
* [^micromark]: things about micromark
|
|
2260
|
+
* ```
|
|
2261
|
+
*
|
|
2262
|
+
* This function will be called with:
|
|
2263
|
+
*
|
|
2264
|
+
* * `0` and `0` for the backreference from `things about micromark` to
|
|
2265
|
+
* `alpha`, as it is the first used definition, and the first call to it
|
|
2266
|
+
* * `0` and `1` for the backreference from `things about micromark` to
|
|
2267
|
+
* `bravo`, as it is the first used definition, and the second call to it
|
|
2268
|
+
* * `1` and `0` for the backreference from `things about remark` to
|
|
2269
|
+
* `charlie`, as it is the second used definition
|
|
2270
|
+
*/
|
|
2271
|
+
type FootnoteBackContentTemplate = (referenceIndex: number, rereferenceIndex: number) => Array<ElementContent> | ElementContent | string;
|
|
2272
|
+
/**
|
|
2273
|
+
* Generate a back label dynamically.
|
|
2274
|
+
*
|
|
2275
|
+
* For the following markdown:
|
|
2276
|
+
*
|
|
2277
|
+
* ```markdown
|
|
2278
|
+
* Alpha[^micromark], bravo[^micromark], and charlie[^remark].
|
|
2279
|
+
*
|
|
2280
|
+
* [^remark]: things about remark
|
|
2281
|
+
* [^micromark]: things about micromark
|
|
2282
|
+
* ```
|
|
2283
|
+
*
|
|
2284
|
+
* This function will be called with:
|
|
2285
|
+
*
|
|
2286
|
+
* * `0` and `0` for the backreference from `things about micromark` to
|
|
2287
|
+
* `alpha`, as it is the first used definition, and the first call to it
|
|
2288
|
+
* * `0` and `1` for the backreference from `things about micromark` to
|
|
2289
|
+
* `bravo`, as it is the first used definition, and the second call to it
|
|
2290
|
+
* * `1` and `0` for the backreference from `things about remark` to
|
|
2291
|
+
* `charlie`, as it is the second used definition
|
|
2292
|
+
*/
|
|
2293
|
+
type FootnoteBackLabelTemplate = (referenceIndex: number, rereferenceIndex: number) => string;
|
|
2294
|
+
|
|
2295
|
+
/**
|
|
2296
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2297
|
+
*/
|
|
2298
|
+
interface Raw$1 extends Literal {
|
|
2299
|
+
/**
|
|
2300
|
+
* Node type of raw.
|
|
2301
|
+
*/
|
|
2302
|
+
type: 'raw'
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* Data associated with the hast raw.
|
|
2306
|
+
*/
|
|
2307
|
+
data?: RawData$1 | undefined
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
/**
|
|
2311
|
+
* Info associated with hast raw nodes by the ecosystem.
|
|
2312
|
+
*/
|
|
2313
|
+
interface RawData$1 extends Data$5 {}
|
|
2314
|
+
|
|
2315
|
+
// Register nodes in content.
|
|
2316
|
+
declare module 'hast' {
|
|
2317
|
+
interface ElementContentMap {
|
|
2318
|
+
/**
|
|
2319
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2320
|
+
*/
|
|
2321
|
+
raw: Raw$1
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
interface RootContentMap {
|
|
2325
|
+
/**
|
|
2326
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2327
|
+
*/
|
|
2328
|
+
raw: Raw$1
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
// Register data on mdast.
|
|
2333
|
+
declare module 'mdast' {
|
|
2334
|
+
interface Data {
|
|
2335
|
+
/**
|
|
2336
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2337
|
+
* result in something with these children.
|
|
2338
|
+
*
|
|
2339
|
+
* When this is defined, when a parent is created, these children will
|
|
2340
|
+
* be used.
|
|
2341
|
+
*/
|
|
2342
|
+
hChildren?: ElementContent$1[] | undefined
|
|
2343
|
+
|
|
2344
|
+
/**
|
|
2345
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2346
|
+
* result in a particular element, instead of its default behavior.
|
|
2347
|
+
*
|
|
2348
|
+
* When this is defined, an element with the given tag name is created.
|
|
2349
|
+
* For example, when setting `hName` to `'b'`, a `<b>` element is created.
|
|
2350
|
+
*/
|
|
2351
|
+
hName?: string | undefined
|
|
2352
|
+
|
|
2353
|
+
/**
|
|
2354
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2355
|
+
* result in an element with these properties.
|
|
2356
|
+
*
|
|
2357
|
+
* When this is defined, when an element is created, these properties will
|
|
2358
|
+
* be used.
|
|
2359
|
+
*/
|
|
2360
|
+
hProperties?: Properties | undefined
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
/**
|
|
2365
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2366
|
+
*/
|
|
2367
|
+
interface Raw extends Literal {
|
|
2368
|
+
/**
|
|
2369
|
+
* Node type of raw.
|
|
2370
|
+
*/
|
|
2371
|
+
type: 'raw'
|
|
2372
|
+
|
|
2373
|
+
/**
|
|
2374
|
+
* Data associated with the hast raw.
|
|
2375
|
+
*/
|
|
2376
|
+
data?: RawData | undefined
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* Info associated with hast raw nodes by the ecosystem.
|
|
2381
|
+
*/
|
|
2382
|
+
interface RawData extends Data$5 {}
|
|
2383
|
+
|
|
2384
|
+
// Register nodes in content.
|
|
2385
|
+
declare module 'hast' {
|
|
2386
|
+
interface ElementContentMap {
|
|
2387
|
+
/**
|
|
2388
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2389
|
+
*/
|
|
2390
|
+
raw: Raw
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
interface RootContentMap {
|
|
2394
|
+
/**
|
|
2395
|
+
* Raw string of HTML embedded into HTML AST.
|
|
2396
|
+
*/
|
|
2397
|
+
raw: Raw
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
// Register data on mdast.
|
|
2402
|
+
declare module 'mdast' {
|
|
2403
|
+
interface Data {
|
|
2404
|
+
/**
|
|
2405
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2406
|
+
* result in something with these children.
|
|
2407
|
+
*
|
|
2408
|
+
* When this is defined, when a parent is created, these children will
|
|
2409
|
+
* be used.
|
|
2410
|
+
*/
|
|
2411
|
+
hChildren?: ElementContent$1[] | undefined
|
|
2412
|
+
|
|
2413
|
+
/**
|
|
2414
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2415
|
+
* result in a particular element, instead of its default behavior.
|
|
2416
|
+
*
|
|
2417
|
+
* When this is defined, an element with the given tag name is created.
|
|
2418
|
+
* For example, when setting `hName` to `'b'`, a `<b>` element is created.
|
|
2419
|
+
*/
|
|
2420
|
+
hName?: string | undefined
|
|
2421
|
+
|
|
2422
|
+
/**
|
|
2423
|
+
* Field supported by `mdast-util-to-hast` to signal that a node should
|
|
2424
|
+
* result in an element with these properties.
|
|
2425
|
+
*
|
|
2426
|
+
* When this is defined, when an element is created, these properties will
|
|
2427
|
+
* be used.
|
|
2428
|
+
*/
|
|
2429
|
+
hProperties?: Properties | undefined
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
type Options$1 = Options$2;
|
|
2434
|
+
|
|
2435
|
+
type Options = Options$1;
|
|
2436
|
+
|
|
2437
|
+
// Expose node types.
|
|
2438
|
+
/**
|
|
2439
|
+
* MDX JSX attribute value set to an expression.
|
|
2440
|
+
*
|
|
2441
|
+
* ```markdown
|
|
2442
|
+
* > | <a b={c} />
|
|
2443
|
+
* ^^^
|
|
2444
|
+
* ```
|
|
2445
|
+
*/
|
|
2446
|
+
interface MdxJsxAttributeValueExpression$1 extends Node$3 {
|
|
2447
|
+
/**
|
|
2448
|
+
* Node type.
|
|
2449
|
+
*/
|
|
2450
|
+
type: 'mdxJsxAttributeValueExpression'
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* Value.
|
|
2454
|
+
*/
|
|
2455
|
+
value: string
|
|
2456
|
+
|
|
2457
|
+
/**
|
|
2458
|
+
* Data associated with the mdast MDX JSX attribute value expression.
|
|
2459
|
+
*/
|
|
2460
|
+
data?: MdxJsxAttributeValueExpressionData$1 | undefined
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
/**
|
|
2464
|
+
* Info associated with mdast MDX JSX attribute value expression nodes by the
|
|
2465
|
+
* ecosystem.
|
|
2466
|
+
*/
|
|
2467
|
+
interface MdxJsxAttributeValueExpressionData$1 extends Data$7 {
|
|
2468
|
+
/**
|
|
2469
|
+
* Program node from estree.
|
|
2470
|
+
*/
|
|
2471
|
+
estree?: Program | null | undefined
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
/**
|
|
2475
|
+
* MDX JSX attribute as an expression.
|
|
2476
|
+
*
|
|
2477
|
+
* ```markdown
|
|
2478
|
+
* > | <a {...b} />
|
|
2479
|
+
* ^^^^^^
|
|
2480
|
+
* ```
|
|
2481
|
+
*/
|
|
2482
|
+
interface MdxJsxExpressionAttribute$2 extends Node$3 {
|
|
2483
|
+
/**
|
|
2484
|
+
* Node type.
|
|
2485
|
+
*/
|
|
2486
|
+
type: 'mdxJsxExpressionAttribute'
|
|
2487
|
+
|
|
2488
|
+
/**
|
|
2489
|
+
* Value.
|
|
2490
|
+
*/
|
|
2491
|
+
value: string
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* Data associated with the mdast MDX JSX expression attributes.
|
|
2495
|
+
*/
|
|
2496
|
+
data?: MdxJsxExpressionAttributeData$1 | undefined
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* Info associated with mdast MDX JSX expression attribute nodes by the
|
|
2501
|
+
* ecosystem.
|
|
2502
|
+
*/
|
|
2503
|
+
interface MdxJsxExpressionAttributeData$1 extends Data$7 {
|
|
2504
|
+
/**
|
|
2505
|
+
* Program node from estree.
|
|
2506
|
+
*/
|
|
2507
|
+
estree?: Program | null | undefined
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* MDX JSX attribute with a key.
|
|
2512
|
+
*
|
|
2513
|
+
* ```markdown
|
|
2514
|
+
* > | <a b="c" />
|
|
2515
|
+
* ^^^^^
|
|
2516
|
+
* ```
|
|
2517
|
+
*/
|
|
2518
|
+
interface MdxJsxAttribute$2 extends Node$3 {
|
|
2519
|
+
/**
|
|
2520
|
+
* Node type.
|
|
2521
|
+
*/
|
|
2522
|
+
type: 'mdxJsxAttribute'
|
|
2523
|
+
/**
|
|
2524
|
+
* Attribute name.
|
|
2525
|
+
*/
|
|
2526
|
+
name: string
|
|
2527
|
+
/**
|
|
2528
|
+
* Attribute value.
|
|
2529
|
+
*/
|
|
2530
|
+
value?: MdxJsxAttributeValueExpression$1 | string | null | undefined
|
|
2531
|
+
/**
|
|
2532
|
+
* Data associated with the mdast MDX JSX attribute.
|
|
2533
|
+
*/
|
|
2534
|
+
data?: MdxJsxAttributeData$1 | undefined
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
/**
|
|
2538
|
+
* Info associated with mdast MDX JSX attribute nodes by the
|
|
2539
|
+
* ecosystem.
|
|
2540
|
+
*/
|
|
2541
|
+
interface MdxJsxAttributeData$1 extends Data$7 {}
|
|
2542
|
+
|
|
2543
|
+
/**
|
|
2544
|
+
* MDX JSX element node, occurring in flow (block).
|
|
2545
|
+
*/
|
|
2546
|
+
interface MdxJsxFlowElement$1 extends Parent {
|
|
2547
|
+
/**
|
|
2548
|
+
* Node type.
|
|
2549
|
+
*/
|
|
2550
|
+
type: 'mdxJsxFlowElement'
|
|
2551
|
+
/**
|
|
2552
|
+
* MDX JSX element name (`null` for fragments).
|
|
2553
|
+
*/
|
|
2554
|
+
name: string | null
|
|
2555
|
+
/**
|
|
2556
|
+
* MDX JSX element attributes.
|
|
2557
|
+
*/
|
|
2558
|
+
attributes: Array<MdxJsxAttribute$2 | MdxJsxExpressionAttribute$2>
|
|
2559
|
+
/**
|
|
2560
|
+
* Content.
|
|
2561
|
+
*/
|
|
2562
|
+
children: Array<BlockContent | DefinitionContent>
|
|
2563
|
+
/**
|
|
2564
|
+
* Data associated with the mdast MDX JSX elements (flow).
|
|
2565
|
+
*/
|
|
2566
|
+
data?: MdxJsxFlowElementData$1 | undefined
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
/**
|
|
2570
|
+
* Info associated with mdast MDX JSX element (flow) nodes by the
|
|
2571
|
+
* ecosystem.
|
|
2572
|
+
*/
|
|
2573
|
+
interface MdxJsxFlowElementData$1 extends Data$6 {}
|
|
2574
|
+
|
|
2575
|
+
/**
|
|
2576
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
2577
|
+
*/
|
|
2578
|
+
interface MdxJsxTextElement$1 extends Parent {
|
|
2579
|
+
/**
|
|
2580
|
+
* Node type.
|
|
2581
|
+
*/
|
|
2582
|
+
type: 'mdxJsxTextElement'
|
|
2583
|
+
/**
|
|
2584
|
+
* MDX JSX element name (`null` for fragments).
|
|
2585
|
+
*/
|
|
2586
|
+
name: string | null
|
|
2587
|
+
/**
|
|
2588
|
+
* MDX JSX element attributes.
|
|
2589
|
+
*/
|
|
2590
|
+
attributes: Array<MdxJsxAttribute$2 | MdxJsxExpressionAttribute$2>
|
|
2591
|
+
/**
|
|
2592
|
+
* Content.
|
|
2593
|
+
*/
|
|
2594
|
+
children: PhrasingContent[]
|
|
2595
|
+
/**
|
|
2596
|
+
* Data associated with the mdast MDX JSX elements (text).
|
|
2597
|
+
*/
|
|
2598
|
+
data?: MdxJsxTextElementData$1 | undefined
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* Info associated with mdast MDX JSX element (text) nodes by the
|
|
2603
|
+
* ecosystem.
|
|
2604
|
+
*/
|
|
2605
|
+
interface MdxJsxTextElementData$1 extends Data$6 {}
|
|
2606
|
+
|
|
2607
|
+
/**
|
|
2608
|
+
* MDX JSX element node, occurring in flow (block), for hast.
|
|
2609
|
+
*/
|
|
2610
|
+
interface MdxJsxFlowElementHast$1 extends Parent$1 {
|
|
2611
|
+
/**
|
|
2612
|
+
* Node type.
|
|
2613
|
+
*/
|
|
2614
|
+
type: 'mdxJsxFlowElement'
|
|
2615
|
+
/**
|
|
2616
|
+
* MDX JSX element name (`null` for fragments).
|
|
2617
|
+
*/
|
|
2618
|
+
name: string | null
|
|
2619
|
+
/**
|
|
2620
|
+
* MDX JSX element attributes.
|
|
2621
|
+
*/
|
|
2622
|
+
attributes: Array<MdxJsxAttribute$2 | MdxJsxExpressionAttribute$2>
|
|
2623
|
+
/**
|
|
2624
|
+
* Content.
|
|
2625
|
+
*/
|
|
2626
|
+
children: ElementContent$1[]
|
|
2627
|
+
/**
|
|
2628
|
+
* Data associated with the hast MDX JSX elements (flow).
|
|
2629
|
+
*/
|
|
2630
|
+
data?: MdxJsxFlowElementHastData$1 | undefined
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
/**
|
|
2634
|
+
* Info associated with hast MDX JSX element (flow) nodes by the
|
|
2635
|
+
* ecosystem.
|
|
2636
|
+
*/
|
|
2637
|
+
interface MdxJsxFlowElementHastData$1 extends Data$5 {}
|
|
2638
|
+
|
|
2639
|
+
/**
|
|
2640
|
+
* MDX JSX element node, occurring in text (phrasing), for hast.
|
|
2641
|
+
*/
|
|
2642
|
+
interface MdxJsxTextElementHast$1 extends Parent$1 {
|
|
2643
|
+
/**
|
|
2644
|
+
* Node type.
|
|
2645
|
+
*/
|
|
2646
|
+
type: 'mdxJsxTextElement'
|
|
2647
|
+
/**
|
|
2648
|
+
* MDX JSX element name (`null` for fragments).
|
|
2649
|
+
*/
|
|
2650
|
+
name: string | null
|
|
2651
|
+
/**
|
|
2652
|
+
* MDX JSX element attributes.
|
|
2653
|
+
*/
|
|
2654
|
+
attributes: Array<MdxJsxAttribute$2 | MdxJsxExpressionAttribute$2>
|
|
2655
|
+
/**
|
|
2656
|
+
* Content.
|
|
2657
|
+
*/
|
|
2658
|
+
children: ElementContent$1[]
|
|
2659
|
+
/**
|
|
2660
|
+
* Data associated with the hast MDX JSX elements (text).
|
|
2661
|
+
*/
|
|
2662
|
+
data?: MdxJsxTextElementHastData$1 | undefined
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
/**
|
|
2666
|
+
* Info associated with hast MDX JSX element (text) nodes by the
|
|
2667
|
+
* ecosystem.
|
|
2668
|
+
*/
|
|
2669
|
+
interface MdxJsxTextElementHastData$1 extends Data$5 {}
|
|
2670
|
+
|
|
2671
|
+
// Add nodes to mdast content.
|
|
2672
|
+
declare module 'mdast' {
|
|
2673
|
+
interface BlockContentMap {
|
|
2674
|
+
/**
|
|
2675
|
+
* MDX JSX element node, occurring in flow (block).
|
|
2676
|
+
*/
|
|
2677
|
+
mdxJsxFlowElement: MdxJsxFlowElement$1
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
interface PhrasingContentMap {
|
|
2681
|
+
/**
|
|
2682
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
2683
|
+
*/
|
|
2684
|
+
mdxJsxTextElement: MdxJsxTextElement$1
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
interface RootContentMap {
|
|
2688
|
+
/**
|
|
2689
|
+
* MDX JSX element node, occurring in flow (block).
|
|
2690
|
+
*/
|
|
2691
|
+
mdxJsxFlowElement: MdxJsxFlowElement$1
|
|
2692
|
+
/**
|
|
2693
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
2694
|
+
*/
|
|
2695
|
+
mdxJsxTextElement: MdxJsxTextElement$1
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
// Add nodes to hast content.
|
|
2700
|
+
declare module 'hast' {
|
|
2701
|
+
interface ElementContentMap {
|
|
2702
|
+
/**
|
|
2703
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
2704
|
+
*/
|
|
2705
|
+
mdxJsxTextElement: MdxJsxTextElementHast$1
|
|
2706
|
+
/**
|
|
2707
|
+
* MDX JSX element node, occurring in flow (block).
|
|
2708
|
+
*/
|
|
2709
|
+
mdxJsxFlowElement: MdxJsxFlowElementHast$1
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
interface RootContentMap {
|
|
2713
|
+
/**
|
|
2714
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
2715
|
+
*/
|
|
2716
|
+
mdxJsxTextElement: MdxJsxTextElementHast$1
|
|
2717
|
+
/**
|
|
2718
|
+
* MDX JSX element node, occurring in flow (block).
|
|
2719
|
+
*/
|
|
2720
|
+
mdxJsxFlowElement: MdxJsxFlowElementHast$1
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
// Add custom data tracked to turn markdown into a tree.
|
|
2725
|
+
declare module 'mdast-util-from-markdown' {
|
|
2726
|
+
interface CompileData {
|
|
2727
|
+
/**
|
|
2728
|
+
* Current MDX JSX tag.
|
|
2729
|
+
*/
|
|
2730
|
+
mdxJsxTag?: Tag | undefined
|
|
2731
|
+
|
|
2732
|
+
/**
|
|
2733
|
+
* Current stack of open MDX JSX tags.
|
|
2734
|
+
*/
|
|
2735
|
+
mdxJsxTagStack?: Tag[] | undefined
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
// Add custom data tracked to turn a syntax tree into markdown.
|
|
2740
|
+
declare module 'mdast-util-to-markdown' {
|
|
2741
|
+
interface ConstructNameMap {
|
|
2742
|
+
/**
|
|
2743
|
+
* Whole JSX element, in flow.
|
|
2744
|
+
*
|
|
2745
|
+
* ```markdown
|
|
2746
|
+
* > | <a />
|
|
2747
|
+
* ^^^^^
|
|
2748
|
+
* ```
|
|
2749
|
+
*/
|
|
2750
|
+
mdxJsxFlowElement: 'mdxJsxFlowElement'
|
|
2751
|
+
|
|
2752
|
+
/**
|
|
2753
|
+
* Whole JSX element, in text.
|
|
2754
|
+
*
|
|
2755
|
+
* ```markdown
|
|
2756
|
+
* > | a <b />.
|
|
2757
|
+
* ^^^^^
|
|
2758
|
+
* ```
|
|
2759
|
+
*/
|
|
2760
|
+
mdxJsxTextElement: 'mdxJsxTextElement'
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
declare module 'micromark-util-types' {
|
|
2765
|
+
interface TokenTypeMap {
|
|
2766
|
+
listItem: 'listItem'
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
interface Token {
|
|
2770
|
+
_spread?: boolean
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
// Note: this file is authored manually, not generated from `index.js`.
|
|
2775
|
+
|
|
2776
|
+
/**
|
|
2777
|
+
* A character code.
|
|
2778
|
+
*
|
|
2779
|
+
* This is often the same as what `String#charCodeAt()` yields but micromark
|
|
2780
|
+
* adds meaning to certain other values.
|
|
2781
|
+
*
|
|
2782
|
+
* `null` represents the end of the input stream (called eof).
|
|
2783
|
+
* Negative integers are used instead of certain sequences of characters (such
|
|
2784
|
+
* as line endings and tabs).
|
|
2785
|
+
*/
|
|
2786
|
+
type Code = number | null
|
|
2787
|
+
|
|
2788
|
+
/**
|
|
2789
|
+
* A chunk is either a character code or a slice of a buffer in the form of a
|
|
2790
|
+
* string.
|
|
2791
|
+
*
|
|
2792
|
+
* Chunks are used because strings are more efficient storage that character
|
|
2793
|
+
* codes, but limited in what they can represent.
|
|
2794
|
+
*/
|
|
2795
|
+
type Chunk = Code | string
|
|
2796
|
+
|
|
2797
|
+
/**
|
|
2798
|
+
* Enumeration of the content types.
|
|
2799
|
+
*
|
|
2800
|
+
* Technically `document` is also a content type, which includes containers
|
|
2801
|
+
* (lists, block quotes) and flow.
|
|
2802
|
+
* As `ContentType` is used on tokens to define the type of subcontent but
|
|
2803
|
+
* `document` is the highest level of content, so it’s not listed here.
|
|
2804
|
+
*
|
|
2805
|
+
* Containers in markdown come from the margin and include more constructs
|
|
2806
|
+
* on the lines that define them.
|
|
2807
|
+
* Take for example a block quote with a paragraph inside it (such as
|
|
2808
|
+
* `> asd`).
|
|
2809
|
+
*
|
|
2810
|
+
* `flow` represents the sections, such as headings, code, and content, which
|
|
2811
|
+
* is also parsed per line
|
|
2812
|
+
* An example is HTML, which has a certain starting condition (such as
|
|
2813
|
+
* `<script>` on its own line), then continues for a while, until an end
|
|
2814
|
+
* condition is found (such as `</style>`).
|
|
2815
|
+
* If that line with an end condition is never found, that flow goes until
|
|
2816
|
+
* the end.
|
|
2817
|
+
*
|
|
2818
|
+
* `content` is zero or more definitions, and then zero or one paragraph.
|
|
2819
|
+
* It’s a weird one, and needed to make certain edge cases around definitions
|
|
2820
|
+
* spec compliant.
|
|
2821
|
+
* Definitions are unlike other things in markdown, in that they behave like
|
|
2822
|
+
* `text` in that they can contain arbitrary line endings, but *have* to end
|
|
2823
|
+
* at a line ending.
|
|
2824
|
+
* If they end in something else, the whole definition instead is seen as a
|
|
2825
|
+
* paragraph.
|
|
2826
|
+
*
|
|
2827
|
+
* The content in markdown first needs to be parsed up to this level to
|
|
2828
|
+
* figure out which things are defined, for the whole document, before
|
|
2829
|
+
* continuing on with `text`, as whether a link or image reference forms or
|
|
2830
|
+
* not depends on whether it’s defined.
|
|
2831
|
+
* This unfortunately prevents a true streaming markdown to HTML compiler.
|
|
2832
|
+
*
|
|
2833
|
+
* `text` contains phrasing content such as attention (emphasis, strong),
|
|
2834
|
+
* media (links, images), and actual text.
|
|
2835
|
+
*
|
|
2836
|
+
* `string` is a limited `text` like content type which only allows character
|
|
2837
|
+
* references and character escapes.
|
|
2838
|
+
* It exists in things such as identifiers (media references, definitions),
|
|
2839
|
+
* titles, or URLs.
|
|
2840
|
+
*/
|
|
2841
|
+
type ContentType = 'content' | 'document' | 'flow' | 'string' | 'text'
|
|
2842
|
+
|
|
2843
|
+
/**
|
|
2844
|
+
* A location in the document (`line`/`column`/`offset`) and chunk (`_index`,
|
|
2845
|
+
* `_bufferIndex`).
|
|
2846
|
+
*
|
|
2847
|
+
* `_bufferIndex` is `-1` when `_index` points to a code chunk and it’s a
|
|
2848
|
+
* non-negative integer when pointing to a string chunk.
|
|
2849
|
+
*
|
|
2850
|
+
* The interface for the location in the document comes from unist `Point`:
|
|
2851
|
+
* <https://github.com/syntax-tree/unist#point>
|
|
2852
|
+
*/
|
|
2853
|
+
type Point = {
|
|
2854
|
+
/**
|
|
2855
|
+
* Position in a string chunk (or `-1` when pointing to a numeric chunk).
|
|
2856
|
+
*/
|
|
2857
|
+
_bufferIndex: number
|
|
2858
|
+
|
|
2859
|
+
/**
|
|
2860
|
+
* Position in a list of chunks.
|
|
2861
|
+
*/
|
|
2862
|
+
_index: number
|
|
2863
|
+
|
|
2864
|
+
/**
|
|
2865
|
+
* 1-indexed column number.
|
|
2866
|
+
*/
|
|
2867
|
+
column: number
|
|
2868
|
+
|
|
2869
|
+
/**
|
|
2870
|
+
* 1-indexed line number.
|
|
2871
|
+
*/
|
|
2872
|
+
line: number
|
|
2873
|
+
|
|
2874
|
+
/**
|
|
2875
|
+
* 0-indexed position in the document.
|
|
2876
|
+
*/
|
|
2877
|
+
offset: number
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
/**
|
|
2881
|
+
* A token: a span of chunks.
|
|
2882
|
+
*
|
|
2883
|
+
* Tokens are what the core of micromark produces: the built in HTML compiler
|
|
2884
|
+
* or other tools can turn them into different things.
|
|
2885
|
+
*
|
|
2886
|
+
* Tokens are essentially names attached to a slice of chunks, such as
|
|
2887
|
+
* `lineEndingBlank` for certain line endings, or `codeFenced` for a whole
|
|
2888
|
+
* fenced code.
|
|
2889
|
+
*
|
|
2890
|
+
* Sometimes, more info is attached to tokens, such as `_open` and `_close`
|
|
2891
|
+
* by `attention` (strong, emphasis) to signal whether the sequence can open
|
|
2892
|
+
* or close an attention run.
|
|
2893
|
+
*
|
|
2894
|
+
* Linked tokens are used because outer constructs are parsed first.
|
|
2895
|
+
* Take for example:
|
|
2896
|
+
*
|
|
2897
|
+
* ```markdown
|
|
2898
|
+
* > *a
|
|
2899
|
+
* b*.
|
|
2900
|
+
* ```
|
|
2901
|
+
*
|
|
2902
|
+
* 1. The block quote marker and the space after it is parsed first
|
|
2903
|
+
* 2. The rest of the line is a `chunkFlow` token
|
|
2904
|
+
* 3. The two spaces on the second line are a `linePrefix`
|
|
2905
|
+
* 4. The rest of the line is another `chunkFlow` token
|
|
2906
|
+
*
|
|
2907
|
+
* The two `chunkFlow` tokens are linked together.
|
|
2908
|
+
* The chunks they span are then passed through the flow tokenizer.
|
|
2909
|
+
*/
|
|
2910
|
+
interface Token$2 {
|
|
2911
|
+
/**
|
|
2912
|
+
* Token type.
|
|
2913
|
+
*/
|
|
2914
|
+
type: TokenType
|
|
2915
|
+
|
|
2916
|
+
/**
|
|
2917
|
+
* Point where the token starts.
|
|
2918
|
+
*/
|
|
2919
|
+
start: Point
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* Point where the token ends.
|
|
2923
|
+
*/
|
|
2924
|
+
end: Point
|
|
2925
|
+
|
|
2926
|
+
/**
|
|
2927
|
+
* The previous token in a list of linked tokens.
|
|
2928
|
+
*/
|
|
2929
|
+
previous?: Token$2 | undefined
|
|
2930
|
+
|
|
2931
|
+
/**
|
|
2932
|
+
* The next token in a list of linked tokens.
|
|
2933
|
+
*/
|
|
2934
|
+
next?: Token$2 | undefined
|
|
2935
|
+
|
|
2936
|
+
/**
|
|
2937
|
+
* Declares a token as having content of a certain type.
|
|
2938
|
+
*/
|
|
2939
|
+
contentType?: ContentType | undefined
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* Connected tokenizer.
|
|
2943
|
+
*
|
|
2944
|
+
* Used when dealing with linked tokens.
|
|
2945
|
+
* A child tokenizer is needed to tokenize them, which is stored on those
|
|
2946
|
+
* tokens.
|
|
2947
|
+
*/
|
|
2948
|
+
_tokenizer?: TokenizeContext | undefined
|
|
2949
|
+
|
|
2950
|
+
/**
|
|
2951
|
+
* Field to help parse attention.
|
|
2952
|
+
*
|
|
2953
|
+
* Depending on the character before sequences (`**`), the sequence can open,
|
|
2954
|
+
* close, both, or none.
|
|
2955
|
+
*/
|
|
2956
|
+
_open?: boolean | undefined
|
|
2957
|
+
|
|
2958
|
+
/**
|
|
2959
|
+
* Field to help parse attention.
|
|
2960
|
+
*
|
|
2961
|
+
* Depending on the character before sequences (`**`), the sequence can open,
|
|
2962
|
+
* close, both, or none.
|
|
2963
|
+
*/
|
|
2964
|
+
_close?: boolean | undefined
|
|
2965
|
+
|
|
2966
|
+
/**
|
|
2967
|
+
* Field to help parse GFM task lists.
|
|
2968
|
+
*
|
|
2969
|
+
* This boolean is used internally to figure out if a token is in the first
|
|
2970
|
+
* content of a list item construct.
|
|
2971
|
+
*/
|
|
2972
|
+
_isInFirstContentOfListItem?: boolean | undefined
|
|
2973
|
+
|
|
2974
|
+
/**
|
|
2975
|
+
* Field to help parse containers.
|
|
2976
|
+
*
|
|
2977
|
+
* This boolean is used internally to figure out if a token is a container
|
|
2978
|
+
* token.
|
|
2979
|
+
*/
|
|
2980
|
+
_container?: boolean | undefined
|
|
2981
|
+
|
|
2982
|
+
/**
|
|
2983
|
+
* Field to help parse lists.
|
|
2984
|
+
*
|
|
2985
|
+
* This boolean is used internally to figure out if a list is loose or not.
|
|
2986
|
+
*/
|
|
2987
|
+
_loose?: boolean | undefined
|
|
2988
|
+
|
|
2989
|
+
/**
|
|
2990
|
+
* Field to help parse links.
|
|
2991
|
+
*
|
|
2992
|
+
* This boolean is used internally to figure out if a link opening
|
|
2993
|
+
* can’t be used (because links in links are incorrect).
|
|
2994
|
+
*/
|
|
2995
|
+
_inactive?: boolean | undefined
|
|
2996
|
+
|
|
2997
|
+
/**
|
|
2998
|
+
* Field to help parse links.
|
|
2999
|
+
*
|
|
3000
|
+
* This boolean is used internally to figure out if a link opening is
|
|
3001
|
+
* balanced: it’s not a link opening but has a balanced closing.
|
|
3002
|
+
*/
|
|
3003
|
+
_balanced?: boolean | undefined
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* The start or end of a token amongst other events.
|
|
3008
|
+
*
|
|
3009
|
+
* Tokens can “contain” other tokens, even though they are stored in a flat
|
|
3010
|
+
* list, through `enter`ing before them, and `exit`ing after them.
|
|
3011
|
+
*/
|
|
3012
|
+
type Event = ['enter' | 'exit', Token$2, TokenizeContext]
|
|
3013
|
+
|
|
3014
|
+
/**
|
|
3015
|
+
* Open a token.
|
|
3016
|
+
*
|
|
3017
|
+
* @param type
|
|
3018
|
+
* Token type.
|
|
3019
|
+
* @param fields
|
|
3020
|
+
* Extra fields.
|
|
3021
|
+
* @returns {Token}
|
|
3022
|
+
* Token.
|
|
3023
|
+
*/
|
|
3024
|
+
type Enter = (
|
|
3025
|
+
type: TokenType,
|
|
3026
|
+
fields?: Omit<Partial<Token$2>, 'type'> | undefined
|
|
3027
|
+
) => Token$2
|
|
3028
|
+
|
|
3029
|
+
/**
|
|
3030
|
+
* Close a token.
|
|
3031
|
+
*
|
|
3032
|
+
* @param type
|
|
3033
|
+
* Token type.
|
|
3034
|
+
* @returns
|
|
3035
|
+
* Token.
|
|
3036
|
+
*/
|
|
3037
|
+
type Exit = (type: TokenType) => Token$2
|
|
3038
|
+
|
|
3039
|
+
/**
|
|
3040
|
+
* Deal with the character and move to the next.
|
|
3041
|
+
*
|
|
3042
|
+
* @param code
|
|
3043
|
+
* Current code.
|
|
3044
|
+
*/
|
|
3045
|
+
type Consume = (code: Code) => undefined
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Attempt deals with several values, and tries to parse according to those
|
|
3049
|
+
* values.
|
|
3050
|
+
*
|
|
3051
|
+
* If a value resulted in `ok`, it worked, the tokens that were made are used,
|
|
3052
|
+
* and `ok` is switched to.
|
|
3053
|
+
* If the result is `nok`, the attempt failed, so we revert to the original
|
|
3054
|
+
* state, and `nok` is used.
|
|
3055
|
+
*
|
|
3056
|
+
* @param construct
|
|
3057
|
+
* Construct(s) to try.
|
|
3058
|
+
* @param ok
|
|
3059
|
+
* State to move to when successful.
|
|
3060
|
+
* @param nok
|
|
3061
|
+
* State to move to when unsuccessful.
|
|
3062
|
+
* @returns
|
|
3063
|
+
* Next state.
|
|
3064
|
+
*/
|
|
3065
|
+
type Attempt = (
|
|
3066
|
+
construct: Array<Construct> | Construct | ConstructRecord,
|
|
3067
|
+
ok: State,
|
|
3068
|
+
nok?: State | undefined
|
|
3069
|
+
) => State
|
|
3070
|
+
|
|
3071
|
+
/**
|
|
3072
|
+
* A context object to transition the state machine.
|
|
3073
|
+
*/
|
|
3074
|
+
type Effects = {
|
|
3075
|
+
/**
|
|
3076
|
+
* Start a new token.
|
|
3077
|
+
*/
|
|
3078
|
+
enter: Enter
|
|
3079
|
+
|
|
3080
|
+
/**
|
|
3081
|
+
* End a started token.
|
|
3082
|
+
*/
|
|
3083
|
+
exit: Exit
|
|
3084
|
+
|
|
3085
|
+
/**
|
|
3086
|
+
* Deal with the character and move to the next.
|
|
3087
|
+
*/
|
|
3088
|
+
consume: Consume
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* Try to tokenize a construct.
|
|
3092
|
+
*/
|
|
3093
|
+
attempt: Attempt
|
|
3094
|
+
|
|
3095
|
+
/**
|
|
3096
|
+
* Interrupt is used for stuff right after a line of content.
|
|
3097
|
+
*/
|
|
3098
|
+
interrupt: Attempt
|
|
3099
|
+
|
|
3100
|
+
/**
|
|
3101
|
+
* Attempt, then revert.
|
|
3102
|
+
*/
|
|
3103
|
+
check: Attempt
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
/**
|
|
3107
|
+
* The main unit in the state machine: a function that gets a character code
|
|
3108
|
+
* and has certain effects.
|
|
3109
|
+
*
|
|
3110
|
+
* A state function should return another function: the next
|
|
3111
|
+
* state-as-a-function to go to.
|
|
3112
|
+
*
|
|
3113
|
+
* But there is one case where they return `undefined`: for the eof character
|
|
3114
|
+
* code (at the end of a value).
|
|
3115
|
+
* The reason being: well, there isn’t any state that makes sense, so
|
|
3116
|
+
* `undefined` works well.
|
|
3117
|
+
* Practically that has also helped: if for some reason it was a mistake, then
|
|
3118
|
+
* an exception is throw because there is no next function, meaning it
|
|
3119
|
+
* surfaces early.
|
|
3120
|
+
*
|
|
3121
|
+
* @param code
|
|
3122
|
+
* Current code.
|
|
3123
|
+
* @returns
|
|
3124
|
+
* Next state.
|
|
3125
|
+
*/
|
|
3126
|
+
type State = (code: Code) => State | undefined
|
|
3127
|
+
|
|
3128
|
+
/**
|
|
3129
|
+
* A resolver handles and cleans events coming from `tokenize`.
|
|
3130
|
+
*
|
|
3131
|
+
* @param events
|
|
3132
|
+
* List of events.
|
|
3133
|
+
* @param context
|
|
3134
|
+
* Tokenize context.
|
|
3135
|
+
* @returns
|
|
3136
|
+
* The given, modified, events.
|
|
3137
|
+
*/
|
|
3138
|
+
type Resolver = (
|
|
3139
|
+
events: Array<Event>,
|
|
3140
|
+
context: TokenizeContext
|
|
3141
|
+
) => Array<Event>
|
|
3142
|
+
|
|
3143
|
+
/**
|
|
3144
|
+
* A tokenize function sets up a state machine to handle character codes streaming in.
|
|
3145
|
+
*
|
|
3146
|
+
* @param this
|
|
3147
|
+
* Tokenize context.
|
|
3148
|
+
* @param effects
|
|
3149
|
+
* Effects.
|
|
3150
|
+
* @param ok
|
|
3151
|
+
* State to go to when successful.
|
|
3152
|
+
* @param nok
|
|
3153
|
+
* State to go to when unsuccessful.
|
|
3154
|
+
* @returns
|
|
3155
|
+
* First state.
|
|
3156
|
+
*/
|
|
3157
|
+
type Tokenizer = (
|
|
3158
|
+
this: TokenizeContext,
|
|
3159
|
+
effects: Effects,
|
|
3160
|
+
ok: State,
|
|
3161
|
+
nok: State
|
|
3162
|
+
) => State
|
|
3163
|
+
|
|
3164
|
+
/**
|
|
3165
|
+
* Like a tokenizer, but without `ok` or `nok`, and returning `undefined`.
|
|
3166
|
+
*
|
|
3167
|
+
* This is the final hook when a container must be closed.
|
|
3168
|
+
*
|
|
3169
|
+
* @param this
|
|
3170
|
+
* Tokenize context.
|
|
3171
|
+
* @param effects
|
|
3172
|
+
* Effects.
|
|
3173
|
+
* @returns
|
|
3174
|
+
* Nothing.
|
|
3175
|
+
*/
|
|
3176
|
+
type Exiter = (this: TokenizeContext, effects: Effects) => undefined
|
|
3177
|
+
|
|
3178
|
+
/**
|
|
3179
|
+
* Guard whether `code` can come before the construct.
|
|
3180
|
+
*
|
|
3181
|
+
* In certain cases a construct can hook into many potential start characters.
|
|
3182
|
+
* Instead of setting up an attempt to parse that construct for most
|
|
3183
|
+
* characters, this is a speedy way to reduce that.
|
|
3184
|
+
*
|
|
3185
|
+
* @param this
|
|
3186
|
+
* Tokenize context.
|
|
3187
|
+
* @param code
|
|
3188
|
+
* Previous code.
|
|
3189
|
+
* @returns
|
|
3190
|
+
* Whether `code` is allowed before.
|
|
3191
|
+
*/
|
|
3192
|
+
type Previous = (this: TokenizeContext, code: Code) => boolean
|
|
3193
|
+
|
|
3194
|
+
/**
|
|
3195
|
+
* An object describing how to parse a markdown construct.
|
|
3196
|
+
*/
|
|
3197
|
+
type Construct = {
|
|
3198
|
+
/**
|
|
3199
|
+
* Set up a state machine to handle character codes streaming in.
|
|
3200
|
+
*/
|
|
3201
|
+
tokenize: Tokenizer
|
|
3202
|
+
|
|
3203
|
+
/**
|
|
3204
|
+
* Guard whether the previous character can come before the construct.
|
|
3205
|
+
*/
|
|
3206
|
+
previous?: Previous | undefined
|
|
3207
|
+
|
|
3208
|
+
/**
|
|
3209
|
+
* For containers, a continuation construct.
|
|
3210
|
+
*/
|
|
3211
|
+
continuation?: Construct | undefined
|
|
3212
|
+
|
|
3213
|
+
/**
|
|
3214
|
+
* For containers, a final hook.
|
|
3215
|
+
*/
|
|
3216
|
+
exit?: Exiter | undefined
|
|
3217
|
+
|
|
3218
|
+
/**
|
|
3219
|
+
* Name of the construct, used to toggle constructs off.
|
|
3220
|
+
*
|
|
3221
|
+
* Named constructs must not be `partial`.
|
|
3222
|
+
*/
|
|
3223
|
+
name?: string | undefined
|
|
3224
|
+
|
|
3225
|
+
/**
|
|
3226
|
+
* Whether this construct represents a partial construct.
|
|
3227
|
+
*
|
|
3228
|
+
* Partial constructs must not have a `name`.
|
|
3229
|
+
*/
|
|
3230
|
+
partial?: boolean | undefined
|
|
3231
|
+
|
|
3232
|
+
/**
|
|
3233
|
+
* Resolve the events parsed by `tokenize`.
|
|
3234
|
+
*
|
|
3235
|
+
* For example, if we’re currently parsing a link title and this construct
|
|
3236
|
+
* parses character references, then `resolve` is called with the events
|
|
3237
|
+
* ranging from the start to the end of a character reference each time one is
|
|
3238
|
+
* found.
|
|
3239
|
+
*/
|
|
3240
|
+
resolve?: Resolver | undefined
|
|
3241
|
+
|
|
3242
|
+
/**
|
|
3243
|
+
* Resolve the events from the start of the content (which includes other
|
|
3244
|
+
* constructs) to the last one parsed by `tokenize`.
|
|
3245
|
+
*
|
|
3246
|
+
* For example, if we’re currently parsing a link title and this construct
|
|
3247
|
+
* parses character references, then `resolveTo` is called with the events
|
|
3248
|
+
* ranging from the start of the link title to the end of a character
|
|
3249
|
+
* reference each time one is found.
|
|
3250
|
+
*/
|
|
3251
|
+
resolveTo?: Resolver | undefined
|
|
3252
|
+
|
|
3253
|
+
/**
|
|
3254
|
+
* Resolve all events when the content is complete, from the start to the end.
|
|
3255
|
+
* Only used if `tokenize` is successful once in the content.
|
|
3256
|
+
*
|
|
3257
|
+
* For example, if we’re currently parsing a link title and this construct
|
|
3258
|
+
* parses character references, then `resolveAll` is called *if* at least one
|
|
3259
|
+
* character reference is found, ranging from the start to the end of the link
|
|
3260
|
+
* title to the end.
|
|
3261
|
+
*/
|
|
3262
|
+
resolveAll?: Resolver | undefined
|
|
3263
|
+
|
|
3264
|
+
/**
|
|
3265
|
+
* Concrete constructs cannot be interrupted by more containers.
|
|
3266
|
+
*
|
|
3267
|
+
* For example, when parsing the document (containers, such as block quotes
|
|
3268
|
+
* and lists) and this construct is parsing fenced code:
|
|
3269
|
+
*
|
|
3270
|
+
* ````markdown
|
|
3271
|
+
* > ```js
|
|
3272
|
+
* > - list?
|
|
3273
|
+
* ````
|
|
3274
|
+
*
|
|
3275
|
+
* …then `- list?` cannot form if this fenced code construct is concrete.
|
|
3276
|
+
*
|
|
3277
|
+
* An example of a construct that is not concrete is a GFM table:
|
|
3278
|
+
*
|
|
3279
|
+
* ````markdown
|
|
3280
|
+
* | a |
|
|
3281
|
+
* | - |
|
|
3282
|
+
* > | b |
|
|
3283
|
+
* ````
|
|
3284
|
+
*
|
|
3285
|
+
* …`b` is not part of the table.
|
|
3286
|
+
*/
|
|
3287
|
+
concrete?: boolean | undefined
|
|
3288
|
+
|
|
3289
|
+
/**
|
|
3290
|
+
* Whether the construct, when in a `ConstructRecord`, precedes over existing
|
|
3291
|
+
* constructs for the same character code when merged.
|
|
3292
|
+
*
|
|
3293
|
+
* The default is that new constructs precede over existing ones.
|
|
3294
|
+
*/
|
|
3295
|
+
add?: 'after' | 'before' | undefined
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
/**
|
|
3299
|
+
* Several constructs, mapped from their initial codes.
|
|
3300
|
+
*/
|
|
3301
|
+
type ConstructRecord = Record<
|
|
3302
|
+
string,
|
|
3303
|
+
Array<Construct> | Construct | undefined
|
|
3304
|
+
>
|
|
3305
|
+
|
|
3306
|
+
/**
|
|
3307
|
+
* State shared between container calls.
|
|
3308
|
+
*/
|
|
3309
|
+
interface ContainerState {
|
|
3310
|
+
/**
|
|
3311
|
+
* Special field to close the current flow (or containers).
|
|
3312
|
+
*/
|
|
3313
|
+
_closeFlow?: boolean | undefined
|
|
3314
|
+
|
|
3315
|
+
/**
|
|
3316
|
+
* Used by block quotes.
|
|
3317
|
+
*/
|
|
3318
|
+
open?: boolean | undefined
|
|
3319
|
+
|
|
3320
|
+
/**
|
|
3321
|
+
* Current marker, used by lists.
|
|
3322
|
+
*/
|
|
3323
|
+
marker?: Code | undefined
|
|
3324
|
+
|
|
3325
|
+
/**
|
|
3326
|
+
* Current token type, used by lists.
|
|
3327
|
+
*/
|
|
3328
|
+
type?: TokenType | undefined
|
|
3329
|
+
|
|
3330
|
+
/**
|
|
3331
|
+
* Current size, used by lists.
|
|
3332
|
+
*/
|
|
3333
|
+
size?: number | undefined
|
|
3334
|
+
|
|
3335
|
+
/**
|
|
3336
|
+
* Whether there first line is blank, used by lists.
|
|
3337
|
+
*/
|
|
3338
|
+
initialBlankLine?: boolean | undefined
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* Whether there are further blank lines, used by lists.
|
|
3342
|
+
*/
|
|
3343
|
+
furtherBlankLines?: boolean | undefined
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
/**
|
|
3347
|
+
* A context object that helps w/ tokenizing markdown constructs.
|
|
3348
|
+
*/
|
|
3349
|
+
interface TokenizeContext {
|
|
3350
|
+
/**
|
|
3351
|
+
* The previous code.
|
|
3352
|
+
*/
|
|
3353
|
+
previous: Code
|
|
3354
|
+
|
|
3355
|
+
/**
|
|
3356
|
+
* Current code.
|
|
3357
|
+
*/
|
|
3358
|
+
code: Code
|
|
3359
|
+
|
|
3360
|
+
/**
|
|
3361
|
+
* Whether we’re currently interrupting.
|
|
3362
|
+
*
|
|
3363
|
+
* Take for example:
|
|
3364
|
+
*
|
|
3365
|
+
* ```markdown
|
|
3366
|
+
* a
|
|
3367
|
+
* # b
|
|
3368
|
+
* ```
|
|
3369
|
+
*
|
|
3370
|
+
* At 2:1, we’re “interrupting”.
|
|
3371
|
+
*/
|
|
3372
|
+
interrupt?: boolean | undefined
|
|
3373
|
+
|
|
3374
|
+
/**
|
|
3375
|
+
* The current construct.
|
|
3376
|
+
*
|
|
3377
|
+
* Constructs that are not `partial` are set here.
|
|
3378
|
+
*/
|
|
3379
|
+
currentConstruct?: Construct | undefined
|
|
3380
|
+
|
|
3381
|
+
/**
|
|
3382
|
+
* share state set when parsing containers.
|
|
3383
|
+
*
|
|
3384
|
+
* Containers are parsed in separate phases: their first line (`tokenize`),
|
|
3385
|
+
* continued lines (`continuation.tokenize`), and finally `exit`.
|
|
3386
|
+
* This record can be used to store some information between these hooks.
|
|
3387
|
+
*/
|
|
3388
|
+
containerState?: ContainerState | undefined
|
|
3389
|
+
|
|
3390
|
+
/**
|
|
3391
|
+
* Current list of events.
|
|
3392
|
+
*/
|
|
3393
|
+
events: Array<Event>
|
|
3394
|
+
|
|
3395
|
+
/**
|
|
3396
|
+
* The relevant parsing context.
|
|
3397
|
+
*/
|
|
3398
|
+
parser: ParseContext
|
|
3399
|
+
|
|
3400
|
+
/**
|
|
3401
|
+
* Get the chunks that span a token (or location).
|
|
3402
|
+
*
|
|
3403
|
+
* @param token
|
|
3404
|
+
* Start/end in stream.
|
|
3405
|
+
* @returns
|
|
3406
|
+
* List of chunks.
|
|
3407
|
+
*/
|
|
3408
|
+
sliceStream: (token: Pick<Token$2, 'end' | 'start'>) => Array<Chunk>
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* Get the source text that spans a token (or location).
|
|
3412
|
+
*
|
|
3413
|
+
* @param token
|
|
3414
|
+
* Start/end in stream.
|
|
3415
|
+
* @param expandTabs
|
|
3416
|
+
* Whether to expand tabs.
|
|
3417
|
+
* @returns
|
|
3418
|
+
* Serialized chunks.
|
|
3419
|
+
*/
|
|
3420
|
+
sliceSerialize: (
|
|
3421
|
+
token: Pick<Token$2, 'end' | 'start'>,
|
|
3422
|
+
expandTabs?: boolean | undefined
|
|
3423
|
+
) => string
|
|
3424
|
+
|
|
3425
|
+
/**
|
|
3426
|
+
* Get the current place.
|
|
3427
|
+
*
|
|
3428
|
+
* @returns
|
|
3429
|
+
* Current point.
|
|
3430
|
+
*/
|
|
3431
|
+
now: () => Point
|
|
3432
|
+
|
|
3433
|
+
/**
|
|
3434
|
+
* Define a skip
|
|
3435
|
+
*
|
|
3436
|
+
* As containers (block quotes, lists), “nibble” a prefix from the margins,
|
|
3437
|
+
* where a line starts after that prefix is defined here.
|
|
3438
|
+
* When the tokenizers moves after consuming a line ending corresponding to
|
|
3439
|
+
* the line number in the given point, the tokenizer shifts past the prefix
|
|
3440
|
+
* based on the column in the shifted point.
|
|
3441
|
+
*
|
|
3442
|
+
* @param point
|
|
3443
|
+
* Skip.
|
|
3444
|
+
* @returns
|
|
3445
|
+
* Nothing.
|
|
3446
|
+
*/
|
|
3447
|
+
defineSkip: (point: Point) => undefined
|
|
3448
|
+
|
|
3449
|
+
/**
|
|
3450
|
+
* Write a slice of chunks.
|
|
3451
|
+
*
|
|
3452
|
+
* The eof code (`null`) can be used to signal the end of the stream.
|
|
3453
|
+
*
|
|
3454
|
+
* @param slice
|
|
3455
|
+
* Chunks.
|
|
3456
|
+
* @returns
|
|
3457
|
+
* Events.
|
|
3458
|
+
*/
|
|
3459
|
+
write: (slice: Array<Chunk>) => Array<Event>
|
|
3460
|
+
|
|
3461
|
+
/**
|
|
3462
|
+
* Internal boolean shared with `micromark-extension-gfm-task-list-item` to
|
|
3463
|
+
* signal whether the tokenizer is tokenizing the first content of a list item
|
|
3464
|
+
* construct.
|
|
3465
|
+
*/
|
|
3466
|
+
_gfmTasklistFirstContentOfListItem?: boolean | undefined
|
|
3467
|
+
|
|
3468
|
+
// To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer
|
|
3469
|
+
// needed in micromark-extension-gfm-table@1.0.6).
|
|
3470
|
+
/**
|
|
3471
|
+
* Internal boolean shared with `micromark-extension-gfm-table` whose body
|
|
3472
|
+
* rows are not affected by normal interruption rules.
|
|
3473
|
+
* “Normal” rules are, for example, that an empty list item can’t interrupt:
|
|
3474
|
+
*
|
|
3475
|
+
* ````markdown
|
|
3476
|
+
* a
|
|
3477
|
+
* *
|
|
3478
|
+
* ````
|
|
3479
|
+
*
|
|
3480
|
+
* The above is one paragraph.
|
|
3481
|
+
* These rules don’t apply to table body rows:
|
|
3482
|
+
*
|
|
3483
|
+
* ````markdown
|
|
3484
|
+
* | a |
|
|
3485
|
+
* | - |
|
|
3486
|
+
* *
|
|
3487
|
+
* ````
|
|
3488
|
+
*
|
|
3489
|
+
* The above list interrupts the table.
|
|
3490
|
+
*/
|
|
3491
|
+
_gfmTableDynamicInterruptHack?: boolean
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
/**
|
|
3495
|
+
* A syntax extension changes how markdown is tokenized.
|
|
3496
|
+
*
|
|
3497
|
+
* See: <https://github.com/micromark/micromark#syntaxextension>
|
|
3498
|
+
*/
|
|
3499
|
+
interface Extension {
|
|
3500
|
+
document?: ConstructRecord | undefined
|
|
3501
|
+
contentInitial?: ConstructRecord | undefined
|
|
3502
|
+
flowInitial?: ConstructRecord | undefined
|
|
3503
|
+
flow?: ConstructRecord | undefined
|
|
3504
|
+
string?: ConstructRecord | undefined
|
|
3505
|
+
text?: ConstructRecord | undefined
|
|
3506
|
+
disable?: {null?: Array<string> | undefined} | undefined
|
|
3507
|
+
insideSpan?:
|
|
3508
|
+
| {null?: Array<Pick<Construct, 'resolveAll'>> | undefined}
|
|
3509
|
+
| undefined
|
|
3510
|
+
attentionMarkers?: {null?: Array<Code> | undefined} | undefined
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
/**
|
|
3514
|
+
* A full, filtereed, normalized, extension.
|
|
3515
|
+
*/
|
|
3516
|
+
type FullNormalizedExtension = {
|
|
3517
|
+
[Key in keyof Extension]-?: Exclude<Extension[Key], undefined>
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
/**
|
|
3521
|
+
* Create a context.
|
|
3522
|
+
*
|
|
3523
|
+
* @param from
|
|
3524
|
+
* Where to create from.
|
|
3525
|
+
* @returns
|
|
3526
|
+
* Context.
|
|
3527
|
+
*/
|
|
3528
|
+
type Create = (
|
|
3529
|
+
from?: Omit<Point, '_bufferIndex' | '_index'> | undefined
|
|
3530
|
+
) => TokenizeContext
|
|
3531
|
+
|
|
3532
|
+
/**
|
|
3533
|
+
* A context object that helps w/ parsing markdown.
|
|
3534
|
+
*/
|
|
3535
|
+
interface ParseContext {
|
|
3536
|
+
/**
|
|
3537
|
+
* All constructs.
|
|
3538
|
+
*/
|
|
3539
|
+
constructs: FullNormalizedExtension
|
|
3540
|
+
|
|
3541
|
+
/**
|
|
3542
|
+
* Create a content tokenizer.
|
|
3543
|
+
*/
|
|
3544
|
+
content: Create
|
|
3545
|
+
|
|
3546
|
+
/**
|
|
3547
|
+
* Create a document tokenizer.
|
|
3548
|
+
*/
|
|
3549
|
+
document: Create
|
|
3550
|
+
|
|
3551
|
+
/**
|
|
3552
|
+
* Create a flow tokenizer.
|
|
3553
|
+
*/
|
|
3554
|
+
flow: Create
|
|
3555
|
+
|
|
3556
|
+
/**
|
|
3557
|
+
* Create a string tokenizer.
|
|
3558
|
+
*/
|
|
3559
|
+
string: Create
|
|
3560
|
+
|
|
3561
|
+
/**
|
|
3562
|
+
* Create a text tokenizer.
|
|
3563
|
+
*/
|
|
3564
|
+
text: Create
|
|
3565
|
+
|
|
3566
|
+
/**
|
|
3567
|
+
* List of defined identifiers.
|
|
3568
|
+
*/
|
|
3569
|
+
defined: Array<string>
|
|
3570
|
+
|
|
3571
|
+
/**
|
|
3572
|
+
* Map of line numbers to whether they are lazy (as opposed to the line before
|
|
3573
|
+
* them).
|
|
3574
|
+
* Take for example:
|
|
3575
|
+
*
|
|
3576
|
+
* ```markdown
|
|
3577
|
+
* > a
|
|
3578
|
+
* b
|
|
3579
|
+
* ```
|
|
3580
|
+
*
|
|
3581
|
+
* L1 here is not lazy, L2 is.
|
|
3582
|
+
*/
|
|
3583
|
+
lazy: Record<number, boolean>
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* Enum of allowed token types.
|
|
3588
|
+
*/
|
|
3589
|
+
type TokenType = keyof TokenTypeMap
|
|
3590
|
+
|
|
3591
|
+
// Note: when changing the next interface, you likely also have to change
|
|
3592
|
+
// `micromark-util-symbol`.
|
|
3593
|
+
/**
|
|
3594
|
+
* Map of allowed token types.
|
|
3595
|
+
*/
|
|
3596
|
+
interface TokenTypeMap {
|
|
3597
|
+
// Note: these are compiled away.
|
|
3598
|
+
attentionSequence: 'attentionSequence' // To do: remove.
|
|
3599
|
+
space: 'space' // To do: remove.
|
|
3600
|
+
|
|
3601
|
+
data: 'data'
|
|
3602
|
+
whitespace: 'whitespace'
|
|
3603
|
+
lineEnding: 'lineEnding'
|
|
3604
|
+
lineEndingBlank: 'lineEndingBlank'
|
|
3605
|
+
linePrefix: 'linePrefix'
|
|
3606
|
+
lineSuffix: 'lineSuffix'
|
|
3607
|
+
atxHeading: 'atxHeading'
|
|
3608
|
+
atxHeadingSequence: 'atxHeadingSequence'
|
|
3609
|
+
atxHeadingText: 'atxHeadingText'
|
|
3610
|
+
autolink: 'autolink'
|
|
3611
|
+
autolinkEmail: 'autolinkEmail'
|
|
3612
|
+
autolinkMarker: 'autolinkMarker'
|
|
3613
|
+
autolinkProtocol: 'autolinkProtocol'
|
|
3614
|
+
characterEscape: 'characterEscape'
|
|
3615
|
+
characterEscapeValue: 'characterEscapeValue'
|
|
3616
|
+
characterReference: 'characterReference'
|
|
3617
|
+
characterReferenceMarker: 'characterReferenceMarker'
|
|
3618
|
+
characterReferenceMarkerNumeric: 'characterReferenceMarkerNumeric'
|
|
3619
|
+
characterReferenceMarkerHexadecimal: 'characterReferenceMarkerHexadecimal'
|
|
3620
|
+
characterReferenceValue: 'characterReferenceValue'
|
|
3621
|
+
codeFenced: 'codeFenced'
|
|
3622
|
+
codeFencedFence: 'codeFencedFence'
|
|
3623
|
+
codeFencedFenceSequence: 'codeFencedFenceSequence'
|
|
3624
|
+
codeFencedFenceInfo: 'codeFencedFenceInfo'
|
|
3625
|
+
codeFencedFenceMeta: 'codeFencedFenceMeta'
|
|
3626
|
+
codeFlowValue: 'codeFlowValue'
|
|
3627
|
+
codeIndented: 'codeIndented'
|
|
3628
|
+
codeText: 'codeText'
|
|
3629
|
+
codeTextData: 'codeTextData'
|
|
3630
|
+
codeTextPadding: 'codeTextPadding'
|
|
3631
|
+
codeTextSequence: 'codeTextSequence'
|
|
3632
|
+
content: 'content'
|
|
3633
|
+
definition: 'definition'
|
|
3634
|
+
definitionDestination: 'definitionDestination'
|
|
3635
|
+
definitionDestinationLiteral: 'definitionDestinationLiteral'
|
|
3636
|
+
definitionDestinationLiteralMarker: 'definitionDestinationLiteralMarker'
|
|
3637
|
+
definitionDestinationRaw: 'definitionDestinationRaw'
|
|
3638
|
+
definitionDestinationString: 'definitionDestinationString'
|
|
3639
|
+
definitionLabel: 'definitionLabel'
|
|
3640
|
+
definitionLabelMarker: 'definitionLabelMarker'
|
|
3641
|
+
definitionLabelString: 'definitionLabelString'
|
|
3642
|
+
definitionMarker: 'definitionMarker'
|
|
3643
|
+
definitionTitle: 'definitionTitle'
|
|
3644
|
+
definitionTitleMarker: 'definitionTitleMarker'
|
|
3645
|
+
definitionTitleString: 'definitionTitleString'
|
|
3646
|
+
emphasis: 'emphasis'
|
|
3647
|
+
emphasisSequence: 'emphasisSequence'
|
|
3648
|
+
emphasisText: 'emphasisText'
|
|
3649
|
+
escapeMarker: 'escapeMarker'
|
|
3650
|
+
hardBreakEscape: 'hardBreakEscape'
|
|
3651
|
+
hardBreakTrailing: 'hardBreakTrailing'
|
|
3652
|
+
htmlFlow: 'htmlFlow'
|
|
3653
|
+
htmlFlowData: 'htmlFlowData'
|
|
3654
|
+
htmlText: 'htmlText'
|
|
3655
|
+
htmlTextData: 'htmlTextData'
|
|
3656
|
+
image: 'image'
|
|
3657
|
+
label: 'label'
|
|
3658
|
+
labelText: 'labelText'
|
|
3659
|
+
labelLink: 'labelLink'
|
|
3660
|
+
labelImage: 'labelImage'
|
|
3661
|
+
labelMarker: 'labelMarker'
|
|
3662
|
+
labelImageMarker: 'labelImageMarker'
|
|
3663
|
+
labelEnd: 'labelEnd'
|
|
3664
|
+
link: 'link'
|
|
3665
|
+
paragraph: 'paragraph'
|
|
3666
|
+
reference: 'reference'
|
|
3667
|
+
referenceMarker: 'referenceMarker'
|
|
3668
|
+
referenceString: 'referenceString'
|
|
3669
|
+
resource: 'resource'
|
|
3670
|
+
resourceDestination: 'resourceDestination'
|
|
3671
|
+
resourceDestinationLiteral: 'resourceDestinationLiteral'
|
|
3672
|
+
resourceDestinationLiteralMarker: 'resourceDestinationLiteralMarker'
|
|
3673
|
+
resourceDestinationRaw: 'resourceDestinationRaw'
|
|
3674
|
+
resourceDestinationString: 'resourceDestinationString'
|
|
3675
|
+
resourceMarker: 'resourceMarker'
|
|
3676
|
+
resourceTitle: 'resourceTitle'
|
|
3677
|
+
resourceTitleMarker: 'resourceTitleMarker'
|
|
3678
|
+
resourceTitleString: 'resourceTitleString'
|
|
3679
|
+
setextHeading: 'setextHeading'
|
|
3680
|
+
setextHeadingText: 'setextHeadingText'
|
|
3681
|
+
setextHeadingLine: 'setextHeadingLine'
|
|
3682
|
+
setextHeadingLineSequence: 'setextHeadingLineSequence'
|
|
3683
|
+
strong: 'strong'
|
|
3684
|
+
strongSequence: 'strongSequence'
|
|
3685
|
+
strongText: 'strongText'
|
|
3686
|
+
thematicBreak: 'thematicBreak'
|
|
3687
|
+
thematicBreakSequence: 'thematicBreakSequence'
|
|
3688
|
+
blockQuote: 'blockQuote'
|
|
3689
|
+
blockQuotePrefix: 'blockQuotePrefix'
|
|
3690
|
+
blockQuoteMarker: 'blockQuoteMarker'
|
|
3691
|
+
blockQuotePrefixWhitespace: 'blockQuotePrefixWhitespace'
|
|
3692
|
+
listOrdered: 'listOrdered'
|
|
3693
|
+
listUnordered: 'listUnordered'
|
|
3694
|
+
listItemIndent: 'listItemIndent'
|
|
3695
|
+
listItemMarker: 'listItemMarker'
|
|
3696
|
+
listItemPrefix: 'listItemPrefix'
|
|
3697
|
+
listItemPrefixWhitespace: 'listItemPrefixWhitespace'
|
|
3698
|
+
listItemValue: 'listItemValue'
|
|
3699
|
+
chunkDocument: 'chunkDocument'
|
|
3700
|
+
chunkContent: 'chunkContent'
|
|
3701
|
+
chunkFlow: 'chunkFlow'
|
|
3702
|
+
chunkText: 'chunkText'
|
|
3703
|
+
chunkString: 'chunkString'
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
type Token$1 = Token$2
|
|
3707
|
+
|
|
3708
|
+
declare module 'micromark-util-types' {
|
|
3709
|
+
interface TokenTypeMap {
|
|
3710
|
+
listItem: 'listItem'
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3713
|
+
interface Token {
|
|
3714
|
+
_spread?: boolean
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
|
|
3718
|
+
type Token = Token$1
|
|
3719
|
+
type MdxJsxAttribute$1 = MdxJsxAttribute$2
|
|
3720
|
+
type MdxJsxExpressionAttribute$1 =
|
|
3721
|
+
MdxJsxExpressionAttribute$2
|
|
3722
|
+
/**
|
|
3723
|
+
* Single tag.
|
|
3724
|
+
*/
|
|
3725
|
+
type Tag = {
|
|
3726
|
+
/**
|
|
3727
|
+
* Name of tag, or `undefined` for fragment.
|
|
3728
|
+
*
|
|
3729
|
+
* > 👉 **Note**: `null` is used in the AST for fragments, as it serializes in
|
|
3730
|
+
* > JSON.
|
|
3731
|
+
*/
|
|
3732
|
+
name: string | undefined
|
|
3733
|
+
/**
|
|
3734
|
+
* Attributes.
|
|
3735
|
+
*/
|
|
3736
|
+
attributes: Array<MdxJsxAttribute$1 | MdxJsxExpressionAttribute$1>
|
|
3737
|
+
/**
|
|
3738
|
+
* Whether the tag is closing (`</x>`).
|
|
3739
|
+
*/
|
|
3740
|
+
close: boolean
|
|
3741
|
+
/**
|
|
3742
|
+
* Whether the tag is self-closing (`<x/>`).
|
|
3743
|
+
*/
|
|
3744
|
+
selfClosing: boolean
|
|
3745
|
+
/**
|
|
3746
|
+
* Start point.
|
|
3747
|
+
*/
|
|
3748
|
+
start: Token['start']
|
|
3749
|
+
/**
|
|
3750
|
+
* End point.
|
|
3751
|
+
*/
|
|
3752
|
+
end: Token['start']
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
// Expose node types.
|
|
3756
|
+
/**
|
|
3757
|
+
* MDX JSX attribute value set to an expression.
|
|
3758
|
+
*
|
|
3759
|
+
* ```markdown
|
|
3760
|
+
* > | <a b={c} />
|
|
3761
|
+
* ^^^
|
|
3762
|
+
* ```
|
|
3763
|
+
*/
|
|
3764
|
+
interface MdxJsxAttributeValueExpression extends Node$3 {
|
|
3765
|
+
/**
|
|
3766
|
+
* Node type.
|
|
3767
|
+
*/
|
|
3768
|
+
type: 'mdxJsxAttributeValueExpression'
|
|
3769
|
+
|
|
3770
|
+
/**
|
|
3771
|
+
* Value.
|
|
3772
|
+
*/
|
|
3773
|
+
value: string
|
|
3774
|
+
|
|
3775
|
+
/**
|
|
3776
|
+
* Data associated with the mdast MDX JSX attribute value expression.
|
|
3777
|
+
*/
|
|
3778
|
+
data?: MdxJsxAttributeValueExpressionData | undefined
|
|
3779
|
+
}
|
|
3780
|
+
|
|
3781
|
+
/**
|
|
3782
|
+
* Info associated with mdast MDX JSX attribute value expression nodes by the
|
|
3783
|
+
* ecosystem.
|
|
3784
|
+
*/
|
|
3785
|
+
interface MdxJsxAttributeValueExpressionData extends Data$7 {
|
|
3786
|
+
/**
|
|
3787
|
+
* Program node from estree.
|
|
3788
|
+
*/
|
|
3789
|
+
estree?: Program | null | undefined
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
/**
|
|
3793
|
+
* MDX JSX attribute as an expression.
|
|
3794
|
+
*
|
|
3795
|
+
* ```markdown
|
|
3796
|
+
* > | <a {...b} />
|
|
3797
|
+
* ^^^^^^
|
|
3798
|
+
* ```
|
|
3799
|
+
*/
|
|
3800
|
+
interface MdxJsxExpressionAttribute extends Node$3 {
|
|
3801
|
+
/**
|
|
3802
|
+
* Node type.
|
|
3803
|
+
*/
|
|
3804
|
+
type: 'mdxJsxExpressionAttribute'
|
|
3805
|
+
|
|
3806
|
+
/**
|
|
3807
|
+
* Value.
|
|
3808
|
+
*/
|
|
3809
|
+
value: string
|
|
3810
|
+
|
|
3811
|
+
/**
|
|
3812
|
+
* Data associated with the mdast MDX JSX expression attributes.
|
|
3813
|
+
*/
|
|
3814
|
+
data?: MdxJsxExpressionAttributeData | undefined
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
/**
|
|
3818
|
+
* Info associated with mdast MDX JSX expression attribute nodes by the
|
|
3819
|
+
* ecosystem.
|
|
3820
|
+
*/
|
|
3821
|
+
interface MdxJsxExpressionAttributeData extends Data$7 {
|
|
3822
|
+
/**
|
|
3823
|
+
* Program node from estree.
|
|
3824
|
+
*/
|
|
3825
|
+
estree?: Program | null | undefined
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
/**
|
|
3829
|
+
* MDX JSX attribute with a key.
|
|
3830
|
+
*
|
|
3831
|
+
* ```markdown
|
|
3832
|
+
* > | <a b="c" />
|
|
3833
|
+
* ^^^^^
|
|
3834
|
+
* ```
|
|
3835
|
+
*/
|
|
3836
|
+
interface MdxJsxAttribute extends Node$3 {
|
|
3837
|
+
/**
|
|
3838
|
+
* Node type.
|
|
3839
|
+
*/
|
|
3840
|
+
type: 'mdxJsxAttribute'
|
|
3841
|
+
/**
|
|
3842
|
+
* Attribute name.
|
|
3843
|
+
*/
|
|
3844
|
+
name: string
|
|
3845
|
+
/**
|
|
3846
|
+
* Attribute value.
|
|
3847
|
+
*/
|
|
3848
|
+
value?: MdxJsxAttributeValueExpression | string | null | undefined
|
|
3849
|
+
/**
|
|
3850
|
+
* Data associated with the mdast MDX JSX attribute.
|
|
3851
|
+
*/
|
|
3852
|
+
data?: MdxJsxAttributeData | undefined
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
/**
|
|
3856
|
+
* Info associated with mdast MDX JSX attribute nodes by the
|
|
3857
|
+
* ecosystem.
|
|
3858
|
+
*/
|
|
3859
|
+
interface MdxJsxAttributeData extends Data$7 {}
|
|
3860
|
+
|
|
3861
|
+
/**
|
|
3862
|
+
* MDX JSX element node, occurring in flow (block).
|
|
3863
|
+
*/
|
|
3864
|
+
interface MdxJsxFlowElement extends Parent {
|
|
3865
|
+
/**
|
|
3866
|
+
* Node type.
|
|
3867
|
+
*/
|
|
3868
|
+
type: 'mdxJsxFlowElement'
|
|
3869
|
+
/**
|
|
3870
|
+
* MDX JSX element name (`null` for fragments).
|
|
3871
|
+
*/
|
|
3872
|
+
name: string | null
|
|
3873
|
+
/**
|
|
3874
|
+
* MDX JSX element attributes.
|
|
3875
|
+
*/
|
|
3876
|
+
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
|
|
3877
|
+
/**
|
|
3878
|
+
* Content.
|
|
3879
|
+
*/
|
|
3880
|
+
children: Array<BlockContent | DefinitionContent>
|
|
3881
|
+
/**
|
|
3882
|
+
* Data associated with the mdast MDX JSX elements (flow).
|
|
3883
|
+
*/
|
|
3884
|
+
data?: MdxJsxFlowElementData | undefined
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
/**
|
|
3888
|
+
* Info associated with mdast MDX JSX element (flow) nodes by the
|
|
3889
|
+
* ecosystem.
|
|
3890
|
+
*/
|
|
3891
|
+
interface MdxJsxFlowElementData extends Data$6 {}
|
|
3892
|
+
|
|
3893
|
+
/**
|
|
3894
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
3895
|
+
*/
|
|
3896
|
+
interface MdxJsxTextElement extends Parent {
|
|
3897
|
+
/**
|
|
3898
|
+
* Node type.
|
|
3899
|
+
*/
|
|
3900
|
+
type: 'mdxJsxTextElement'
|
|
3901
|
+
/**
|
|
3902
|
+
* MDX JSX element name (`null` for fragments).
|
|
3903
|
+
*/
|
|
3904
|
+
name: string | null
|
|
3905
|
+
/**
|
|
3906
|
+
* MDX JSX element attributes.
|
|
3907
|
+
*/
|
|
3908
|
+
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
|
|
3909
|
+
/**
|
|
3910
|
+
* Content.
|
|
3911
|
+
*/
|
|
3912
|
+
children: PhrasingContent[]
|
|
3913
|
+
/**
|
|
3914
|
+
* Data associated with the mdast MDX JSX elements (text).
|
|
3915
|
+
*/
|
|
3916
|
+
data?: MdxJsxTextElementData | undefined
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
/**
|
|
3920
|
+
* Info associated with mdast MDX JSX element (text) nodes by the
|
|
3921
|
+
* ecosystem.
|
|
3922
|
+
*/
|
|
3923
|
+
interface MdxJsxTextElementData extends Data$6 {}
|
|
3924
|
+
|
|
3925
|
+
/**
|
|
3926
|
+
* MDX JSX element node, occurring in flow (block), for hast.
|
|
3927
|
+
*/
|
|
3928
|
+
interface MdxJsxFlowElementHast extends Parent$1 {
|
|
3929
|
+
/**
|
|
3930
|
+
* Node type.
|
|
3931
|
+
*/
|
|
3932
|
+
type: 'mdxJsxFlowElement'
|
|
3933
|
+
/**
|
|
3934
|
+
* MDX JSX element name (`null` for fragments).
|
|
3935
|
+
*/
|
|
3936
|
+
name: string | null
|
|
3937
|
+
/**
|
|
3938
|
+
* MDX JSX element attributes.
|
|
3939
|
+
*/
|
|
3940
|
+
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
|
|
3941
|
+
/**
|
|
3942
|
+
* Content.
|
|
3943
|
+
*/
|
|
3944
|
+
children: ElementContent$1[]
|
|
3945
|
+
/**
|
|
3946
|
+
* Data associated with the hast MDX JSX elements (flow).
|
|
3947
|
+
*/
|
|
3948
|
+
data?: MdxJsxFlowElementHastData | undefined
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
/**
|
|
3952
|
+
* Info associated with hast MDX JSX element (flow) nodes by the
|
|
3953
|
+
* ecosystem.
|
|
3954
|
+
*/
|
|
3955
|
+
interface MdxJsxFlowElementHastData extends Data$5 {}
|
|
3956
|
+
|
|
3957
|
+
/**
|
|
3958
|
+
* MDX JSX element node, occurring in text (phrasing), for hast.
|
|
3959
|
+
*/
|
|
3960
|
+
interface MdxJsxTextElementHast extends Parent$1 {
|
|
3961
|
+
/**
|
|
3962
|
+
* Node type.
|
|
3963
|
+
*/
|
|
3964
|
+
type: 'mdxJsxTextElement'
|
|
3965
|
+
/**
|
|
3966
|
+
* MDX JSX element name (`null` for fragments).
|
|
3967
|
+
*/
|
|
3968
|
+
name: string | null
|
|
3969
|
+
/**
|
|
3970
|
+
* MDX JSX element attributes.
|
|
3971
|
+
*/
|
|
3972
|
+
attributes: Array<MdxJsxAttribute | MdxJsxExpressionAttribute>
|
|
3973
|
+
/**
|
|
3974
|
+
* Content.
|
|
3975
|
+
*/
|
|
3976
|
+
children: ElementContent$1[]
|
|
3977
|
+
/**
|
|
3978
|
+
* Data associated with the hast MDX JSX elements (text).
|
|
3979
|
+
*/
|
|
3980
|
+
data?: MdxJsxTextElementHastData | undefined
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
/**
|
|
3984
|
+
* Info associated with hast MDX JSX element (text) nodes by the
|
|
3985
|
+
* ecosystem.
|
|
3986
|
+
*/
|
|
3987
|
+
interface MdxJsxTextElementHastData extends Data$5 {}
|
|
3988
|
+
|
|
3989
|
+
// Add nodes to mdast content.
|
|
3990
|
+
declare module 'mdast' {
|
|
3991
|
+
interface BlockContentMap {
|
|
3992
|
+
/**
|
|
3993
|
+
* MDX JSX element node, occurring in flow (block).
|
|
3994
|
+
*/
|
|
3995
|
+
mdxJsxFlowElement: MdxJsxFlowElement
|
|
3996
|
+
}
|
|
3997
|
+
|
|
3998
|
+
interface PhrasingContentMap {
|
|
3999
|
+
/**
|
|
4000
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
4001
|
+
*/
|
|
4002
|
+
mdxJsxTextElement: MdxJsxTextElement
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
interface RootContentMap {
|
|
4006
|
+
/**
|
|
4007
|
+
* MDX JSX element node, occurring in flow (block).
|
|
4008
|
+
*/
|
|
4009
|
+
mdxJsxFlowElement: MdxJsxFlowElement
|
|
4010
|
+
/**
|
|
4011
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
4012
|
+
*/
|
|
4013
|
+
mdxJsxTextElement: MdxJsxTextElement
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
// Add nodes to hast content.
|
|
4018
|
+
declare module 'hast' {
|
|
4019
|
+
interface ElementContentMap {
|
|
4020
|
+
/**
|
|
4021
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
4022
|
+
*/
|
|
4023
|
+
mdxJsxTextElement: MdxJsxTextElementHast
|
|
4024
|
+
/**
|
|
4025
|
+
* MDX JSX element node, occurring in flow (block).
|
|
4026
|
+
*/
|
|
4027
|
+
mdxJsxFlowElement: MdxJsxFlowElementHast
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
interface RootContentMap {
|
|
4031
|
+
/**
|
|
4032
|
+
* MDX JSX element node, occurring in text (phrasing).
|
|
4033
|
+
*/
|
|
4034
|
+
mdxJsxTextElement: MdxJsxTextElementHast
|
|
4035
|
+
/**
|
|
4036
|
+
* MDX JSX element node, occurring in flow (block).
|
|
4037
|
+
*/
|
|
4038
|
+
mdxJsxFlowElement: MdxJsxFlowElementHast
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
// Add custom data tracked to turn markdown into a tree.
|
|
4043
|
+
declare module 'mdast-util-from-markdown' {
|
|
4044
|
+
interface CompileData {
|
|
4045
|
+
/**
|
|
4046
|
+
* Current MDX JSX tag.
|
|
4047
|
+
*/
|
|
4048
|
+
mdxJsxTag?: Tag | undefined
|
|
4049
|
+
|
|
4050
|
+
/**
|
|
4051
|
+
* Current stack of open MDX JSX tags.
|
|
4052
|
+
*/
|
|
4053
|
+
mdxJsxTagStack?: Tag[] | undefined
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
// Add custom data tracked to turn a syntax tree into markdown.
|
|
4058
|
+
declare module 'mdast-util-to-markdown' {
|
|
4059
|
+
interface ConstructNameMap {
|
|
4060
|
+
/**
|
|
4061
|
+
* Whole JSX element, in flow.
|
|
4062
|
+
*
|
|
4063
|
+
* ```markdown
|
|
4064
|
+
* > | <a />
|
|
4065
|
+
* ^^^^^
|
|
4066
|
+
* ```
|
|
4067
|
+
*/
|
|
4068
|
+
mdxJsxFlowElement: 'mdxJsxFlowElement'
|
|
4069
|
+
|
|
4070
|
+
/**
|
|
4071
|
+
* Whole JSX element, in text.
|
|
4072
|
+
*
|
|
4073
|
+
* ```markdown
|
|
4074
|
+
* > | a <b />.
|
|
4075
|
+
* ^^^^^
|
|
4076
|
+
* ```
|
|
4077
|
+
*/
|
|
4078
|
+
mdxJsxTextElement: 'mdxJsxTextElement'
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
/**
|
|
4083
|
+
* Specify casing to use for attribute names.
|
|
4084
|
+
*
|
|
4085
|
+
* HTML casing is for example `class`, `stroke-linecap`, `xml:lang`.
|
|
4086
|
+
* React casing is for example `className`, `strokeLinecap`, `xmlLang`.
|
|
4087
|
+
*/
|
|
4088
|
+
type ElementAttributeNameCase$2 = 'html' | 'react';
|
|
4089
|
+
/**
|
|
4090
|
+
* Casing to use for property names in `style` objects.
|
|
4091
|
+
*
|
|
4092
|
+
* CSS casing is for example `background-color` and `-webkit-line-clamp`.
|
|
4093
|
+
* DOM casing is for example `backgroundColor` and `WebkitLineClamp`.
|
|
4094
|
+
*/
|
|
4095
|
+
type StylePropertyNameCase$2 = 'css' | 'dom';
|
|
4096
|
+
|
|
4097
|
+
/**
|
|
4098
|
+
* MDX expression node, occurring in flow (block).
|
|
4099
|
+
*/
|
|
4100
|
+
interface MdxFlowExpression$1 extends Literal$1 {
|
|
4101
|
+
/**
|
|
4102
|
+
* Node type.
|
|
4103
|
+
*/
|
|
4104
|
+
type: 'mdxFlowExpression'
|
|
4105
|
+
|
|
4106
|
+
/**
|
|
4107
|
+
* Data associated with the mdast MDX expression (flow).
|
|
4108
|
+
*/
|
|
4109
|
+
data?: MdxFlowExpressionData$1 | undefined
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
/**
|
|
4113
|
+
* Info associated with mdast MDX expression (flow) nodes by the ecosystem.
|
|
4114
|
+
*/
|
|
4115
|
+
interface MdxFlowExpressionData$1 extends Data$6 {
|
|
4116
|
+
/**
|
|
4117
|
+
* Program node from estree.
|
|
4118
|
+
*/
|
|
4119
|
+
estree?: Program | null | undefined
|
|
4120
|
+
}
|
|
4121
|
+
|
|
4122
|
+
/**
|
|
4123
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4124
|
+
*/
|
|
4125
|
+
interface MdxTextExpression$1 extends Literal$1 {
|
|
4126
|
+
/**
|
|
4127
|
+
* Node type.
|
|
4128
|
+
*/
|
|
4129
|
+
type: 'mdxTextExpression'
|
|
4130
|
+
|
|
4131
|
+
/**
|
|
4132
|
+
* Data associated with the mdast MDX expression (text).
|
|
4133
|
+
*/
|
|
4134
|
+
data?: MdxTextExpressionData$1 | undefined
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
/**
|
|
4138
|
+
* Info associated with mdast MDX expression (text) nodes by the ecosystem.
|
|
4139
|
+
*/
|
|
4140
|
+
interface MdxTextExpressionData$1 extends Data$6 {
|
|
4141
|
+
/**
|
|
4142
|
+
* Program node from estree.
|
|
4143
|
+
*/
|
|
4144
|
+
estree?: Program | null | undefined
|
|
4145
|
+
}
|
|
4146
|
+
|
|
4147
|
+
/**
|
|
4148
|
+
* MDX expression node, occurring in flow (block), for hast.
|
|
4149
|
+
*/
|
|
4150
|
+
interface MdxFlowExpressionHast$1 extends Literal {
|
|
4151
|
+
/**
|
|
4152
|
+
* Node type.
|
|
4153
|
+
*/
|
|
4154
|
+
type: 'mdxFlowExpression'
|
|
4155
|
+
|
|
4156
|
+
/**
|
|
4157
|
+
* Data associated with the hast MDX expression (flow).
|
|
4158
|
+
*/
|
|
4159
|
+
data?: MdxFlowExpressionHastData$1 | undefined
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
/**
|
|
4163
|
+
* Info associated with hast MDX expression (flow) nodes by the ecosystem.
|
|
4164
|
+
*/
|
|
4165
|
+
interface MdxFlowExpressionHastData$1 extends Data$5 {
|
|
4166
|
+
/**
|
|
4167
|
+
* Program node from estree.
|
|
4168
|
+
*/
|
|
4169
|
+
estree?: Program | null | undefined
|
|
4170
|
+
}
|
|
4171
|
+
|
|
4172
|
+
/**
|
|
4173
|
+
* MDX expression node, occurring in text (phrasing), for hast.
|
|
4174
|
+
*/
|
|
4175
|
+
interface MdxTextExpressionHast$1 extends Literal {
|
|
4176
|
+
/**
|
|
4177
|
+
* Node type.
|
|
4178
|
+
*/
|
|
4179
|
+
type: 'mdxTextExpression'
|
|
4180
|
+
|
|
4181
|
+
/**
|
|
4182
|
+
* Data associated with the hast MDX expression (text).
|
|
4183
|
+
*/
|
|
4184
|
+
data?: MdxTextExpressionHastData$1 | undefined
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4187
|
+
/**
|
|
4188
|
+
* Info associated with hast MDX expression (text) nodes by the ecosystem.
|
|
4189
|
+
*/
|
|
4190
|
+
interface MdxTextExpressionHastData$1 extends Data$5 {
|
|
4191
|
+
/**
|
|
4192
|
+
* Program node from estree.
|
|
4193
|
+
*/
|
|
4194
|
+
estree?: Program | null | undefined
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4197
|
+
// Add nodes to mdast content.
|
|
4198
|
+
declare module 'mdast' {
|
|
4199
|
+
interface RootContentMap {
|
|
4200
|
+
/**
|
|
4201
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4202
|
+
*/
|
|
4203
|
+
mdxTextExpression: MdxTextExpression$1
|
|
4204
|
+
/**
|
|
4205
|
+
* MDX expression node, occurring in flow (block).
|
|
4206
|
+
*/
|
|
4207
|
+
mdxFlowExpression: MdxFlowExpression$1
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4210
|
+
interface PhrasingContentMap {
|
|
4211
|
+
/**
|
|
4212
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4213
|
+
*/
|
|
4214
|
+
mdxTextExpression: MdxTextExpression$1
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
interface BlockContentMap {
|
|
4218
|
+
/**
|
|
4219
|
+
* MDX expression node, occurring in flow (block).
|
|
4220
|
+
*/
|
|
4221
|
+
mdxFlowExpression: MdxFlowExpression$1
|
|
4222
|
+
}
|
|
4223
|
+
}
|
|
4224
|
+
|
|
4225
|
+
// Add nodes to hast content.
|
|
4226
|
+
declare module 'hast' {
|
|
4227
|
+
interface RootContentMap {
|
|
4228
|
+
/**
|
|
4229
|
+
* MDX expression node, occurring in flow (block).
|
|
4230
|
+
*/
|
|
4231
|
+
mdxFlowExpression: MdxFlowExpressionHast$1
|
|
4232
|
+
/**
|
|
4233
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4234
|
+
*/
|
|
4235
|
+
mdxTextExpression: MdxTextExpressionHast$1
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4238
|
+
interface ElementContentMap {
|
|
4239
|
+
/**
|
|
4240
|
+
* MDX expression node, occurring in flow (block).
|
|
4241
|
+
*/
|
|
4242
|
+
mdxFlowExpression: MdxFlowExpressionHast$1
|
|
4243
|
+
/**
|
|
4244
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4245
|
+
*/
|
|
4246
|
+
mdxTextExpression: MdxTextExpressionHast$1
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
|
|
4250
|
+
/**
|
|
4251
|
+
* MDX expression node, occurring in flow (block).
|
|
4252
|
+
*/
|
|
4253
|
+
interface MdxFlowExpression extends Literal$1 {
|
|
4254
|
+
/**
|
|
4255
|
+
* Node type.
|
|
4256
|
+
*/
|
|
4257
|
+
type: 'mdxFlowExpression'
|
|
4258
|
+
|
|
4259
|
+
/**
|
|
4260
|
+
* Data associated with the mdast MDX expression (flow).
|
|
4261
|
+
*/
|
|
4262
|
+
data?: MdxFlowExpressionData | undefined
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
/**
|
|
4266
|
+
* Info associated with mdast MDX expression (flow) nodes by the ecosystem.
|
|
4267
|
+
*/
|
|
4268
|
+
interface MdxFlowExpressionData extends Data$6 {
|
|
4269
|
+
/**
|
|
4270
|
+
* Program node from estree.
|
|
4271
|
+
*/
|
|
4272
|
+
estree?: Program | null | undefined
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4275
|
+
/**
|
|
4276
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4277
|
+
*/
|
|
4278
|
+
interface MdxTextExpression extends Literal$1 {
|
|
4279
|
+
/**
|
|
4280
|
+
* Node type.
|
|
4281
|
+
*/
|
|
4282
|
+
type: 'mdxTextExpression'
|
|
4283
|
+
|
|
4284
|
+
/**
|
|
4285
|
+
* Data associated with the mdast MDX expression (text).
|
|
4286
|
+
*/
|
|
4287
|
+
data?: MdxTextExpressionData | undefined
|
|
4288
|
+
}
|
|
4289
|
+
|
|
4290
|
+
/**
|
|
4291
|
+
* Info associated with mdast MDX expression (text) nodes by the ecosystem.
|
|
4292
|
+
*/
|
|
4293
|
+
interface MdxTextExpressionData extends Data$6 {
|
|
4294
|
+
/**
|
|
4295
|
+
* Program node from estree.
|
|
4296
|
+
*/
|
|
4297
|
+
estree?: Program | null | undefined
|
|
4298
|
+
}
|
|
4299
|
+
|
|
4300
|
+
/**
|
|
4301
|
+
* MDX expression node, occurring in flow (block), for hast.
|
|
4302
|
+
*/
|
|
4303
|
+
interface MdxFlowExpressionHast extends Literal {
|
|
4304
|
+
/**
|
|
4305
|
+
* Node type.
|
|
4306
|
+
*/
|
|
4307
|
+
type: 'mdxFlowExpression'
|
|
4308
|
+
|
|
4309
|
+
/**
|
|
4310
|
+
* Data associated with the hast MDX expression (flow).
|
|
4311
|
+
*/
|
|
4312
|
+
data?: MdxFlowExpressionHastData | undefined
|
|
4313
|
+
}
|
|
4314
|
+
|
|
4315
|
+
/**
|
|
4316
|
+
* Info associated with hast MDX expression (flow) nodes by the ecosystem.
|
|
4317
|
+
*/
|
|
4318
|
+
interface MdxFlowExpressionHastData extends Data$5 {
|
|
4319
|
+
/**
|
|
4320
|
+
* Program node from estree.
|
|
4321
|
+
*/
|
|
4322
|
+
estree?: Program | null | undefined
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4325
|
+
/**
|
|
4326
|
+
* MDX expression node, occurring in text (phrasing), for hast.
|
|
4327
|
+
*/
|
|
4328
|
+
interface MdxTextExpressionHast extends Literal {
|
|
4329
|
+
/**
|
|
4330
|
+
* Node type.
|
|
4331
|
+
*/
|
|
4332
|
+
type: 'mdxTextExpression'
|
|
4333
|
+
|
|
4334
|
+
/**
|
|
4335
|
+
* Data associated with the hast MDX expression (text).
|
|
4336
|
+
*/
|
|
4337
|
+
data?: MdxTextExpressionHastData | undefined
|
|
4338
|
+
}
|
|
4339
|
+
|
|
4340
|
+
/**
|
|
4341
|
+
* Info associated with hast MDX expression (text) nodes by the ecosystem.
|
|
4342
|
+
*/
|
|
4343
|
+
interface MdxTextExpressionHastData extends Data$5 {
|
|
4344
|
+
/**
|
|
4345
|
+
* Program node from estree.
|
|
4346
|
+
*/
|
|
4347
|
+
estree?: Program | null | undefined
|
|
4348
|
+
}
|
|
4349
|
+
|
|
4350
|
+
// Add nodes to mdast content.
|
|
4351
|
+
declare module 'mdast' {
|
|
4352
|
+
interface RootContentMap {
|
|
4353
|
+
/**
|
|
4354
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4355
|
+
*/
|
|
4356
|
+
mdxTextExpression: MdxTextExpression
|
|
4357
|
+
/**
|
|
4358
|
+
* MDX expression node, occurring in flow (block).
|
|
4359
|
+
*/
|
|
4360
|
+
mdxFlowExpression: MdxFlowExpression
|
|
4361
|
+
}
|
|
4362
|
+
|
|
4363
|
+
interface PhrasingContentMap {
|
|
4364
|
+
/**
|
|
4365
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4366
|
+
*/
|
|
4367
|
+
mdxTextExpression: MdxTextExpression
|
|
4368
|
+
}
|
|
4369
|
+
|
|
4370
|
+
interface BlockContentMap {
|
|
4371
|
+
/**
|
|
4372
|
+
* MDX expression node, occurring in flow (block).
|
|
4373
|
+
*/
|
|
4374
|
+
mdxFlowExpression: MdxFlowExpression
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
|
|
4378
|
+
// Add nodes to hast content.
|
|
4379
|
+
declare module 'hast' {
|
|
4380
|
+
interface RootContentMap {
|
|
4381
|
+
/**
|
|
4382
|
+
* MDX expression node, occurring in flow (block).
|
|
4383
|
+
*/
|
|
4384
|
+
mdxFlowExpression: MdxFlowExpressionHast
|
|
4385
|
+
/**
|
|
4386
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4387
|
+
*/
|
|
4388
|
+
mdxTextExpression: MdxTextExpressionHast
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4391
|
+
interface ElementContentMap {
|
|
4392
|
+
/**
|
|
4393
|
+
* MDX expression node, occurring in flow (block).
|
|
4394
|
+
*/
|
|
4395
|
+
mdxFlowExpression: MdxFlowExpressionHast
|
|
4396
|
+
/**
|
|
4397
|
+
* MDX expression node, occurring in text (phrasing).
|
|
4398
|
+
*/
|
|
4399
|
+
mdxTextExpression: MdxTextExpressionHast
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
/**
|
|
4404
|
+
* MDX ESM (import/export) node.
|
|
4405
|
+
*/
|
|
4406
|
+
interface MdxjsEsm$1 extends Literal$1 {
|
|
4407
|
+
/**
|
|
4408
|
+
* Node type.
|
|
4409
|
+
*/
|
|
4410
|
+
type: 'mdxjsEsm'
|
|
4411
|
+
|
|
4412
|
+
/**
|
|
4413
|
+
* Data associated with mdast MDX.js ESM.
|
|
4414
|
+
*/
|
|
4415
|
+
data?: MdxjsEsmData$1 | undefined
|
|
4416
|
+
}
|
|
4417
|
+
|
|
4418
|
+
/**
|
|
4419
|
+
* Info associated with mdast MDX.js ESM nodes by the ecosystem.
|
|
4420
|
+
*/
|
|
4421
|
+
interface MdxjsEsmData$1 extends Data$6 {
|
|
4422
|
+
/**
|
|
4423
|
+
* Program node from estree.
|
|
4424
|
+
*/
|
|
4425
|
+
estree?: Program | null | undefined
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4428
|
+
/**
|
|
4429
|
+
* MDX ESM (import/export) node (for hast).
|
|
4430
|
+
*/
|
|
4431
|
+
interface MdxjsEsmHast$1 extends Literal {
|
|
4432
|
+
/**
|
|
4433
|
+
* Node type.
|
|
4434
|
+
*/
|
|
4435
|
+
type: 'mdxjsEsm'
|
|
4436
|
+
|
|
4437
|
+
/**
|
|
4438
|
+
* Data associated with hast MDX.js ESM.
|
|
4439
|
+
*/
|
|
4440
|
+
data?: MdxjsEsmHastData$1 | undefined
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
/**
|
|
4444
|
+
* Info associated with hast MDX.js ESM nodes by the ecosystem.
|
|
4445
|
+
*/
|
|
4446
|
+
interface MdxjsEsmHastData$1 extends Data$5 {
|
|
4447
|
+
/**
|
|
4448
|
+
* Program node from estree.
|
|
4449
|
+
*/
|
|
4450
|
+
estree?: Program | null | undefined
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
// Add nodes to mdast content.
|
|
4454
|
+
declare module 'mdast' {
|
|
4455
|
+
interface FrontmatterContentMap {
|
|
4456
|
+
/**
|
|
4457
|
+
* MDX ESM.
|
|
4458
|
+
*/
|
|
4459
|
+
mdxjsEsm: MdxjsEsm$1
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4462
|
+
interface RootContentMap {
|
|
4463
|
+
/**
|
|
4464
|
+
* MDX ESM.
|
|
4465
|
+
*/
|
|
4466
|
+
mdxjsEsm: MdxjsEsm$1
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
|
|
4470
|
+
// Add nodes to hast content.
|
|
4471
|
+
declare module 'hast' {
|
|
4472
|
+
interface RootContentMap {
|
|
4473
|
+
/**
|
|
4474
|
+
* MDX ESM.
|
|
4475
|
+
*/
|
|
4476
|
+
mdxjsEsm: MdxjsEsmHast$1
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4480
|
+
/**
|
|
4481
|
+
* MDX ESM (import/export) node.
|
|
4482
|
+
*/
|
|
4483
|
+
interface MdxjsEsm extends Literal$1 {
|
|
4484
|
+
/**
|
|
4485
|
+
* Node type.
|
|
4486
|
+
*/
|
|
4487
|
+
type: 'mdxjsEsm'
|
|
4488
|
+
|
|
4489
|
+
/**
|
|
4490
|
+
* Data associated with mdast MDX.js ESM.
|
|
4491
|
+
*/
|
|
4492
|
+
data?: MdxjsEsmData | undefined
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
/**
|
|
4496
|
+
* Info associated with mdast MDX.js ESM nodes by the ecosystem.
|
|
4497
|
+
*/
|
|
4498
|
+
interface MdxjsEsmData extends Data$6 {
|
|
4499
|
+
/**
|
|
4500
|
+
* Program node from estree.
|
|
4501
|
+
*/
|
|
4502
|
+
estree?: Program | null | undefined
|
|
4503
|
+
}
|
|
4504
|
+
|
|
4505
|
+
/**
|
|
4506
|
+
* MDX ESM (import/export) node (for hast).
|
|
4507
|
+
*/
|
|
4508
|
+
interface MdxjsEsmHast extends Literal {
|
|
4509
|
+
/**
|
|
4510
|
+
* Node type.
|
|
4511
|
+
*/
|
|
4512
|
+
type: 'mdxjsEsm'
|
|
4513
|
+
|
|
4514
|
+
/**
|
|
4515
|
+
* Data associated with hast MDX.js ESM.
|
|
4516
|
+
*/
|
|
4517
|
+
data?: MdxjsEsmHastData | undefined
|
|
4518
|
+
}
|
|
4519
|
+
|
|
4520
|
+
/**
|
|
4521
|
+
* Info associated with hast MDX.js ESM nodes by the ecosystem.
|
|
4522
|
+
*/
|
|
4523
|
+
interface MdxjsEsmHastData extends Data$5 {
|
|
4524
|
+
/**
|
|
4525
|
+
* Program node from estree.
|
|
4526
|
+
*/
|
|
4527
|
+
estree?: Program | null | undefined
|
|
4528
|
+
}
|
|
4529
|
+
|
|
4530
|
+
// Add nodes to mdast content.
|
|
4531
|
+
declare module 'mdast' {
|
|
4532
|
+
interface FrontmatterContentMap {
|
|
4533
|
+
/**
|
|
4534
|
+
* MDX ESM.
|
|
4535
|
+
*/
|
|
4536
|
+
mdxjsEsm: MdxjsEsm
|
|
4537
|
+
}
|
|
4538
|
+
|
|
4539
|
+
interface RootContentMap {
|
|
4540
|
+
/**
|
|
4541
|
+
* MDX ESM.
|
|
4542
|
+
*/
|
|
4543
|
+
mdxjsEsm: MdxjsEsm
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4547
|
+
// Add nodes to hast content.
|
|
4548
|
+
declare module 'hast' {
|
|
4549
|
+
interface RootContentMap {
|
|
4550
|
+
/**
|
|
4551
|
+
* MDX ESM.
|
|
4552
|
+
*/
|
|
4553
|
+
mdxjsEsm: MdxjsEsmHast
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
|
|
4557
|
+
type ElementAttributeNameCase$1 = ElementAttributeNameCase$2;
|
|
4558
|
+
type StylePropertyNameCase$1 = StylePropertyNameCase$2;
|
|
4559
|
+
|
|
4560
|
+
type ElementAttributeNameCase = ElementAttributeNameCase$1;
|
|
4561
|
+
type StylePropertyNameCase = StylePropertyNameCase$1;
|
|
4562
|
+
type RemarkRehypeOptions = Options;
|
|
4563
|
+
type SourceMapGenerator = typeof SourceMapGenerator$1;
|
|
4564
|
+
/**
|
|
4565
|
+
* Configuration for `createProcessor`.
|
|
4566
|
+
*/
|
|
4567
|
+
type ProcessorOptions$1 = {
|
|
4568
|
+
/**
|
|
4569
|
+
* Add a source map (object form) as the `map` field on the resulting file
|
|
4570
|
+
* (optional).
|
|
4571
|
+
*/
|
|
4572
|
+
SourceMapGenerator?: SourceMapGenerator | null | undefined;
|
|
4573
|
+
/**
|
|
4574
|
+
* Use this URL as `import.meta.url` and resolve `import` and `export … from`
|
|
4575
|
+
* relative to it (optional, example: `import.meta.url`).
|
|
4576
|
+
*/
|
|
4577
|
+
baseUrl?: URL | string | null | undefined;
|
|
4578
|
+
/**
|
|
4579
|
+
* Whether to add extra info to error messages in generated code and use the
|
|
4580
|
+
* development automatic JSX runtime (`Fragment` and `jsxDEV` from
|
|
4581
|
+
* `/jsx-dev-runtime`) (default: `false`);
|
|
4582
|
+
* when using the webpack loader (`@mdx-js/loader`) or the Rollup integration
|
|
4583
|
+
* (`@mdx-js/rollup`) through Vite, this is automatically inferred from how
|
|
4584
|
+
* you configure those tools.
|
|
4585
|
+
*/
|
|
4586
|
+
development?: boolean | null | undefined;
|
|
4587
|
+
/**
|
|
4588
|
+
* Casing to use for attribute names (default: `'react'`);
|
|
4589
|
+
* HTML casing is for example `class`, `stroke-linecap`, `xml:lang`;
|
|
4590
|
+
* React casing is for example `className`, `strokeLinecap`, `xmlLang`;
|
|
4591
|
+
* for JSX components written in MDX, the author has to be aware of which
|
|
4592
|
+
* framework they use and write code accordingly;
|
|
4593
|
+
* for AST nodes generated by this project, this option configures it
|
|
4594
|
+
*/
|
|
4595
|
+
elementAttributeNameCase?: ElementAttributeNameCase | null | undefined;
|
|
4596
|
+
/**
|
|
4597
|
+
* format of the file (default: `'mdx'`);
|
|
4598
|
+
* `'md'` means treat as markdown and `'mdx'` means treat as MDX.
|
|
4599
|
+
*/
|
|
4600
|
+
format?: 'md' | 'mdx' | null | undefined;
|
|
4601
|
+
/**
|
|
4602
|
+
* Whether to keep JSX (default: `false`);
|
|
4603
|
+
* the default is to compile JSX away so that the resulting file is
|
|
4604
|
+
* immediately runnable.
|
|
4605
|
+
*/
|
|
4606
|
+
jsx?: boolean | null | undefined;
|
|
4607
|
+
/**
|
|
4608
|
+
* Place to import automatic JSX runtimes from (default: `'react'`);
|
|
4609
|
+
* when in the `automatic` runtime, this is used to define an import for
|
|
4610
|
+
* `Fragment`, `jsx`, `jsxDEV`, and `jsxs`.
|
|
4611
|
+
*/
|
|
4612
|
+
jsxImportSource?: string | null | undefined;
|
|
4613
|
+
/**
|
|
4614
|
+
* JSX runtime to use (default: `'automatic'`);
|
|
4615
|
+
* the automatic runtime compiles to `import _jsx from
|
|
4616
|
+
* '$importSource/jsx-runtime'\n_jsx('p')`;
|
|
4617
|
+
* the classic runtime compiles to calls such as `h('p')`.
|
|
4618
|
+
*
|
|
4619
|
+
* > 👉 **Note**: support for the classic runtime is deprecated and will
|
|
4620
|
+
* > likely be removed in the next major version.
|
|
4621
|
+
*/
|
|
4622
|
+
jsxRuntime?: 'automatic' | 'classic' | null | undefined;
|
|
4623
|
+
/**
|
|
4624
|
+
* List of markdown extensions, with dot (default: `['.md', '.markdown', …]`);
|
|
4625
|
+
* affects integrations.
|
|
4626
|
+
*/
|
|
4627
|
+
mdExtensions?: ReadonlyArray<string> | null | undefined;
|
|
4628
|
+
/**
|
|
4629
|
+
* List of MDX extensions, with dot (default: `['.mdx']`);
|
|
4630
|
+
* affects integrations.
|
|
4631
|
+
*/
|
|
4632
|
+
mdxExtensions?: ReadonlyArray<string> | null | undefined;
|
|
4633
|
+
/**
|
|
4634
|
+
* Output format to generate (default: `'program'`);
|
|
4635
|
+
* in most cases `'program'` should be used, it results in a whole program;
|
|
4636
|
+
* internally `evaluate` uses `'function-body'` to compile to
|
|
4637
|
+
* code that can be passed to `run`;
|
|
4638
|
+
* in some cases, you might want what `evaluate` does in separate steps, such
|
|
4639
|
+
* as when compiling on the server and running on the client.
|
|
4640
|
+
*/
|
|
4641
|
+
outputFormat?: 'function-body' | 'program' | null | undefined;
|
|
4642
|
+
/**
|
|
4643
|
+
* Pragma for JSX, used in the classic runtime as an identifier for function
|
|
4644
|
+
* calls: `<x />` to `React.createElement('x')` (default:
|
|
4645
|
+
* `'React.createElement'`);
|
|
4646
|
+
* when changing this, you should also define `pragmaFrag` and
|
|
4647
|
+
* `pragmaImportSource` too.
|
|
4648
|
+
*
|
|
4649
|
+
* > 👉 **Note**: support for the classic runtime is deprecated and will
|
|
4650
|
+
* > likely be removed in the next major version.
|
|
4651
|
+
*/
|
|
4652
|
+
pragma?: string | null | undefined;
|
|
4653
|
+
/**
|
|
4654
|
+
* Pragma for fragment symbol, used in the classic runtime as an identifier
|
|
4655
|
+
* for unnamed calls: `<>` to `React.createElement(React.Fragment)` (default:
|
|
4656
|
+
* `'React.Fragment'`);
|
|
4657
|
+
* when changing this, you should also define `pragma` and
|
|
4658
|
+
* `pragmaImportSource` too.
|
|
4659
|
+
*
|
|
4660
|
+
* > 👉 **Note**: support for the classic runtime is deprecated and will
|
|
4661
|
+
* > likely be removed in the next major version.
|
|
4662
|
+
*/
|
|
4663
|
+
pragmaFrag?: string | null | undefined;
|
|
4664
|
+
/**
|
|
4665
|
+
* Where to import the identifier of `pragma` from, used in the classic
|
|
4666
|
+
* runtime (default: `'react'`);
|
|
4667
|
+
* to illustrate, when `pragma` is `'a.b'` and `pragmaImportSource` is `'c'`
|
|
4668
|
+
* the following will be generated: `import a from 'c'` and things such as
|
|
4669
|
+
* `a.b('h1', {})`.
|
|
4670
|
+
* when changing this, you should also define `pragma` and `pragmaFrag` too.
|
|
4671
|
+
*
|
|
4672
|
+
* > 👉 **Note**: support for the classic runtime is deprecated and will
|
|
4673
|
+
* > likely be removed in the next major version.
|
|
4674
|
+
*/
|
|
4675
|
+
pragmaImportSource?: string | null | undefined;
|
|
4676
|
+
/**
|
|
4677
|
+
* Place to import a provider from (optional, example: `'@mdx-js/react'`);
|
|
4678
|
+
* normally it’s used for runtimes that support context (React, Preact), but
|
|
4679
|
+
* it can be used to inject components into the compiled code;
|
|
4680
|
+
* the module must export and identifier `useMDXComponents` which is called
|
|
4681
|
+
* without arguments to get an object of components (`MDXComponents` from
|
|
4682
|
+
* `mdx/types.js`).
|
|
4683
|
+
*/
|
|
4684
|
+
providerImportSource?: string | null | undefined;
|
|
4685
|
+
/**
|
|
4686
|
+
* List of recma plugins (optional);
|
|
4687
|
+
* this is a new ecosystem, currently in beta, to transform esast trees
|
|
4688
|
+
* (JavaScript)
|
|
4689
|
+
*/
|
|
4690
|
+
recmaPlugins?: PluggableList | null | undefined;
|
|
4691
|
+
/**
|
|
4692
|
+
* List of remark plugins (optional).
|
|
4693
|
+
*/
|
|
4694
|
+
remarkPlugins?: PluggableList | null | undefined;
|
|
4695
|
+
/**
|
|
4696
|
+
* List of rehype plugins (optional).
|
|
4697
|
+
*/
|
|
4698
|
+
rehypePlugins?: PluggableList | null | undefined;
|
|
4699
|
+
/**
|
|
4700
|
+
* Options to pass through to `remark-rehype` (optional);
|
|
4701
|
+
* the option `allowDangerousHtml` will always be set to `true` and the MDX
|
|
4702
|
+
* nodes (see `nodeTypes`) are passed through;
|
|
4703
|
+
* In particular, you might want to pass configuration for footnotes if your
|
|
4704
|
+
* content is not in English.
|
|
4705
|
+
*/
|
|
4706
|
+
remarkRehypeOptions?: Readonly<RemarkRehypeOptions> | null | undefined;
|
|
4707
|
+
/**
|
|
4708
|
+
* Casing to use for property names in `style` objects (default: `'dom'`);
|
|
4709
|
+
* CSS casing is for example `background-color` and `-webkit-line-clamp`;
|
|
4710
|
+
* DOM casing is for example `backgroundColor` and `WebkitLineClamp`;
|
|
4711
|
+
* for JSX components written in MDX, the author has to be aware of which
|
|
4712
|
+
* framework they use and write code accordingly;
|
|
4713
|
+
* for AST nodes generated by this project, this option configures it
|
|
4714
|
+
*/
|
|
4715
|
+
stylePropertyNameCase?: StylePropertyNameCase | null | undefined;
|
|
4716
|
+
/**
|
|
4717
|
+
* Turn obsolete `align` props on `td` and `th` into CSS `style` props
|
|
4718
|
+
* (default: `true`).
|
|
4719
|
+
*/
|
|
4720
|
+
tableCellAlignToStyle?: boolean | null | undefined;
|
|
4721
|
+
};
|
|
4722
|
+
|
|
4723
|
+
/**
|
|
4724
|
+
* Compile MDX to JS.
|
|
4725
|
+
*
|
|
4726
|
+
* @param {Readonly<Compatible>} vfileCompatible
|
|
4727
|
+
* MDX document to parse.
|
|
4728
|
+
* @param {Readonly<CompileOptions> | null | undefined} [compileOptions]
|
|
4729
|
+
* Compile configuration (optional).
|
|
4730
|
+
* @return {Promise<VFile>}
|
|
4731
|
+
* Promise to compiled file.
|
|
4732
|
+
*/
|
|
4733
|
+
declare function compile(vfileCompatible: Readonly<Compatible>, compileOptions?: Readonly<CompileOptions$1> | null | undefined): Promise<VFile>;
|
|
4734
|
+
type VFile = VFile$1;
|
|
4735
|
+
type Compatible = Compatible$2;
|
|
4736
|
+
type ProcessorOptions = ProcessorOptions$1;
|
|
4737
|
+
/**
|
|
4738
|
+
* Core configuration.
|
|
4739
|
+
*/
|
|
4740
|
+
type CoreProcessorOptions = Omit<ProcessorOptions, 'format'>;
|
|
4741
|
+
/**
|
|
4742
|
+
* Extra configuration.
|
|
4743
|
+
*/
|
|
4744
|
+
type ExtraOptions = {
|
|
4745
|
+
/**
|
|
4746
|
+
* Format of `file` (default: `'detect'`).
|
|
4747
|
+
*/
|
|
4748
|
+
format?: 'detect' | 'md' | 'mdx' | null | undefined;
|
|
4749
|
+
};
|
|
4750
|
+
/**
|
|
4751
|
+
* Configuration for `compile`.
|
|
4752
|
+
*
|
|
4753
|
+
* `CompileOptions` is the same as `ProcessorOptions` with the exception that
|
|
4754
|
+
* the `format` option supports a `'detect'` value, which is the default.
|
|
4755
|
+
* The `'detect'` format means to use `'md'` for files with an extension in
|
|
4756
|
+
* `mdExtensions` and `'mdx'` otherwise.
|
|
4757
|
+
*/
|
|
4758
|
+
type CompileOptions$1 = CoreProcessorOptions & ExtraOptions;
|
|
4759
|
+
|
|
4760
|
+
type MdxCompileOptions = Parameters<typeof compile>[1];
|
|
4761
|
+
type BabelOptions = Parameters<typeof transformAsync>[1];
|
|
4762
|
+
interface CompileOptions {
|
|
4763
|
+
mdxCompileOptions?: MdxCompileOptions;
|
|
4764
|
+
}
|
|
4765
|
+
type LoaderOptions = {
|
|
4766
|
+
filepath?: string;
|
|
4767
|
+
[key: string]: any;
|
|
4768
|
+
} & any;
|
|
4769
|
+
interface LoaderContext {
|
|
4770
|
+
async: () => (err: Error | null, result?: string) => void;
|
|
4771
|
+
getOptions: () => LoaderOptions;
|
|
4772
|
+
resourcePath: string;
|
|
4773
|
+
}
|
|
4774
|
+
declare function loader(this: LoaderContext, content: string): Promise<void>;
|
|
4775
|
+
|
|
4776
|
+
export { BabelOptions, CompileOptions, MdxCompileOptions, loader as default };
|