@isdk/mdast-plus 0.1.2 → 0.2.0

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.
Files changed (43) hide show
  1. package/README.cn.md +69 -22
  2. package/README.md +69 -22
  3. package/dist/index.d.mts +564 -199
  4. package/dist/index.d.ts +564 -199
  5. package/dist/index.js +1 -1
  6. package/dist/index.mjs +1 -1
  7. package/docs/README.md +69 -22
  8. package/docs/_media/CONTRIBUTING.md +53 -24
  9. package/docs/_media/README.cn.md +69 -22
  10. package/docs/classes/MdastBasePipeline.md +416 -0
  11. package/docs/classes/MdastPipeline.md +611 -0
  12. package/docs/enumerations/PipelineStage.md +62 -0
  13. package/docs/functions/astCompiler.md +25 -0
  14. package/docs/functions/jsonParser.md +24 -0
  15. package/docs/functions/mdast.md +4 -4
  16. package/docs/globals.md +17 -10
  17. package/docs/interfaces/MdastDataOrigin.md +8 -8
  18. package/docs/interfaces/MdastFormat.md +71 -0
  19. package/docs/interfaces/MdastMark.md +4 -4
  20. package/docs/interfaces/MdastPlugin.md +57 -25
  21. package/docs/interfaces/MdastSub.md +4 -4
  22. package/docs/interfaces/MdastSup.md +4 -4
  23. package/docs/interfaces/ReadabilityOptions.md +33 -0
  24. package/docs/type-aliases/PipelineStageName.md +13 -0
  25. package/docs/variables/DefaultPipelineStage.md +13 -0
  26. package/docs/variables/astFormat.md +15 -0
  27. package/docs/variables/htmlFormat.md +6 -4
  28. package/docs/variables/htmlReadability.md +13 -0
  29. package/docs/variables/htmlReadabilityPlugin.md +27 -0
  30. package/docs/variables/htmlReadabilityPlugins.md +13 -0
  31. package/docs/variables/markdownFormat.md +6 -4
  32. package/docs/variables/restoreReadabilityMetaPlugin.md +49 -0
  33. package/package.json +18 -9
  34. package/docs/classes/FluentProcessor.md +0 -210
  35. package/docs/functions/htmlStringify.md +0 -23
  36. package/docs/functions/markdownCommon.md +0 -23
  37. package/docs/interfaces/ConvertResult.md +0 -39
  38. package/docs/interfaces/MdastAsset.md +0 -41
  39. package/docs/interfaces/MdastFormatDefinition.md +0 -51
  40. package/docs/interfaces/MdastReader.md +0 -41
  41. package/docs/interfaces/MdastTransformer.md +0 -33
  42. package/docs/interfaces/MdastWriter.md +0 -47
  43. package/docs/type-aliases/Stage.md +0 -13
@@ -0,0 +1,416 @@
1
+ [**@isdk/mdast-plus**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/mdast-plus](../globals.md) / MdastBasePipeline
6
+
7
+ # Class: MdastBasePipeline
8
+
9
+ Defined in: [packages/mdast-plus/src/pipeline.ts:26](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L26)
10
+
11
+ Base implementation of the fluent mdast processing pipeline.
12
+ Manages the plugin registry and the execution queue.
13
+
14
+ ## Extended by
15
+
16
+ - [`MdastPipeline`](MdastPipeline.md)
17
+
18
+ ## Constructors
19
+
20
+ ### Constructor
21
+
22
+ > **new MdastBasePipeline**(`input`): `MdastBasePipeline`
23
+
24
+ Defined in: [packages/mdast-plus/src/pipeline.ts:54](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L54)
25
+
26
+ Initializes a new pipeline instance with the given input.
27
+
28
+ #### Parameters
29
+
30
+ ##### input
31
+
32
+ `Compatible`
33
+
34
+ Content to process (string, Buffer, VFile, or AST Node).
35
+
36
+ #### Returns
37
+
38
+ `MdastBasePipeline`
39
+
40
+ ## Properties
41
+
42
+ ### \_data
43
+
44
+ > `protected` **\_data**: `Record`\<`string`, `any`\> = `{}`
45
+
46
+ Defined in: [packages/mdast-plus/src/pipeline.ts:48](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L48)
47
+
48
+ ***
49
+
50
+ ### input
51
+
52
+ > `protected` **input**: `Compatible`
53
+
54
+ Defined in: [packages/mdast-plus/src/pipeline.ts:46](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L46)
55
+
56
+ ***
57
+
58
+ ### queue
59
+
60
+ > `protected` **queue**: [`MdastPlugin`](../interfaces/MdastPlugin.md)[] = `[]`
61
+
62
+ Defined in: [packages/mdast-plus/src/pipeline.ts:47](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L47)
63
+
64
+ ## Methods
65
+
66
+ ### assembleProcessor()
67
+
68
+ > `protected` **assembleProcessor**(`queue`): `Processor`
69
+
70
+ Defined in: [packages/mdast-plus/src/pipeline.ts:326](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L326)
71
+
72
+ Assembles a unified processor based on the sorted plugin queue.
73
+
74
+ #### Parameters
75
+
76
+ ##### queue
77
+
78
+ [`MdastPlugin`](../interfaces/MdastPlugin.md)[]
79
+
80
+ #### Returns
81
+
82
+ `Processor`
83
+
84
+ ***
85
+
86
+ ### data()
87
+
88
+ > **data**(`key`, `value?`): `this`
89
+
90
+ Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L64)
91
+
92
+ Configures global data for the pipeline, which will be available to all plugins via this.data().
93
+
94
+ #### Parameters
95
+
96
+ ##### key
97
+
98
+ Data key or a record of multiple data entries.
99
+
100
+ `string` | `Record`\<`string`, `any`\>
101
+
102
+ ##### value?
103
+
104
+ `any`
105
+
106
+ Value to set (if key is a string).
107
+
108
+ #### Returns
109
+
110
+ `this`
111
+
112
+ The pipeline instance for chaining.
113
+
114
+ ***
115
+
116
+ ### ensureInputPlugins()
117
+
118
+ > `protected` **ensureInputPlugins**(`queue`, `overrides?`, `maxStage?`): `void`
119
+
120
+ Defined in: [packages/mdast-plus/src/pipeline.ts:149](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L149)
121
+
122
+ Ensures that input plugins (parser, normalizers) are present in the queue.
123
+ Adds implicit plugins if no parser is detected.
124
+
125
+ #### Parameters
126
+
127
+ ##### queue
128
+
129
+ [`MdastPlugin`](../interfaces/MdastPlugin.md)[]
130
+
131
+ ##### overrides?
132
+
133
+ `Record`\<`string`, `any`\>
134
+
135
+ ##### maxStage?
136
+
137
+ [`PipelineStage`](../enumerations/PipelineStage.md) = `PipelineStage.stringify`
138
+
139
+ #### Returns
140
+
141
+ `void`
142
+
143
+ ***
144
+
145
+ ### from()
146
+
147
+ > **from**(`fmt`, `overrides?`): `this`
148
+
149
+ Defined in: [packages/mdast-plus/src/pipeline.ts:178](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L178)
150
+
151
+ Configures the input format and adds its associated plugins to the pipeline.
152
+
153
+ #### Parameters
154
+
155
+ ##### fmt
156
+
157
+ Format ID or definition.
158
+
159
+ `string` | [`MdastFormat`](../interfaces/MdastFormat.md)
160
+
161
+ ##### overrides?
162
+
163
+ `Record`\<`string`, `any`\>
164
+
165
+ Optional map to override plugin options by plugin name.
166
+
167
+ #### Returns
168
+
169
+ `this`
170
+
171
+ The pipeline instance for chaining.
172
+
173
+ ***
174
+
175
+ ### getFormat()
176
+
177
+ > **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
178
+
179
+ Defined in: [packages/mdast-plus/src/pipeline.ts:76](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L76)
180
+
181
+ Instance-level access to the global format registry.
182
+
183
+ #### Parameters
184
+
185
+ ##### id
186
+
187
+ `string`
188
+
189
+ #### Returns
190
+
191
+ `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
192
+
193
+ ***
194
+
195
+ ### priority()
196
+
197
+ > **priority**(`order`): `this`
198
+
199
+ Defined in: [packages/mdast-plus/src/pipeline.ts:314](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L314)
200
+
201
+ Sets the priority order for the most recently added plugin.
202
+ Plugins with lower order run earlier within the same stage.
203
+
204
+ #### Parameters
205
+
206
+ ##### order
207
+
208
+ `number`
209
+
210
+ Numeric priority.
211
+
212
+ #### Returns
213
+
214
+ `this`
215
+
216
+ The pipeline instance for chaining.
217
+
218
+ ***
219
+
220
+ ### to()
221
+
222
+ > **to**(`fmt`, `overrides?`): `Promise`\<`VFile`\>
223
+
224
+ Defined in: [packages/mdast-plus/src/pipeline.ts:198](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L198)
225
+
226
+ Processes the pipeline and serializes the result into the specified format.
227
+
228
+ #### Parameters
229
+
230
+ ##### fmt
231
+
232
+ Target format ID or definition.
233
+
234
+ `string` | [`MdastFormat`](../interfaces/MdastFormat.md)
235
+
236
+ ##### overrides?
237
+
238
+ `Record`\<`string`, `any`\>
239
+
240
+ Optional map to override plugin options.
241
+
242
+ #### Returns
243
+
244
+ `Promise`\<`VFile`\>
245
+
246
+ A promise resolving to a VFile containing the result.
247
+
248
+ ***
249
+
250
+ ### toRuntimeEntry()
251
+
252
+ > `protected` **toRuntimeEntry**(`entry`, `defaultStage`, `overrides?`): [`MdastPlugin`](../interfaces/MdastPlugin.md) & `object`
253
+
254
+ Defined in: [packages/mdast-plus/src/pipeline.ts:100](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L100)
255
+
256
+ Normalizes a plugin entry for runtime execution.
257
+
258
+ #### Parameters
259
+
260
+ ##### entry
261
+
262
+ [`MdastPlugin`](../interfaces/MdastPlugin.md)
263
+
264
+ ##### defaultStage
265
+
266
+ [`PipelineStage`](../enumerations/PipelineStage.md)
267
+
268
+ ##### overrides?
269
+
270
+ `Record`\<`string`, `any`\>
271
+
272
+ #### Returns
273
+
274
+ [`MdastPlugin`](../interfaces/MdastPlugin.md) & `object`
275
+
276
+ ***
277
+
278
+ ### use()
279
+
280
+ > **use**(`plugin`, ...`options`): `this`
281
+
282
+ Defined in: [packages/mdast-plus/src/pipeline.ts:241](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L241)
283
+
284
+ Adds a plugin or an array of plugins to the pipeline's compile stage.
285
+
286
+ #### Parameters
287
+
288
+ ##### plugin
289
+
290
+ The unified plugin function, a MdastPlugin object, or an array of them.
291
+
292
+ [`MdastPlugin`](../interfaces/MdastPlugin.md) | `Plugin` | ([`MdastPlugin`](../interfaces/MdastPlugin.md) \| `Plugin`)[]
293
+
294
+ ##### options
295
+
296
+ ...`any`[]
297
+
298
+ Arguments for the plugin(s).
299
+
300
+ #### Returns
301
+
302
+ `this`
303
+
304
+ The pipeline instance for chaining.
305
+
306
+ ***
307
+
308
+ ### useAt()
309
+
310
+ #### Call Signature
311
+
312
+ > **useAt**(`stage`, `plugin`, ...`options`): `this`
313
+
314
+ Defined in: [packages/mdast-plus/src/pipeline.ts:252](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L252)
315
+
316
+ Adds a plugin or an array of plugins to the pipeline at a specific stage.
317
+
318
+ ##### Parameters
319
+
320
+ ###### stage
321
+
322
+ The stage name or numeric value.
323
+
324
+ `"parse"` | `"normalize"` | `"compile"` | `"finalize"` | `"stringify"`
325
+
326
+ ###### plugin
327
+
328
+ The unified plugin function, a MdastPlugin object, or an array of them.
329
+
330
+ [`MdastPlugin`](../interfaces/MdastPlugin.md) | `Plugin` | ([`MdastPlugin`](../interfaces/MdastPlugin.md) \| `Plugin`)[]
331
+
332
+ ###### options
333
+
334
+ ...`any`[]
335
+
336
+ Arguments for the plugin(s).
337
+
338
+ ##### Returns
339
+
340
+ `this`
341
+
342
+ The pipeline instance for chaining.
343
+
344
+ #### Call Signature
345
+
346
+ > **useAt**(`plugin`, ...`options`): `this`
347
+
348
+ Defined in: [packages/mdast-plus/src/pipeline.ts:259](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L259)
349
+
350
+ Adds a plugin or an array of plugins to the pipeline. The stage is taken from the plugin object(s).
351
+
352
+ ##### Parameters
353
+
354
+ ###### plugin
355
+
356
+ The MdastPlugin object or an array of them.
357
+
358
+ [`MdastPlugin`](../interfaces/MdastPlugin.md) | ([`MdastPlugin`](../interfaces/MdastPlugin.md) \| `Plugin`)[]
359
+
360
+ ###### options
361
+
362
+ ...`any`[]
363
+
364
+ Arguments for the plugin(s) (overrides plugin.options if provided).
365
+
366
+ ##### Returns
367
+
368
+ `this`
369
+
370
+ The pipeline instance for chaining.
371
+
372
+ ***
373
+
374
+ ### getFormat()
375
+
376
+ > `static` **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
377
+
378
+ Defined in: [packages/mdast-plus/src/pipeline.ts:42](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L42)
379
+
380
+ Retrieves a registered format by its ID.
381
+
382
+ #### Parameters
383
+
384
+ ##### id
385
+
386
+ `string`
387
+
388
+ The format identifier.
389
+
390
+ #### Returns
391
+
392
+ `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
393
+
394
+ The format definition or undefined if not found.
395
+
396
+ ***
397
+
398
+ ### register()
399
+
400
+ > `static` **register**(`format`): `void`
401
+
402
+ Defined in: [packages/mdast-plus/src/pipeline.ts:33](https://github.com/isdk/mdast-plus.js/blob/8870eec4ef97dd48bead818813d06479ceff9450/src/pipeline.ts#L33)
403
+
404
+ Registers a global document format.
405
+
406
+ #### Parameters
407
+
408
+ ##### format
409
+
410
+ [`MdastFormat`](../interfaces/MdastFormat.md)
411
+
412
+ The format definition to register.
413
+
414
+ #### Returns
415
+
416
+ `void`