@mdream/js 1.5.4 → 1.5.6
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/dist/_chunks/const.mjs +2 -0
- package/dist/_chunks/markdown-processor.mjs +477 -79
- package/dist/_chunks/parse.mjs +201 -99
- package/dist/_chunks/plugins.mjs +3 -17
- package/dist/_chunks/src.mjs +2 -2
- package/dist/_chunks/types.d.mts +34 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/_chunks/types.d.mts
CHANGED
|
@@ -167,6 +167,11 @@ interface ElementNode extends Node {
|
|
|
167
167
|
interface TextNode extends Node {
|
|
168
168
|
/** Text content (for TEXT_NODE) */
|
|
169
169
|
value: string;
|
|
170
|
+
/** Markdown delimiters generated by a plugin around this literal text. */
|
|
171
|
+
generatedMarkdown?: {
|
|
172
|
+
prefix: string;
|
|
173
|
+
suffix: string;
|
|
174
|
+
};
|
|
170
175
|
/** Custom data added by plugins */
|
|
171
176
|
context?: PluginContext;
|
|
172
177
|
}
|
|
@@ -271,6 +276,8 @@ interface MdreamRuntimeState extends Partial<MdreamProcessingState> {
|
|
|
271
276
|
preFencePending?: boolean;
|
|
272
277
|
preFenceLang?: string;
|
|
273
278
|
preOwnFence?: boolean;
|
|
279
|
+
/** Number of default blockquotes currently buffered for line prefixing. */
|
|
280
|
+
bufferedBlockquoteDepth?: number;
|
|
274
281
|
/** Whether output should omit Markdown/HTML markup */
|
|
275
282
|
plainText?: boolean;
|
|
276
283
|
}
|
|
@@ -298,13 +305,38 @@ interface HandlerContext {
|
|
|
298
305
|
/** Runtime state */
|
|
299
306
|
state: MdreamRuntimeState;
|
|
300
307
|
}
|
|
308
|
+
/** Internal serializer lifecycle emitted only by built-in GFM handlers. */
|
|
309
|
+
type GfmAction = {
|
|
310
|
+
_tag: 'BlockquoteEnter';
|
|
311
|
+
output?: string;
|
|
312
|
+
} | {
|
|
313
|
+
_tag: 'BlockquoteExit';
|
|
314
|
+
} | {
|
|
315
|
+
_tag: 'PreEnter';
|
|
316
|
+
language: string;
|
|
317
|
+
} | {
|
|
318
|
+
_tag: 'PreExit';
|
|
319
|
+
} | {
|
|
320
|
+
_tag: 'CodeSpanEnter';
|
|
321
|
+
output: string;
|
|
322
|
+
} | {
|
|
323
|
+
_tag: 'CodeSpanExit';
|
|
324
|
+
} | {
|
|
325
|
+
_tag: 'CodeFenceEnter';
|
|
326
|
+
language: string;
|
|
327
|
+
output: string;
|
|
328
|
+
} | {
|
|
329
|
+
_tag: 'CodeFenceExit';
|
|
330
|
+
output: string;
|
|
331
|
+
};
|
|
332
|
+
type TagHandlerResult = string | GfmAction | undefined | void;
|
|
301
333
|
/**
|
|
302
334
|
* Tag handler interface for HTML elements
|
|
303
335
|
* Used by plugins to extend or customize tag handling
|
|
304
336
|
*/
|
|
305
337
|
interface TagHandler {
|
|
306
|
-
enter?: (context: HandlerContext) =>
|
|
307
|
-
exit?: (context: HandlerContext) =>
|
|
338
|
+
enter?: (context: HandlerContext) => TagHandlerResult;
|
|
339
|
+
exit?: (context: HandlerContext) => TagHandlerResult;
|
|
308
340
|
isSelfClosing?: boolean;
|
|
309
341
|
isNonNesting?: boolean;
|
|
310
342
|
collapsesInnerWhiteSpace?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { htmlToMarkdown, streamHtmlToMarkdown } from "./_chunks/src.mjs";
|
|
2
1
|
import { ELEMENT_NODE, NodeEventEnter, NodeEventExit, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TEXT_NODE } from "./_chunks/const.mjs";
|
|
2
|
+
import { htmlToMarkdown, streamHtmlToMarkdown } from "./_chunks/src.mjs";
|
|
3
3
|
import { createPlugin } from "./_chunks/plugins.mjs";
|
|
4
4
|
import { withMinimalPreset } from "./preset/minimal.mjs";
|
|
5
5
|
export { ELEMENT_NODE, NodeEventEnter, NodeEventExit, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TEXT_NODE, createPlugin, htmlToMarkdown, streamHtmlToMarkdown, withMinimalPreset };
|
package/package.json
CHANGED