@flex-development/docmark-util-types 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +28 -0
- package/README.md +109 -0
- package/dist/index.d.mts +1957 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1957 @@
|
|
|
1
|
+
import type { Construct as Construct$1, Extension as Extension$1, Constructs as Constructs$1, State as State$1, Code as Code$1, CommentKindMap as CommentKindMap$1, AnyConstruct as AnyConstruct$1, ConstructPack as ConstructPack$1, ConstructPosition as ConstructPosition$1, Exiter as Exiter$1, Previous as Previous$1, Resolver as Resolver$1, Tokenizer as Tokenizer$1, ConstructRecord as ConstructRecord$1, CommentKind as CommentKind$1, Point as Point$1, TokenizeContext as TokenizeContext$1, Place as Place$1, Attempt as Attempt$1, Check, Consume as Consume$1, Enter as Enter$1, Exit as Exit$1, Interrupt, EncodingMap as EncodingMap$1, TokenType as TokenType$1, TokenFields as TokenFields$1, Token as Token$1, EventType as EventType$1, Effects as Effects$1, AttentionMarkers as AttentionMarkers$1, Disable as Disable$1, InsideSpan as InsideSpan$1, Value as Value$1, Initializer as Initializer$1, ContentType as ContentType$1, InitialConstruct as InitialConstruct$1, Create as Create$1, FullNormalizedExtension as FullNormalizedExtension$1, Lazy as Lazy$1, AnyExtension as AnyExtension$1, FinalizeContext as FinalizeContext$1, InitialConstructs as InitialConstructs$1, Column as Column$1, Line as Line$1, Offset as Offset$1, FileLike as FileLike$1, Encoding as Encoding$1, Chunk as Chunk$1, Event as Event$1, Position as Position$1, SerializeOptions as SerializeOptions$1, TokenTypeMap as TokenTypeMap$1, ContainerState as ContainerState$1, DefineSkip as DefineSkip$1, Now as Now$1, ParseContext as ParseContext$1, SliceSerialize as SliceSerialize$1, SliceStream as SliceStream$1, Write as Write$1 } from '@flex-development/docmark-util-types';
|
|
2
|
+
import type * as micromark from 'micromark-util-types';
|
|
3
|
+
import type { Debugger } from 'debug';
|
|
4
|
+
import type { Numeric } from '@flex-development/mark/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file AnyConstruct
|
|
8
|
+
* @module docmark-util-types/AnyConstruct
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A `docmark` or `micromark` construct.
|
|
13
|
+
*
|
|
14
|
+
* @see {@linkcode Construct}
|
|
15
|
+
* @see {@linkcode micromark.Construct}
|
|
16
|
+
*/
|
|
17
|
+
type AnyConstruct = Construct$1 | micromark.Construct;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @file AnyExtension
|
|
21
|
+
* @module docmark-util-types/AnyExtension
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A `docmark` or `micromark` syntax extension.
|
|
26
|
+
*
|
|
27
|
+
* @see {@linkcode Extension}
|
|
28
|
+
* @see {@linkcode micromark.Extension}
|
|
29
|
+
*/
|
|
30
|
+
type AnyExtension = Extension$1 | micromark.Extension;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @file Attempt
|
|
34
|
+
* @module docmark-util-types/Attempt
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Attempt deals with several constructs,
|
|
39
|
+
* and tries to parse according to those constructs.
|
|
40
|
+
*
|
|
41
|
+
* If a construct results in `ok`, the tokens that were produced are used and
|
|
42
|
+
* the `ok` state is switched to.
|
|
43
|
+
*
|
|
44
|
+
* If the result is `nok`, the attempt failed and the state machine reverts back
|
|
45
|
+
* to its original state.
|
|
46
|
+
*
|
|
47
|
+
* @see {@linkcode Constructs}
|
|
48
|
+
* @see {@linkcode State}
|
|
49
|
+
*
|
|
50
|
+
* @this {void}
|
|
51
|
+
*
|
|
52
|
+
* @param {Constructs} construct
|
|
53
|
+
* The construct, construct list, or construct record to try
|
|
54
|
+
* @param {State} ok
|
|
55
|
+
* The successful tokenization state
|
|
56
|
+
* @param {State | undefined} [nok]
|
|
57
|
+
* The failed tokenization state
|
|
58
|
+
* @return {State}
|
|
59
|
+
* The next state
|
|
60
|
+
*/
|
|
61
|
+
type Attempt = (this: void, construct: Constructs$1, ok: State$1, nok?: State$1 | undefined) => State$1;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @file AttentionMarkers
|
|
65
|
+
* @module docmark-util-types/AttentionMarkers
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Attention marker settings.
|
|
70
|
+
*/
|
|
71
|
+
interface AttentionMarkers {
|
|
72
|
+
/**
|
|
73
|
+
* The list of character codes representing attention markers.
|
|
74
|
+
*
|
|
75
|
+
* @see {@linkcode Code}
|
|
76
|
+
*/
|
|
77
|
+
null?: Code$1[] | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @file Chunk
|
|
82
|
+
* @module docmark-util-types/Chunk
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A character code or a slice of a buffer in the form of a string.
|
|
87
|
+
*
|
|
88
|
+
* Chunks are used because strings are more efficient storage that character
|
|
89
|
+
* codes, but limited in what they can represent.
|
|
90
|
+
*
|
|
91
|
+
* @see {@linkcode Code}
|
|
92
|
+
*/
|
|
93
|
+
type Chunk = Code$1 | string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @file Code
|
|
97
|
+
* @module docmark-util-types/Code
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* A character code.
|
|
101
|
+
*
|
|
102
|
+
* This often the same as what [`String#codePointAt`][codepointat] yields,
|
|
103
|
+
* but docmark adds meaning to other values as well.
|
|
104
|
+
*
|
|
105
|
+
* The code `null` represents the end of the input stream (`eos`).
|
|
106
|
+
* Negative integers are used instead of certain sequences of characters (such
|
|
107
|
+
* as line endings and tabs).
|
|
108
|
+
*
|
|
109
|
+
* [codepointat]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt
|
|
110
|
+
*/
|
|
111
|
+
type Code = number | null;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @file Column
|
|
115
|
+
* @module docmark-util-types/Column
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* A column in the source content (`1`-indexed integer).
|
|
119
|
+
*/
|
|
120
|
+
type Column = number;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @file CommentKindMap
|
|
124
|
+
* @module docmark-util-types/CommentKindMap
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* Registry of comment kinds.
|
|
128
|
+
*
|
|
129
|
+
* Libraries and other tools can augment this interface to register custom
|
|
130
|
+
* comment kinds.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
134
|
+
* interface CommentKindMap {
|
|
135
|
+
* hashbang: 'hashbang'
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
*/
|
|
139
|
+
interface CommentKindMap {
|
|
140
|
+
block: 'block';
|
|
141
|
+
docblock: 'docblock';
|
|
142
|
+
line: 'line';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @file CommentKind
|
|
147
|
+
* @module docmark-util-types/CommentKind
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Union of registered comment kinds.
|
|
152
|
+
*
|
|
153
|
+
* To register custom comment kinds, augment {@linkcode CommentKindMap}.
|
|
154
|
+
* They will be added to this union automatically.
|
|
155
|
+
*/
|
|
156
|
+
type CommentKind = CommentKindMap$1[keyof CommentKindMap$1];
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @file ConstructPack
|
|
160
|
+
* @module docmark-util-types/ConstructPack
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A construct or a list of constructs.
|
|
165
|
+
*
|
|
166
|
+
* @see {@linkcode AnyConstruct}
|
|
167
|
+
*/
|
|
168
|
+
type ConstructPack = AnyConstruct$1 | AnyConstruct$1[];
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @file ConstructPosition
|
|
172
|
+
* @module docmark-util-types/ConstructPosition
|
|
173
|
+
*/
|
|
174
|
+
/**
|
|
175
|
+
* Union of construct positions.
|
|
176
|
+
*
|
|
177
|
+
* Positions determine whether a construct,
|
|
178
|
+
* when in a {@linkcode ConstructRecord}, takes precedence over existing
|
|
179
|
+
* constructs for the same character code when merged.
|
|
180
|
+
*/
|
|
181
|
+
type ConstructPosition = 'after' | 'before';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @file ConstructRecord
|
|
185
|
+
* @module docmark-util-types/ConstructRecord
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Several constructs, mapped from their initial codes.
|
|
190
|
+
*/
|
|
191
|
+
interface ConstructRecord {
|
|
192
|
+
/**
|
|
193
|
+
* Try tokenizing constructs that start with the specified character code.
|
|
194
|
+
*
|
|
195
|
+
* @see {@linkcode ConstructPack}
|
|
196
|
+
* @see {@linkcode Numeric}
|
|
197
|
+
*/
|
|
198
|
+
[code: Numeric | number]: ConstructPack$1 | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Try tokenizing constructs that start with any character code.
|
|
201
|
+
*
|
|
202
|
+
* @see {@linkcode ConstructPack}
|
|
203
|
+
*/
|
|
204
|
+
null?: ConstructPack$1 | undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @file Construct
|
|
209
|
+
* @module docmark-util-types/Construct
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Object describing how to tokenize a syntax construct.
|
|
214
|
+
*/
|
|
215
|
+
interface Construct {
|
|
216
|
+
/**
|
|
217
|
+
* Whether the construct, when in a {@linkcode ConstructRecord},
|
|
218
|
+
* takes precedence over existing constructs for the same character code
|
|
219
|
+
* when merged.
|
|
220
|
+
*
|
|
221
|
+
* @see {@linkcode ConstructPosition}
|
|
222
|
+
*/
|
|
223
|
+
add?: ConstructPosition$1 | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Whether the construct is concrete.
|
|
226
|
+
*
|
|
227
|
+
* Concrete constructs cannot be interrupted by other constructs.
|
|
228
|
+
*
|
|
229
|
+
* For example, when parsing a markdown document (containers, such as block
|
|
230
|
+
* quotes and lists) and this construct is parsing fenced code:
|
|
231
|
+
*
|
|
232
|
+
* ````markdown
|
|
233
|
+
* > ```js
|
|
234
|
+
* > - list?
|
|
235
|
+
* ````
|
|
236
|
+
*
|
|
237
|
+
* …then `- list?` cannot form if this fenced code construct is concrete.
|
|
238
|
+
*
|
|
239
|
+
* An example of a construct that is not concrete is a GFM table:
|
|
240
|
+
*
|
|
241
|
+
* ````markdown
|
|
242
|
+
* | a |
|
|
243
|
+
* | - |
|
|
244
|
+
* > | b |
|
|
245
|
+
* ````
|
|
246
|
+
*
|
|
247
|
+
* ...`b` is not part of the table.
|
|
248
|
+
*/
|
|
249
|
+
concrete?: boolean | undefined;
|
|
250
|
+
/**
|
|
251
|
+
* For containers, a continuation construct.
|
|
252
|
+
*/
|
|
253
|
+
continuation?: Construct | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* For containers, a final exit hook.
|
|
256
|
+
*
|
|
257
|
+
* @see {@linkcode Exiter}
|
|
258
|
+
*/
|
|
259
|
+
exit?: Exiter$1 | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* The name of the construct, used to toggle constructs off.
|
|
262
|
+
*
|
|
263
|
+
* > 👉 **Note**: Named constructs must not be {@linkcode partial}.
|
|
264
|
+
*/
|
|
265
|
+
name?: string | undefined;
|
|
266
|
+
/**
|
|
267
|
+
* Whether the construct represents a partial construct.
|
|
268
|
+
*
|
|
269
|
+
* > 👉 **Note**: Partial constructs must not have a {@linkcode name}.
|
|
270
|
+
*/
|
|
271
|
+
partial?: boolean | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Check if the previous character code can precede this construct.
|
|
274
|
+
*
|
|
275
|
+
* @see {@linkcode Previous}
|
|
276
|
+
*/
|
|
277
|
+
previous?: Previous$1 | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* Resolve the events parsed by {@linkcode tokenize}.
|
|
280
|
+
*
|
|
281
|
+
* @see {@linkcode Resolver}
|
|
282
|
+
*/
|
|
283
|
+
resolve?: Resolver$1 | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* Resolve all events when the content is complete, from the start to the end.
|
|
286
|
+
*
|
|
287
|
+
* > 👉 **Note**: Only called if {@linkcode tokenize} is successful at least
|
|
288
|
+
* > once in the content.
|
|
289
|
+
*
|
|
290
|
+
* @see {@linkcode Resolver}
|
|
291
|
+
*/
|
|
292
|
+
resolveAll?: Resolver$1 | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Resolve the events parsed from the start of the content (which may include
|
|
295
|
+
* other constructs) to the last one parsed by {@linkcode tokenize}.
|
|
296
|
+
*
|
|
297
|
+
* @see {@linkcode Resolver}
|
|
298
|
+
*/
|
|
299
|
+
resolveTo?: Resolver$1 | undefined;
|
|
300
|
+
/**
|
|
301
|
+
* Set up a state machine to handle character codes streaming in.
|
|
302
|
+
*
|
|
303
|
+
* @see {@linkcode Tokenizer}
|
|
304
|
+
*/
|
|
305
|
+
tokenize: Tokenizer$1;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @file Constructs
|
|
310
|
+
* @module docmark-util-types/Constructs
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A single construct, a list of constructs, or a record of constructs.
|
|
315
|
+
*
|
|
316
|
+
* @see {@linkcode ConstructPack}
|
|
317
|
+
* @see {@linkcode ConstructRecord}
|
|
318
|
+
*/
|
|
319
|
+
type Constructs = ConstructPack$1 | ConstructRecord$1;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* @file Consume
|
|
323
|
+
* @module docmark-util-types/Consume
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Deal with a character `code` and move onto the next.
|
|
328
|
+
*
|
|
329
|
+
* @see {@linkcode Code}
|
|
330
|
+
*
|
|
331
|
+
* @this {void}
|
|
332
|
+
*
|
|
333
|
+
* @param {Code} code
|
|
334
|
+
* The character code to consume
|
|
335
|
+
* @return {undefined}
|
|
336
|
+
*/
|
|
337
|
+
type Consume = (this: void, code: Code$1) => undefined;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @file ContainerState
|
|
341
|
+
* @module docmark-util-types/ContainerState
|
|
342
|
+
*/
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* State shared between container calls.
|
|
346
|
+
*
|
|
347
|
+
* This interface can be augmented to register custom fields.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
351
|
+
* interface ContainerState {
|
|
352
|
+
* custom?: boolean | null | undefined
|
|
353
|
+
* }
|
|
354
|
+
* }
|
|
355
|
+
*
|
|
356
|
+
* @see {@linkcode micromark.ContainerState}
|
|
357
|
+
*
|
|
358
|
+
* @extends {micromark.ContainerState}
|
|
359
|
+
*/
|
|
360
|
+
interface ContainerState extends micromark.ContainerState {
|
|
361
|
+
/**
|
|
362
|
+
* The current comment kind.
|
|
363
|
+
*
|
|
364
|
+
* The comment kind is captured at the `source` level after a comment has just
|
|
365
|
+
* been entered.\
|
|
366
|
+
* The kind ({@linkcode TokenFields._kind}) is extracted from the first event
|
|
367
|
+
* produced by the current comment construct.
|
|
368
|
+
*
|
|
369
|
+
* @see {@linkcode CommentKind}
|
|
370
|
+
*/
|
|
371
|
+
comment?: CommentKind$1 | undefined;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* @file ContentType
|
|
376
|
+
* @module docmark-util-types/ContentType
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Union of content types.\
|
|
381
|
+
* Content types are used on tokens to define their subcontent type.
|
|
382
|
+
*
|
|
383
|
+
* The highest level of content is `source`, and represents a source document or
|
|
384
|
+
* source content fragment.
|
|
385
|
+
*
|
|
386
|
+
* The next level is `comment`, and represents the contents of a documentation
|
|
387
|
+
* comment after the opening delimiter and before the closing delimiter.\
|
|
388
|
+
* By default, comment content consists of an optional summary followed by zero
|
|
389
|
+
* or more block tags.
|
|
390
|
+
*
|
|
391
|
+
* @todo document markdown content levels
|
|
392
|
+
*
|
|
393
|
+
* @see {@linkcode micromark.ContentType}
|
|
394
|
+
*/
|
|
395
|
+
type ContentType = micromark.ContentType | 'comment' | 'source' | 'type';
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @file ContinuableConstruct
|
|
399
|
+
* @module docmark-util-types/ContinuableConstruct
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* A construct that can be continued.
|
|
404
|
+
*
|
|
405
|
+
* @see {@linkcode Construct}
|
|
406
|
+
*
|
|
407
|
+
* @extends {Construct}
|
|
408
|
+
*/
|
|
409
|
+
interface ContinuableConstruct extends Construct$1 {
|
|
410
|
+
/**
|
|
411
|
+
* The continuation construct.
|
|
412
|
+
*
|
|
413
|
+
* @see {@linkcode Construct}
|
|
414
|
+
*
|
|
415
|
+
* @override
|
|
416
|
+
*/
|
|
417
|
+
continuation: Construct$1;
|
|
418
|
+
/**
|
|
419
|
+
* For containers, a final exit hook.
|
|
420
|
+
*
|
|
421
|
+
* @see {@linkcode Exiter}
|
|
422
|
+
*
|
|
423
|
+
* @override
|
|
424
|
+
*/
|
|
425
|
+
exit: Exiter$1;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* @file Create
|
|
430
|
+
* @module docmark-util-types/Create
|
|
431
|
+
*/
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Create a tokenization context.
|
|
435
|
+
*
|
|
436
|
+
* @see {@linkcode Point}
|
|
437
|
+
* @see {@linkcode TokenizeContext}
|
|
438
|
+
*
|
|
439
|
+
* @this {void}
|
|
440
|
+
*
|
|
441
|
+
* @param {Point | undefined} [from]
|
|
442
|
+
* Where to start parsing from
|
|
443
|
+
* @return {TokenizeContext}
|
|
444
|
+
* The new tokenization context
|
|
445
|
+
*/
|
|
446
|
+
type Create = (this: void, from?: Point$1 | undefined) => TokenizeContext$1;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @file DefineSkip
|
|
450
|
+
* @module docmark-util-types/DefineSkip
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Define a skip.
|
|
455
|
+
*
|
|
456
|
+
* Where a line starts after a prefix can be defined here.
|
|
457
|
+
*
|
|
458
|
+
* When the tokenizer moves after consuming a line ending corresponding to
|
|
459
|
+
* the line number in the given point, the tokenizer shifts past the prefix
|
|
460
|
+
* based on the column in the shifted point.
|
|
461
|
+
*
|
|
462
|
+
* @see {@linkcode Place}
|
|
463
|
+
*
|
|
464
|
+
* @this {void}
|
|
465
|
+
*
|
|
466
|
+
* @param {Place} point
|
|
467
|
+
* The skip point
|
|
468
|
+
* @return {undefined}
|
|
469
|
+
*/
|
|
470
|
+
type DefineSkip = (this: void, point: Place$1) => undefined;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @file Disable
|
|
474
|
+
* @module docmark-util-types/Disable
|
|
475
|
+
*/
|
|
476
|
+
/**
|
|
477
|
+
* Disabled construct settings.
|
|
478
|
+
*/
|
|
479
|
+
interface Disable {
|
|
480
|
+
/**
|
|
481
|
+
* The list of disabled construct names.
|
|
482
|
+
*/
|
|
483
|
+
null?: string[] | undefined;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @file Effects
|
|
488
|
+
* @module docmark-util-types/Effects
|
|
489
|
+
*/
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Context object to transition the state machine.
|
|
493
|
+
*/
|
|
494
|
+
interface Effects {
|
|
495
|
+
/**
|
|
496
|
+
* Try to tokenize a construct.
|
|
497
|
+
*
|
|
498
|
+
* @see {@linkcode Attempt}
|
|
499
|
+
*/
|
|
500
|
+
attempt: Attempt$1;
|
|
501
|
+
/**
|
|
502
|
+
* Try to tokenize a construct, then revert.
|
|
503
|
+
*
|
|
504
|
+
* @see {@linkcode Check}
|
|
505
|
+
*/
|
|
506
|
+
check: Check;
|
|
507
|
+
/**
|
|
508
|
+
* Deal with a character code and move onto the next.
|
|
509
|
+
*
|
|
510
|
+
* @see {@linkcode Consume}
|
|
511
|
+
*/
|
|
512
|
+
consume: Consume$1;
|
|
513
|
+
/**
|
|
514
|
+
* Start a new token.
|
|
515
|
+
*
|
|
516
|
+
* @see {@linkcode Enter}
|
|
517
|
+
*/
|
|
518
|
+
enter: Enter$1;
|
|
519
|
+
/**
|
|
520
|
+
* Close an open token.
|
|
521
|
+
*
|
|
522
|
+
* @see {@linkcode Exit}
|
|
523
|
+
*/
|
|
524
|
+
exit: Exit$1;
|
|
525
|
+
/**
|
|
526
|
+
* Try to tokenize a construct, then revert.
|
|
527
|
+
*
|
|
528
|
+
* > 👉 **Note**: Sets `context.interrupt` to `true`.
|
|
529
|
+
*
|
|
530
|
+
* @see {@linkcode Interrupt}
|
|
531
|
+
*/
|
|
532
|
+
interrupt: Interrupt;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @file EncodingMap
|
|
537
|
+
* @module docmark-util-types/EncodingMap
|
|
538
|
+
*/
|
|
539
|
+
/**
|
|
540
|
+
* Registry of encodings supported by {@linkcode TextDecoder}.
|
|
541
|
+
*
|
|
542
|
+
* > 👉 **Note**: Arbitrary encodings can be supported depending on how an
|
|
543
|
+
* > engine is built, so any string *could* be valid.
|
|
544
|
+
*
|
|
545
|
+
* This interface can be augmented to register custom encodings.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
549
|
+
* interface EncodingMap {
|
|
550
|
+
* custom: 'custom'
|
|
551
|
+
* }
|
|
552
|
+
* }
|
|
553
|
+
*
|
|
554
|
+
* @see https://nodejs.org/api/util.html#whatwg-supported-encodings
|
|
555
|
+
*/
|
|
556
|
+
interface EncodingMap {
|
|
557
|
+
unicode: 'unicode-1-1-utf-8';
|
|
558
|
+
unknown: string & {};
|
|
559
|
+
utf16: 'utf16';
|
|
560
|
+
utf16be: 'utf-16be' | 'utf16be';
|
|
561
|
+
utf16le: 'utf-16le' | 'utf16le';
|
|
562
|
+
utf8: 'utf-8' | 'utf8';
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* @file Encoding
|
|
567
|
+
* @module docmark-util-types/Encoding
|
|
568
|
+
*/
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Union of encodings supported by {@linkcode TextDecoder}.
|
|
572
|
+
*
|
|
573
|
+
* > 👉 **Note**: Arbitrary encodings can be supported depending on how an
|
|
574
|
+
* > engine is built, so any string *could* be valid.
|
|
575
|
+
*
|
|
576
|
+
* To register custom encodings, augment {@linkcode EncodingMap}.
|
|
577
|
+
* They will be added to this union automatically.
|
|
578
|
+
*/
|
|
579
|
+
type Encoding = EncodingMap$1[keyof EncodingMap$1];
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @file Enter
|
|
583
|
+
* @module docmark-util-types/Enter
|
|
584
|
+
*/
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Start a new token.
|
|
588
|
+
*
|
|
589
|
+
* @see {@linkcode TokenFields}
|
|
590
|
+
* @see {@linkcode TokenType}
|
|
591
|
+
* @see {@linkcode Token}
|
|
592
|
+
*
|
|
593
|
+
* @this {void}
|
|
594
|
+
*
|
|
595
|
+
* @param {TokenType} type
|
|
596
|
+
* The token type
|
|
597
|
+
* @param {TokenFields | undefined} [fields]
|
|
598
|
+
* The token fields
|
|
599
|
+
* @return {Token}
|
|
600
|
+
* The open token
|
|
601
|
+
*/
|
|
602
|
+
type Enter = (this: void, type: TokenType$1, fields?: TokenFields$1 | undefined) => Token$1;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* @file Event
|
|
606
|
+
* @module docmark-util-types/Event
|
|
607
|
+
*/
|
|
608
|
+
/**
|
|
609
|
+
* Union of event types.
|
|
610
|
+
*/
|
|
611
|
+
type EventType = 'enter' | 'exit';
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* @file Event
|
|
615
|
+
* @module docmark-util-types/Event
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* The start or end of a token amongst other events.
|
|
620
|
+
*
|
|
621
|
+
* Tokens can "contain" other tokens, even though they are stored in a flat
|
|
622
|
+
* list, through `enter`ing before them, and `exit`ing after them.
|
|
623
|
+
*
|
|
624
|
+
* @see {@linkcode EventType}
|
|
625
|
+
* @see {@linkcode TokenType}
|
|
626
|
+
* @see {@linkcode TokenizeContext}
|
|
627
|
+
* @see {@linkcode Token}
|
|
628
|
+
*
|
|
629
|
+
* @template {TokenType} [T=TokenType]
|
|
630
|
+
* The token type
|
|
631
|
+
*/
|
|
632
|
+
type Event<T extends TokenType$1 = TokenType$1> = [
|
|
633
|
+
event: EventType$1,
|
|
634
|
+
token: Token$1<T>,
|
|
635
|
+
context: TokenizeContext$1
|
|
636
|
+
];
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @file Exit
|
|
640
|
+
* @module docmark-util-types/Exit
|
|
641
|
+
*/
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Close an open token.
|
|
645
|
+
*
|
|
646
|
+
* @see {@linkcode TokenType}
|
|
647
|
+
* @see {@linkcode Token}
|
|
648
|
+
*
|
|
649
|
+
* @this {void}
|
|
650
|
+
*
|
|
651
|
+
* @param {TokenType} type
|
|
652
|
+
* The token type
|
|
653
|
+
* @return {Token}
|
|
654
|
+
* The closed token
|
|
655
|
+
*/
|
|
656
|
+
type Exit = (this: void, type: TokenType$1) => Token$1;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* @file Exiter
|
|
660
|
+
* @module docmark-util-types/Exiter
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* The final hook to run when a container must be closed.
|
|
665
|
+
*
|
|
666
|
+
* > 👉 **Note**: Like a {@linkcode Tokenizer}, but without `ok` and `nok`, and
|
|
667
|
+
* > returns `undefined`.
|
|
668
|
+
*
|
|
669
|
+
* @see {@linkcode Effects}
|
|
670
|
+
* @see {@linkcode TokenizeContext}
|
|
671
|
+
*
|
|
672
|
+
* @this {TokenizeContext}
|
|
673
|
+
*
|
|
674
|
+
* @param {Effects} effects
|
|
675
|
+
* The context object used to transition the state machine
|
|
676
|
+
* @return {undefined}
|
|
677
|
+
*/
|
|
678
|
+
type Exiter = (this: TokenizeContext$1, effects: Effects$1) => undefined;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* @file Extension
|
|
682
|
+
* @module docmark-util-types/Extension
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* A syntax extension.
|
|
687
|
+
*
|
|
688
|
+
* Syntax extensions are objects whose fields are typically the names of hooks,
|
|
689
|
+
* referring to where constructs "hook" into. The fields at such objects are
|
|
690
|
+
* character codes, mapping to constructs as values.
|
|
691
|
+
*
|
|
692
|
+
* This interface can be augmented to register custom fields.
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
696
|
+
* interface Extension {
|
|
697
|
+
* custom?: { null?: Code[] | undefined } | undefined
|
|
698
|
+
* }
|
|
699
|
+
* }
|
|
700
|
+
*/
|
|
701
|
+
interface Extension {
|
|
702
|
+
/**
|
|
703
|
+
* The attention marker settings.
|
|
704
|
+
*
|
|
705
|
+
* @see {@linkcode AttentionMarkers}
|
|
706
|
+
*/
|
|
707
|
+
attentionMarkers?: AttentionMarkers$1 | undefined;
|
|
708
|
+
/**
|
|
709
|
+
* @todo `comment`
|
|
710
|
+
*
|
|
711
|
+
* @see {@linkcode ConstructRecord}
|
|
712
|
+
*/
|
|
713
|
+
comment?: ConstructRecord$1 | undefined;
|
|
714
|
+
/**
|
|
715
|
+
* @todo `content`
|
|
716
|
+
*
|
|
717
|
+
* @see {@linkcode ConstructRecord}
|
|
718
|
+
*/
|
|
719
|
+
content?: ConstructRecord$1 | undefined;
|
|
720
|
+
/**
|
|
721
|
+
* @todo `contentInitial`
|
|
722
|
+
*
|
|
723
|
+
* @see {@linkcode ConstructRecord}
|
|
724
|
+
*/
|
|
725
|
+
contentInitial?: ConstructRecord$1 | undefined;
|
|
726
|
+
/**
|
|
727
|
+
* The disabled construct settings.
|
|
728
|
+
*
|
|
729
|
+
* @see {@linkcode Disable}
|
|
730
|
+
*/
|
|
731
|
+
disable?: Disable$1 | undefined;
|
|
732
|
+
/**
|
|
733
|
+
* @todo `document`
|
|
734
|
+
*
|
|
735
|
+
* @see {@linkcode ConstructRecord}
|
|
736
|
+
*/
|
|
737
|
+
document?: ConstructRecord$1 | undefined;
|
|
738
|
+
/**
|
|
739
|
+
* @todo `flow`
|
|
740
|
+
*
|
|
741
|
+
* @see {@linkcode ConstructRecord}
|
|
742
|
+
*/
|
|
743
|
+
flow?: ConstructRecord$1 | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* @todo `flowInitial`
|
|
746
|
+
*
|
|
747
|
+
* @see {@linkcode ConstructRecord}
|
|
748
|
+
*/
|
|
749
|
+
flowInitial?: ConstructRecord$1 | undefined;
|
|
750
|
+
/**
|
|
751
|
+
* @todo `insideSpan`
|
|
752
|
+
*
|
|
753
|
+
* @see {@linkcode InsideSpan}
|
|
754
|
+
*/
|
|
755
|
+
insideSpan?: InsideSpan$1 | undefined;
|
|
756
|
+
/**
|
|
757
|
+
* @todo `source`
|
|
758
|
+
*
|
|
759
|
+
* @see {@linkcode ConstructRecord}
|
|
760
|
+
*/
|
|
761
|
+
source?: ConstructRecord$1 | undefined;
|
|
762
|
+
/**
|
|
763
|
+
* @todo `string`
|
|
764
|
+
*
|
|
765
|
+
* @see {@linkcode ConstructRecord}
|
|
766
|
+
*/
|
|
767
|
+
string?: ConstructRecord$1 | undefined;
|
|
768
|
+
/**
|
|
769
|
+
* @todo `text`
|
|
770
|
+
*
|
|
771
|
+
* @see {@linkcode ConstructRecord}
|
|
772
|
+
*/
|
|
773
|
+
text?: ConstructRecord$1 | undefined;
|
|
774
|
+
/**
|
|
775
|
+
* @todo `type`
|
|
776
|
+
*
|
|
777
|
+
* @see {@linkcode ConstructRecord}
|
|
778
|
+
*/
|
|
779
|
+
type?: ConstructRecord$1 | undefined;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* @file FileLike
|
|
784
|
+
* @module docmark-util-types/FileLike
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* A file-like structure.
|
|
789
|
+
*/
|
|
790
|
+
type FileLike = {
|
|
791
|
+
/**
|
|
792
|
+
* The contents of the file.
|
|
793
|
+
*
|
|
794
|
+
* @see {@linkcode Value}
|
|
795
|
+
*/
|
|
796
|
+
value: Value$1;
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @file FinalizeContext
|
|
801
|
+
* @module docmark-util-types/FinalizeContext
|
|
802
|
+
*/
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Finalize the tokenization context.
|
|
806
|
+
*
|
|
807
|
+
* @see {@linkcode TokenizeContext}
|
|
808
|
+
*
|
|
809
|
+
* @this {void}
|
|
810
|
+
*
|
|
811
|
+
* @param {TokenizeContext} context
|
|
812
|
+
* The current tokenization context
|
|
813
|
+
* @return {undefined}
|
|
814
|
+
*/
|
|
815
|
+
type FinalizeContext = (this: void, context: TokenizeContext$1) => undefined;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* @file FullNormalizedExtension
|
|
819
|
+
* @module docmark-util-types/FullNormalizedExtension
|
|
820
|
+
*/
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* A full, filtered, and normalized extension, where all properties are required
|
|
824
|
+
* and defined.
|
|
825
|
+
*
|
|
826
|
+
* @see {@linkcode Extension}
|
|
827
|
+
*/
|
|
828
|
+
type FullNormalizedExtension = {
|
|
829
|
+
[K in keyof Extension$1]-?: Exclude<Extension$1[K], null | undefined>;
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* @file InitialConstruct
|
|
834
|
+
* @module docmark-util-types/InitialConstruct
|
|
835
|
+
*/
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* An initial construct.
|
|
839
|
+
*
|
|
840
|
+
* > 👉 **Note**: Like a construct,
|
|
841
|
+
* > but `tokenize` does not accept `ok` or `nok`.
|
|
842
|
+
*
|
|
843
|
+
* @see {@linkcode Construct}
|
|
844
|
+
*
|
|
845
|
+
* @extends {Construct}
|
|
846
|
+
*/
|
|
847
|
+
interface InitialConstruct extends Construct$1 {
|
|
848
|
+
/**
|
|
849
|
+
* Set up a state machine to handle character codes streaming in.
|
|
850
|
+
*
|
|
851
|
+
* @see {@linkcode Initializer}
|
|
852
|
+
*
|
|
853
|
+
* @override
|
|
854
|
+
*/
|
|
855
|
+
tokenize: Initializer$1;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* @file InitialConstructs
|
|
860
|
+
* @module docmark-util-types/InitialConstructs
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Record where each key is {@linkcode ContentType},
|
|
865
|
+
* and each value is an {@linkcode InitialConstruct}.
|
|
866
|
+
*/
|
|
867
|
+
type InitialConstructs = {
|
|
868
|
+
[K in ContentType$1]: InitialConstruct$1;
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* @file Initializer
|
|
873
|
+
* @module docmark-util-types/Initializer
|
|
874
|
+
*/
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Set up an initial state machine.
|
|
878
|
+
*
|
|
879
|
+
* > 👉 **Note**: Like a {@linkcode Tokenizer}, but without `ok` and `nok`.
|
|
880
|
+
*
|
|
881
|
+
* @see {@linkcode Effects}
|
|
882
|
+
* @see {@linkcode State}
|
|
883
|
+
* @see {@linkcode TokenizeContext}
|
|
884
|
+
*
|
|
885
|
+
* @this {TokenizeContext}
|
|
886
|
+
*
|
|
887
|
+
* @param {Effects} effects
|
|
888
|
+
* The context object used to transition the state machine
|
|
889
|
+
* @return {State}
|
|
890
|
+
* The initial state
|
|
891
|
+
*/
|
|
892
|
+
type Initializer = (this: TokenizeContext$1, effects: Effects$1) => State$1;
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* @file InsideSpan
|
|
896
|
+
* @module docmark-util-types/InsideSpan
|
|
897
|
+
*/
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Resolvers to run inside a span.
|
|
901
|
+
*/
|
|
902
|
+
interface InsideSpan {
|
|
903
|
+
/**
|
|
904
|
+
* The list of resolvers to run.
|
|
905
|
+
*
|
|
906
|
+
* @see {@linkcode AnyConstruct}
|
|
907
|
+
*/
|
|
908
|
+
null?: Pick<AnyConstruct$1, 'resolveAll'>[] | undefined;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* @file Lazy
|
|
913
|
+
* @module docmark-util-types/Lazy
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Record, where each key is a line number, and each value is a boolean
|
|
918
|
+
* indicating if the line is lazy (as opposed to the line before it).
|
|
919
|
+
*
|
|
920
|
+
* For example:
|
|
921
|
+
*
|
|
922
|
+
* ```markdown
|
|
923
|
+
* > a
|
|
924
|
+
* b
|
|
925
|
+
* ```
|
|
926
|
+
*
|
|
927
|
+
* L1 is not lazy, but L2 is.
|
|
928
|
+
*
|
|
929
|
+
* @see {@linkcode Line}
|
|
930
|
+
*/
|
|
931
|
+
type Lazy = {
|
|
932
|
+
[line: Line]: boolean;
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* @file Line
|
|
937
|
+
* @module docmark-util-types/Line
|
|
938
|
+
*/
|
|
939
|
+
/**
|
|
940
|
+
* A line in the source content (`1`-indexed integer).
|
|
941
|
+
*/
|
|
942
|
+
type Line = number;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* @file NamedConstruct
|
|
946
|
+
* @module docmark-util-types/NamedConstruct
|
|
947
|
+
*/
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* A construct with a name.
|
|
951
|
+
*
|
|
952
|
+
* @see {@linkcode Construct}
|
|
953
|
+
*
|
|
954
|
+
* @extends {Construct}
|
|
955
|
+
*/
|
|
956
|
+
interface NamedConstruct extends Construct$1 {
|
|
957
|
+
/**
|
|
958
|
+
* The name of the construct.
|
|
959
|
+
*
|
|
960
|
+
* @override
|
|
961
|
+
*/
|
|
962
|
+
name: string;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* @file NormalizedExtension
|
|
967
|
+
* @module docmark-util-types/NormalizedExtension
|
|
968
|
+
*/
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* A filtered, combined extension, where all properties are optional,
|
|
972
|
+
* but defined.
|
|
973
|
+
*
|
|
974
|
+
* @see {@linkcode Extension}
|
|
975
|
+
*/
|
|
976
|
+
type NormalizedExtension = {
|
|
977
|
+
[Key in keyof Extension$1]: Exclude<Extension$1[Key], null | undefined>;
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* @file Now
|
|
982
|
+
* @module docmark-util-types/Now
|
|
983
|
+
*/
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Get the current place in the content.
|
|
987
|
+
*
|
|
988
|
+
* @see {@linkcode Place}
|
|
989
|
+
*
|
|
990
|
+
* @this {void}
|
|
991
|
+
*
|
|
992
|
+
* @return {Place}
|
|
993
|
+
* The current place
|
|
994
|
+
*/
|
|
995
|
+
type Now = (this: void) => Place$1;
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* @file Offset
|
|
999
|
+
* @module docmark-util-types/Offset
|
|
1000
|
+
*/
|
|
1001
|
+
/**
|
|
1002
|
+
* A position in the source content (`0`-indexed integer).
|
|
1003
|
+
*/
|
|
1004
|
+
type Offset = number;
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @file ParseContext
|
|
1008
|
+
* @module docmark-util-types/ParseContext
|
|
1009
|
+
*/
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Context object to assist with parsing.
|
|
1013
|
+
*
|
|
1014
|
+
* This interface can be augmented to register custom fields.
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1018
|
+
* interface ParseContext {
|
|
1019
|
+
* list: string[]
|
|
1020
|
+
* }
|
|
1021
|
+
* }
|
|
1022
|
+
*/
|
|
1023
|
+
interface ParseContext {
|
|
1024
|
+
/**
|
|
1025
|
+
* Whether the current line is blank.
|
|
1026
|
+
*/
|
|
1027
|
+
atBlankLine?: boolean | null | undefined;
|
|
1028
|
+
/**
|
|
1029
|
+
* Create a comment content parser.
|
|
1030
|
+
*
|
|
1031
|
+
* @see {@linkcode Create}
|
|
1032
|
+
*/
|
|
1033
|
+
comment: Create$1;
|
|
1034
|
+
/**
|
|
1035
|
+
* The normalized syntax extension.
|
|
1036
|
+
*
|
|
1037
|
+
* @see {@linkcode FullNormalizedExtension}
|
|
1038
|
+
*/
|
|
1039
|
+
constructs: FullNormalizedExtension$1;
|
|
1040
|
+
/**
|
|
1041
|
+
* Create a markdown content parser.
|
|
1042
|
+
*
|
|
1043
|
+
* @see {@linkcode Create}
|
|
1044
|
+
*/
|
|
1045
|
+
content: Create$1;
|
|
1046
|
+
/**
|
|
1047
|
+
* The list of defined markdown identifiers.
|
|
1048
|
+
*/
|
|
1049
|
+
defined: string[];
|
|
1050
|
+
/**
|
|
1051
|
+
* Create a markdown document parser.
|
|
1052
|
+
*
|
|
1053
|
+
* @see {@linkcode Create}
|
|
1054
|
+
*/
|
|
1055
|
+
document: Create$1;
|
|
1056
|
+
/**
|
|
1057
|
+
* Create a markdown flow parser.
|
|
1058
|
+
*
|
|
1059
|
+
* @see {@linkcode Create}
|
|
1060
|
+
*/
|
|
1061
|
+
flow: Create$1;
|
|
1062
|
+
/**
|
|
1063
|
+
* Whether a comment was just added.
|
|
1064
|
+
*/
|
|
1065
|
+
freshComment?: boolean | null | undefined;
|
|
1066
|
+
/**
|
|
1067
|
+
* Whether a comment region was just added.
|
|
1068
|
+
*/
|
|
1069
|
+
freshRegion?: boolean | null | undefined;
|
|
1070
|
+
/**
|
|
1071
|
+
* At the `document` level, a record where each key is a line number, and each
|
|
1072
|
+
* value is a boolean indicating if the line is lazy (as opposed to the line
|
|
1073
|
+
* before it).
|
|
1074
|
+
*
|
|
1075
|
+
* For example:
|
|
1076
|
+
*
|
|
1077
|
+
* ```markdown
|
|
1078
|
+
* > a
|
|
1079
|
+
* b
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* L1 is not lazy, but L2 is.
|
|
1083
|
+
*
|
|
1084
|
+
* @see {@linkcode Lazy}
|
|
1085
|
+
*/
|
|
1086
|
+
lazy: Lazy$1;
|
|
1087
|
+
/**
|
|
1088
|
+
* Whether the previous line is blank.
|
|
1089
|
+
*/
|
|
1090
|
+
previousBlankLine?: boolean | null | undefined;
|
|
1091
|
+
/**
|
|
1092
|
+
* Whether a comment summary is not allowed.
|
|
1093
|
+
*/
|
|
1094
|
+
skipSummary?: boolean | undefined;
|
|
1095
|
+
/**
|
|
1096
|
+
* Create a source document parser.
|
|
1097
|
+
*
|
|
1098
|
+
* @see {@linkcode Create}
|
|
1099
|
+
*/
|
|
1100
|
+
source: Create$1;
|
|
1101
|
+
/**
|
|
1102
|
+
* Create a markdown string parser.
|
|
1103
|
+
*
|
|
1104
|
+
* @see {@linkcode Create}
|
|
1105
|
+
*/
|
|
1106
|
+
string: Create$1;
|
|
1107
|
+
/**
|
|
1108
|
+
* Create a markdown text parser.
|
|
1109
|
+
*
|
|
1110
|
+
* @see {@linkcode Create}
|
|
1111
|
+
*/
|
|
1112
|
+
text: Create$1;
|
|
1113
|
+
/**
|
|
1114
|
+
* Create a type expression parser.
|
|
1115
|
+
*
|
|
1116
|
+
* @see {@linkcode Create}
|
|
1117
|
+
*/
|
|
1118
|
+
type: Create$1;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* @file ParseOptions
|
|
1123
|
+
* @module docmark-util-types/ParseOptions
|
|
1124
|
+
*/
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Configuration object defining how to parse.
|
|
1128
|
+
*
|
|
1129
|
+
* This interface can be augmented to register custom fields.
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1133
|
+
* interface ParseOptions {
|
|
1134
|
+
* from?: Point | null | undefined
|
|
1135
|
+
* }
|
|
1136
|
+
* }
|
|
1137
|
+
*/
|
|
1138
|
+
interface ParseOptions {
|
|
1139
|
+
/**
|
|
1140
|
+
* The list of syntax extensions to apply.
|
|
1141
|
+
*
|
|
1142
|
+
* @see {@linkcode AnyExtension}
|
|
1143
|
+
*/
|
|
1144
|
+
extensions?: AnyExtension$1[] | null | undefined;
|
|
1145
|
+
/**
|
|
1146
|
+
* Finalize the tokenization context.
|
|
1147
|
+
*
|
|
1148
|
+
* @see {@linkcode FinalizeContext}
|
|
1149
|
+
*/
|
|
1150
|
+
finalizeContext?: FinalizeContext$1 | null | undefined;
|
|
1151
|
+
/**
|
|
1152
|
+
* Record where each key is {@linkcode ContentType},
|
|
1153
|
+
* and each value is an {@linkcode InitialConstruct} override.
|
|
1154
|
+
*/
|
|
1155
|
+
initializers?: Partial<InitialConstructs$1> | null | undefined;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* @file PartialConstruct
|
|
1160
|
+
* @module docmark-util-types/PartialConstruct
|
|
1161
|
+
*/
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* A partial construct.
|
|
1165
|
+
*
|
|
1166
|
+
* @see {@linkcode Construct}
|
|
1167
|
+
*
|
|
1168
|
+
* @extends {Construct}
|
|
1169
|
+
*/
|
|
1170
|
+
interface PartialConstruct extends Construct$1 {
|
|
1171
|
+
/**
|
|
1172
|
+
* Whether the construct represents a partial construct.
|
|
1173
|
+
*
|
|
1174
|
+
* @override
|
|
1175
|
+
*/
|
|
1176
|
+
partial: true;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* @file Place
|
|
1181
|
+
* @module docmark-util-types/Place
|
|
1182
|
+
*/
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* A location in the source content (`line`/`column`/`offset`)
|
|
1186
|
+
* and chunk (`_index`, `_bufferIndex`).
|
|
1187
|
+
*
|
|
1188
|
+
* @see {@linkcode Point}
|
|
1189
|
+
*
|
|
1190
|
+
* @extends {Point}
|
|
1191
|
+
*/
|
|
1192
|
+
interface Place extends Point$1 {
|
|
1193
|
+
/**
|
|
1194
|
+
* The position in a string chunk (or `-1` when pointing to a numeric chunk).
|
|
1195
|
+
*/
|
|
1196
|
+
_bufferIndex: number;
|
|
1197
|
+
/**
|
|
1198
|
+
* The position in a list of chunks.
|
|
1199
|
+
*/
|
|
1200
|
+
_index: number;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* @file Point
|
|
1205
|
+
* @module docmark-util-types/Point
|
|
1206
|
+
*/
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* A location in the source content.
|
|
1210
|
+
*/
|
|
1211
|
+
interface Point {
|
|
1212
|
+
/**
|
|
1213
|
+
* The column in the source content (`1`-indexed integer).
|
|
1214
|
+
*
|
|
1215
|
+
* @see {@linkcode Column}
|
|
1216
|
+
*/
|
|
1217
|
+
column: Column$1;
|
|
1218
|
+
/**
|
|
1219
|
+
* The line in the source content (`1`-indexed integer).
|
|
1220
|
+
*
|
|
1221
|
+
* @see {@linkcode Line}
|
|
1222
|
+
*/
|
|
1223
|
+
line: Line$1;
|
|
1224
|
+
/**
|
|
1225
|
+
* The position in the source content (`0`-indexed integer).
|
|
1226
|
+
*
|
|
1227
|
+
* @see {@linkcode Offset}
|
|
1228
|
+
*/
|
|
1229
|
+
offset: Offset$1;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* @file Position
|
|
1234
|
+
* @module docmark-util-types/Position
|
|
1235
|
+
*/
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Range between two points in a source file.
|
|
1239
|
+
*/
|
|
1240
|
+
interface Position {
|
|
1241
|
+
/**
|
|
1242
|
+
* The place of the last character code in the range.
|
|
1243
|
+
*
|
|
1244
|
+
* @see {@linkcode Place}
|
|
1245
|
+
*/
|
|
1246
|
+
end: Place$1;
|
|
1247
|
+
/**
|
|
1248
|
+
* The place of the first character code in the range.
|
|
1249
|
+
*
|
|
1250
|
+
* @see {@linkcode Place}
|
|
1251
|
+
*/
|
|
1252
|
+
start: Place$1;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* @file PreprocessOptions
|
|
1257
|
+
* @module docmark-util-types/PreprocessOptions
|
|
1258
|
+
*/
|
|
1259
|
+
/**
|
|
1260
|
+
* Options for configuring a preprocessor.
|
|
1261
|
+
*/
|
|
1262
|
+
interface PreprocessOptions {
|
|
1263
|
+
/**
|
|
1264
|
+
* The number of spaces a tab is equivalent to.
|
|
1265
|
+
*
|
|
1266
|
+
* @default constants.tabSize
|
|
1267
|
+
*/
|
|
1268
|
+
tabSize?: number | null | undefined;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* @file Preprocessor
|
|
1273
|
+
* @module docmark-util-types/Preprocessor
|
|
1274
|
+
*/
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Turn a code, file, or value into chunks.
|
|
1278
|
+
*
|
|
1279
|
+
* @see {@linkcode Chunk}
|
|
1280
|
+
* @see {@linkcode Code}
|
|
1281
|
+
* @see {@linkcode Encoding}
|
|
1282
|
+
* @see {@linkcode FileLike}
|
|
1283
|
+
* @see {@linkcode Value}
|
|
1284
|
+
*/
|
|
1285
|
+
type Preprocess = {
|
|
1286
|
+
/**
|
|
1287
|
+
* Turn `value` into chunks.
|
|
1288
|
+
*
|
|
1289
|
+
* @see {@linkcode Code}
|
|
1290
|
+
* @see {@linkcode Encoding}
|
|
1291
|
+
* @see {@linkcode FileLike}
|
|
1292
|
+
* @see {@linkcode Value}
|
|
1293
|
+
*
|
|
1294
|
+
* @this {void}
|
|
1295
|
+
*
|
|
1296
|
+
* @param {Code | FileLike | Value | undefined} value
|
|
1297
|
+
* The code, file, or value to preprocess
|
|
1298
|
+
* @param {Encoding | null | undefined} encoding
|
|
1299
|
+
* The character encoding to use when `value`
|
|
1300
|
+
* or its contents is an {@linkcode Uint8Array}
|
|
1301
|
+
* @param {true} end
|
|
1302
|
+
* Whether the end of stream has been reached
|
|
1303
|
+
* @return {[...NonNullable<Chunk>[], null]}
|
|
1304
|
+
* The list of chunks
|
|
1305
|
+
*/
|
|
1306
|
+
(this: void, value: Code$1 | FileLike$1 | Value$1 | undefined, encoding: Encoding$1 | null | undefined, end: true): [...NonNullable<Chunk$1>[], null];
|
|
1307
|
+
/**
|
|
1308
|
+
* Turn `value` into chunks.
|
|
1309
|
+
*
|
|
1310
|
+
* @see {@linkcode Code}
|
|
1311
|
+
* @see {@linkcode Encoding}
|
|
1312
|
+
* @see {@linkcode FileLike}
|
|
1313
|
+
* @see {@linkcode Value}
|
|
1314
|
+
*
|
|
1315
|
+
* @this {void}
|
|
1316
|
+
*
|
|
1317
|
+
* @param {Code | FileLike | Value | undefined} value
|
|
1318
|
+
* The code, file, or value to preprocess
|
|
1319
|
+
* @param {Encoding | null | undefined} encoding
|
|
1320
|
+
* The character encoding to use when `value`
|
|
1321
|
+
* or its contents is an {@linkcode Uint8Array}
|
|
1322
|
+
* @param {false | null | undefined} [end]
|
|
1323
|
+
* Whether the end of stream has been reached
|
|
1324
|
+
* @return {NonNullable<Chunk>[]}
|
|
1325
|
+
* The list of chunks
|
|
1326
|
+
*/
|
|
1327
|
+
(this: void, value: Code$1 | FileLike$1 | Value$1 | undefined, encoding?: Encoding$1 | null | undefined, end?: false | null | undefined): NonNullable<Chunk$1>[];
|
|
1328
|
+
/**
|
|
1329
|
+
* Turn `value` into chunks.
|
|
1330
|
+
*
|
|
1331
|
+
* @see {@linkcode Code}
|
|
1332
|
+
* @see {@linkcode Encoding}
|
|
1333
|
+
* @see {@linkcode FileLike}
|
|
1334
|
+
* @see {@linkcode Value}
|
|
1335
|
+
*
|
|
1336
|
+
* @this {void}
|
|
1337
|
+
*
|
|
1338
|
+
* @param {Code | FileLike | Value | undefined} value
|
|
1339
|
+
* The code, file, or value to preprocess
|
|
1340
|
+
* @param {Encoding | null | undefined} [encoding]
|
|
1341
|
+
* The character encoding to use when `value`
|
|
1342
|
+
* or its contents is an {@linkcode Uint8Array}
|
|
1343
|
+
* @param {boolean | null | undefined} [end]
|
|
1344
|
+
* Whether the end of stream has been reached
|
|
1345
|
+
* @return {Chunk[]}
|
|
1346
|
+
* The list of chunks
|
|
1347
|
+
*/
|
|
1348
|
+
(this: void, value: Code$1 | FileLike$1 | Value$1 | undefined, encoding?: Encoding$1 | null | undefined, end?: boolean | null | undefined): Chunk$1[];
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
/**
|
|
1352
|
+
* @file Previous
|
|
1353
|
+
* @module docmark-util-types/Previous
|
|
1354
|
+
*/
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Check if the previous character `code` can precede a construct.
|
|
1358
|
+
*
|
|
1359
|
+
* > 👉 **Note**: A construct can hook into many potential start characters.
|
|
1360
|
+
* > Instead of setting up an attempt to parse that construct for most
|
|
1361
|
+
* > characters, this is a speedy way to reduce that.
|
|
1362
|
+
*
|
|
1363
|
+
* @see {@linkcode Code}
|
|
1364
|
+
* @see {@linkcode TokenizeContext}
|
|
1365
|
+
*
|
|
1366
|
+
* @this {TokenizeContext}
|
|
1367
|
+
*
|
|
1368
|
+
* @param {Code} code
|
|
1369
|
+
* The previous character code
|
|
1370
|
+
* @return {boolean}
|
|
1371
|
+
* Whether `code` is allowed before the construct
|
|
1372
|
+
*/
|
|
1373
|
+
type Previous = (this: TokenizeContext$1, code: Code$1) => boolean;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* @file Resolver
|
|
1377
|
+
* @module docmark-util-types/Resolver
|
|
1378
|
+
*/
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* Handle events coming from `tokenize`.
|
|
1382
|
+
*
|
|
1383
|
+
* @see {@linkcode Construct.tokenize}
|
|
1384
|
+
* @see {@linkcode Event}
|
|
1385
|
+
* @see {@linkcode TokenizeContext}
|
|
1386
|
+
*
|
|
1387
|
+
* @this {void}
|
|
1388
|
+
*
|
|
1389
|
+
* @param {Event[]} events
|
|
1390
|
+
* The current list of events
|
|
1391
|
+
* @param {TokenizeContext} context
|
|
1392
|
+
* The tokenize context
|
|
1393
|
+
* @return {Event[]}
|
|
1394
|
+
* The list of changed events
|
|
1395
|
+
*/
|
|
1396
|
+
type Resolver = (this: void, events: Event$1[], context: TokenizeContext$1) => Event$1[];
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @file SerializeOptions
|
|
1400
|
+
* @module docmark-util-types/SerializeOptions
|
|
1401
|
+
*/
|
|
1402
|
+
/**
|
|
1403
|
+
* Options for serializing chunks.
|
|
1404
|
+
*/
|
|
1405
|
+
interface SerializeOptions {
|
|
1406
|
+
/**
|
|
1407
|
+
* A string representing a serialized stream break, a boolean indicating
|
|
1408
|
+
* whether the stream break code should be serialized to a space (` `) rather
|
|
1409
|
+
* than an empty string, or `null` to error on serialization attempt.
|
|
1410
|
+
*
|
|
1411
|
+
* @default null
|
|
1412
|
+
*/
|
|
1413
|
+
breaks?: boolean | string | null | undefined;
|
|
1414
|
+
/**
|
|
1415
|
+
* Whether to expand tabs.
|
|
1416
|
+
*/
|
|
1417
|
+
expandTabs?: boolean | null | undefined;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* @file SliceSerialize
|
|
1422
|
+
* @module docmark-util-types/SliceSerialize
|
|
1423
|
+
*/
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Get the text spanning `range`.
|
|
1427
|
+
*
|
|
1428
|
+
* @see {@linkcode Position}
|
|
1429
|
+
* @see {@linkcode SerializeOptions}
|
|
1430
|
+
*
|
|
1431
|
+
* @this {void}
|
|
1432
|
+
*
|
|
1433
|
+
* @param {Position} range
|
|
1434
|
+
* The position in stream
|
|
1435
|
+
* @param {SerializeOptions | boolean | null | undefined} [options]
|
|
1436
|
+
* Options for serializing or whether to expand tabs
|
|
1437
|
+
* @return {string}
|
|
1438
|
+
* The serialized slice
|
|
1439
|
+
*/
|
|
1440
|
+
type SliceSerialize = (this: void, range: Position$1, options?: SerializeOptions$1 | boolean | null | undefined) => string;
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* @file SliceStream
|
|
1444
|
+
* @module docmark-util-types/SliceStream
|
|
1445
|
+
*/
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Get the chunks spanning `range`.
|
|
1449
|
+
*
|
|
1450
|
+
* @see {@linkcode Chunk}
|
|
1451
|
+
* @see {@linkcode Position}
|
|
1452
|
+
*
|
|
1453
|
+
* @this {void}
|
|
1454
|
+
*
|
|
1455
|
+
* @param {Position} range
|
|
1456
|
+
* The position in stream
|
|
1457
|
+
* @return {Chunk[]}
|
|
1458
|
+
* The chunks in stream spanning `range`
|
|
1459
|
+
*/
|
|
1460
|
+
type SliceStream = (this: void, range: Position$1) => Chunk$1[];
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* @file State
|
|
1464
|
+
* @module docmark-util-types/State
|
|
1465
|
+
*/
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* The main unit in the state machine: a function that gets a character code and
|
|
1469
|
+
* has certain effects.
|
|
1470
|
+
*
|
|
1471
|
+
* A state function returns another function: the next state-as-a-function to go
|
|
1472
|
+
* to, or `undefined` when a final state is reached.
|
|
1473
|
+
*
|
|
1474
|
+
* @see {@linkcode Code}
|
|
1475
|
+
*
|
|
1476
|
+
* @this {void}
|
|
1477
|
+
*
|
|
1478
|
+
* @param {Code} code
|
|
1479
|
+
* The current character code
|
|
1480
|
+
* @return {State | undefined}
|
|
1481
|
+
* The next state
|
|
1482
|
+
*/
|
|
1483
|
+
type State = (this: void, code: Code$1) => State | undefined;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* @file TokenFields
|
|
1487
|
+
* @module docmark-util-types/TokenFields
|
|
1488
|
+
*/
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* Registry of token fields.
|
|
1492
|
+
*
|
|
1493
|
+
* This interface can be augmented to register custom token fields.
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1497
|
+
* interface TokenFields {
|
|
1498
|
+
* value?: string | null | undefined
|
|
1499
|
+
* }
|
|
1500
|
+
* }
|
|
1501
|
+
*/
|
|
1502
|
+
interface TokenFields {
|
|
1503
|
+
/**
|
|
1504
|
+
* Whether a link opening is balanced balanced:
|
|
1505
|
+
* it’s not a link opening, but has a balanced closing.
|
|
1506
|
+
*/
|
|
1507
|
+
_balanced?: boolean | undefined;
|
|
1508
|
+
/**
|
|
1509
|
+
* Whether an attention sequence is a closer.
|
|
1510
|
+
*
|
|
1511
|
+
* Depending on the character before sequences (`**`), the sequence can open,
|
|
1512
|
+
* close, both, or none.
|
|
1513
|
+
*/
|
|
1514
|
+
_close?: boolean | undefined;
|
|
1515
|
+
/**
|
|
1516
|
+
* Whether the token represents a `document`, `comment`,
|
|
1517
|
+
* or `source`-level container.
|
|
1518
|
+
*/
|
|
1519
|
+
_container?: boolean | undefined;
|
|
1520
|
+
/**
|
|
1521
|
+
* When {@linkcode contentType} is `string` or `text`, whether trailing
|
|
1522
|
+
* whitespace is sensitive and allowed.\
|
|
1523
|
+
* Normally, trailing spaces and tabs are dropped.
|
|
1524
|
+
*/
|
|
1525
|
+
_contentTypeTextTrailing?: boolean | undefined;
|
|
1526
|
+
/**
|
|
1527
|
+
* Whether a link opening cannot be used because links are incorrect.
|
|
1528
|
+
*/
|
|
1529
|
+
_inactive?: boolean | undefined;
|
|
1530
|
+
/**
|
|
1531
|
+
* When parsing GFM task lists, whether a token is in the first content of a
|
|
1532
|
+
* list item construct.
|
|
1533
|
+
*/
|
|
1534
|
+
_isInFirstContentOfListItem?: boolean | undefined;
|
|
1535
|
+
/**
|
|
1536
|
+
* The comment kind.
|
|
1537
|
+
*
|
|
1538
|
+
* @see {@linkcode CommentKind}
|
|
1539
|
+
*/
|
|
1540
|
+
_kind?: CommentKind$1 | undefined;
|
|
1541
|
+
/**
|
|
1542
|
+
* When parsing lists, whether a list is loose or not.
|
|
1543
|
+
*/
|
|
1544
|
+
_loose?: boolean | undefined;
|
|
1545
|
+
/**
|
|
1546
|
+
* Whether an attention sequence is an opener.
|
|
1547
|
+
*
|
|
1548
|
+
* Depending on the character before sequences (`**`), the sequence can open,
|
|
1549
|
+
* close, both, or none.
|
|
1550
|
+
*/
|
|
1551
|
+
_open?: boolean | undefined;
|
|
1552
|
+
/**
|
|
1553
|
+
* When {@linkcode contentType} is `comment`, whether the token represents a
|
|
1554
|
+
* comment region.
|
|
1555
|
+
*/
|
|
1556
|
+
_region?: boolean | undefined;
|
|
1557
|
+
/**
|
|
1558
|
+
* The connected tokenizer, used when dealing with linked tokens.
|
|
1559
|
+
*
|
|
1560
|
+
* @see {@linkcode TokenizeContext}
|
|
1561
|
+
*/
|
|
1562
|
+
_tokenizer?: TokenizeContext$1 | undefined;
|
|
1563
|
+
/**
|
|
1564
|
+
* At the `comment` or `source` level, whether a `whitespace` token represents
|
|
1565
|
+
* trailing whitespace.\
|
|
1566
|
+
* Depending on the next logical comment line, trailing whitespaces are
|
|
1567
|
+
* resolved into hard breaks or line suffixes.
|
|
1568
|
+
*/
|
|
1569
|
+
_trailing?: boolean | undefined;
|
|
1570
|
+
/**
|
|
1571
|
+
* Declare the token as having content of a certain type.
|
|
1572
|
+
*
|
|
1573
|
+
* @see {@linkcode ContentType}
|
|
1574
|
+
*/
|
|
1575
|
+
contentType?: ContentType$1 | undefined;
|
|
1576
|
+
/**
|
|
1577
|
+
* The next token in a list of linked tokens.
|
|
1578
|
+
*
|
|
1579
|
+
* @see {@linkcode Token}
|
|
1580
|
+
*/
|
|
1581
|
+
next?: Token$1 | undefined;
|
|
1582
|
+
/**
|
|
1583
|
+
* The previous token in a list of linked tokens.
|
|
1584
|
+
*
|
|
1585
|
+
* @see {@linkcode Token}
|
|
1586
|
+
*/
|
|
1587
|
+
previous?: Token$1 | undefined;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* @file TokenTypeMap
|
|
1592
|
+
* @module docmark-util-types/TokenTypeMap
|
|
1593
|
+
*/
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Registry of token types.
|
|
1597
|
+
*
|
|
1598
|
+
* The token type `null` is forbidden.
|
|
1599
|
+
* The ecosystem uses the `null` key to support additional functionality.
|
|
1600
|
+
*
|
|
1601
|
+
* Libraries and other tools can augment this interface
|
|
1602
|
+
* to register custom token types.
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1606
|
+
* interface TokenTypeMap {
|
|
1607
|
+
* custom: 'custom'
|
|
1608
|
+
* }
|
|
1609
|
+
* }
|
|
1610
|
+
*
|
|
1611
|
+
* @see {@linkcode micromark.TokenTypeMap}
|
|
1612
|
+
*
|
|
1613
|
+
* @extends {micromark.TokenTypeMap}
|
|
1614
|
+
*/
|
|
1615
|
+
interface TokenTypeMap extends micromark.TokenTypeMap {
|
|
1616
|
+
blockTag: 'blockTag';
|
|
1617
|
+
chunkComment: 'chunkComment';
|
|
1618
|
+
chunkMarkdown: 'chunkMarkdown';
|
|
1619
|
+
chunkType: 'chunkType';
|
|
1620
|
+
comment: 'comment';
|
|
1621
|
+
commentCloser: 'commentCloser';
|
|
1622
|
+
commentLineMarker: 'commentLineMarker';
|
|
1623
|
+
commentLinePrefix: 'commentLinePrefix';
|
|
1624
|
+
commentOpener: 'commentOpener';
|
|
1625
|
+
commentPadding: 'commentPadding';
|
|
1626
|
+
eoc: 'eoc';
|
|
1627
|
+
identifier: 'identifier';
|
|
1628
|
+
inlineTag: 'inlineTag';
|
|
1629
|
+
inlineTagMarker: 'inlineTagMarker';
|
|
1630
|
+
inlineTagText: 'inlineTagText';
|
|
1631
|
+
namepath: 'namepath';
|
|
1632
|
+
namepathConnector: 'namepathConnector';
|
|
1633
|
+
namepathIdentifier: 'namepathIdentifier';
|
|
1634
|
+
namepathMarker: 'namepathMarker';
|
|
1635
|
+
/**
|
|
1636
|
+
* Forbidden token type.
|
|
1637
|
+
*
|
|
1638
|
+
* The ecosystem uses the `null` key to support additional functionality.
|
|
1639
|
+
*/
|
|
1640
|
+
null: never;
|
|
1641
|
+
summary: 'summary';
|
|
1642
|
+
summaryMarker: 'summaryMarker';
|
|
1643
|
+
tagName: 'tagName';
|
|
1644
|
+
tagNameIdentifier: 'tagNameIdentifier';
|
|
1645
|
+
tagNameMarker: 'tagNameMarker';
|
|
1646
|
+
typeExpression: 'typeExpression';
|
|
1647
|
+
typeExpressionValue: 'typeExpressionValue';
|
|
1648
|
+
typeMetadata: 'typeMetadata';
|
|
1649
|
+
typeMetadataMarker: 'typeMetadataMarker';
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* @file TokenType
|
|
1654
|
+
* @module docmark-util-types/TokenType
|
|
1655
|
+
*/
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
* Union of registered token types.
|
|
1659
|
+
*
|
|
1660
|
+
* The token type `null` is forbidden.
|
|
1661
|
+
* The `docmark` ecosystem uses the `null` key
|
|
1662
|
+
* to support additional functionality.
|
|
1663
|
+
*
|
|
1664
|
+
* To register custom token types, augment {@linkcode TokenTypeMap}.
|
|
1665
|
+
* They will be added to this union automatically.
|
|
1666
|
+
*/
|
|
1667
|
+
type TokenType = TokenTypeMap$1[keyof TokenTypeMap$1];
|
|
1668
|
+
|
|
1669
|
+
/**
|
|
1670
|
+
* @file Token
|
|
1671
|
+
* @module docmark-util-types/Token
|
|
1672
|
+
*/
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* A span of one (`1`) or more chunks.
|
|
1676
|
+
*
|
|
1677
|
+
* Tokens are the core of what docmark produces: libraries and other tools can
|
|
1678
|
+
* turn them into different things.
|
|
1679
|
+
*
|
|
1680
|
+
* Tokens are essentially names attached to a slice of chunks, such as
|
|
1681
|
+
* `lineEndingBlank` for certain line endings, `codeFenced` for fenced code, or
|
|
1682
|
+
* `summary` for an entire comment summary.
|
|
1683
|
+
*
|
|
1684
|
+
* Sometimes, more info is attached to tokens, such as `_open` and `_close`
|
|
1685
|
+
* by `attention` (strong, emphasis) to signal whether the sequence can open
|
|
1686
|
+
* or close an attention run.
|
|
1687
|
+
*
|
|
1688
|
+
* Linked tokens are used because outer constructs are parsed first.
|
|
1689
|
+
* For example:
|
|
1690
|
+
*
|
|
1691
|
+
* ```markdown
|
|
1692
|
+
* > *a
|
|
1693
|
+
* b*.
|
|
1694
|
+
* ```
|
|
1695
|
+
*
|
|
1696
|
+
* 1. The block quote marker and the space after it is parsed first
|
|
1697
|
+
* 2. The rest of the line is a `chunkFlow` token
|
|
1698
|
+
* 3. The two spaces on the second line are a `linePrefix`
|
|
1699
|
+
* 4. The rest of the line is another `chunkFlow` token
|
|
1700
|
+
*
|
|
1701
|
+
* The two `chunkFlow` tokens are linked together.
|
|
1702
|
+
* The chunks they span are then passed through the `flow` tokenizer.
|
|
1703
|
+
*
|
|
1704
|
+
* Sometimes tokens need more info!
|
|
1705
|
+
* This interface can be augmented to register custom token fields.
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1709
|
+
* interface Token {
|
|
1710
|
+
* value?: string | null | undefined
|
|
1711
|
+
* }
|
|
1712
|
+
* }
|
|
1713
|
+
*
|
|
1714
|
+
* @see {@linkcode Code}
|
|
1715
|
+
* @see {@linkcode Position}
|
|
1716
|
+
* @see {@linkcode TokenFields}
|
|
1717
|
+
* @see {@linkcode TokenType}
|
|
1718
|
+
*
|
|
1719
|
+
* @template {TokenType} [T=TokenType]
|
|
1720
|
+
* The token type
|
|
1721
|
+
*
|
|
1722
|
+
* @extends {Position}
|
|
1723
|
+
* @extends {TokenFields}
|
|
1724
|
+
*/
|
|
1725
|
+
interface Token<T extends TokenType$1 = TokenType$1> extends Position$1, TokenFields$1 {
|
|
1726
|
+
/**
|
|
1727
|
+
* The token type.
|
|
1728
|
+
*/
|
|
1729
|
+
type: T;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* @file TokenizeContext
|
|
1734
|
+
* @module docmark-util-types/TokenizeContext
|
|
1735
|
+
*/
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Context object to assist with tokenizing syntax constructs.
|
|
1739
|
+
*
|
|
1740
|
+
* This interface can be augmented to register custom fields.
|
|
1741
|
+
*
|
|
1742
|
+
* @example
|
|
1743
|
+
* declare module '@flex-development/docmark-util-types' {
|
|
1744
|
+
* interface TokenizeContext {
|
|
1745
|
+
* field?: string | undefined
|
|
1746
|
+
* }
|
|
1747
|
+
* }
|
|
1748
|
+
*/
|
|
1749
|
+
interface TokenizeContext {
|
|
1750
|
+
/**
|
|
1751
|
+
* Whether trailing whitespace is sensitive and allowed when tokenizing `text`
|
|
1752
|
+
* or `string` content.\
|
|
1753
|
+
* Normally, trailing spaces and tabs are dropped.
|
|
1754
|
+
*/
|
|
1755
|
+
_contentTypeTextTrailing?: boolean | undefined;
|
|
1756
|
+
/**
|
|
1757
|
+
* Whether the tokenizer is tokenizing the first content of a list item
|
|
1758
|
+
* construct.
|
|
1759
|
+
*
|
|
1760
|
+
* > 👉 **Note**: Shared with `micromark-extension-gfm-task-list-item`.
|
|
1761
|
+
*/
|
|
1762
|
+
_gfmTasklistFirstContentOfListItem?: boolean | undefined;
|
|
1763
|
+
/**
|
|
1764
|
+
* Whether a speculative check is being ran.
|
|
1765
|
+
*
|
|
1766
|
+
* @see {@linkcode Check}
|
|
1767
|
+
*/
|
|
1768
|
+
check?: boolean | undefined;
|
|
1769
|
+
/**
|
|
1770
|
+
* The current character code.
|
|
1771
|
+
*
|
|
1772
|
+
* @see {@linkcode Code}
|
|
1773
|
+
*/
|
|
1774
|
+
code: Code$1;
|
|
1775
|
+
/**
|
|
1776
|
+
* Whether concrete markdown was detected.
|
|
1777
|
+
*
|
|
1778
|
+
* Concrete constructs cannot be interrupted by other constructs.
|
|
1779
|
+
*/
|
|
1780
|
+
concrete?: boolean | undefined;
|
|
1781
|
+
/**
|
|
1782
|
+
* Shared state set when parsing containers.
|
|
1783
|
+
*
|
|
1784
|
+
* Containers are parsed in separate phases:
|
|
1785
|
+
* their first line (`tokenize`), continued lines (`continuation.tokenize`),
|
|
1786
|
+
* and finally `exit`.
|
|
1787
|
+
* This record can be used to store information between these hooks.
|
|
1788
|
+
*
|
|
1789
|
+
* @see {@linkcode ContainerState}
|
|
1790
|
+
*/
|
|
1791
|
+
containerState?: ContainerState$1 | undefined;
|
|
1792
|
+
/**
|
|
1793
|
+
* The content type the tokenizer deals with.
|
|
1794
|
+
*
|
|
1795
|
+
* @see {@linkcode ContentType}
|
|
1796
|
+
*
|
|
1797
|
+
* @readonly
|
|
1798
|
+
*/
|
|
1799
|
+
readonly contentType: ContentType$1;
|
|
1800
|
+
/**
|
|
1801
|
+
* The current construct.
|
|
1802
|
+
*
|
|
1803
|
+
* Constructs that are not `partial` are set here.
|
|
1804
|
+
*
|
|
1805
|
+
* @see {@linkcode Construct}
|
|
1806
|
+
*/
|
|
1807
|
+
currentConstruct?: Construct$1 | undefined;
|
|
1808
|
+
/**
|
|
1809
|
+
* The debug logger.
|
|
1810
|
+
*
|
|
1811
|
+
* @see {@linkcode Debugger}
|
|
1812
|
+
*
|
|
1813
|
+
* @readonly
|
|
1814
|
+
*/
|
|
1815
|
+
readonly debug: Debugger;
|
|
1816
|
+
/**
|
|
1817
|
+
* Define a skip.
|
|
1818
|
+
*
|
|
1819
|
+
* As containers (comment lines, block quotes, lists), "nibble" a prefix from
|
|
1820
|
+
* the margins, where a line starts after that prefix can be defined here.
|
|
1821
|
+
*
|
|
1822
|
+
* When the tokenizer moves after consuming a line ending corresponding to
|
|
1823
|
+
* the line number in the given point, the tokenizer shifts past the prefix
|
|
1824
|
+
* based on the column in the shifted point.
|
|
1825
|
+
*
|
|
1826
|
+
* @see {@linkcode DefineSkip}
|
|
1827
|
+
*/
|
|
1828
|
+
defineSkip: DefineSkip$1;
|
|
1829
|
+
/**
|
|
1830
|
+
* The current list of events.
|
|
1831
|
+
*
|
|
1832
|
+
* @see {@linkcode Event}
|
|
1833
|
+
*/
|
|
1834
|
+
events: Event$1[];
|
|
1835
|
+
/**
|
|
1836
|
+
* Whether we're currently interrupting.
|
|
1837
|
+
*
|
|
1838
|
+
* For example:
|
|
1839
|
+
*
|
|
1840
|
+
* ```markdown
|
|
1841
|
+
* a
|
|
1842
|
+
* # b
|
|
1843
|
+
* ```
|
|
1844
|
+
*
|
|
1845
|
+
* At `2:1`, we’re "interrupting".
|
|
1846
|
+
*/
|
|
1847
|
+
interrupt?: boolean | undefined;
|
|
1848
|
+
/**
|
|
1849
|
+
* Whether to error on empty tokens.
|
|
1850
|
+
*
|
|
1851
|
+
* > 👉 **Note**: Error only thrown with `development` export condition.
|
|
1852
|
+
*
|
|
1853
|
+
* @see https://github.com/wooorm/devlop#okvalue-message
|
|
1854
|
+
*/
|
|
1855
|
+
noEmptyTokens?: boolean | undefined;
|
|
1856
|
+
/**
|
|
1857
|
+
* Get the current place in the content.
|
|
1858
|
+
*
|
|
1859
|
+
* @see {@linkcode Now}
|
|
1860
|
+
*/
|
|
1861
|
+
now: Now$1;
|
|
1862
|
+
/**
|
|
1863
|
+
* The relevant parsing context.
|
|
1864
|
+
*
|
|
1865
|
+
* Tokenizers deal with one content type.
|
|
1866
|
+
* The parser is the object dealing with it all.
|
|
1867
|
+
*
|
|
1868
|
+
* @see {@linkcode ParseContext}
|
|
1869
|
+
*/
|
|
1870
|
+
parser: ParseContext$1;
|
|
1871
|
+
/**
|
|
1872
|
+
* The previous character code.
|
|
1873
|
+
*
|
|
1874
|
+
* @see {@linkcode Code}
|
|
1875
|
+
*/
|
|
1876
|
+
previous: Code$1;
|
|
1877
|
+
/**
|
|
1878
|
+
* Get the text that spans a token (or location).
|
|
1879
|
+
*
|
|
1880
|
+
* @see {@linkcode SliceSerialize}
|
|
1881
|
+
*/
|
|
1882
|
+
sliceSerialize: SliceSerialize$1;
|
|
1883
|
+
/**
|
|
1884
|
+
* Get the chunks that span a token (or location).
|
|
1885
|
+
*
|
|
1886
|
+
* @see {@linkcode SliceStream}
|
|
1887
|
+
*/
|
|
1888
|
+
sliceStream: SliceStream$1;
|
|
1889
|
+
/**
|
|
1890
|
+
* Write a slice of chunks.
|
|
1891
|
+
*
|
|
1892
|
+
* The eos code (`null`) can be used to signal the end of the stream.
|
|
1893
|
+
*
|
|
1894
|
+
* @see {@linkcode Write}
|
|
1895
|
+
*/
|
|
1896
|
+
write: Write$1;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* @file Tokenizer
|
|
1901
|
+
* @module docmark-util-types/Tokenizer
|
|
1902
|
+
*/
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* Set up a state machine to handle character codes streaming in.
|
|
1906
|
+
*
|
|
1907
|
+
* @see {@linkcode Effects}
|
|
1908
|
+
* @see {@linkcode State}
|
|
1909
|
+
* @see {@linkcode TokenizeContext}
|
|
1910
|
+
*
|
|
1911
|
+
* @this {TokenizeContext}
|
|
1912
|
+
*
|
|
1913
|
+
* @param {Effects} effects
|
|
1914
|
+
* The context object used to transition the state machine
|
|
1915
|
+
* @param {State} ok
|
|
1916
|
+
* The successful tokenization state
|
|
1917
|
+
* @param {State} nok
|
|
1918
|
+
* The failed tokenization state
|
|
1919
|
+
* @return {State}
|
|
1920
|
+
* The initial state
|
|
1921
|
+
*/
|
|
1922
|
+
type Tokenizer = (this: TokenizeContext$1, effects: Effects$1, ok: State$1, nok: State$1) => State$1;
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* @file Value
|
|
1926
|
+
* @module docmark-util-types/Value
|
|
1927
|
+
*/
|
|
1928
|
+
/**
|
|
1929
|
+
* The contents of a file.
|
|
1930
|
+
*
|
|
1931
|
+
* Can either be text, or a {@linkcode Uint8Array} like structure.
|
|
1932
|
+
*/
|
|
1933
|
+
type Value = Uint8Array | string;
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* @file Write
|
|
1937
|
+
* @module docmark-util-types/Write
|
|
1938
|
+
*/
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Write a slice of chunks.
|
|
1942
|
+
*
|
|
1943
|
+
* The eos code (`null`) can be used to signal end of stream.
|
|
1944
|
+
*
|
|
1945
|
+
* @see {@linkcode Chunk}
|
|
1946
|
+
* @see {@linkcode Event}
|
|
1947
|
+
*
|
|
1948
|
+
* @this {void}
|
|
1949
|
+
*
|
|
1950
|
+
* @param {Chunk[]} slice
|
|
1951
|
+
* The list of chunks to write
|
|
1952
|
+
* @return {Event[]}
|
|
1953
|
+
* The current list of events
|
|
1954
|
+
*/
|
|
1955
|
+
type Write = (this: void, slice: Chunk$1[]) => Event$1[];
|
|
1956
|
+
|
|
1957
|
+
export type { AnyConstruct, AnyExtension, Attempt, AttentionMarkers, Attempt as Check, Chunk, Code, Column, CommentKind, CommentKindMap, Construct, ConstructPack, ConstructPosition, ConstructRecord, Constructs, Consume, ContainerState, ContentType, ContinuableConstruct, Create, DefineSkip, Disable, Effects, Encoding, EncodingMap, Enter, Event, EventType, Exit, Exiter, Extension, FileLike, FinalizeContext, FullNormalizedExtension, InitialConstruct, InitialConstructs, Initializer, InsideSpan, Attempt as Interrupt, Lazy, Line, NamedConstruct, NormalizedExtension, Now, Offset, ParseContext, ParseOptions, PartialConstruct, Place, Point, Position, PreprocessOptions, Preprocess as Preprocessor, Previous, Resolver, SerializeOptions, SliceSerialize, SliceStream, State, Token, TokenFields, TokenType, TokenTypeMap, TokenizeContext, Tokenizer, Value, Write };
|