@f-o-t/markdown 1.0.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.
- package/README.md +305 -0
- package/dist/index.d.ts +1452 -0
- package/dist/index.js +3512 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1452 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Default maximum buffer size (10MB) to prevent memory exhaustion attacks.
|
|
4
|
+
*/
|
|
5
|
+
declare const DEFAULT_MAX_BUFFER_SIZE: number;
|
|
6
|
+
/**
|
|
7
|
+
* Source position for a node in the original markdown.
|
|
8
|
+
*/
|
|
9
|
+
declare const positionSchema: z.ZodObject<{
|
|
10
|
+
startLine: z.ZodNumber;
|
|
11
|
+
startColumn: z.ZodNumber;
|
|
12
|
+
endLine: z.ZodNumber;
|
|
13
|
+
endColumn: z.ZodNumber;
|
|
14
|
+
startOffset: z.ZodNumber;
|
|
15
|
+
endOffset: z.ZodNumber;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type Position = z.infer<typeof positionSchema>;
|
|
18
|
+
interface TextNode {
|
|
19
|
+
type: "text";
|
|
20
|
+
value: string;
|
|
21
|
+
position?: Position;
|
|
22
|
+
}
|
|
23
|
+
interface CodeSpanNode {
|
|
24
|
+
type: "codeSpan";
|
|
25
|
+
value: string;
|
|
26
|
+
position?: Position;
|
|
27
|
+
}
|
|
28
|
+
interface HardBreakNode {
|
|
29
|
+
type: "hardBreak";
|
|
30
|
+
position?: Position;
|
|
31
|
+
}
|
|
32
|
+
interface SoftBreakNode {
|
|
33
|
+
type: "softBreak";
|
|
34
|
+
position?: Position;
|
|
35
|
+
}
|
|
36
|
+
interface HtmlInlineNode {
|
|
37
|
+
type: "htmlInline";
|
|
38
|
+
value: string;
|
|
39
|
+
position?: Position;
|
|
40
|
+
}
|
|
41
|
+
interface EmphasisNode {
|
|
42
|
+
type: "emphasis";
|
|
43
|
+
children: InlineNode[];
|
|
44
|
+
marker: "*" | "_";
|
|
45
|
+
position?: Position;
|
|
46
|
+
}
|
|
47
|
+
interface StrongNode {
|
|
48
|
+
type: "strong";
|
|
49
|
+
children: InlineNode[];
|
|
50
|
+
marker: "**" | "__";
|
|
51
|
+
position?: Position;
|
|
52
|
+
}
|
|
53
|
+
interface LinkNode {
|
|
54
|
+
type: "link";
|
|
55
|
+
url: string;
|
|
56
|
+
children: InlineNode[];
|
|
57
|
+
title?: string;
|
|
58
|
+
reference?: string;
|
|
59
|
+
position?: Position;
|
|
60
|
+
}
|
|
61
|
+
interface ImageNode {
|
|
62
|
+
type: "image";
|
|
63
|
+
alt: string;
|
|
64
|
+
url: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
reference?: string;
|
|
67
|
+
position?: Position;
|
|
68
|
+
}
|
|
69
|
+
type InlineNode = TextNode | CodeSpanNode | HardBreakNode | SoftBreakNode | HtmlInlineNode | EmphasisNode | StrongNode | LinkNode | ImageNode;
|
|
70
|
+
interface ThematicBreakNode {
|
|
71
|
+
type: "thematicBreak";
|
|
72
|
+
marker: "-" | "*" | "_";
|
|
73
|
+
position?: Position;
|
|
74
|
+
}
|
|
75
|
+
interface HeadingNode {
|
|
76
|
+
type: "heading";
|
|
77
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
78
|
+
children: InlineNode[];
|
|
79
|
+
style: "atx" | "setext";
|
|
80
|
+
position?: Position;
|
|
81
|
+
}
|
|
82
|
+
interface CodeBlockNode {
|
|
83
|
+
type: "codeBlock";
|
|
84
|
+
value: string;
|
|
85
|
+
style: "fenced" | "indented";
|
|
86
|
+
lang?: string;
|
|
87
|
+
meta?: string;
|
|
88
|
+
fence?: "`" | "~";
|
|
89
|
+
fenceLength?: number;
|
|
90
|
+
position?: Position;
|
|
91
|
+
}
|
|
92
|
+
interface HtmlBlockNode {
|
|
93
|
+
type: "htmlBlock";
|
|
94
|
+
value: string;
|
|
95
|
+
htmlType: number;
|
|
96
|
+
position?: Position;
|
|
97
|
+
}
|
|
98
|
+
interface ParagraphNode {
|
|
99
|
+
type: "paragraph";
|
|
100
|
+
children: InlineNode[];
|
|
101
|
+
position?: Position;
|
|
102
|
+
}
|
|
103
|
+
interface LinkReferenceDefinitionNode {
|
|
104
|
+
type: "linkReferenceDefinition";
|
|
105
|
+
label: string;
|
|
106
|
+
url: string;
|
|
107
|
+
title?: string;
|
|
108
|
+
position?: Position;
|
|
109
|
+
}
|
|
110
|
+
interface BlockquoteNode {
|
|
111
|
+
type: "blockquote";
|
|
112
|
+
children: BlockNode2[];
|
|
113
|
+
position?: Position;
|
|
114
|
+
}
|
|
115
|
+
interface ListItemNode {
|
|
116
|
+
type: "listItem";
|
|
117
|
+
children: BlockNode2[];
|
|
118
|
+
marker: "-" | "*" | "+" | ")" | ".";
|
|
119
|
+
spread: boolean;
|
|
120
|
+
checked?: boolean;
|
|
121
|
+
position?: Position;
|
|
122
|
+
}
|
|
123
|
+
interface ListNode {
|
|
124
|
+
type: "list";
|
|
125
|
+
ordered: boolean;
|
|
126
|
+
start?: number;
|
|
127
|
+
spread: boolean;
|
|
128
|
+
marker: "-" | "*" | "+" | ")" | ".";
|
|
129
|
+
children: ListItemNode[];
|
|
130
|
+
position?: Position;
|
|
131
|
+
}
|
|
132
|
+
interface TableCellNode {
|
|
133
|
+
type: "tableCell";
|
|
134
|
+
children: InlineNode[];
|
|
135
|
+
align?: "left" | "center" | "right";
|
|
136
|
+
isHeader: boolean;
|
|
137
|
+
position?: Position;
|
|
138
|
+
}
|
|
139
|
+
interface TableRowNode {
|
|
140
|
+
type: "tableRow";
|
|
141
|
+
children: TableCellNode[];
|
|
142
|
+
isHeader: boolean;
|
|
143
|
+
position?: Position;
|
|
144
|
+
}
|
|
145
|
+
interface TableNode {
|
|
146
|
+
type: "table";
|
|
147
|
+
children: TableRowNode[];
|
|
148
|
+
align: Array<"left" | "center" | "right" | null>;
|
|
149
|
+
position?: Position;
|
|
150
|
+
}
|
|
151
|
+
type BlockNode2 = ThematicBreakNode | HeadingNode | CodeBlockNode | HtmlBlockNode | ParagraphNode | LinkReferenceDefinitionNode | BlockquoteNode | ListItemNode | ListNode | TableNode;
|
|
152
|
+
interface DocumentNode {
|
|
153
|
+
type: "document";
|
|
154
|
+
children: BlockNode2[];
|
|
155
|
+
references?: Record<string, {
|
|
156
|
+
type: "linkReferenceDefinition";
|
|
157
|
+
label: string;
|
|
158
|
+
url: string;
|
|
159
|
+
title?: string;
|
|
160
|
+
position?: Position;
|
|
161
|
+
}>;
|
|
162
|
+
position?: Position;
|
|
163
|
+
}
|
|
164
|
+
interface MarkdownDocument {
|
|
165
|
+
root: DocumentNode;
|
|
166
|
+
lineEnding: "\n" | "\r\n";
|
|
167
|
+
source?: string;
|
|
168
|
+
}
|
|
169
|
+
declare const textNodeSchema: z.ZodObject<{
|
|
170
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
171
|
+
startLine: z.ZodNumber;
|
|
172
|
+
startColumn: z.ZodNumber;
|
|
173
|
+
endLine: z.ZodNumber;
|
|
174
|
+
endColumn: z.ZodNumber;
|
|
175
|
+
startOffset: z.ZodNumber;
|
|
176
|
+
endOffset: z.ZodNumber;
|
|
177
|
+
}, z.core.$strip>>;
|
|
178
|
+
type: z.ZodLiteral<"text">;
|
|
179
|
+
value: z.ZodString;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
declare const codeSpanNodeSchema: z.ZodObject<{
|
|
182
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
183
|
+
startLine: z.ZodNumber;
|
|
184
|
+
startColumn: z.ZodNumber;
|
|
185
|
+
endLine: z.ZodNumber;
|
|
186
|
+
endColumn: z.ZodNumber;
|
|
187
|
+
startOffset: z.ZodNumber;
|
|
188
|
+
endOffset: z.ZodNumber;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
type: z.ZodLiteral<"codeSpan">;
|
|
191
|
+
value: z.ZodString;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
declare const hardBreakNodeSchema: z.ZodObject<{
|
|
194
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
195
|
+
startLine: z.ZodNumber;
|
|
196
|
+
startColumn: z.ZodNumber;
|
|
197
|
+
endLine: z.ZodNumber;
|
|
198
|
+
endColumn: z.ZodNumber;
|
|
199
|
+
startOffset: z.ZodNumber;
|
|
200
|
+
endOffset: z.ZodNumber;
|
|
201
|
+
}, z.core.$strip>>;
|
|
202
|
+
type: z.ZodLiteral<"hardBreak">;
|
|
203
|
+
}, z.core.$strip>;
|
|
204
|
+
declare const softBreakNodeSchema: z.ZodObject<{
|
|
205
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
206
|
+
startLine: z.ZodNumber;
|
|
207
|
+
startColumn: z.ZodNumber;
|
|
208
|
+
endLine: z.ZodNumber;
|
|
209
|
+
endColumn: z.ZodNumber;
|
|
210
|
+
startOffset: z.ZodNumber;
|
|
211
|
+
endOffset: z.ZodNumber;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
type: z.ZodLiteral<"softBreak">;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
declare const htmlInlineNodeSchema: z.ZodObject<{
|
|
216
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
217
|
+
startLine: z.ZodNumber;
|
|
218
|
+
startColumn: z.ZodNumber;
|
|
219
|
+
endLine: z.ZodNumber;
|
|
220
|
+
endColumn: z.ZodNumber;
|
|
221
|
+
startOffset: z.ZodNumber;
|
|
222
|
+
endOffset: z.ZodNumber;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
type: z.ZodLiteral<"htmlInline">;
|
|
225
|
+
value: z.ZodString;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
declare const emphasisNodeSchema: z.ZodObject<{
|
|
228
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
229
|
+
startLine: z.ZodNumber;
|
|
230
|
+
startColumn: z.ZodNumber;
|
|
231
|
+
endLine: z.ZodNumber;
|
|
232
|
+
endColumn: z.ZodNumber;
|
|
233
|
+
startOffset: z.ZodNumber;
|
|
234
|
+
endOffset: z.ZodNumber;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
type: z.ZodLiteral<"emphasis">;
|
|
237
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
238
|
+
marker: z.ZodEnum<{
|
|
239
|
+
"*": "*";
|
|
240
|
+
_: "_";
|
|
241
|
+
}>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
declare const strongNodeSchema: z.ZodObject<{
|
|
244
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
245
|
+
startLine: z.ZodNumber;
|
|
246
|
+
startColumn: z.ZodNumber;
|
|
247
|
+
endLine: z.ZodNumber;
|
|
248
|
+
endColumn: z.ZodNumber;
|
|
249
|
+
startOffset: z.ZodNumber;
|
|
250
|
+
endOffset: z.ZodNumber;
|
|
251
|
+
}, z.core.$strip>>;
|
|
252
|
+
type: z.ZodLiteral<"strong">;
|
|
253
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
254
|
+
marker: z.ZodEnum<{
|
|
255
|
+
"**": "**";
|
|
256
|
+
__: "__";
|
|
257
|
+
}>;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
declare const linkNodeSchema: z.ZodObject<{
|
|
260
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
261
|
+
startLine: z.ZodNumber;
|
|
262
|
+
startColumn: z.ZodNumber;
|
|
263
|
+
endLine: z.ZodNumber;
|
|
264
|
+
endColumn: z.ZodNumber;
|
|
265
|
+
startOffset: z.ZodNumber;
|
|
266
|
+
endOffset: z.ZodNumber;
|
|
267
|
+
}, z.core.$strip>>;
|
|
268
|
+
type: z.ZodLiteral<"link">;
|
|
269
|
+
url: z.ZodString;
|
|
270
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
271
|
+
title: z.ZodOptional<z.ZodString>;
|
|
272
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
declare const imageNodeSchema: z.ZodObject<{
|
|
275
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
276
|
+
startLine: z.ZodNumber;
|
|
277
|
+
startColumn: z.ZodNumber;
|
|
278
|
+
endLine: z.ZodNumber;
|
|
279
|
+
endColumn: z.ZodNumber;
|
|
280
|
+
startOffset: z.ZodNumber;
|
|
281
|
+
endOffset: z.ZodNumber;
|
|
282
|
+
}, z.core.$strip>>;
|
|
283
|
+
type: z.ZodLiteral<"image">;
|
|
284
|
+
alt: z.ZodString;
|
|
285
|
+
url: z.ZodString;
|
|
286
|
+
title: z.ZodOptional<z.ZodString>;
|
|
287
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
declare const inlineNodeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
290
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
291
|
+
startLine: z.ZodNumber;
|
|
292
|
+
startColumn: z.ZodNumber;
|
|
293
|
+
endLine: z.ZodNumber;
|
|
294
|
+
endColumn: z.ZodNumber;
|
|
295
|
+
startOffset: z.ZodNumber;
|
|
296
|
+
endOffset: z.ZodNumber;
|
|
297
|
+
}, z.core.$strip>>;
|
|
298
|
+
type: z.ZodLiteral<"text">;
|
|
299
|
+
value: z.ZodString;
|
|
300
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
301
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
302
|
+
startLine: z.ZodNumber;
|
|
303
|
+
startColumn: z.ZodNumber;
|
|
304
|
+
endLine: z.ZodNumber;
|
|
305
|
+
endColumn: z.ZodNumber;
|
|
306
|
+
startOffset: z.ZodNumber;
|
|
307
|
+
endOffset: z.ZodNumber;
|
|
308
|
+
}, z.core.$strip>>;
|
|
309
|
+
type: z.ZodLiteral<"codeSpan">;
|
|
310
|
+
value: z.ZodString;
|
|
311
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
312
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
313
|
+
startLine: z.ZodNumber;
|
|
314
|
+
startColumn: z.ZodNumber;
|
|
315
|
+
endLine: z.ZodNumber;
|
|
316
|
+
endColumn: z.ZodNumber;
|
|
317
|
+
startOffset: z.ZodNumber;
|
|
318
|
+
endOffset: z.ZodNumber;
|
|
319
|
+
}, z.core.$strip>>;
|
|
320
|
+
type: z.ZodLiteral<"hardBreak">;
|
|
321
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
322
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
323
|
+
startLine: z.ZodNumber;
|
|
324
|
+
startColumn: z.ZodNumber;
|
|
325
|
+
endLine: z.ZodNumber;
|
|
326
|
+
endColumn: z.ZodNumber;
|
|
327
|
+
startOffset: z.ZodNumber;
|
|
328
|
+
endOffset: z.ZodNumber;
|
|
329
|
+
}, z.core.$strip>>;
|
|
330
|
+
type: z.ZodLiteral<"softBreak">;
|
|
331
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
332
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
333
|
+
startLine: z.ZodNumber;
|
|
334
|
+
startColumn: z.ZodNumber;
|
|
335
|
+
endLine: z.ZodNumber;
|
|
336
|
+
endColumn: z.ZodNumber;
|
|
337
|
+
startOffset: z.ZodNumber;
|
|
338
|
+
endOffset: z.ZodNumber;
|
|
339
|
+
}, z.core.$strip>>;
|
|
340
|
+
type: z.ZodLiteral<"htmlInline">;
|
|
341
|
+
value: z.ZodString;
|
|
342
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
343
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
344
|
+
startLine: z.ZodNumber;
|
|
345
|
+
startColumn: z.ZodNumber;
|
|
346
|
+
endLine: z.ZodNumber;
|
|
347
|
+
endColumn: z.ZodNumber;
|
|
348
|
+
startOffset: z.ZodNumber;
|
|
349
|
+
endOffset: z.ZodNumber;
|
|
350
|
+
}, z.core.$strip>>;
|
|
351
|
+
type: z.ZodLiteral<"emphasis">;
|
|
352
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
353
|
+
marker: z.ZodEnum<{
|
|
354
|
+
"*": "*";
|
|
355
|
+
_: "_";
|
|
356
|
+
}>;
|
|
357
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
358
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
359
|
+
startLine: z.ZodNumber;
|
|
360
|
+
startColumn: z.ZodNumber;
|
|
361
|
+
endLine: z.ZodNumber;
|
|
362
|
+
endColumn: z.ZodNumber;
|
|
363
|
+
startOffset: z.ZodNumber;
|
|
364
|
+
endOffset: z.ZodNumber;
|
|
365
|
+
}, z.core.$strip>>;
|
|
366
|
+
type: z.ZodLiteral<"strong">;
|
|
367
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
368
|
+
marker: z.ZodEnum<{
|
|
369
|
+
"**": "**";
|
|
370
|
+
__: "__";
|
|
371
|
+
}>;
|
|
372
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
373
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
374
|
+
startLine: z.ZodNumber;
|
|
375
|
+
startColumn: z.ZodNumber;
|
|
376
|
+
endLine: z.ZodNumber;
|
|
377
|
+
endColumn: z.ZodNumber;
|
|
378
|
+
startOffset: z.ZodNumber;
|
|
379
|
+
endOffset: z.ZodNumber;
|
|
380
|
+
}, z.core.$strip>>;
|
|
381
|
+
type: z.ZodLiteral<"link">;
|
|
382
|
+
url: z.ZodString;
|
|
383
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
384
|
+
title: z.ZodOptional<z.ZodString>;
|
|
385
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
386
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
387
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
388
|
+
startLine: z.ZodNumber;
|
|
389
|
+
startColumn: z.ZodNumber;
|
|
390
|
+
endLine: z.ZodNumber;
|
|
391
|
+
endColumn: z.ZodNumber;
|
|
392
|
+
startOffset: z.ZodNumber;
|
|
393
|
+
endOffset: z.ZodNumber;
|
|
394
|
+
}, z.core.$strip>>;
|
|
395
|
+
type: z.ZodLiteral<"image">;
|
|
396
|
+
alt: z.ZodString;
|
|
397
|
+
url: z.ZodString;
|
|
398
|
+
title: z.ZodOptional<z.ZodString>;
|
|
399
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
400
|
+
}, z.core.$strip>]>;
|
|
401
|
+
declare const thematicBreakNodeSchema: z.ZodObject<{
|
|
402
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
403
|
+
startLine: z.ZodNumber;
|
|
404
|
+
startColumn: z.ZodNumber;
|
|
405
|
+
endLine: z.ZodNumber;
|
|
406
|
+
endColumn: z.ZodNumber;
|
|
407
|
+
startOffset: z.ZodNumber;
|
|
408
|
+
endOffset: z.ZodNumber;
|
|
409
|
+
}, z.core.$strip>>;
|
|
410
|
+
type: z.ZodLiteral<"thematicBreak">;
|
|
411
|
+
marker: z.ZodEnum<{
|
|
412
|
+
"*": "*";
|
|
413
|
+
_: "_";
|
|
414
|
+
"-": "-";
|
|
415
|
+
}>;
|
|
416
|
+
}, z.core.$strip>;
|
|
417
|
+
declare const headingNodeSchema: z.ZodObject<{
|
|
418
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
419
|
+
startLine: z.ZodNumber;
|
|
420
|
+
startColumn: z.ZodNumber;
|
|
421
|
+
endLine: z.ZodNumber;
|
|
422
|
+
endColumn: z.ZodNumber;
|
|
423
|
+
startOffset: z.ZodNumber;
|
|
424
|
+
endOffset: z.ZodNumber;
|
|
425
|
+
}, z.core.$strip>>;
|
|
426
|
+
type: z.ZodLiteral<"heading">;
|
|
427
|
+
level: z.ZodNumber;
|
|
428
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
429
|
+
style: z.ZodEnum<{
|
|
430
|
+
atx: "atx";
|
|
431
|
+
setext: "setext";
|
|
432
|
+
}>;
|
|
433
|
+
}, z.core.$strip>;
|
|
434
|
+
declare const codeBlockNodeSchema: z.ZodObject<{
|
|
435
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
436
|
+
startLine: z.ZodNumber;
|
|
437
|
+
startColumn: z.ZodNumber;
|
|
438
|
+
endLine: z.ZodNumber;
|
|
439
|
+
endColumn: z.ZodNumber;
|
|
440
|
+
startOffset: z.ZodNumber;
|
|
441
|
+
endOffset: z.ZodNumber;
|
|
442
|
+
}, z.core.$strip>>;
|
|
443
|
+
type: z.ZodLiteral<"codeBlock">;
|
|
444
|
+
value: z.ZodString;
|
|
445
|
+
style: z.ZodEnum<{
|
|
446
|
+
fenced: "fenced";
|
|
447
|
+
indented: "indented";
|
|
448
|
+
}>;
|
|
449
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
450
|
+
meta: z.ZodOptional<z.ZodString>;
|
|
451
|
+
fence: z.ZodOptional<z.ZodEnum<{
|
|
452
|
+
"`": "`";
|
|
453
|
+
"~": "~";
|
|
454
|
+
}>>;
|
|
455
|
+
fenceLength: z.ZodOptional<z.ZodNumber>;
|
|
456
|
+
}, z.core.$strip>;
|
|
457
|
+
declare const htmlBlockNodeSchema: z.ZodObject<{
|
|
458
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
459
|
+
startLine: z.ZodNumber;
|
|
460
|
+
startColumn: z.ZodNumber;
|
|
461
|
+
endLine: z.ZodNumber;
|
|
462
|
+
endColumn: z.ZodNumber;
|
|
463
|
+
startOffset: z.ZodNumber;
|
|
464
|
+
endOffset: z.ZodNumber;
|
|
465
|
+
}, z.core.$strip>>;
|
|
466
|
+
type: z.ZodLiteral<"htmlBlock">;
|
|
467
|
+
value: z.ZodString;
|
|
468
|
+
htmlType: z.ZodNumber;
|
|
469
|
+
}, z.core.$strip>;
|
|
470
|
+
declare const paragraphNodeSchema: z.ZodObject<{
|
|
471
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
472
|
+
startLine: z.ZodNumber;
|
|
473
|
+
startColumn: z.ZodNumber;
|
|
474
|
+
endLine: z.ZodNumber;
|
|
475
|
+
endColumn: z.ZodNumber;
|
|
476
|
+
startOffset: z.ZodNumber;
|
|
477
|
+
endOffset: z.ZodNumber;
|
|
478
|
+
}, z.core.$strip>>;
|
|
479
|
+
type: z.ZodLiteral<"paragraph">;
|
|
480
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
481
|
+
}, z.core.$strip>;
|
|
482
|
+
declare const linkReferenceDefinitionSchema: z.ZodObject<{
|
|
483
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
484
|
+
startLine: z.ZodNumber;
|
|
485
|
+
startColumn: z.ZodNumber;
|
|
486
|
+
endLine: z.ZodNumber;
|
|
487
|
+
endColumn: z.ZodNumber;
|
|
488
|
+
startOffset: z.ZodNumber;
|
|
489
|
+
endOffset: z.ZodNumber;
|
|
490
|
+
}, z.core.$strip>>;
|
|
491
|
+
type: z.ZodLiteral<"linkReferenceDefinition">;
|
|
492
|
+
label: z.ZodString;
|
|
493
|
+
url: z.ZodString;
|
|
494
|
+
title: z.ZodOptional<z.ZodString>;
|
|
495
|
+
}, z.core.$strip>;
|
|
496
|
+
declare const blockquoteNodeSchema: z.ZodObject<{
|
|
497
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
498
|
+
startLine: z.ZodNumber;
|
|
499
|
+
startColumn: z.ZodNumber;
|
|
500
|
+
endLine: z.ZodNumber;
|
|
501
|
+
endColumn: z.ZodNumber;
|
|
502
|
+
startOffset: z.ZodNumber;
|
|
503
|
+
endOffset: z.ZodNumber;
|
|
504
|
+
}, z.core.$strip>>;
|
|
505
|
+
type: z.ZodLiteral<"blockquote">;
|
|
506
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
507
|
+
}, z.core.$strip>;
|
|
508
|
+
declare const listItemNodeSchema: z.ZodObject<{
|
|
509
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
510
|
+
startLine: z.ZodNumber;
|
|
511
|
+
startColumn: z.ZodNumber;
|
|
512
|
+
endLine: z.ZodNumber;
|
|
513
|
+
endColumn: z.ZodNumber;
|
|
514
|
+
startOffset: z.ZodNumber;
|
|
515
|
+
endOffset: z.ZodNumber;
|
|
516
|
+
}, z.core.$strip>>;
|
|
517
|
+
type: z.ZodLiteral<"listItem">;
|
|
518
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
519
|
+
marker: z.ZodEnum<{
|
|
520
|
+
"*": "*";
|
|
521
|
+
"-": "-";
|
|
522
|
+
"+": "+";
|
|
523
|
+
")": ")";
|
|
524
|
+
".": ".";
|
|
525
|
+
}>;
|
|
526
|
+
spread: z.ZodBoolean;
|
|
527
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
528
|
+
}, z.core.$strip>;
|
|
529
|
+
declare const listNodeSchema: z.ZodObject<{
|
|
530
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
531
|
+
startLine: z.ZodNumber;
|
|
532
|
+
startColumn: z.ZodNumber;
|
|
533
|
+
endLine: z.ZodNumber;
|
|
534
|
+
endColumn: z.ZodNumber;
|
|
535
|
+
startOffset: z.ZodNumber;
|
|
536
|
+
endOffset: z.ZodNumber;
|
|
537
|
+
}, z.core.$strip>>;
|
|
538
|
+
type: z.ZodLiteral<"list">;
|
|
539
|
+
ordered: z.ZodBoolean;
|
|
540
|
+
start: z.ZodOptional<z.ZodNumber>;
|
|
541
|
+
spread: z.ZodBoolean;
|
|
542
|
+
marker: z.ZodEnum<{
|
|
543
|
+
"*": "*";
|
|
544
|
+
"-": "-";
|
|
545
|
+
"+": "+";
|
|
546
|
+
")": ")";
|
|
547
|
+
".": ".";
|
|
548
|
+
}>;
|
|
549
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
550
|
+
}, z.core.$strip>;
|
|
551
|
+
declare const tableCellNodeSchema: z.ZodObject<{
|
|
552
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
553
|
+
startLine: z.ZodNumber;
|
|
554
|
+
startColumn: z.ZodNumber;
|
|
555
|
+
endLine: z.ZodNumber;
|
|
556
|
+
endColumn: z.ZodNumber;
|
|
557
|
+
startOffset: z.ZodNumber;
|
|
558
|
+
endOffset: z.ZodNumber;
|
|
559
|
+
}, z.core.$strip>>;
|
|
560
|
+
type: z.ZodLiteral<"tableCell">;
|
|
561
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
562
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
563
|
+
left: "left";
|
|
564
|
+
center: "center";
|
|
565
|
+
right: "right";
|
|
566
|
+
}>>;
|
|
567
|
+
isHeader: z.ZodBoolean;
|
|
568
|
+
}, z.core.$strip>;
|
|
569
|
+
declare const tableRowNodeSchema: z.ZodObject<{
|
|
570
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
571
|
+
startLine: z.ZodNumber;
|
|
572
|
+
startColumn: z.ZodNumber;
|
|
573
|
+
endLine: z.ZodNumber;
|
|
574
|
+
endColumn: z.ZodNumber;
|
|
575
|
+
startOffset: z.ZodNumber;
|
|
576
|
+
endOffset: z.ZodNumber;
|
|
577
|
+
}, z.core.$strip>>;
|
|
578
|
+
type: z.ZodLiteral<"tableRow">;
|
|
579
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
580
|
+
isHeader: z.ZodBoolean;
|
|
581
|
+
}, z.core.$strip>;
|
|
582
|
+
declare const tableNodeSchema: z.ZodObject<{
|
|
583
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
584
|
+
startLine: z.ZodNumber;
|
|
585
|
+
startColumn: z.ZodNumber;
|
|
586
|
+
endLine: z.ZodNumber;
|
|
587
|
+
endColumn: z.ZodNumber;
|
|
588
|
+
startOffset: z.ZodNumber;
|
|
589
|
+
endOffset: z.ZodNumber;
|
|
590
|
+
}, z.core.$strip>>;
|
|
591
|
+
type: z.ZodLiteral<"table">;
|
|
592
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
593
|
+
align: z.ZodArray<z.ZodNullable<z.ZodEnum<{
|
|
594
|
+
left: "left";
|
|
595
|
+
center: "center";
|
|
596
|
+
right: "right";
|
|
597
|
+
}>>>;
|
|
598
|
+
}, z.core.$strip>;
|
|
599
|
+
declare const blockNodeSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
600
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
601
|
+
startLine: z.ZodNumber;
|
|
602
|
+
startColumn: z.ZodNumber;
|
|
603
|
+
endLine: z.ZodNumber;
|
|
604
|
+
endColumn: z.ZodNumber;
|
|
605
|
+
startOffset: z.ZodNumber;
|
|
606
|
+
endOffset: z.ZodNumber;
|
|
607
|
+
}, z.core.$strip>>;
|
|
608
|
+
type: z.ZodLiteral<"thematicBreak">;
|
|
609
|
+
marker: z.ZodEnum<{
|
|
610
|
+
"*": "*";
|
|
611
|
+
_: "_";
|
|
612
|
+
"-": "-";
|
|
613
|
+
}>;
|
|
614
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
615
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
616
|
+
startLine: z.ZodNumber;
|
|
617
|
+
startColumn: z.ZodNumber;
|
|
618
|
+
endLine: z.ZodNumber;
|
|
619
|
+
endColumn: z.ZodNumber;
|
|
620
|
+
startOffset: z.ZodNumber;
|
|
621
|
+
endOffset: z.ZodNumber;
|
|
622
|
+
}, z.core.$strip>>;
|
|
623
|
+
type: z.ZodLiteral<"heading">;
|
|
624
|
+
level: z.ZodNumber;
|
|
625
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
626
|
+
style: z.ZodEnum<{
|
|
627
|
+
atx: "atx";
|
|
628
|
+
setext: "setext";
|
|
629
|
+
}>;
|
|
630
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
631
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
632
|
+
startLine: z.ZodNumber;
|
|
633
|
+
startColumn: z.ZodNumber;
|
|
634
|
+
endLine: z.ZodNumber;
|
|
635
|
+
endColumn: z.ZodNumber;
|
|
636
|
+
startOffset: z.ZodNumber;
|
|
637
|
+
endOffset: z.ZodNumber;
|
|
638
|
+
}, z.core.$strip>>;
|
|
639
|
+
type: z.ZodLiteral<"codeBlock">;
|
|
640
|
+
value: z.ZodString;
|
|
641
|
+
style: z.ZodEnum<{
|
|
642
|
+
fenced: "fenced";
|
|
643
|
+
indented: "indented";
|
|
644
|
+
}>;
|
|
645
|
+
lang: z.ZodOptional<z.ZodString>;
|
|
646
|
+
meta: z.ZodOptional<z.ZodString>;
|
|
647
|
+
fence: z.ZodOptional<z.ZodEnum<{
|
|
648
|
+
"`": "`";
|
|
649
|
+
"~": "~";
|
|
650
|
+
}>>;
|
|
651
|
+
fenceLength: z.ZodOptional<z.ZodNumber>;
|
|
652
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
653
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
654
|
+
startLine: z.ZodNumber;
|
|
655
|
+
startColumn: z.ZodNumber;
|
|
656
|
+
endLine: z.ZodNumber;
|
|
657
|
+
endColumn: z.ZodNumber;
|
|
658
|
+
startOffset: z.ZodNumber;
|
|
659
|
+
endOffset: z.ZodNumber;
|
|
660
|
+
}, z.core.$strip>>;
|
|
661
|
+
type: z.ZodLiteral<"htmlBlock">;
|
|
662
|
+
value: z.ZodString;
|
|
663
|
+
htmlType: z.ZodNumber;
|
|
664
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
665
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
666
|
+
startLine: z.ZodNumber;
|
|
667
|
+
startColumn: z.ZodNumber;
|
|
668
|
+
endLine: z.ZodNumber;
|
|
669
|
+
endColumn: z.ZodNumber;
|
|
670
|
+
startOffset: z.ZodNumber;
|
|
671
|
+
endOffset: z.ZodNumber;
|
|
672
|
+
}, z.core.$strip>>;
|
|
673
|
+
type: z.ZodLiteral<"paragraph">;
|
|
674
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
675
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
676
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
677
|
+
startLine: z.ZodNumber;
|
|
678
|
+
startColumn: z.ZodNumber;
|
|
679
|
+
endLine: z.ZodNumber;
|
|
680
|
+
endColumn: z.ZodNumber;
|
|
681
|
+
startOffset: z.ZodNumber;
|
|
682
|
+
endOffset: z.ZodNumber;
|
|
683
|
+
}, z.core.$strip>>;
|
|
684
|
+
type: z.ZodLiteral<"linkReferenceDefinition">;
|
|
685
|
+
label: z.ZodString;
|
|
686
|
+
url: z.ZodString;
|
|
687
|
+
title: z.ZodOptional<z.ZodString>;
|
|
688
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
689
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
690
|
+
startLine: z.ZodNumber;
|
|
691
|
+
startColumn: z.ZodNumber;
|
|
692
|
+
endLine: z.ZodNumber;
|
|
693
|
+
endColumn: z.ZodNumber;
|
|
694
|
+
startOffset: z.ZodNumber;
|
|
695
|
+
endOffset: z.ZodNumber;
|
|
696
|
+
}, z.core.$strip>>;
|
|
697
|
+
type: z.ZodLiteral<"blockquote">;
|
|
698
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
699
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
700
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
701
|
+
startLine: z.ZodNumber;
|
|
702
|
+
startColumn: z.ZodNumber;
|
|
703
|
+
endLine: z.ZodNumber;
|
|
704
|
+
endColumn: z.ZodNumber;
|
|
705
|
+
startOffset: z.ZodNumber;
|
|
706
|
+
endOffset: z.ZodNumber;
|
|
707
|
+
}, z.core.$strip>>;
|
|
708
|
+
type: z.ZodLiteral<"listItem">;
|
|
709
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
710
|
+
marker: z.ZodEnum<{
|
|
711
|
+
"*": "*";
|
|
712
|
+
"-": "-";
|
|
713
|
+
"+": "+";
|
|
714
|
+
")": ")";
|
|
715
|
+
".": ".";
|
|
716
|
+
}>;
|
|
717
|
+
spread: z.ZodBoolean;
|
|
718
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
719
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
720
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
721
|
+
startLine: z.ZodNumber;
|
|
722
|
+
startColumn: z.ZodNumber;
|
|
723
|
+
endLine: z.ZodNumber;
|
|
724
|
+
endColumn: z.ZodNumber;
|
|
725
|
+
startOffset: z.ZodNumber;
|
|
726
|
+
endOffset: z.ZodNumber;
|
|
727
|
+
}, z.core.$strip>>;
|
|
728
|
+
type: z.ZodLiteral<"list">;
|
|
729
|
+
ordered: z.ZodBoolean;
|
|
730
|
+
start: z.ZodOptional<z.ZodNumber>;
|
|
731
|
+
spread: z.ZodBoolean;
|
|
732
|
+
marker: z.ZodEnum<{
|
|
733
|
+
"*": "*";
|
|
734
|
+
"-": "-";
|
|
735
|
+
"+": "+";
|
|
736
|
+
")": ")";
|
|
737
|
+
".": ".";
|
|
738
|
+
}>;
|
|
739
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
740
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
741
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
742
|
+
startLine: z.ZodNumber;
|
|
743
|
+
startColumn: z.ZodNumber;
|
|
744
|
+
endLine: z.ZodNumber;
|
|
745
|
+
endColumn: z.ZodNumber;
|
|
746
|
+
startOffset: z.ZodNumber;
|
|
747
|
+
endOffset: z.ZodNumber;
|
|
748
|
+
}, z.core.$strip>>;
|
|
749
|
+
type: z.ZodLiteral<"table">;
|
|
750
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
751
|
+
align: z.ZodArray<z.ZodNullable<z.ZodEnum<{
|
|
752
|
+
left: "left";
|
|
753
|
+
center: "center";
|
|
754
|
+
right: "right";
|
|
755
|
+
}>>>;
|
|
756
|
+
}, z.core.$strip>]>;
|
|
757
|
+
declare const documentNodeSchema: z.ZodObject<{
|
|
758
|
+
type: z.ZodLiteral<"document">;
|
|
759
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
760
|
+
references: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
761
|
+
type: z.ZodLiteral<"linkReferenceDefinition">;
|
|
762
|
+
label: z.ZodString;
|
|
763
|
+
url: z.ZodString;
|
|
764
|
+
title: z.ZodOptional<z.ZodString>;
|
|
765
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
766
|
+
startLine: z.ZodNumber;
|
|
767
|
+
startColumn: z.ZodNumber;
|
|
768
|
+
endLine: z.ZodNumber;
|
|
769
|
+
endColumn: z.ZodNumber;
|
|
770
|
+
startOffset: z.ZodNumber;
|
|
771
|
+
endOffset: z.ZodNumber;
|
|
772
|
+
}, z.core.$strip>>;
|
|
773
|
+
}, z.core.$strip>>>;
|
|
774
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
775
|
+
startLine: z.ZodNumber;
|
|
776
|
+
startColumn: z.ZodNumber;
|
|
777
|
+
endLine: z.ZodNumber;
|
|
778
|
+
endColumn: z.ZodNumber;
|
|
779
|
+
startOffset: z.ZodNumber;
|
|
780
|
+
endOffset: z.ZodNumber;
|
|
781
|
+
}, z.core.$strip>>;
|
|
782
|
+
}, z.core.$strip>;
|
|
783
|
+
declare const markdownDocumentSchema: z.ZodObject<{
|
|
784
|
+
root: z.ZodObject<{
|
|
785
|
+
type: z.ZodLiteral<"document">;
|
|
786
|
+
children: z.ZodArray<z.ZodUnknown>;
|
|
787
|
+
references: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
788
|
+
type: z.ZodLiteral<"linkReferenceDefinition">;
|
|
789
|
+
label: z.ZodString;
|
|
790
|
+
url: z.ZodString;
|
|
791
|
+
title: z.ZodOptional<z.ZodString>;
|
|
792
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
793
|
+
startLine: z.ZodNumber;
|
|
794
|
+
startColumn: z.ZodNumber;
|
|
795
|
+
endLine: z.ZodNumber;
|
|
796
|
+
endColumn: z.ZodNumber;
|
|
797
|
+
startOffset: z.ZodNumber;
|
|
798
|
+
endOffset: z.ZodNumber;
|
|
799
|
+
}, z.core.$strip>>;
|
|
800
|
+
}, z.core.$strip>>>;
|
|
801
|
+
position: z.ZodOptional<z.ZodObject<{
|
|
802
|
+
startLine: z.ZodNumber;
|
|
803
|
+
startColumn: z.ZodNumber;
|
|
804
|
+
endLine: z.ZodNumber;
|
|
805
|
+
endColumn: z.ZodNumber;
|
|
806
|
+
startOffset: z.ZodNumber;
|
|
807
|
+
endOffset: z.ZodNumber;
|
|
808
|
+
}, z.core.$strip>>;
|
|
809
|
+
}, z.core.$strip>;
|
|
810
|
+
lineEnding: z.ZodEnum<{
|
|
811
|
+
"\n": "\n";
|
|
812
|
+
"\r\n": "\r\n";
|
|
813
|
+
}>;
|
|
814
|
+
source: z.ZodOptional<z.ZodString>;
|
|
815
|
+
}, z.core.$strip>;
|
|
816
|
+
/**
|
|
817
|
+
* Parse options.
|
|
818
|
+
*/
|
|
819
|
+
declare const parseOptionsSchema: z.ZodObject<{
|
|
820
|
+
positions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
821
|
+
preserveSource: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
822
|
+
}, z.core.$strip>;
|
|
823
|
+
type ParseOptions = z.input<typeof parseOptionsSchema>;
|
|
824
|
+
/**
|
|
825
|
+
* Generate options.
|
|
826
|
+
*/
|
|
827
|
+
declare const generateOptionsSchema: z.ZodObject<{
|
|
828
|
+
lineEnding: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
829
|
+
"\n": "\n";
|
|
830
|
+
"\r\n": "\r\n";
|
|
831
|
+
}>>>;
|
|
832
|
+
indent: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
833
|
+
setext: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
834
|
+
fence: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
835
|
+
"`": "`";
|
|
836
|
+
"~": "~";
|
|
837
|
+
}>>>;
|
|
838
|
+
fenceLength: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
839
|
+
emphasis: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
840
|
+
"*": "*";
|
|
841
|
+
_: "_";
|
|
842
|
+
}>>>;
|
|
843
|
+
strong: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
844
|
+
"**": "**";
|
|
845
|
+
__: "__";
|
|
846
|
+
}>>>;
|
|
847
|
+
bullet: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
848
|
+
"*": "*";
|
|
849
|
+
"-": "-";
|
|
850
|
+
"+": "+";
|
|
851
|
+
}>>>;
|
|
852
|
+
orderedMarker: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
853
|
+
")": ")";
|
|
854
|
+
".": ".";
|
|
855
|
+
}>>>;
|
|
856
|
+
thematicBreak: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
857
|
+
"*": "*";
|
|
858
|
+
_: "_";
|
|
859
|
+
"-": "-";
|
|
860
|
+
}>>>;
|
|
861
|
+
thematicBreakLength: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
862
|
+
}, z.core.$strip>;
|
|
863
|
+
type GenerateOptions = z.input<typeof generateOptionsSchema>;
|
|
864
|
+
/**
|
|
865
|
+
* Stream options.
|
|
866
|
+
*/
|
|
867
|
+
declare const streamOptionsSchema: z.ZodObject<{
|
|
868
|
+
positions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
869
|
+
preserveSource: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
870
|
+
chunkSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
871
|
+
maxBufferSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
872
|
+
}, z.core.$strip>;
|
|
873
|
+
type StreamOptions = z.input<typeof streamOptionsSchema>;
|
|
874
|
+
interface BlockStreamEvent {
|
|
875
|
+
type: "block";
|
|
876
|
+
data: BlockNode2;
|
|
877
|
+
}
|
|
878
|
+
interface CompleteStreamEvent {
|
|
879
|
+
type: "complete";
|
|
880
|
+
document: MarkdownDocument;
|
|
881
|
+
}
|
|
882
|
+
interface ErrorStreamEvent {
|
|
883
|
+
type: "error";
|
|
884
|
+
error: string;
|
|
885
|
+
}
|
|
886
|
+
type StreamEvent = BlockStreamEvent | CompleteStreamEvent | ErrorStreamEvent;
|
|
887
|
+
interface BatchMarkdownFileInput {
|
|
888
|
+
filename: string;
|
|
889
|
+
content: string;
|
|
890
|
+
}
|
|
891
|
+
interface FileStartEvent {
|
|
892
|
+
type: "file_start";
|
|
893
|
+
fileIndex: number;
|
|
894
|
+
filename: string;
|
|
895
|
+
}
|
|
896
|
+
interface FileCompleteEvent {
|
|
897
|
+
type: "file_complete";
|
|
898
|
+
fileIndex: number;
|
|
899
|
+
filename: string;
|
|
900
|
+
document: MarkdownDocument;
|
|
901
|
+
}
|
|
902
|
+
interface FileErrorEvent {
|
|
903
|
+
type: "file_error";
|
|
904
|
+
fileIndex: number;
|
|
905
|
+
filename: string;
|
|
906
|
+
error: string;
|
|
907
|
+
}
|
|
908
|
+
interface BatchBlockEvent {
|
|
909
|
+
type: "block";
|
|
910
|
+
fileIndex: number;
|
|
911
|
+
data: BlockNode2;
|
|
912
|
+
}
|
|
913
|
+
interface BatchCompleteEvent {
|
|
914
|
+
type: "batch_complete";
|
|
915
|
+
totalFiles: number;
|
|
916
|
+
errorCount: number;
|
|
917
|
+
}
|
|
918
|
+
type BatchMarkdownStreamEvent = FileStartEvent | FileCompleteEvent | FileErrorEvent | BatchBlockEvent | BatchCompleteEvent;
|
|
919
|
+
interface BatchMarkdownFileResult {
|
|
920
|
+
filename: string;
|
|
921
|
+
document?: MarkdownDocument;
|
|
922
|
+
error?: string;
|
|
923
|
+
}
|
|
924
|
+
/** Alias for LinkReferenceDefinitionNode */
|
|
925
|
+
type LinkReferenceDefinition = LinkReferenceDefinitionNode;
|
|
926
|
+
/** Alias for BatchMarkdownFileResult */
|
|
927
|
+
type BatchParsedMarkdownFile = BatchMarkdownFileResult;
|
|
928
|
+
/** Union type for any node */
|
|
929
|
+
type Node = InlineNode | BlockNode2 | DocumentNode;
|
|
930
|
+
/** Nodes that contain a value property */
|
|
931
|
+
type LiteralNode = TextNode | CodeSpanNode | HtmlInlineNode | CodeBlockNode | HtmlBlockNode;
|
|
932
|
+
/** Nodes that contain children */
|
|
933
|
+
type ParentNode = EmphasisNode | StrongNode | LinkNode | HeadingNode | ParagraphNode | BlockquoteNode | ListItemNode | ListNode | TableNode | TableRowNode | TableCellNode | DocumentNode;
|
|
934
|
+
/**
|
|
935
|
+
* Result type for parse operations that may fail.
|
|
936
|
+
*/
|
|
937
|
+
type ParseResult<T> = {
|
|
938
|
+
success: true;
|
|
939
|
+
data: T;
|
|
940
|
+
} | {
|
|
941
|
+
success: false;
|
|
942
|
+
error: Error;
|
|
943
|
+
};
|
|
944
|
+
/**
|
|
945
|
+
* Parses markdown content and returns a result object.
|
|
946
|
+
*
|
|
947
|
+
* @param content - The markdown string to parse
|
|
948
|
+
* @param options - Parsing options
|
|
949
|
+
* @returns A ParseResult containing either the parsed document or an error
|
|
950
|
+
*
|
|
951
|
+
* @example
|
|
952
|
+
* ```typescript
|
|
953
|
+
* const result = parse("# Hello World");
|
|
954
|
+
* if (result.success) {
|
|
955
|
+
* console.log(result.data.root.children);
|
|
956
|
+
* }
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
declare function parse(content: string, options?: ParseOptions): ParseResult<MarkdownDocument>;
|
|
960
|
+
/**
|
|
961
|
+
* Parses markdown content and throws on error.
|
|
962
|
+
*
|
|
963
|
+
* @param content - The markdown string to parse
|
|
964
|
+
* @param options - Parsing options
|
|
965
|
+
* @returns The parsed markdown document
|
|
966
|
+
* @throws Error if parsing fails or options are invalid
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* const doc = parseOrThrow("# Hello World");
|
|
971
|
+
* console.log(doc.root.children);
|
|
972
|
+
* ```
|
|
973
|
+
*/
|
|
974
|
+
declare function parseOrThrow(content: string, options?: ParseOptions): MarkdownDocument;
|
|
975
|
+
/**
|
|
976
|
+
* Parses markdown from a buffer with automatic encoding detection.
|
|
977
|
+
*
|
|
978
|
+
* @param buffer - The buffer containing markdown data
|
|
979
|
+
* @param options - Parsing options
|
|
980
|
+
* @returns A ParseResult containing either the parsed document or an error
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```typescript
|
|
984
|
+
* const buffer = new Uint8Array([...]);
|
|
985
|
+
* const result = parseBuffer(buffer);
|
|
986
|
+
* if (result.success) {
|
|
987
|
+
* console.log(result.data.root.children);
|
|
988
|
+
* }
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
declare function parseBuffer(buffer: Uint8Array, options?: ParseOptions): ParseResult<MarkdownDocument>;
|
|
992
|
+
/**
|
|
993
|
+
* Parses markdown from a buffer with automatic encoding detection.
|
|
994
|
+
* Throws on error.
|
|
995
|
+
*
|
|
996
|
+
* @param buffer - The buffer containing markdown data
|
|
997
|
+
* @param options - Parsing options
|
|
998
|
+
* @returns The parsed markdown document
|
|
999
|
+
* @throws Error if parsing fails
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* const buffer = new Uint8Array([...]);
|
|
1004
|
+
* const doc = parseBufferOrThrow(buffer);
|
|
1005
|
+
* console.log(doc.root.children);
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
1008
|
+
declare function parseBufferOrThrow(buffer: Uint8Array, options?: ParseOptions): MarkdownDocument;
|
|
1009
|
+
/**
|
|
1010
|
+
* Parses markdown and returns just the AST root node.
|
|
1011
|
+
*
|
|
1012
|
+
* @param content - The markdown string to parse
|
|
1013
|
+
* @param options - Parsing options
|
|
1014
|
+
* @returns The root document node
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
* ```typescript
|
|
1018
|
+
* const root = parseToAst("# Hello");
|
|
1019
|
+
* console.log(root.type); // "document"
|
|
1020
|
+
* ```
|
|
1021
|
+
*/
|
|
1022
|
+
declare function parseToAst(content: string, options?: ParseOptions): MarkdownDocument["root"];
|
|
1023
|
+
/**
|
|
1024
|
+
* Checks if the given content is valid markdown (doesn't throw during parsing).
|
|
1025
|
+
*
|
|
1026
|
+
* @param content - The content to check
|
|
1027
|
+
* @returns True if the content can be parsed as markdown
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* isValidMarkdown("# Hello"); // true
|
|
1032
|
+
* isValidMarkdown("anything"); // true (markdown is very permissive)
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
declare function isValidMarkdown(content: string): boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* Generates markdown string from a document AST.
|
|
1038
|
+
*
|
|
1039
|
+
* @param document - The markdown document or root node to convert
|
|
1040
|
+
* @param options - Generation options
|
|
1041
|
+
* @returns The generated markdown string
|
|
1042
|
+
*
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```typescript
|
|
1045
|
+
* const doc = parse("# Hello");
|
|
1046
|
+
* const markdown = generate(doc);
|
|
1047
|
+
* console.log(markdown); // "# Hello"
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
1050
|
+
declare function generate(document: MarkdownDocument | DocumentNode, options?: GenerateOptions): string;
|
|
1051
|
+
/**
|
|
1052
|
+
* Generates markdown string from any AST node.
|
|
1053
|
+
*
|
|
1054
|
+
* @param node - The node to convert
|
|
1055
|
+
* @param options - Generation options
|
|
1056
|
+
* @returns The generated markdown string
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* const node: HeadingNode = { type: "heading", level: 1, children: [...], style: "atx" };
|
|
1061
|
+
* const markdown = generateNode(node);
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
declare function generateNode(node: Node, options?: GenerateOptions): string;
|
|
1065
|
+
/**
|
|
1066
|
+
* Creates an incremental markdown generator.
|
|
1067
|
+
*
|
|
1068
|
+
* @param options - Generation options
|
|
1069
|
+
* @returns A generator object with methods to add nodes
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```typescript
|
|
1073
|
+
* const gen = createGenerator();
|
|
1074
|
+
* gen.addNode({ type: "heading", level: 1, children: [...], style: "atx" });
|
|
1075
|
+
* gen.addNode({ type: "paragraph", children: [...] });
|
|
1076
|
+
* console.log(gen.toString());
|
|
1077
|
+
* ```
|
|
1078
|
+
*/
|
|
1079
|
+
declare function createGenerator(options?: GenerateOptions): {
|
|
1080
|
+
addNode: (node: Node) => void;
|
|
1081
|
+
toString: () => string;
|
|
1082
|
+
toStream: () => ReadableStream<string>;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Generates a heading string.
|
|
1086
|
+
*
|
|
1087
|
+
* @param level - Heading level (1-6)
|
|
1088
|
+
* @param text - Heading text
|
|
1089
|
+
* @param style - Heading style (atx or setext)
|
|
1090
|
+
* @returns The generated heading
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```typescript
|
|
1094
|
+
* generateHeadingString(1, "Hello"); // "# Hello"
|
|
1095
|
+
* generateHeadingString(2, "World", "setext"); // "World\n------"
|
|
1096
|
+
* ```
|
|
1097
|
+
*/
|
|
1098
|
+
declare function generateHeadingString(level: 1 | 2 | 3 | 4 | 5 | 6, text: string, style?: "atx" | "setext"): string;
|
|
1099
|
+
/**
|
|
1100
|
+
* Generates a link string.
|
|
1101
|
+
*
|
|
1102
|
+
* @param text - Link text
|
|
1103
|
+
* @param url - Link URL
|
|
1104
|
+
* @param title - Optional link title
|
|
1105
|
+
* @returns The generated link
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```typescript
|
|
1109
|
+
* generateLinkString("Example", "https://example.com"); // "[Example](https://example.com)"
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
declare function generateLinkString(text: string, url: string, title?: string): string;
|
|
1113
|
+
/**
|
|
1114
|
+
* Generates an image string.
|
|
1115
|
+
*
|
|
1116
|
+
* @param alt - Alt text
|
|
1117
|
+
* @param url - Image URL
|
|
1118
|
+
* @param title - Optional image title
|
|
1119
|
+
* @returns The generated image
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```typescript
|
|
1123
|
+
* generateImageString("Logo", "logo.png"); // ""
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
declare function generateImageString(alt: string, url: string, title?: string): string;
|
|
1127
|
+
/**
|
|
1128
|
+
* Generates a code block string.
|
|
1129
|
+
*
|
|
1130
|
+
* @param code - The code content
|
|
1131
|
+
* @param lang - Optional language identifier
|
|
1132
|
+
* @param style - Code block style (fenced or indented)
|
|
1133
|
+
* @returns The generated code block
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* generateCodeBlockString("console.log('hi');", "js");
|
|
1138
|
+
* // "```js\nconsole.log('hi');\n```"
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
declare function generateCodeBlockString(code: string, lang?: string, style?: "fenced" | "indented"): string;
|
|
1142
|
+
/**
|
|
1143
|
+
* Generates a list string from items.
|
|
1144
|
+
*
|
|
1145
|
+
* @param items - List items (strings or nested lists)
|
|
1146
|
+
* @param ordered - Whether the list is ordered
|
|
1147
|
+
* @param start - Starting number for ordered lists
|
|
1148
|
+
* @returns The generated list
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* ```typescript
|
|
1152
|
+
* generateListString(["First", "Second"]); // "- First\n- Second"
|
|
1153
|
+
* generateListString(["First", "Second"], true); // "1. First\n2. Second"
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
declare function generateListString(items: string[], ordered?: boolean, start?: number): string;
|
|
1157
|
+
/**
|
|
1158
|
+
* Generates a blockquote string.
|
|
1159
|
+
*
|
|
1160
|
+
* @param content - The content to quote
|
|
1161
|
+
* @returns The generated blockquote
|
|
1162
|
+
*
|
|
1163
|
+
* @example
|
|
1164
|
+
* ```typescript
|
|
1165
|
+
* generateBlockquoteString("Hello world"); // "> Hello world"
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
declare function generateBlockquoteString(content: string): string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Wraps text with emphasis markers.
|
|
1171
|
+
*
|
|
1172
|
+
* @param text - The text to emphasize
|
|
1173
|
+
* @param marker - The emphasis marker (* or _)
|
|
1174
|
+
* @returns The emphasized text
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```typescript
|
|
1178
|
+
* generateEmphasisString("hello"); // "*hello*"
|
|
1179
|
+
* ```
|
|
1180
|
+
*/
|
|
1181
|
+
declare function generateEmphasisString(text: string, marker?: "*" | "_"): string;
|
|
1182
|
+
/**
|
|
1183
|
+
* Wraps text with strong emphasis markers.
|
|
1184
|
+
*
|
|
1185
|
+
* @param text - The text to emphasize
|
|
1186
|
+
* @param marker - The strong marker (** or __)
|
|
1187
|
+
* @returns The strongly emphasized text
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```typescript
|
|
1191
|
+
* generateStrongString("hello"); // "**hello**"
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
declare function generateStrongString(text: string, marker?: "**" | "__"): string;
|
|
1195
|
+
/**
|
|
1196
|
+
* Wraps text in inline code.
|
|
1197
|
+
*
|
|
1198
|
+
* @param text - The text to wrap
|
|
1199
|
+
* @returns The inline code
|
|
1200
|
+
*
|
|
1201
|
+
* @example
|
|
1202
|
+
* ```typescript
|
|
1203
|
+
* generateInlineCodeString("foo"); // "`foo`"
|
|
1204
|
+
* ```
|
|
1205
|
+
*/
|
|
1206
|
+
declare function generateInlineCodeString(text: string): string;
|
|
1207
|
+
/**
|
|
1208
|
+
* Generates a GFM table string from headers, rows, and optional alignment.
|
|
1209
|
+
*
|
|
1210
|
+
* @param headers - Array of column header strings
|
|
1211
|
+
* @param rows - 2D array of cell values
|
|
1212
|
+
* @param alignments - Optional array of alignment values ('left' | 'center' | 'right')
|
|
1213
|
+
* @returns The generated table markdown
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```typescript
|
|
1217
|
+
* generateTableString(
|
|
1218
|
+
* ["Name", "Age"],
|
|
1219
|
+
* [["Alice", "30"], ["Bob", "25"]]
|
|
1220
|
+
* );
|
|
1221
|
+
* // "| Name | Age |\n| --- | --- |\n| Alice | 30 |\n| Bob | 25 |"
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
declare function generateTableString(headers: string[], rows: string[][], alignments?: ("left" | "center" | "right" | null)[]): string;
|
|
1225
|
+
/**
|
|
1226
|
+
* Generates a task list (checklist) string.
|
|
1227
|
+
*
|
|
1228
|
+
* @param items - Array of items with text and optional checked state
|
|
1229
|
+
* @returns The generated task list markdown
|
|
1230
|
+
*
|
|
1231
|
+
* @example
|
|
1232
|
+
* ```typescript
|
|
1233
|
+
* generateTaskListString([
|
|
1234
|
+
* { text: "Buy groceries", checked: true },
|
|
1235
|
+
* { text: "Walk the dog", checked: false },
|
|
1236
|
+
* ]);
|
|
1237
|
+
* // "- [x] Buy groceries\n- [ ] Walk the dog"
|
|
1238
|
+
* ```
|
|
1239
|
+
*/
|
|
1240
|
+
declare function generateTaskListString(items: Array<{
|
|
1241
|
+
text: string;
|
|
1242
|
+
checked?: boolean;
|
|
1243
|
+
}>): string;
|
|
1244
|
+
/**
|
|
1245
|
+
* Wraps text with strikethrough markers (GFM extension).
|
|
1246
|
+
*
|
|
1247
|
+
* @param text - The text to strike through
|
|
1248
|
+
* @returns The strikethrough text
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* ```typescript
|
|
1252
|
+
* generateStrikethroughString("deleted"); // "~~deleted~~"
|
|
1253
|
+
* ```
|
|
1254
|
+
*/
|
|
1255
|
+
declare function generateStrikethroughString(text: string): string;
|
|
1256
|
+
/**
|
|
1257
|
+
* Options for HTML rendering.
|
|
1258
|
+
*/
|
|
1259
|
+
interface HtmlRenderOptions {
|
|
1260
|
+
/** Whether to sanitize raw HTML blocks/inline (default: true) */
|
|
1261
|
+
sanitizeHtml?: boolean;
|
|
1262
|
+
/** Whether to add target="_blank" to external links (default: false) */
|
|
1263
|
+
externalLinksNewTab?: boolean;
|
|
1264
|
+
/** Custom class prefix for elements (default: none) */
|
|
1265
|
+
classPrefix?: string;
|
|
1266
|
+
/** Whether to render soft breaks as <br> (default: false) */
|
|
1267
|
+
softBreakAsBr?: boolean;
|
|
1268
|
+
/** Custom URL transformer for links and images */
|
|
1269
|
+
transformUrl?: (url: string, type: "link" | "image") => string;
|
|
1270
|
+
/** Custom attributes to add to specific elements */
|
|
1271
|
+
elementAttributes?: {
|
|
1272
|
+
link?: Record<string, string>;
|
|
1273
|
+
image?: Record<string, string>;
|
|
1274
|
+
codeBlock?: Record<string, string>;
|
|
1275
|
+
heading?: Record<string, string>;
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Renders a markdown document to HTML string.
|
|
1280
|
+
*
|
|
1281
|
+
* @param document - The markdown document or root node
|
|
1282
|
+
* @param options - Rendering options
|
|
1283
|
+
* @returns The generated HTML string
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```typescript
|
|
1287
|
+
* const doc = parse("# Hello **World**");
|
|
1288
|
+
* const html = renderToHtml(doc);
|
|
1289
|
+
* // => "<h1>Hello <strong>World</strong></h1>"
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
declare function renderToHtml(document: MarkdownDocument | DocumentNode, options?: HtmlRenderOptions): string;
|
|
1293
|
+
/**
|
|
1294
|
+
* Renders any AST node to HTML string.
|
|
1295
|
+
*
|
|
1296
|
+
* @param node - The node to render
|
|
1297
|
+
* @param options - Rendering options
|
|
1298
|
+
* @returns The generated HTML string
|
|
1299
|
+
*/
|
|
1300
|
+
declare function renderNodeToHtml(node: Node, options?: HtmlRenderOptions): string;
|
|
1301
|
+
/**
|
|
1302
|
+
* Options for HTML to Markdown conversion
|
|
1303
|
+
*/
|
|
1304
|
+
interface HtmlToMarkdownOptions {
|
|
1305
|
+
/** Keep original whitespace (default: false) */
|
|
1306
|
+
preserveWhitespace?: boolean;
|
|
1307
|
+
/** Heading style: "atx" (#) or "setext" (===) (default: "atx") */
|
|
1308
|
+
headingStyle?: "atx" | "setext";
|
|
1309
|
+
/** Unordered list marker (default: "-") */
|
|
1310
|
+
bulletMarker?: "-" | "*" | "+";
|
|
1311
|
+
/** Code block style (default: "fenced") */
|
|
1312
|
+
codeBlockStyle?: "fenced" | "indented";
|
|
1313
|
+
/** Fence character (default: "`") */
|
|
1314
|
+
fence?: "`" | "~";
|
|
1315
|
+
/** Strong marker (default: "**") */
|
|
1316
|
+
strongMarker?: "**" | "__";
|
|
1317
|
+
/** Emphasis marker (default: "*") */
|
|
1318
|
+
emphasisMarker?: "*" | "_";
|
|
1319
|
+
/** Link style (default: "inline") */
|
|
1320
|
+
linkStyle?: "inline" | "reference";
|
|
1321
|
+
}
|
|
1322
|
+
/** Intermediate HTML node representation */
|
|
1323
|
+
interface HtmlNode {
|
|
1324
|
+
type: "element" | "text" | "comment";
|
|
1325
|
+
tag?: string;
|
|
1326
|
+
attributes?: Record<string, string>;
|
|
1327
|
+
children?: HtmlNode[];
|
|
1328
|
+
content?: string;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Parse HTML string into an intermediate AST
|
|
1332
|
+
*/
|
|
1333
|
+
declare function parseHtml(html: string): HtmlNode[];
|
|
1334
|
+
/**
|
|
1335
|
+
* Convert HTML AST to Markdown AST
|
|
1336
|
+
*/
|
|
1337
|
+
declare function htmlAstToMarkdownAst(nodes: HtmlNode[], options?: HtmlToMarkdownOptions): DocumentNode;
|
|
1338
|
+
/**
|
|
1339
|
+
* Convert HTML string to Markdown string
|
|
1340
|
+
*
|
|
1341
|
+
* @param html - The HTML content to convert
|
|
1342
|
+
* @param options - Conversion options
|
|
1343
|
+
* @returns Markdown string
|
|
1344
|
+
*
|
|
1345
|
+
* @example
|
|
1346
|
+
* ```typescript
|
|
1347
|
+
* const html = '<h1>Hello</h1><p>This is <strong>bold</strong> text.</p>';
|
|
1348
|
+
* const markdown = htmlToMarkdown(html);
|
|
1349
|
+
* // Result: "# Hello\n\nThis is **bold** text."
|
|
1350
|
+
* ```
|
|
1351
|
+
*/
|
|
1352
|
+
declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string;
|
|
1353
|
+
/**
|
|
1354
|
+
* Parses markdown content from a stream, yielding events for each block.
|
|
1355
|
+
*
|
|
1356
|
+
* @param input - A ReadableStream of Uint8Array or AsyncIterable of strings
|
|
1357
|
+
* @param options - Parsing options
|
|
1358
|
+
* @yields StreamEvent for each block and completion
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```typescript
|
|
1362
|
+
* const response = await fetch("doc.md");
|
|
1363
|
+
* for await (const event of parseStream(response.body)) {
|
|
1364
|
+
* if (event.type === "block") {
|
|
1365
|
+
* console.log(event.data.type);
|
|
1366
|
+
* }
|
|
1367
|
+
* }
|
|
1368
|
+
* ```
|
|
1369
|
+
*/
|
|
1370
|
+
declare function parseStream(input: ReadableStream<Uint8Array> | AsyncIterable<string>, options?: StreamOptions): AsyncGenerator<StreamEvent>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Parses markdown content from a stream and collects all blocks into a document.
|
|
1373
|
+
*
|
|
1374
|
+
* @param input - A ReadableStream of Uint8Array or AsyncIterable of strings
|
|
1375
|
+
* @param options - Parsing options
|
|
1376
|
+
* @returns A promise that resolves to the complete MarkdownDocument
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```typescript
|
|
1380
|
+
* const response = await fetch("doc.md");
|
|
1381
|
+
* const doc = await parseStreamToDocument(response.body);
|
|
1382
|
+
* console.log(doc.root.children.length);
|
|
1383
|
+
* ```
|
|
1384
|
+
*/
|
|
1385
|
+
declare function parseStreamToDocument(input: ReadableStream<Uint8Array> | AsyncIterable<string>, options?: StreamOptions): Promise<MarkdownDocument>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Creates a streaming parser from a buffer.
|
|
1388
|
+
* Useful when you have a buffer but want to use the streaming API.
|
|
1389
|
+
*
|
|
1390
|
+
* @param buffer - The buffer containing markdown data
|
|
1391
|
+
* @param options - Parsing options
|
|
1392
|
+
* @yields StreamEvent for each block and completion
|
|
1393
|
+
*/
|
|
1394
|
+
declare function parseBufferStream(buffer: Uint8Array, options?: StreamOptions): AsyncGenerator<StreamEvent>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Streaming batch parser - processes files sequentially, yielding events.
|
|
1397
|
+
*
|
|
1398
|
+
* @param files - Array of files with filename and content
|
|
1399
|
+
* @param options - Stream options
|
|
1400
|
+
* @yields BatchMarkdownStreamEvent for each file start, block, completion, or error
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```typescript
|
|
1404
|
+
* const files = [
|
|
1405
|
+
* { filename: "readme.md", content: "# Hello" },
|
|
1406
|
+
* { filename: "docs.md", content: "## World" }
|
|
1407
|
+
* ];
|
|
1408
|
+
* for await (const event of parseBatchStream(files)) {
|
|
1409
|
+
* console.log(event.type, event.filename);
|
|
1410
|
+
* }
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
declare function parseBatchStream(files: BatchMarkdownFileInput[], options?: StreamOptions): AsyncGenerator<BatchMarkdownStreamEvent>;
|
|
1414
|
+
/**
|
|
1415
|
+
* Convenience function that collects streaming batch results into arrays.
|
|
1416
|
+
*
|
|
1417
|
+
* @param files - Array of files with filename and content
|
|
1418
|
+
* @param options - Stream options
|
|
1419
|
+
* @returns Array of parsed file results
|
|
1420
|
+
*/
|
|
1421
|
+
declare function parseBatchStreamToArray(files: BatchMarkdownFileInput[], options?: StreamOptions): Promise<BatchParsedMarkdownFile[]>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Normalizes line endings to LF.
|
|
1424
|
+
*
|
|
1425
|
+
* @param content - The content to normalize
|
|
1426
|
+
* @returns The content with normalized line endings
|
|
1427
|
+
*/
|
|
1428
|
+
declare function normalizeLineEndings(content: string): string;
|
|
1429
|
+
/**
|
|
1430
|
+
* Normalizes escaped newline sequences to actual newlines.
|
|
1431
|
+
* Handles AI-generated content that may contain literal \n strings
|
|
1432
|
+
* instead of actual newline characters.
|
|
1433
|
+
*
|
|
1434
|
+
* @param content - The content to normalize
|
|
1435
|
+
* @returns The content with escaped newlines converted to actual newlines
|
|
1436
|
+
*/
|
|
1437
|
+
declare function normalizeEscapedNewlines(content: string): string;
|
|
1438
|
+
/**
|
|
1439
|
+
* Normalizes markdown by unescaping incorrectly escaped emphasis markers.
|
|
1440
|
+
* LLMs sometimes escape ** or * markers that shouldn't be escaped.
|
|
1441
|
+
*
|
|
1442
|
+
* @param text - The markdown text to normalize
|
|
1443
|
+
* @returns The normalized text with unescaped emphasis markers
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```typescript
|
|
1447
|
+
* normalizeMarkdownEmphasis("\\*\\*bold\\*\\*"); // "**bold**"
|
|
1448
|
+
* normalizeMarkdownEmphasis("\\*italic\\*"); // "*italic*"
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
declare function normalizeMarkdownEmphasis(text: string): string;
|
|
1452
|
+
export { thematicBreakNodeSchema, textNodeSchema, tableRowNodeSchema, tableNodeSchema, tableCellNodeSchema, strongNodeSchema, streamOptionsSchema, softBreakNodeSchema, renderToHtml, renderNodeToHtml, positionSchema, parseToAst, parseStreamToDocument, parseStream, parseOrThrow, parseOptionsSchema, parseHtml, parseBufferStream, parseBufferOrThrow, parseBuffer, parseBatchStreamToArray, parseBatchStream, parse, paragraphNodeSchema, normalizeMarkdownEmphasis, normalizeLineEndings, normalizeEscapedNewlines, markdownDocumentSchema, listNodeSchema, listItemNodeSchema, linkReferenceDefinitionSchema, linkNodeSchema, isValidMarkdown, inlineNodeSchema, imageNodeSchema, htmlToMarkdown, htmlInlineNodeSchema, htmlBlockNodeSchema, htmlAstToMarkdownAst, headingNodeSchema, hardBreakNodeSchema, generateTaskListString, generateTableString, generateStrongString, generateStrikethroughString, generateOptionsSchema, generateNode, generateListString, generateLinkString, generateInlineCodeString, generateImageString, generateHeadingString, generateEmphasisString, generateCodeBlockString, generateBlockquoteString, generate, emphasisNodeSchema, documentNodeSchema, createGenerator, codeSpanNodeSchema, codeBlockNodeSchema, blockquoteNodeSchema, blockNodeSchema, ThematicBreakNode, TextNode, TableRowNode, TableNode, TableCellNode, StrongNode, StreamOptions, StreamEvent, SoftBreakNode, Position, ParseResult, ParseOptions, ParentNode, ParagraphNode, Node, MarkdownDocument, LiteralNode, ListNode, ListItemNode, LinkReferenceDefinition, LinkNode, InlineNode, ImageNode, HtmlToMarkdownOptions, HtmlRenderOptions, HtmlInlineNode, HtmlBlockNode, HeadingNode, HardBreakNode, GenerateOptions, EmphasisNode, DocumentNode, DEFAULT_MAX_BUFFER_SIZE, CodeSpanNode, CodeBlockNode, BlockquoteNode, BlockNode2 as BlockNode, BatchParsedMarkdownFile, BatchMarkdownStreamEvent, BatchMarkdownFileInput };
|