mdream 0.13.3 → 0.15.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 +111 -0
- package/dist/_chunks/{const-BOAJ1T5c.mjs → const-Bf_XN9U9.mjs} +2 -5
- package/dist/_chunks/{extraction-BPaDGYvv.mjs → extraction-BA9MDtq3.mjs} +4 -6
- package/dist/_chunks/{llms-txt-DC12yO2l.mjs → llms-txt-T79S7X24.mjs} +123 -35
- package/dist/_chunks/{markdown-processor-f7XT0--8.mjs → markdown-processor-D26Uo5td.mjs} +35 -64
- package/dist/_chunks/{minimal-co1tIZYm.mjs → minimal-BiDhcwif.mjs} +3 -3
- package/dist/_chunks/{plugin-DrovQriD.mjs → plugin-CjWWQTuL.mjs} +1 -1
- package/dist/_chunks/{plugin-CgnpSqtP.d.mts → plugin-D5soyEXm.d.mts} +2 -2
- package/dist/_chunks/{plugins-C5_irVJs.mjs → plugins-DJnqR2fA.mjs} +23 -41
- package/dist/_chunks/{src-C3QpB75q.mjs → src-BJpipdul.mjs} +3 -4
- package/dist/_chunks/{types-DqiI86yW.d.mts → types-CT4ZxeOH.d.mts} +1 -1
- package/dist/cli.mjs +12 -18
- package/dist/iife.js +8 -18
- package/dist/index.d.mts +2 -5
- package/dist/index.mjs +4 -4
- package/dist/llms-txt.d.mts +45 -1
- package/dist/llms-txt.mjs +7 -7
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.mjs +4 -4
- package/dist/preset/minimal.d.mts +1 -1
- package/dist/preset/minimal.mjs +5 -5
- package/dist/splitter.d.mts +7 -2
- package/dist/splitter.mjs +45 -34
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createPlugin } from "./plugin-
|
|
3
|
-
import { parseSelector } from "./extraction-
|
|
1
|
+
import { $ as TAG_H2, $t as TAG_TBODY, A as TAG_BUTTON, At as TAG_P, Bt as TAG_SCRIPT, C as TAG_AUDIO, D as TAG_BLOCKQUOTE, Dt as TAG_OBJECT, F as TAG_CODE, G as TAG_EM, Gt as TAG_SPAN, H as TAG_DIV, Ht as TAG_SELECT, J as TAG_FIGCAPTION, K as TAG_EMBED, Kt as TAG_STRONG, L as TAG_DD, M as TAG_CAPTION, Nt as TAG_PRE, O as TAG_BODY, Ot as TAG_OL, Q as TAG_H1, Qt as TAG_TABLE, S as TAG_ASIDE, St as TAG_META, U as TAG_DL, Vt as TAG_SECTION, W as TAG_DT, X as TAG_FOOTER, Y as TAG_FIGURE, Yt as TAG_SUMMARY, Z as TAG_FORM, Zt as TAG_SVG, _ as TAG_A, _t as TAG_LI, an as TAG_THEAD, at as TAG_HEADER, bn as createBufferRegion, cn as TAG_TR, ct as TAG_I, dn as TAG_UL, dt as TAG_INPUT, en as TAG_TD, et as TAG_H3, gn as TEXT_NODE, in as TAG_TH, it as TAG_HEAD, k as TAG_BR, lt as TAG_IFRAME, nn as TAG_TEXTAREA, nt as TAG_H5, ot as TAG_HR, pn as TAG_VIDEO, q as TAG_FIELDSET, qt as TAG_STYLE, r as ELEMENT_NODE, rn as TAG_TFOOT, rt as TAG_H6, sn as TAG_TITLE, st as TAG_HTML, tt as TAG_H4, ut as TAG_IMG, w as TAG_B, wt as TAG_NAV, x as TAG_ARTICLE, y as TAG_ADDRESS, yn as collectNodeContent, yt as TAG_MAIN, z as TAG_DETAILS } from "./const-Bf_XN9U9.mjs";
|
|
2
|
+
import { t as createPlugin } from "./plugin-CjWWQTuL.mjs";
|
|
3
|
+
import { n as parseSelector } from "./extraction-BA9MDtq3.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/filter.ts
|
|
6
6
|
/**
|
|
@@ -28,11 +28,9 @@ function filterPlugin(options = {}) {
|
|
|
28
28
|
return createPlugin({ beforeNodeProcess(event) {
|
|
29
29
|
const { node } = event;
|
|
30
30
|
if (node.type === TEXT_NODE) {
|
|
31
|
-
|
|
32
|
-
let currentParent$1 = textNode.parent;
|
|
31
|
+
let currentParent$1 = node.parent;
|
|
33
32
|
while (currentParent$1 && excludeSelectors.length) {
|
|
34
|
-
|
|
35
|
-
if (parentShouldExclude) return { skip: true };
|
|
33
|
+
if (excludeSelectors.some((selector) => selector.matches(currentParent$1))) return { skip: true };
|
|
36
34
|
currentParent$1 = currentParent$1.parent;
|
|
37
35
|
}
|
|
38
36
|
return;
|
|
@@ -41,22 +39,19 @@ function filterPlugin(options = {}) {
|
|
|
41
39
|
const element = node;
|
|
42
40
|
if (excludeSelectors.length) {
|
|
43
41
|
if (element.attributes.style?.includes("absolute") || element.attributes.style?.includes("fixed")) return { skip: true };
|
|
44
|
-
|
|
45
|
-
if (shouldExclude) return { skip: true };
|
|
42
|
+
if (excludeSelectors.some((selector) => selector.matches(element))) return { skip: true };
|
|
46
43
|
}
|
|
47
44
|
let currentParent = element.parent;
|
|
48
45
|
while (currentParent) {
|
|
49
46
|
if (excludeSelectors.length) {
|
|
50
|
-
|
|
51
|
-
if (parentShouldExclude) return { skip: true };
|
|
47
|
+
if (excludeSelectors.some((selector) => selector.matches(currentParent))) return { skip: true };
|
|
52
48
|
}
|
|
53
49
|
currentParent = currentParent.parent;
|
|
54
50
|
}
|
|
55
51
|
if (includeSelectors.length) {
|
|
56
52
|
let currentElement = element;
|
|
57
53
|
while (currentElement) {
|
|
58
|
-
|
|
59
|
-
if (shouldInclude) return;
|
|
54
|
+
if (includeSelectors.some((selector) => selector.matches(currentElement))) return;
|
|
60
55
|
if (!processChildren) break;
|
|
61
56
|
currentElement = currentElement.parent;
|
|
62
57
|
}
|
|
@@ -102,25 +97,20 @@ function frontmatterPlugin(options = {}) {
|
|
|
102
97
|
}
|
|
103
98
|
if (inHead && node.type === ELEMENT_NODE && node.tagId === TAG_TITLE) return;
|
|
104
99
|
if (inHead && node.type === ELEMENT_NODE && node.tagId === TAG_META) {
|
|
105
|
-
const
|
|
106
|
-
const { name, property, content } = elementNode.attributes || {};
|
|
100
|
+
const { name, property, content } = node.attributes || {};
|
|
107
101
|
const metaName = property || name;
|
|
108
102
|
if (metaName && content && metaFields.has(metaName)) frontmatter.meta[metaName.includes(":") ? `"${metaName}"` : metaName] = formatValue(metaName, content);
|
|
109
|
-
return
|
|
103
|
+
return;
|
|
110
104
|
}
|
|
111
105
|
},
|
|
112
106
|
onNodeExit(node, state) {
|
|
113
107
|
if (node.type === ELEMENT_NODE && node.tagId === TAG_HEAD) {
|
|
114
108
|
inHead = false;
|
|
115
|
-
if (Object.keys(frontmatter).length > 0) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
regionId: 0
|
|
120
|
-
}, frontmatterContent, state);
|
|
121
|
-
}
|
|
109
|
+
if (Object.keys(frontmatter).length > 0) collectNodeContent({
|
|
110
|
+
type: 1,
|
|
111
|
+
regionId: 0
|
|
112
|
+
}, generateFrontmatter(), state);
|
|
122
113
|
}
|
|
123
|
-
return void 0;
|
|
124
114
|
},
|
|
125
115
|
processTextNode(node) {
|
|
126
116
|
if (!inHead) return;
|
|
@@ -237,8 +227,7 @@ function isolateMainPlugin() {
|
|
|
237
227
|
}
|
|
238
228
|
}
|
|
239
229
|
if (firstHeaderElement && !afterFooter && element.tagId === TAG_FOOTER) {
|
|
240
|
-
|
|
241
|
-
if (depthDifference <= 5) {
|
|
230
|
+
if (element.depth - firstHeaderElement.depth <= 5) {
|
|
242
231
|
afterFooter = true;
|
|
243
232
|
return { skip: true };
|
|
244
233
|
}
|
|
@@ -400,8 +389,7 @@ function readabilityPlugin() {
|
|
|
400
389
|
node.context.tagCount = 1;
|
|
401
390
|
node.context.linkTextLength = 0;
|
|
402
391
|
node.context.textLength = 0;
|
|
403
|
-
|
|
404
|
-
if (hasStrongNegativePattern) createBufferRegion(node, state, false);
|
|
392
|
+
if (node.name && /nav|header|footer|aside|form|fieldset|button/i.test(node.name) || node.attributes?.class && /nav|menu|header|footer|sidebar|hidden|copyright|ad-|advertisement|banner|promo|related|comment|login|register|subscribe|newsletter|category|meta|tag|cta|button|apply|trial|engagement|sharing|likes|views|metrics|stats|breadcrumb|pagination|filter|sort|search/i.test(node.attributes.class) || node.attributes?.id && /nav|menu|header|footer|sidebar|hidden|copyright|ad-|advertisement|banner|promo|related|comment|login|register|subscribe|newsletter|category|meta|tag|cta|button|apply|trial|engagement|sharing|likes|views|metrics|stats|breadcrumb|pagination|filter|sort|search/i.test(node.attributes.id) || node.attributes?.style && /display:\s*none|visibility:\s*hidden/i.test(node.attributes.style) || node.attributes && Object.keys(node.attributes).some((attr) => attr.startsWith("aria-") && node.attributes[attr] === "true" && /hidden|invisible/i.test(attr))) createBufferRegion(node, state, false);
|
|
405
393
|
else if (node.parent && node.parent.context) node.context.score = (node.context.score || 0) + (node.parent.context.score || 0);
|
|
406
394
|
},
|
|
407
395
|
processTextNode(node) {
|
|
@@ -418,7 +406,6 @@ function readabilityPlugin() {
|
|
|
418
406
|
if (isInsideLink) parent.context.linkTextLength = (parent.context.linkTextLength || 0) + len;
|
|
419
407
|
parent = parent.parent;
|
|
420
408
|
}
|
|
421
|
-
return void 0;
|
|
422
409
|
},
|
|
423
410
|
onNodeExit(node, state) {
|
|
424
411
|
if (!node.context) return;
|
|
@@ -505,14 +492,13 @@ const TAILWIND_TO_MARKDOWN_MAP = {
|
|
|
505
492
|
* Extract base class name from a responsive breakpoint variant
|
|
506
493
|
*/
|
|
507
494
|
function extractBaseClass(className) {
|
|
508
|
-
const
|
|
495
|
+
for (const bp of [
|
|
509
496
|
"sm:",
|
|
510
497
|
"md:",
|
|
511
498
|
"lg:",
|
|
512
499
|
"xl:",
|
|
513
500
|
"2xl:"
|
|
514
|
-
]
|
|
515
|
-
for (const bp of breakpoints) if (className.startsWith(bp)) return {
|
|
501
|
+
]) if (className.startsWith(bp)) return {
|
|
516
502
|
baseClass: className.substring(bp.length),
|
|
517
503
|
breakpoint: bp
|
|
518
504
|
};
|
|
@@ -604,8 +590,7 @@ function processTailwindClasses(classes) {
|
|
|
604
590
|
let prefix = "";
|
|
605
591
|
let suffix = "";
|
|
606
592
|
let hidden = false;
|
|
607
|
-
const
|
|
608
|
-
const grouped = groupByFormattingType(normalizedClasses);
|
|
593
|
+
const grouped = groupByFormattingType(normalizeClasses(classes));
|
|
609
594
|
if (grouped.weight.length > 0) {
|
|
610
595
|
const { baseClass } = extractBaseClass(grouped.weight[0]);
|
|
611
596
|
const mapping = TAILWIND_TO_MARKDOWN_MAP[baseClass];
|
|
@@ -660,8 +645,7 @@ function tailwindPlugin() {
|
|
|
660
645
|
processAttributes(node) {
|
|
661
646
|
const classAttr = node.attributes?.class;
|
|
662
647
|
if (!classAttr) return;
|
|
663
|
-
const
|
|
664
|
-
const { prefix, suffix, hidden } = processTailwindClasses(classes);
|
|
648
|
+
const { prefix, suffix, hidden } = processTailwindClasses(classAttr.trim().split(" ").filter(Boolean));
|
|
665
649
|
node.context = node.context || {};
|
|
666
650
|
node.context.tailwind = {
|
|
667
651
|
prefix,
|
|
@@ -671,7 +655,7 @@ function tailwindPlugin() {
|
|
|
671
655
|
},
|
|
672
656
|
processTextNode(node) {
|
|
673
657
|
const parentNode = node.parent;
|
|
674
|
-
if (!parentNode || parentNode.type !== ELEMENT_NODE) return
|
|
658
|
+
if (!parentNode || parentNode.type !== ELEMENT_NODE) return;
|
|
675
659
|
const tailwindData = parentNode.context?.tailwind;
|
|
676
660
|
if (tailwindData?.hidden) return {
|
|
677
661
|
content: "",
|
|
@@ -691,13 +675,11 @@ function tailwindPlugin() {
|
|
|
691
675
|
},
|
|
692
676
|
beforeNodeProcess({ node }) {
|
|
693
677
|
if (node.type === ELEMENT_NODE) {
|
|
694
|
-
|
|
695
|
-
const tailwindData = elementNode.context?.tailwind;
|
|
696
|
-
if (tailwindData?.hidden) return { skip: true };
|
|
678
|
+
if ((node.context?.tailwind)?.hidden) return { skip: true };
|
|
697
679
|
}
|
|
698
680
|
}
|
|
699
681
|
});
|
|
700
682
|
}
|
|
701
683
|
|
|
702
684
|
//#endregion
|
|
703
|
-
export { filterPlugin, frontmatterPlugin
|
|
685
|
+
export { filterPlugin as a, frontmatterPlugin as i, readabilityPlugin as n, isolateMainPlugin as r, tailwindPlugin as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as parseHtmlStream, n as createMarkdownProcessor, r as processPluginsForEvent } from "./markdown-processor-D26Uo5td.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/stream.ts
|
|
4
4
|
/**
|
|
@@ -22,8 +22,7 @@ async function* streamHtmlToMarkdown(htmlStream, options = {}) {
|
|
|
22
22
|
while (true) {
|
|
23
23
|
const { done, value } = await reader.read();
|
|
24
24
|
if (done) break;
|
|
25
|
-
|
|
26
|
-
remainingHtml = parseHtmlStream(htmlContent, parseState, (event) => {
|
|
25
|
+
remainingHtml = parseHtmlStream(`${remainingHtml}${typeof value === "string" ? value : decoder.decode(value, { stream: true })}`, parseState, (event) => {
|
|
27
26
|
processPluginsForEvent(event, options.plugins, processor.state, processor.processEvent);
|
|
28
27
|
});
|
|
29
28
|
const chunk = processor.getMarkdownChunk();
|
|
@@ -49,4 +48,4 @@ function htmlToMarkdown(html, options = {}) {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
//#endregion
|
|
52
|
-
export {
|
|
51
|
+
export { streamHtmlToMarkdown as n, htmlToMarkdown as t };
|
|
@@ -317,4 +317,4 @@ interface SplitterOptions extends HTMLToMarkdownOptions {
|
|
|
317
317
|
keepSeparator?: boolean;
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
|
-
export {
|
|
320
|
+
export { TagHandler as _, HandlerContext as a, ExtractedElement as b, MdreamRuntimeState as c, Plugin as d, PluginContext as f, TEXT_NODE as g, SplitterOptions as h, HTMLToMarkdownOptions as i, Node as l, ReadabilityContext as m, ELEMENT_NODE as n, MarkdownChunk as o, PluginCreationOptions as p, ElementNode as r, MdreamProcessingState as s, BufferRegion as t, NodeEvent as u, TailwindContext as v, extractionPlugin as x, TextNode as y };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import "./_chunks/const-
|
|
2
|
-
import "./_chunks/markdown-processor-
|
|
3
|
-
import "./_chunks/plugin-
|
|
4
|
-
import { streamHtmlToMarkdown } from "./_chunks/src-
|
|
5
|
-
import "./_chunks/extraction-
|
|
6
|
-
import { generateLlmsTxtArtifacts } from "./_chunks/llms-txt-
|
|
7
|
-
import "./_chunks/plugins-
|
|
8
|
-
import { withMinimalPreset } from "./_chunks/minimal-
|
|
1
|
+
import "./_chunks/const-Bf_XN9U9.mjs";
|
|
2
|
+
import "./_chunks/markdown-processor-D26Uo5td.mjs";
|
|
3
|
+
import "./_chunks/plugin-CjWWQTuL.mjs";
|
|
4
|
+
import { n as streamHtmlToMarkdown } from "./_chunks/src-BJpipdul.mjs";
|
|
5
|
+
import "./_chunks/extraction-BA9MDtq3.mjs";
|
|
6
|
+
import { n as generateLlmsTxtArtifacts } from "./_chunks/llms-txt-T79S7X24.mjs";
|
|
7
|
+
import "./_chunks/plugins-DJnqR2fA.mjs";
|
|
8
|
+
import { t as withMinimalPreset } from "./_chunks/minimal-BiDhcwif.mjs";
|
|
9
9
|
import { readFileSync } from "node:fs";
|
|
10
10
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
11
11
|
import { Readable } from "node:stream";
|
|
@@ -38,12 +38,8 @@ async function generateLlms(patterns, options) {
|
|
|
38
38
|
generateMarkdown: artifacts.includes("markdown")
|
|
39
39
|
});
|
|
40
40
|
await mkdir(outputDir, { recursive: true });
|
|
41
|
-
|
|
42
|
-
await writeFile(
|
|
43
|
-
if (artifacts.includes("llms-full.txt") && result.llmsFullTxt) {
|
|
44
|
-
const fullPath = join(outputDir, "llms-full.txt");
|
|
45
|
-
await writeFile(fullPath, result.llmsFullTxt, "utf-8");
|
|
46
|
-
}
|
|
41
|
+
await writeFile(join(outputDir, "llms.txt"), result.llmsTxt, "utf-8");
|
|
42
|
+
if (artifacts.includes("llms-full.txt") && result.llmsFullTxt) await writeFile(join(outputDir, "llms-full.txt"), result.llmsFullTxt, "utf-8");
|
|
47
43
|
if (artifacts.includes("markdown") && result.markdownFiles) for (const mdFile of result.markdownFiles) {
|
|
48
44
|
const fullPath = join(outputDir, mdFile.path);
|
|
49
45
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
@@ -55,10 +51,8 @@ async function generateLlms(patterns, options) {
|
|
|
55
51
|
process.exit(1);
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
61
|
-
const version = packageJson.version;
|
|
54
|
+
const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
55
|
+
const version = JSON.parse(readFileSync(packageJsonPath, "utf-8")).version;
|
|
62
56
|
const cli = cac();
|
|
63
57
|
cli.command("[options]", "Convert HTML from stdin to Markdown on stdout").option("--origin <url>", "Origin URL for resolving relative image paths").option("--preset <preset>", "Conversion presets: minimal").action(async (_, opts) => {
|
|
64
58
|
await streamingConvert(opts);
|
package/dist/iife.js
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
'use strict';
|
|
1
|
+
function e(e,t,n){if(!t)return;let r=e.regionId||0,i=n.regionContentBuffers.get(r);i&&(i.push(t),n.lastContentCache=t)}function t(e){let t=[];for(let[n,r]of Array.from(e.regionContentBuffers.entries()))e.regionToggles.get(n)&&t.push(...r);return e.regionToggles.clear(),e.regionContentBuffers.clear(),t.join(``).trimStart()}const n={"&":`&`,"<":`<`,">":`>`,""":`"`,"'":`'`,"'":`'`," ":` `},r={html:0,head:1,details:2,summary:3,title:4,meta:5,br:6,h1:7,h2:8,h3:9,h4:10,h5:11,h6:12,hr:13,strong:14,b:15,em:16,i:17,del:18,sub:19,sup:20,ins:21,blockquote:22,code:23,ul:24,li:25,a:26,img:27,table:28,thead:29,tr:30,th:31,td:32,ol:33,pre:34,p:35,div:36,span:37,tbody:38,tfoot:39,form:40,nav:41,label:42,button:43,body:44,center:45,kbd:46,footer:47,path:48,svg:49,article:50,section:51,script:52,style:53,link:54,area:55,base:56,col:57,embed:58,input:59,keygen:60,param:61,source:62,track:63,wbr:64,select:65,textarea:66,option:67,fieldset:68,legend:69,audio:70,video:71,canvas:72,iframe:73,map:74,dialog:75,meter:76,progress:77,template:78,abbr:79,mark:80,q:81,samp:82,small:83,noscript:84,noframes:85,xmp:86,plaintext:87,aside:88,u:89,cite:90,dfn:91,var:92,time:93,bdo:94,ruby:95,rt:96,rp:97,dd:98,dt:99,dl:101,address:100,figure:102,object:103,main:104,header:105,figcaption:106,caption:107},i=[0,0],a=[2,2],o=[1,1],s=[1,0],c=[0,1];function l(e,t){if(!e)return e;if(e.startsWith(`//`))return`https:${e}`;if(e.startsWith(`#`))return e;if(t){if(e.startsWith(`/`)&&t)return`${t.endsWith(`/`)?t.slice(0,-1):t}${e}`;if(e.startsWith(`./`))return`${t}/${e.slice(2)}`;if(!e.startsWith(`http`))return`${t}/${e.startsWith(`/`)?e.slice(1):e}`}return e}function u(e){return e.depthMap[32]>0}function d(e){if(!e)return``;let t=e.split(` `).map(e=>e.split(`language-`)[1]).filter(Boolean);return t.length>0?t[0].trim():``}function f(e){return{enter:({node:t})=>t.depthMap[26]?`<h${e}>`:`${`#`.repeat(e)} `,exit:({node:t})=>{if(t.depthMap[26])return`</h${e}>`},collapsesInnerWhiteSpace:!0}}const p={enter:({node:e})=>e.depthMap[15]>1?``:`**`,exit:({node:e})=>e.depthMap[15]>1?``:`**`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},m={enter:({node:e})=>e.depthMap[17]>1?``:`_`,exit:({node:e})=>e.depthMap[17]>1?``:`_`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},h={1:{spacing:i,collapsesInnerWhiteSpace:!0},2:{enter:()=>`<details>`,exit:()=>`</details>
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
`},3:{enter:()=>`<summary>`,exit:()=>`</summary>
|
|
5
4
|
|
|
6
|
-
`},[a]:{enter:()=>`<summary>`,exit:()=>`</summary>
|
|
7
|
-
|
|
8
|
-
`},[o]:{collapsesInnerWhiteSpace:!0,isNonNesting:!0,spacing:z},[N]:{excludesTextNodes:!0,isNonNesting:!0},[P]:{isNonNesting:!0,excludesTextNodes:!0},[s]:{collapsesInnerWhiteSpace:!0,isSelfClosing:!0,spacing:z},[c]:{enter:({node:e})=>V(e)?`<br>`:void 0,isSelfClosing:!0,spacing:z,collapsesInnerWhiteSpace:!0,isInline:!0},[l]:H(1),[u]:H(2),[d]:H(3),[f]:H(4),[p]:H(5),[m]:H(6),[h]:{enter:()=>kt,isSelfClosing:!0},[g]:Ft,[_]:Ft,[v]:It,[y]:It,[ee]:{enter:()=>Et,exit:()=>Et,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[te]:{enter:()=>`<sub>`,exit:()=>`</sub>`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[ne]:{enter:()=>`<sup>`,exit:()=>`</sup>`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[re]:{enter:()=>`<ins>`,exit:()=>`</ins>`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[b]:{enter:({node:e})=>{let t=e.depthMap[b]||1,n=`> `.repeat(t);return e.depthMap[C]>0&&(n=`\n${` `.repeat(e.depthMap[C])}${n}`),n},spacing:jt},[x]:{enter:({node:e})=>{if((e.depthMap[O]||0)>0){let t=Pt(e.attributes?.class);return`${Dt}${t}\n`}return Ot},exit:({node:e})=>e.depthMap[O]>0?`\n${Dt}`:Ot,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[S]:{enter:({node:e})=>V(e)?`<ul>`:void 0,exit:({node:e})=>V(e)?`</ul>`:void 0},[C]:{enter:({node:e})=>{if(V(e))return`<li>`;let t=(e.depthMap[S]||0)+(e.depthMap[D]||0)-1,n=e.parent?.tagId===D,r=` `.repeat(Math.max(0,t)),i=n?`${e.index+1}. `:`- `;return`${r}${i}`},exit:({node:e})=>V(e)?`</li>`:void 0,spacing:Mt},[w]:{enter:({node:e})=>{if(e.attributes?.href)return`[`},exit:({node:e,state:t})=>{if(!e.attributes?.href)return``;let n=Nt(e.attributes?.href||``,t.options?.origin),r=e.attributes?.title,i=t.lastContentCache;return i===r&&(r=``),r?`](${n} "${r}")`:`](${n})`},collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[ie]:{enter:({node:e,state:t})=>{let n=e.attributes?.alt||``,r=Nt(e.attributes?.src||``,t.options?.origin);return``},collapsesInnerWhiteSpace:!0,isSelfClosing:!0,spacing:z,isInline:!0},[T]:{enter:({node:e,state:t})=>{if(V(e))return`<table>`;e.depthMap[T]<=1&&(t.tableRenderedTable=!1),t.tableColumnAlignments=[]},exit:({node:e})=>V(e)?`</table>`:void 0},[ae]:{enter:({node:e})=>{if(V(e))return`<thead>`},exit:({node:e})=>V(e)?`</thead>`:void 0,spacing:B,excludesTextNodes:!0},[oe]:{enter:({node:e,state:t})=>V(e)?`<tr>`:(t.tableCurrentRowCells=0,`| `),exit:({node:e,state:t})=>{if(V(e)||e.depthMap[T]>1)return`</tr>`;if(!t.tableRenderedTable){t.tableRenderedTable=!0;let e=t.tableColumnAlignments;for(;e.length<t.tableCurrentRowCells;)e.push(``);let n=e.map(e=>{switch(e){case`left`:return`:---`;case`center`:return`:---:`;case`right`:return`---:`;default:return`---`}});return` |\n| ${n.join(` | `)} |`}return` |`},excludesTextNodes:!0,spacing:B},[se]:{enter:({node:e,state:t})=>{if(e.depthMap[T]>1)return`<th>`;let n=e.attributes?.align?.toLowerCase();return n?t.tableColumnAlignments.push(n):t.tableColumnAlignments.length<=t.tableCurrentRowCells&&t.tableColumnAlignments.push(``),e.index===0?``:` | `},exit:({node:e,state:t})=>{if(e.depthMap[T]>1)return`</th>`;t.tableCurrentRowCells++},collapsesInnerWhiteSpace:!0,spacing:z},[E]:{enter:({node:e})=>e.depthMap[T]>1?`<td>`:e.index===0?``:` | `,exit:({node:e,state:t})=>{if(e.depthMap[T]>1)return`</td>`;t.tableCurrentRowCells++},collapsesInnerWhiteSpace:!0,spacing:z},[k]:{},[A]:{},[j]:{collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[de]:{},[fe]:{collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[pe]:{collapsesInnerWhiteSpace:!0,isInline:!0},[me]:{spacing:z},[he]:{enter:({node:e})=>{if(e.depthMap[T]>1)return`<center>`},exit:({node:e})=>{if(e.depthMap[T]>1)return`</center>`},spacing:z},[ce]:{spacing:z,excludesTextNodes:!0},[le]:{spacing:B,excludesTextNodes:!0},[ge]:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[_e]:{spacing:z},[ue]:{spacing:z},[F]:{isSelfClosing:!0,spacing:z,collapsesInnerWhiteSpace:!0,isInline:!0},[xe]:{isSelfClosing:!0,spacing:z,isInline:!0},[Se]:{isSelfClosing:!0,spacing:z,isInline:!0},[Ce]:{isSelfClosing:!0,spacing:z},[we]:{isSelfClosing:!0,spacing:z},[Te]:{isSelfClosing:!0,spacing:z,isInline:!0},[Ee]:{isSelfClosing:!0,spacing:z,isInline:!0},[De]:{isSelfClosing:!0,spacing:z},[Oe]:{isSelfClosing:!0,spacing:z},[ke]:{isSelfClosing:!0,spacing:z},[Ae]:{isSelfClosing:!0,spacing:z,isInline:!0},[M]:{spacing:z},[je]:{spacing:z},[Me]:{isNonNesting:!0,spacing:z},[Ne]:{isNonNesting:!0,spacing:z},[Pe]:{spacing:z},[Fe]:{spacing:z},[Ie]:{spacing:z},[Le]:{spacing:z},[Re]:{spacing:z},[ze]:{isNonNesting:!0,spacing:z},[Be]:{spacing:z},[Ve]:{spacing:z},[He]:{spacing:z},[Ue]:{spacing:z},[We]:{spacing:z},[Ge]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[Ke]:{enter:()=>`<mark>`,exit:()=>`</mark>`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[qe]:{enter:()=>`"`,exit:()=>`"`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[Je]:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[Ye]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[Xe]:{excludesTextNodes:!0,spacing:z},[Ze]:{isNonNesting:!0,spacing:z},[Qe]:{isNonNesting:!0,spacing:z},[$e]:{isNonNesting:!0,spacing:z},[et]:{spacing:z},[tt]:{enter:()=>`<u>`,exit:()=>`</u>`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[nt]:{enter:()=>`*`,exit:()=>`*`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[rt]:{enter:()=>`**`,exit:()=>`**`,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[it]:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[at]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[ot]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[st]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[ct]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[lt]:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},[ft]:{enter:()=>`<address>`,exit:()=>`</address>`,spacing:z,collapsesInnerWhiteSpace:!0},[pt]:{spacing:z,enter:()=>`<dl>`,exit:()=>`</dl>`},[dt]:{enter:()=>`<dt>`,exit:()=>`</dt>`,collapsesInnerWhiteSpace:!0,spacing:[0,1]},[ut]:{enter:()=>`<dd>`,exit:()=>`</dd>`,spacing:[0,1]}};function Rt(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`&`){let r=!1;for(let[i,a]of Object.entries(xt))if(e.startsWith(i,n)){t+=a,n+=i.length,r=!0;break}if(r)continue;if(n+2<e.length&&e[n+1]===`#`){let r=n;n+=2;let i=e[n]===`x`||e[n]===`X`;i&&n++;let a=n;for(;n<e.length&&e[n]!==`;`;)n++;if(n<e.length&&e[n]===`;`){let r=e.substring(a,n),o=i?16:10;try{let e=Number.parseInt(r,o);if(!Number.isNaN(e)){t+=String.fromCodePoint(e),n++;continue}}catch{}}n=r}}t+=e[n],n++}return t}function zt(e){let t=e,n=[t];for(;t.tagHandler?.isInline&&t.parent;)t=t.parent,n.push(t);return n}const Bt=60,U=62,W=47,G=61,K=34,q=39,Vt=33,Ht=38,J=92,Y=45,X=32,Ut=9,Wt=10,Gt=13,Kt=96,qt=124,Jt=91,Yt=93,Xt=Object.freeze({});function Zt(e){return new Uint8Array(e)}function Z(e){return e===X||e===Ut||e===Wt||e===Gt}function Qt(e,t,n){return $t(e,t,n)}function $t(e,t,n){let r=``;t.depthMap??=new Uint8Array(bt),t.depth??=0,t.lastCharWasWhitespace??=!0,t.justClosedTag??=!1,t.isFirstTextInElement??=!1,t.lastCharWasBackslash??=!1;let i=0,a=e.length;for(;i<a;){let o=e.charCodeAt(i);if(o!==Bt){if(o===Ht&&(t.hasEncodedHtmlEntity=!0),Z(o)){let n=t.depthMap[O]>0;if(t.justClosedTag&&(t.justClosedTag=!1,t.lastCharWasWhitespace=!1),!n&&t.lastCharWasWhitespace){i++;continue}n?r+=e[i]:(o===X||!t.lastCharWasWhitespace)&&(r+=` `),t.lastCharWasWhitespace=!0,t.textBufferContainsWhitespace=!0,t.lastCharWasBackslash=!1}else t.textBufferContainsNonWhitespace=!0,t.lastCharWasWhitespace=!1,t.justClosedTag=!1,o===qt&&t.depthMap[T]?r+=`\\|`:o===Kt&&(t.depthMap[x]||t.depthMap[O])?r+="\\`":o===Jt&&t.depthMap[w]?r+=`\\[`:o===Yt&&t.depthMap[w]?r+=`\\]`:o===U&&t.depthMap[b]?r+=`\\>`:r+=e[i],t.currentNode?.tagHandler?.isNonNesting&&(t.lastCharWasBackslash||(o===q&&!t.inDoubleQuote&&!t.inBacktick?t.inSingleQuote=!t.inSingleQuote:o===K&&!t.inSingleQuote&&!t.inBacktick?t.inDoubleQuote=!t.inDoubleQuote:o===Kt&&!t.inSingleQuote&&!t.inDoubleQuote&&(t.inBacktick=!t.inBacktick))),t.lastCharWasBackslash=o===J;i++;continue}if(i+1>=a){r+=e[i];break}let s=e.charCodeAt(i+1);if(s===Vt){r.length>0&&(Q(r,t,n),r=``);let a=tn(e,i);if(a.complete)i=a.newPosition;else{r+=a.remainingText;break}}else if(s===W){let a=t.inSingleQuote||t.inDoubleQuote||t.inBacktick;if(t.currentNode?.tagHandler?.isNonNesting&&a){r+=e[i],i++;continue}r.length>0&&(Q(r,t,n),r=``);let o=en(e,i,t,n);if(o.complete)i=o.newPosition;else{r+=o.remainingText;break}}else{let o=i+1,s=o,c=-1;for(;o<a;){let t=e.charCodeAt(o);if(Z(t)||t===W||t===U){c=o;break}o++}if(c===-1){r+=e.substring(i);break}let l=e.substring(s,c).toLowerCase();if(!l){i=c;break}let u=Ct[l]??-1;if(o=c,t.currentNode?.tagHandler?.isNonNesting&&u!==t.currentNode?.tagId){r+=e[i++];continue}r.length>0&&(Q(r,t,n),r=``);let d=nn(l,u,e,o,t,n);if(d.skip)r+=e[i++];else if(d.complete)i=d.newPosition,d.selfClosing||(t.isFirstTextInElement=!0);else{r+=d.remainingText;break}}}return r}function Q(e,t,n){let r=t.textBufferContainsNonWhitespace,i=t.textBufferContainsWhitespace;if(t.textBufferContainsNonWhitespace=!1,t.textBufferContainsWhitespace=!1,!t.currentNode)return;let a=t.currentNode?.tagHandler?.excludesTextNodes,o=t.depthMap[O]>0;if(!o&&!r&&!t.currentNode.childTextNodeIndex)return;let s=e;if(s.length===0)return;let c=zt(t.currentNode),l=c[c.length-1];if(i&&!l?.childTextNodeIndex){let e=0;for(;e<s.length&&(o?s.charCodeAt(e)===Wt||s.charCodeAt(e)===Gt:Z(s.charCodeAt(e)));)e++;e>0&&(s=s.substring(e))}t.hasEncodedHtmlEntity&&(s=Rt(String(s)),t.hasEncodedHtmlEntity=!1);let u={type:L,value:s,parent:t.currentNode,regionId:t.currentNode?.regionId,index:t.currentNode.currentWalkIndex++,depth:t.depth,containsWhitespace:i,excludedFromMarkdown:a};for(let e of c)e.childTextNodeIndex=(e.childTextNodeIndex||0)+1;n({type:R,node:u}),t.lastTextNode=u}function en(e,t,n,r){let i=t+2,a=i,o=e.length,s=!1;for(;i<o;){let t=e.charCodeAt(i);if(t===U){s=!0;break}i++}if(!s)return{complete:!1,newPosition:t,remainingText:e.substring(t)};let c=e.substring(a,i).toLowerCase(),l=Ct[c]??-1;if(n.currentNode?.tagHandler?.isNonNesting&&l!==n.currentNode.tagId)return{complete:!1,newPosition:t,remainingText:e.substring(t)};let u=n.currentNode;if(u){let e=u.tagId!==l;for(;u&&e;)$(u,n,r),u=u.parent,e=u?.tagId!==l}return u&&$(u,n,r),n.justClosedTag=!0,{complete:!0,newPosition:i+1,remainingText:``}}function $(e,t,n){if(e){if(e.tagId===w&&!e.childTextNodeIndex){let t=e.attributes?.title||e.attributes?.[`aria-label`]||``;if(t){e.childTextNodeIndex=1;let r={type:L,value:t,parent:e,index:0,depth:e.depth+1};n({type:R,node:r});for(let t of zt(e))t.childTextNodeIndex=(t.childTextNodeIndex||0)+1}}e.tagId&&(t.depthMap[e.tagId]=Math.max(0,t.depthMap[e.tagId]-1)),e.tagHandler?.isNonNesting&&(t.inSingleQuote=!1,t.inDoubleQuote=!1,t.inBacktick=!1,t.lastCharWasBackslash=!1),t.depth--,n({type:St,node:e}),t.currentNode=t.currentNode.parent,t.hasEncodedHtmlEntity=!1,t.justClosedTag=!0}}function tn(e,t){let n=t,r=e.length;if(n+3<r&&e.charCodeAt(n+2)===Y&&e.charCodeAt(n+3)===Y){for(n+=4;n<r-2;){if(e.charCodeAt(n)===Y&&e.charCodeAt(n+1)===Y&&e.charCodeAt(n+2)===U)return n+=3,{complete:!0,newPosition:n,remainingText:``};n++}return{complete:!1,newPosition:t,remainingText:e.substring(t)}}else{for(n+=2;n<r;){if(e.charCodeAt(n)===U)return n++,{complete:!0,newPosition:n,remainingText:``};n++}return{complete:!1,newPosition:n,remainingText:e.substring(t,n)}}}function nn(e,t,n,r,i,a){i.currentNode?.tagHandler?.isNonNesting&&$(i.currentNode,i,a);let o=Lt[t],s=rn(n,r,o);if(!s.complete)return{complete:!1,newPosition:r,remainingText:`<${e}${s.attrBuffer}`,selfClosing:!1};let c=i.depthMap[t];i.depthMap[t]=c+1,i.depth++,r=s.newPosition,i.currentNode&&(i.currentNode.currentWalkIndex=i.currentNode.currentWalkIndex||0);let l=i.currentNode?i.currentNode.currentWalkIndex++:0,u={type:I,name:e,attributes:s.attributes,parent:i.currentNode,depthMap:Zt(i.depthMap),depth:i.depth,index:l,regionId:i.currentNode?.regionId,tagId:t,tagHandler:o};i.lastTextNode=u,a({type:R,node:u});let d=u;return d.currentWalkIndex=0,i.currentNode=d,i.hasEncodedHtmlEntity=!1,o?.isNonNesting&&!s.selfClosing&&(i.inSingleQuote=!1,i.inDoubleQuote=!1,i.inBacktick=!1,i.lastCharWasBackslash=!1),s.selfClosing?($(u,i,a),i.justClosedTag=!0):i.justClosedTag=!1,{complete:!0,newPosition:r,remainingText:``,selfClosing:s.selfClosing}}function rn(e,t,n){let r=t,i=e.length,a=n?.isSelfClosing||!1,o=r,s=!1,c=0,l=0;for(;r<i;){let t=e.charCodeAt(r);if(s){t===c&&l!==J&&(s=!1),r++;continue}else if(t===K||t===q)s=!0,c=t;else if(t===W&&r+1<i&&e.charCodeAt(r+1)===U){let t=e.substring(o,r).trim();return{complete:!0,newPosition:r+2,attributes:an(t),selfClosing:!0,attrBuffer:t}}else if(t===U){let t=e.substring(o,r).trim();return{complete:!0,newPosition:r+1,attributes:an(t),selfClosing:a,attrBuffer:t}}r++,l=t}return{complete:!1,newPosition:r,attributes:Xt,selfClosing:!1,attrBuffer:e.substring(o,r)}}function an(e){if(!e)return Xt;let t={},n=e.length,r=0,i=0,a=1,o=2,s=3,c=4,l=5,u=i,d=0,f=0,p=0,m=0,h=``;for(;r<n;){let g=e.charCodeAt(r),_=Z(g);switch(u){case i:_||(u=a,d=r,f=0);break;case a:(g===G||_)&&(f=r,h=e.substring(d,f).toLowerCase(),u=g===G?s:o);break;case o:g===G?u=s:_||(t[h]=``,u=a,d=r,f=0);break;case s:g===K||g===q?(m=g,u=c,p=r+1):_||(u=l,p=r);break;case c:g===J&&r+1<n?r++:g===m&&(t[h]=e.substring(p,r),u=i);break;case l:(_||g===U)&&(t[h]=e.substring(p,r),u=i);break}r++}if(u===c||u===l)h&&(t[h]=e.substring(p,r));else if(u===a||u===o||u===s){f||=r;let n=e.substring(d,f).toLowerCase();n&&(t[n]=``)}return t}function on(e,t,n,r){if(t?.length){for(let r of t){let t=r.beforeNodeProcess?.(e,n);if(typeof t==`object`&&t.skip)return!0}if(e.node.type===I){let r=e.node;if(e.type===R)for(let e of t)e.processAttributes&&e.processAttributes(r,n);let i=e.type===R?`onNodeEnter`:`onNodeExit`,a=[];for(let e of t)if(e[i]){let t=e[i](r,n);t&&a.push(t)}a.length>0&&(r.pluginOutput=(r.pluginOutput||[]).concat(a))}else if(e.node.type===L&&e.type===R){let r=e.node;for(let e of t)if(e.processTextNode){let t=e.processTextNode(r,n);if(t){if(t.skip)return!0;r.value=t.content}}}}return r(e),!1}function sn(e,t,n){if(e===` `||e===`
|
|
5
|
+
`},4:{collapsesInnerWhiteSpace:!0,isNonNesting:!0,spacing:i},52:{excludesTextNodes:!0,isNonNesting:!0},53:{isNonNesting:!0,excludesTextNodes:!0},5:{collapsesInnerWhiteSpace:!0,isSelfClosing:!0,spacing:i},6:{enter:({node:e})=>u(e)?`<br>`:void 0,isSelfClosing:!0,spacing:i,collapsesInnerWhiteSpace:!0,isInline:!0},7:f(1),8:f(2),9:f(3),10:f(4),11:f(5),12:f(6),13:{enter:()=>`---`,isSelfClosing:!0},14:p,15:p,16:m,17:m,18:{enter:()=>`~~`,exit:()=>`~~`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},19:{enter:()=>`<sub>`,exit:()=>`</sub>`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},20:{enter:()=>`<sup>`,exit:()=>`</sup>`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},21:{enter:()=>`<ins>`,exit:()=>`</ins>`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},22:{enter:({node:e})=>{let t=e.depthMap[22]||1,n=`> `.repeat(t);return e.depthMap[25]>0&&(n=`\n${` `.repeat(e.depthMap[25])}${n}`),n},spacing:o},23:{enter:({node:e})=>(e.depthMap[34]||0)>0?`\`\`\`${d(e.attributes?.class)}\n`:"`",exit:({node:e})=>e.depthMap[34]>0?"\n```":"`",collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},24:{enter:({node:e})=>u(e)?`<ul>`:void 0,exit:({node:e})=>u(e)?`</ul>`:void 0},25:{enter:({node:e})=>{if(u(e))return`<li>`;let t=(e.depthMap[24]||0)+(e.depthMap[33]||0)-1,n=e.parent?.tagId===33;return`${` `.repeat(Math.max(0,t))}${n?`${e.index+1}. `:`- `}`},exit:({node:e})=>u(e)?`</li>`:void 0,spacing:s},26:{enter:({node:e})=>{if(e.attributes?.href)return`[`},exit:({node:e,state:t})=>{if(!e.attributes?.href)return``;let n=l(e.attributes?.href||``,t.options?.origin),r=e.attributes?.title;return t.lastContentCache===r&&(r=``),r?`](${n} "${r}")`:`](${n})`},collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},27:{enter:({node:e,state:t})=>`})`,collapsesInnerWhiteSpace:!0,isSelfClosing:!0,spacing:i,isInline:!0},28:{enter:({node:e,state:t})=>{if(u(e))return`<table>`;e.depthMap[28]<=1&&(t.tableRenderedTable=!1),t.tableColumnAlignments=[]},exit:({node:e})=>u(e)?`</table>`:void 0},29:{enter:({node:e})=>{if(u(e))return`<thead>`},exit:({node:e})=>u(e)?`</thead>`:void 0,spacing:c,excludesTextNodes:!0},30:{enter:({node:e,state:t})=>u(e)?`<tr>`:(t.tableCurrentRowCells=0,`| `),exit:({node:e,state:t})=>{if(u(e)||e.depthMap[28]>1)return`</tr>`;if(!t.tableRenderedTable){t.tableRenderedTable=!0;let e=t.tableColumnAlignments;for(;e.length<t.tableCurrentRowCells;)e.push(``);return` |\n| ${e.map(e=>{switch(e){case`left`:return`:---`;case`center`:return`:---:`;case`right`:return`---:`;default:return`---`}}).join(` | `)} |`}return` |`},excludesTextNodes:!0,spacing:c},31:{enter:({node:e,state:t})=>{if(e.depthMap[28]>1)return`<th>`;let n=e.attributes?.align?.toLowerCase();return n?t.tableColumnAlignments.push(n):t.tableColumnAlignments.length<=t.tableCurrentRowCells&&t.tableColumnAlignments.push(``),e.index===0?``:` | `},exit:({node:e,state:t})=>{if(e.depthMap[28]>1)return`</th>`;t.tableCurrentRowCells++},collapsesInnerWhiteSpace:!0,spacing:i},32:{enter:({node:e})=>e.depthMap[28]>1?`<td>`:e.index===0?``:` | `,exit:({node:e,state:t})=>{if(e.depthMap[28]>1)return`</td>`;t.tableCurrentRowCells++},collapsesInnerWhiteSpace:!0,spacing:i},35:{},36:{},37:{collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},41:{},42:{collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},43:{collapsesInnerWhiteSpace:!0,isInline:!0},44:{spacing:i},45:{enter:({node:e})=>{if(e.depthMap[28]>1)return`<center>`},exit:({node:e})=>{if(e.depthMap[28]>1)return`</center>`},spacing:i},38:{spacing:i,excludesTextNodes:!0},39:{spacing:c,excludesTextNodes:!0},46:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},47:{spacing:i},40:{spacing:i},54:{isSelfClosing:!0,spacing:i,collapsesInnerWhiteSpace:!0,isInline:!0},55:{isSelfClosing:!0,spacing:i,isInline:!0},56:{isSelfClosing:!0,spacing:i,isInline:!0},57:{isSelfClosing:!0,spacing:i},58:{isSelfClosing:!0,spacing:i},59:{isSelfClosing:!0,spacing:i,isInline:!0},60:{isSelfClosing:!0,spacing:i,isInline:!0},61:{isSelfClosing:!0,spacing:i},62:{isSelfClosing:!0,spacing:i},63:{isSelfClosing:!0,spacing:i},64:{isSelfClosing:!0,spacing:i,isInline:!0},49:{spacing:i},65:{spacing:i},66:{isNonNesting:!0,spacing:i},67:{isNonNesting:!0,spacing:i},68:{spacing:i},69:{spacing:i},70:{spacing:i},71:{spacing:i},72:{spacing:i},73:{isNonNesting:!0,spacing:i},74:{spacing:i},75:{spacing:i},76:{spacing:i},77:{spacing:i},78:{spacing:i},79:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},80:{enter:()=>`<mark>`,exit:()=>`</mark>`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},81:{enter:()=>`"`,exit:()=>`"`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},82:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},83:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},84:{excludesTextNodes:!0,spacing:i},85:{isNonNesting:!0,spacing:i},86:{isNonNesting:!0,spacing:i},87:{isNonNesting:!0,spacing:i},88:{spacing:i},89:{enter:()=>`<u>`,exit:()=>`</u>`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},90:{enter:()=>`*`,exit:()=>`*`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},91:{enter:()=>`**`,exit:()=>`**`,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},92:{enter:()=>"`",exit:()=>"`",collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},93:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},94:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},95:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},96:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},97:{enter:()=>``,exit:()=>``,collapsesInnerWhiteSpace:!0,spacing:i,isInline:!0},100:{enter:()=>`<address>`,exit:()=>`</address>`,spacing:i,collapsesInnerWhiteSpace:!0},101:{spacing:i,enter:()=>`<dl>`,exit:()=>`</dl>`},99:{enter:()=>`<dt>`,exit:()=>`</dt>`,collapsesInnerWhiteSpace:!0,spacing:[0,1]},98:{enter:()=>`<dd>`,exit:()=>`</dd>`,spacing:[0,1]}};function g(e){let t=``,r=0;for(;r<e.length;){if(e[r]===`&`){let i=!1;for(let[a,o]of Object.entries(n))if(e.startsWith(a,r)){t+=o,r+=a.length,i=!0;break}if(i)continue;if(r+2<e.length&&e[r+1]===`#`){let n=r;r+=2;let i=e[r]===`x`||e[r]===`X`;i&&r++;let a=r;for(;r<e.length&&e[r]!==`;`;)r++;if(r<e.length&&e[r]===`;`){let n=e.substring(a,r),o=i?16:10;try{let e=Number.parseInt(n,o);if(!Number.isNaN(e)){t+=String.fromCodePoint(e),r++;continue}}catch{}}r=n}}t+=e[r],r++}return t}function _(e){let t=e,n=[t];for(;t.tagHandler?.isInline&&t.parent;)t=t.parent,n.push(t);return n}const v=Object.freeze({});function y(e){return new Uint8Array(e)}function b(e){return e===32||e===9||e===10||e===13}function x(e,t,n){return S(e,t,n)}function S(e,t,n){let i=``;t.depthMap??=new Uint8Array(108),t.depth??=0,t.lastCharWasWhitespace??=!0,t.justClosedTag??=!1,t.isFirstTextInElement??=!1,t.lastCharWasBackslash??=!1;let a=0,o=e.length;for(;a<o;){let s=e.charCodeAt(a);if(s!==60){if(s===38&&(t.hasEncodedHtmlEntity=!0),b(s)){let n=t.depthMap[34]>0;if(t.justClosedTag&&(t.justClosedTag=!1,t.lastCharWasWhitespace=!1),!n&&t.lastCharWasWhitespace){a++;continue}n?i+=e[a]:(s===32||!t.lastCharWasWhitespace)&&(i+=` `),t.lastCharWasWhitespace=!0,t.textBufferContainsWhitespace=!0,t.lastCharWasBackslash=!1}else t.textBufferContainsNonWhitespace=!0,t.lastCharWasWhitespace=!1,t.justClosedTag=!1,s===124&&t.depthMap[28]?i+=`\\|`:s===96&&(t.depthMap[23]||t.depthMap[34])?i+="\\`":s===91&&t.depthMap[26]?i+=`\\[`:s===93&&t.depthMap[26]?i+=`\\]`:s===62&&t.depthMap[22]?i+=`\\>`:i+=e[a],t.currentNode?.tagHandler?.isNonNesting&&(t.lastCharWasBackslash||(s===39&&!t.inDoubleQuote&&!t.inBacktick?t.inSingleQuote=!t.inSingleQuote:s===34&&!t.inSingleQuote&&!t.inBacktick?t.inDoubleQuote=!t.inDoubleQuote:s===96&&!t.inSingleQuote&&!t.inDoubleQuote&&(t.inBacktick=!t.inBacktick))),t.lastCharWasBackslash=s===92;a++;continue}if(a+1>=o){i+=e[a];break}let c=e.charCodeAt(a+1);if(c===33){i.length>0&&(C(i,t,n),i=``);let r=E(e,a);if(r.complete)a=r.newPosition;else{i+=r.remainingText;break}}else if(c===47){let r=t.inSingleQuote||t.inDoubleQuote||t.inBacktick;if(t.currentNode?.tagHandler?.isNonNesting&&r){i+=e[a],a++;continue}i.length>0&&(C(i,t,n),i=``);let o=w(e,a,t,n);if(o.complete)a=o.newPosition;else{i+=o.remainingText;break}}else{let s=a+1,c=s,l=-1;for(;s<o;){let t=e.charCodeAt(s);if(b(t)||t===47||t===62){l=s;break}s++}if(l===-1){i+=e.substring(a);break}let u=e.substring(c,l).toLowerCase();if(!u){a=l;break}let d=r[u]??-1;if(s=l,t.currentNode?.tagHandler?.isNonNesting&&d!==t.currentNode?.tagId){i+=e[a++];continue}i.length>0&&(C(i,t,n),i=``);let f=D(u,d,e,s,t,n);if(f.skip)i+=e[a++];else if(f.complete)a=f.newPosition,f.selfClosing||(t.isFirstTextInElement=!0);else{i+=f.remainingText;break}}}return i}function C(e,t,n){let r=t.textBufferContainsNonWhitespace,i=t.textBufferContainsWhitespace;if(t.textBufferContainsNonWhitespace=!1,t.textBufferContainsWhitespace=!1,!t.currentNode)return;let a=t.currentNode?.tagHandler?.excludesTextNodes,o=t.depthMap[34]>0;if(!o&&!r&&!t.currentNode.childTextNodeIndex)return;let s=e;if(s.length===0)return;let c=_(t.currentNode),l=c[c.length-1];if(i&&!l?.childTextNodeIndex){let e=0;for(;e<s.length&&(o?s.charCodeAt(e)===10||s.charCodeAt(e)===13:b(s.charCodeAt(e)));)e++;e>0&&(s=s.substring(e))}t.hasEncodedHtmlEntity&&=(s=g(String(s)),!1);let u={type:2,value:s,parent:t.currentNode,regionId:t.currentNode?.regionId,index:t.currentNode.currentWalkIndex++,depth:t.depth,containsWhitespace:i,excludedFromMarkdown:a};for(let e of c)e.childTextNodeIndex=(e.childTextNodeIndex||0)+1;n({type:0,node:u}),t.lastTextNode=u}function w(e,t,n,i){let a=t+2,o=a,s=e.length,c=!1;for(;a<s;){if(e.charCodeAt(a)===62){c=!0;break}a++}if(!c)return{complete:!1,newPosition:t,remainingText:e.substring(t)};let l=r[e.substring(o,a).toLowerCase()]??-1;if(n.currentNode?.tagHandler?.isNonNesting&&l!==n.currentNode.tagId)return{complete:!1,newPosition:t,remainingText:e.substring(t)};let u=n.currentNode;if(u){let e=u.tagId!==l;for(;u&&e;)T(u,n,i),u=u.parent,e=u?.tagId!==l}return u&&T(u,n,i),n.justClosedTag=!0,{complete:!0,newPosition:a+1,remainingText:``}}function T(e,t,n){if(e){if(e.tagId===26&&!e.childTextNodeIndex){let t=e.attributes?.title||e.attributes?.[`aria-label`]||``;if(t){e.childTextNodeIndex=1,n({type:0,node:{type:2,value:t,parent:e,index:0,depth:e.depth+1}});for(let t of _(e))t.childTextNodeIndex=(t.childTextNodeIndex||0)+1}}e.tagId&&(t.depthMap[e.tagId]=Math.max(0,t.depthMap[e.tagId]-1)),e.tagHandler?.isNonNesting&&(t.inSingleQuote=!1,t.inDoubleQuote=!1,t.inBacktick=!1,t.lastCharWasBackslash=!1),t.depth--,n({type:1,node:e}),t.currentNode=t.currentNode.parent,t.hasEncodedHtmlEntity=!1,t.justClosedTag=!0}}function E(e,t){let n=t,r=e.length;if(n+3<r&&e.charCodeAt(n+2)===45&&e.charCodeAt(n+3)===45){for(n+=4;n<r-2;){if(e.charCodeAt(n)===45&&e.charCodeAt(n+1)===45&&e.charCodeAt(n+2)===62)return n+=3,{complete:!0,newPosition:n,remainingText:``};n++}return{complete:!1,newPosition:t,remainingText:e.substring(t)}}else{for(n+=2;n<r;){if(e.charCodeAt(n)===62)return n++,{complete:!0,newPosition:n,remainingText:``};n++}return{complete:!1,newPosition:n,remainingText:e.substring(t,n)}}}function D(e,t,n,r,i,a){i.currentNode?.tagHandler?.isNonNesting&&T(i.currentNode,i,a);let o=h[t],s=O(n,r,o);if(!s.complete)return{complete:!1,newPosition:r,remainingText:`<${e}${s.attrBuffer}`,selfClosing:!1};let c=i.depthMap[t];i.depthMap[t]=c+1,i.depth++,r=s.newPosition,i.currentNode&&(i.currentNode.currentWalkIndex=i.currentNode.currentWalkIndex||0);let l=i.currentNode?i.currentNode.currentWalkIndex++:0,u={type:1,name:e,attributes:s.attributes,parent:i.currentNode,depthMap:y(i.depthMap),depth:i.depth,index:l,regionId:i.currentNode?.regionId,tagId:t,tagHandler:o};i.lastTextNode=u,a({type:0,node:u});let d=u;return d.currentWalkIndex=0,i.currentNode=d,i.hasEncodedHtmlEntity=!1,o?.isNonNesting&&!s.selfClosing&&(i.inSingleQuote=!1,i.inDoubleQuote=!1,i.inBacktick=!1,i.lastCharWasBackslash=!1),s.selfClosing?(T(u,i,a),i.justClosedTag=!0):i.justClosedTag=!1,{complete:!0,newPosition:r,remainingText:``,selfClosing:s.selfClosing}}function O(e,t,n){let r=t,i=e.length,a=n?.isSelfClosing||!1,o=r,s=!1,c=0,l=0;for(;r<i;){let t=e.charCodeAt(r);if(s){t===c&&l!==92&&(s=!1),r++;continue}else if(t===34||t===39)s=!0,c=t;else if(t===47&&r+1<i&&e.charCodeAt(r+1)===62){let t=e.substring(o,r).trim();return{complete:!0,newPosition:r+2,attributes:k(t),selfClosing:!0,attrBuffer:t}}else if(t===62){let t=e.substring(o,r).trim();return{complete:!0,newPosition:r+1,attributes:k(t),selfClosing:a,attrBuffer:t}}r++,l=t}return{complete:!1,newPosition:r,attributes:v,selfClosing:!1,attrBuffer:e.substring(o,r)}}function k(e){if(!e)return v;let t={},n=e.length,r=0,i=0,a=0,o=0,s=0,c=0,l=``;for(;r<n;){let u=e.charCodeAt(r),d=b(u);switch(i){case 0:d||(i=1,a=r,o=0);break;case 1:(u===61||d)&&(o=r,l=e.substring(a,o).toLowerCase(),i=u===61?3:2);break;case 2:u===61?i=3:d||(t[l]=``,i=1,a=r,o=0);break;case 3:u===34||u===39?(c=u,i=4,s=r+1):d||(i=5,s=r);break;case 4:u===92&&r+1<n?r++:u===c&&(t[l]=e.substring(s,r),i=0);break;case 5:(d||u===62)&&(t[l]=e.substring(s,r),i=0);break}r++}if(i===4||i===5)l&&(t[l]=e.substring(s,r));else if(i===1||i===2||i===3){o||=r;let n=e.substring(a,o).toLowerCase();n&&(t[n]=``)}return t}function A(e,t,n,r){if(t?.length){for(let r of t){let t=r.beforeNodeProcess?.(e,n);if(typeof t==`object`&&t.skip)return!0}if(e.node.type===1){let r=e.node;if(e.type===0)for(let e of t)e.processAttributes&&e.processAttributes(r,n);let i=e.type===0?`onNodeEnter`:`onNodeExit`,a=[];for(let e of t)if(e[i]){let t=e[i](r,n);t&&a.push(t)}a.length>0&&(r.pluginOutput=(r.pluginOutput||[]).concat(a))}else if(e.node.type===2&&e.type===0){let r=e.node;for(let e of t)if(e.processTextNode){let t=e.processTextNode(r,n);if(t){if(t.skip)return!0;r.value=t.content}}}}return r(e),!1}function j(e,t,n){if(e===` `||e===`
|
|
9
6
|
`||e===` `||t===` `||t===`
|
|
10
|
-
`||t===` `)return!1;let r=new Set([`[`,`(`,`>`,`*`,`_`,"`"]),i=new Set([`]`,`)`,`<`,`.`,`,`,`!`,`?`,`:`,`;`,`*`,`_`,"`"]);return e===`|`&&t===`<`&&n&&n.depthMap[
|
|
11
|
-
`&&e!==` `&&e!==`[`&&e!==`>`&&!t?.tagHandler?.isInline&&n.value[0]!==` `}function
|
|
12
|
-
`)return;
|
|
7
|
+
`||t===` `)return!1;let r=new Set([`[`,`(`,`>`,`*`,`_`,"`"]),i=new Set([`]`,`)`,`<`,`.`,`,`,`!`,`?`,`:`,`;`,`*`,`_`,"`"]);return e===`|`&&t===`<`&&n&&n.depthMap[28]>0?!0:!(r.has(e)||i.has(t))}function M(e,t,n){return!!e&&e!==`
|
|
8
|
+
`&&e!==` `&&e!==`[`&&e!==`>`&&!t?.tagHandler?.isInline&&n.value[0]!==` `}function N(e){let t=e.tagId,n=e.depthMap;if(t!==25&&n[25]>0||t!==22&&n[22]>0)return i;let r=t!==void 0&&(t>=7&&t<=12||t===35||t===36),o=e.parent;for(;o;){if(o.tagHandler?.collapsesInnerWhiteSpace){if(r&&o.tagId===37){o=o.parent;continue}return i}o=o.parent}return e.tagHandler?.spacing?e.tagHandler?.spacing:a}function P(n={}){let r={options:n,regionToggles:new Map,regionContentBuffers:new Map,depthMap:new Uint8Array(108)};r.regionToggles.set(0,!0),r.regionContentBuffers.set(0,[]);let i=0;function a(t){let{type:n,node:i}=t,a=r.lastNode;r.lastNode=t.node,r.depth=i.depth;let o=r.regionContentBuffers.get(i.regionId||0)||[],s=o[o.length-1],c=s?.charAt(s.length-1)||``,l;if(l=s?.length>1?s.charAt(s.length-2):o[o.length-2]?.charAt(o[o.length-2].length-1),i.type===2&&n===0){let t=i;if(t.value){if(t.excludedFromMarkdown||t.value===` `&&c===`
|
|
9
|
+
`)return;M(c,a,t)&&(t.value=` ${t.value}`),e(t,t.value,r)}r.lastTextNode=t;return}if(i.type!==1)return;let u={node:i,state:r},d=[],f=i;f.pluginOutput?.length&&(d.push(...f.pluginOutput),f.pluginOutput=[]);let p=r.lastContentCache,m=0;c===`
|
|
13
10
|
`&&m++,l===`
|
|
14
|
-
`&&m++;let h=n===
|
|
15
|
-
`.repeat(
|
|
16
|
-
|
|
17
|
-
// Expose mdream globally
|
|
18
|
-
if (typeof window !== 'undefined') {
|
|
19
|
-
window.mdream = fn;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
})();
|
|
11
|
+
`&&m++;let h=n===0?`enter`:`exit`,g=i.tagHandler;if(!d.length&&g?.[h]){let e=g[h](u);e&&d.push(e)}let _=N(i)[n]||0,v=Math.max(0,_-m);if(v>0){if(!o.length){for(let t of d)e(i,t,r);return}let t=`
|
|
12
|
+
`.repeat(v);c===` `&&o?.length&&(o[o.length-1]=o[o.length-1].substring(0,o[o.length-1].length-1)),n===0?d.unshift(t):d.push(t)}else if(p&&r.lastTextNode?.containsWhitespace&&i.parent&&`value`in r.lastTextNode&&typeof r.lastTextNode.value==`string`&&(!i.parent.depthMap[34]||i.parent.tagId===34)){let e=i.tagHandler?.isInline,t=i.tagHandler?.collapsesInnerWhiteSpace,a=i.tagHandler?.spacing&&Array.isArray(i.tagHandler.spacing);if((!e||n===1)&&!(!e&&!t&&_>0)&&!(t&&n===0)&&!(a&&n===0)){let e=p.length,t=p.trimEnd();e-t.length>0&&o?.length&&o[o.length-1]===p&&(o[o.length-1]=t)}r.lastTextNode=void 0}d[0]?.[0]&&n===0&&c&&j(c,d[0][0],r)&&e(i,` `,r);for(let t of d)e(i,t,r)}function o(e){x(e,{depthMap:r.depthMap,depth:0,plugins:r.options?.plugins||[]},e=>{A(e,r.options?.plugins,r,a)})}function s(){return t(r).trimEnd()}function c(){let e=[];for(let[t,n]of Array.from(r.regionContentBuffers.entries()))r.regionToggles.get(t)&&e.push(...n);let t=e.join(``).trimStart(),n=t.slice(i);return i=t.length,n}return{processEvent:a,processHtml:o,getMarkdown:s,getMarkdownChunk:c,state:r}}function F(e,t={}){let n=P(t);return n.processHtml(e),n.getMarkdown()}const I={htmlToMarkdown:F};typeof window<`u`&&(window.mdream=I);var L=I;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _ as TagHandler, a as HandlerContext, b as ExtractedElement, c as MdreamRuntimeState, d as Plugin, f as PluginContext, g as TEXT_NODE, h as SplitterOptions, i as HTMLToMarkdownOptions, l as Node, m as ReadabilityContext, n as ELEMENT_NODE, o as MarkdownChunk, p as PluginCreationOptions, r as ElementNode, s as MdreamProcessingState, t as BufferRegion, u as NodeEvent, v as TailwindContext, y as TextNode } from "./_chunks/types-CT4ZxeOH.mjs";
|
|
2
|
+
import { t as createPlugin } from "./_chunks/plugin-D5soyEXm.mjs";
|
|
3
3
|
import { ReadableStream } from "node:stream/web";
|
|
4
4
|
|
|
5
5
|
//#region src/const.d.ts
|
|
@@ -165,9 +165,6 @@ interface ParseResult {
|
|
|
165
165
|
* Completely decoupled from markdown generation
|
|
166
166
|
*/
|
|
167
167
|
declare function parseHtml(html: string, options?: ParseOptions): ParseResult;
|
|
168
|
-
/**
|
|
169
|
-
* Streaming HTML parser - calls onEvent for each DOM event
|
|
170
|
-
*/
|
|
171
168
|
//#endregion
|
|
172
169
|
//#region src/stream.d.ts
|
|
173
170
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TagIdMap } from "./_chunks/const-
|
|
2
|
-
import {
|
|
3
|
-
import { createPlugin } from "./_chunks/plugin-
|
|
4
|
-
import {
|
|
1
|
+
import { _n as TagIdMap } from "./_chunks/const-Bf_XN9U9.mjs";
|
|
2
|
+
import { i as parseHtml, t as MarkdownProcessor } from "./_chunks/markdown-processor-D26Uo5td.mjs";
|
|
3
|
+
import { t as createPlugin } from "./_chunks/plugin-CjWWQTuL.mjs";
|
|
4
|
+
import { n as streamHtmlToMarkdown, t as htmlToMarkdown } from "./_chunks/src-BJpipdul.mjs";
|
|
5
5
|
|
|
6
6
|
export { MarkdownProcessor, TagIdMap, createPlugin, htmlToMarkdown, parseHtml, streamHtmlToMarkdown };
|
package/dist/llms-txt.d.mts
CHANGED
|
@@ -34,5 +34,49 @@ interface LlmsTxtArtifactsResult {
|
|
|
34
34
|
* Main function to process files and generate llms.txt artifacts
|
|
35
35
|
*/
|
|
36
36
|
declare function generateLlmsTxtArtifacts(options: LlmsTxtArtifactsOptions): Promise<LlmsTxtArtifactsResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Options for creating an llms.txt stream
|
|
39
|
+
*/
|
|
40
|
+
interface CreateLlmsTxtStreamOptions extends Omit<LlmsTxtArtifactsOptions, 'patterns' | 'files' | 'outputDir' | 'generateMarkdown'> {
|
|
41
|
+
/** Directory to write files to (defaults to process.cwd()) */
|
|
42
|
+
outputDir?: string;
|
|
43
|
+
/** Site name for the header (defaults to 'Site') */
|
|
44
|
+
siteName?: string;
|
|
45
|
+
/** Site description for the header */
|
|
46
|
+
description?: string;
|
|
47
|
+
/** Origin URL to prepend to relative URLs */
|
|
48
|
+
origin?: string;
|
|
49
|
+
/** Generate llms-full.txt with complete page content (defaults to false) */
|
|
50
|
+
generateFull?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a WritableStream that generates llms.txt artifacts by streaming pages to disk
|
|
54
|
+
*
|
|
55
|
+
* Writes llms.txt (and optionally llms-full.txt) incrementally as pages are written,
|
|
56
|
+
* never keeping full content in memory. Creates outputDir recursively if needed.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const stream = createLlmsTxtStream({
|
|
61
|
+
* siteName: 'My Docs',
|
|
62
|
+
* description: 'Documentation site',
|
|
63
|
+
* origin: 'https://example.com',
|
|
64
|
+
* generateFull: true,
|
|
65
|
+
* outputDir: './dist',
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* const writer = stream.getWriter()
|
|
69
|
+
* await writer.write({
|
|
70
|
+
* title: 'Home',
|
|
71
|
+
* content: '# Welcome\n\nHome page content.',
|
|
72
|
+
* url: '/',
|
|
73
|
+
* })
|
|
74
|
+
* await writer.close()
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param options - Configuration options
|
|
78
|
+
* @returns WritableStream that accepts ProcessedFile objects
|
|
79
|
+
*/
|
|
80
|
+
declare function createLlmsTxtStream(options?: CreateLlmsTxtStreamOptions): WritableStream<ProcessedFile>;
|
|
37
81
|
//#endregion
|
|
38
|
-
export { LlmsTxtArtifactsOptions, LlmsTxtArtifactsResult, ProcessedFile, generateLlmsTxtArtifacts };
|
|
82
|
+
export { CreateLlmsTxtStreamOptions, LlmsTxtArtifactsOptions, LlmsTxtArtifactsResult, ProcessedFile, createLlmsTxtStream, generateLlmsTxtArtifacts };
|
package/dist/llms-txt.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./_chunks/const-
|
|
2
|
-
import "./_chunks/markdown-processor-
|
|
3
|
-
import "./_chunks/plugin-
|
|
4
|
-
import "./_chunks/src-
|
|
5
|
-
import "./_chunks/extraction-
|
|
6
|
-
import { generateLlmsTxtArtifacts } from "./_chunks/llms-txt-
|
|
1
|
+
import "./_chunks/const-Bf_XN9U9.mjs";
|
|
2
|
+
import "./_chunks/markdown-processor-D26Uo5td.mjs";
|
|
3
|
+
import "./_chunks/plugin-CjWWQTuL.mjs";
|
|
4
|
+
import "./_chunks/src-BJpipdul.mjs";
|
|
5
|
+
import "./_chunks/extraction-BA9MDtq3.mjs";
|
|
6
|
+
import { n as generateLlmsTxtArtifacts, t as createLlmsTxtStream } from "./_chunks/llms-txt-T79S7X24.mjs";
|
|
7
7
|
|
|
8
|
-
export { generateLlmsTxtArtifacts };
|
|
8
|
+
export { createLlmsTxtStream, generateLlmsTxtArtifacts };
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin,
|
|
2
|
-
import {
|
|
1
|
+
import { d as Plugin, x as extractionPlugin } from "./_chunks/types-CT4ZxeOH.mjs";
|
|
2
|
+
import { t as createPlugin } from "./_chunks/plugin-D5soyEXm.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/filter.d.ts
|
|
5
5
|
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./_chunks/const-
|
|
2
|
-
import { createPlugin } from "./_chunks/plugin-
|
|
3
|
-
import { extractionPlugin } from "./_chunks/extraction-
|
|
4
|
-
import { filterPlugin, frontmatterPlugin,
|
|
1
|
+
import "./_chunks/const-Bf_XN9U9.mjs";
|
|
2
|
+
import { t as createPlugin } from "./_chunks/plugin-CjWWQTuL.mjs";
|
|
3
|
+
import { t as extractionPlugin } from "./_chunks/extraction-BA9MDtq3.mjs";
|
|
4
|
+
import { a as filterPlugin, i as frontmatterPlugin, n as readabilityPlugin, r as isolateMainPlugin, t as tailwindPlugin } from "./_chunks/plugins-DJnqR2fA.mjs";
|
|
5
5
|
|
|
6
6
|
export { createPlugin, extractionPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
|
package/dist/preset/minimal.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../_chunks/const-
|
|
2
|
-
import "../_chunks/plugin-
|
|
3
|
-
import "../_chunks/extraction-
|
|
4
|
-
import "../_chunks/plugins-
|
|
5
|
-
import { withMinimalPreset } from "../_chunks/minimal-
|
|
1
|
+
import "../_chunks/const-Bf_XN9U9.mjs";
|
|
2
|
+
import "../_chunks/plugin-CjWWQTuL.mjs";
|
|
3
|
+
import "../_chunks/extraction-BA9MDtq3.mjs";
|
|
4
|
+
import "../_chunks/plugins-DJnqR2fA.mjs";
|
|
5
|
+
import { t as withMinimalPreset } from "../_chunks/minimal-BiDhcwif.mjs";
|
|
6
6
|
|
|
7
7
|
export { withMinimalPreset };
|
package/dist/splitter.d.mts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as SplitterOptions, o as MarkdownChunk } from "./_chunks/types-CT4ZxeOH.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/splitter.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Convert HTML to Markdown and split into chunks in single pass
|
|
7
|
+
* Yields chunks during HTML event processing for better memory efficiency
|
|
8
|
+
*/
|
|
9
|
+
declare function htmlToMarkdownSplitChunksStream(html: string, options?: SplitterOptions): Generator<MarkdownChunk, void, undefined>;
|
|
5
10
|
/**
|
|
6
11
|
* Convert HTML to Markdown and split into chunks in single pass
|
|
7
12
|
* Chunks are created during HTML event processing
|
|
8
13
|
*/
|
|
9
14
|
declare function htmlToMarkdownSplitChunks(html: string, options?: SplitterOptions): MarkdownChunk[];
|
|
10
15
|
//#endregion
|
|
11
|
-
export { type MarkdownChunk, type SplitterOptions, htmlToMarkdownSplitChunks };
|
|
16
|
+
export { type MarkdownChunk, type SplitterOptions, htmlToMarkdownSplitChunks, htmlToMarkdownSplitChunksStream };
|