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.
@@ -1,6 +1,6 @@
1
- import { ELEMENT_NODE, TAG_A, TAG_ADDRESS, TAG_ARTICLE, TAG_ASIDE, TAG_AUDIO, TAG_B, TAG_BLOCKQUOTE, TAG_BODY, TAG_BR, TAG_BUTTON, TAG_CAPTION, TAG_CODE, TAG_DD, TAG_DETAILS, TAG_DIV, TAG_DL, TAG_DT, TAG_EM, TAG_EMBED, TAG_FIELDSET, TAG_FIGCAPTION, TAG_FIGURE, TAG_FOOTER, TAG_FORM, TAG_H1, TAG_H2, TAG_H3, TAG_H4, TAG_H5, TAG_H6, TAG_HEAD, TAG_HEADER, TAG_HR, TAG_HTML, TAG_I, TAG_IFRAME, TAG_IMG, TAG_INPUT, TAG_LI, TAG_MAIN, TAG_META, TAG_NAV, TAG_OBJECT, TAG_OL, TAG_P, TAG_PRE, TAG_SCRIPT, TAG_SECTION, TAG_SELECT, TAG_SPAN, TAG_STRONG, TAG_STYLE, TAG_SUMMARY, TAG_SVG, TAG_TABLE, TAG_TBODY, TAG_TD, TAG_TEXTAREA, TAG_TFOOT, TAG_TH, TAG_THEAD, TAG_TITLE, TAG_TR, TAG_UL, TAG_VIDEO, TEXT_NODE, collectNodeContent, createBufferRegion } from "./const-BOAJ1T5c.mjs";
2
- import { createPlugin } from "./plugin-DrovQriD.mjs";
3
- import { parseSelector } from "./extraction-BPaDGYvv.mjs";
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
- const textNode = node;
32
- let currentParent$1 = textNode.parent;
31
+ let currentParent$1 = node.parent;
33
32
  while (currentParent$1 && excludeSelectors.length) {
34
- const parentShouldExclude = excludeSelectors.some((selector) => selector.matches(currentParent$1));
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
- const shouldExclude = excludeSelectors.some((selector) => selector.matches(element));
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
- const parentShouldExclude = excludeSelectors.some((selector) => selector.matches(currentParent));
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
- const shouldInclude = includeSelectors.some((selector) => selector.matches(currentElement));
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 elementNode = node;
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 void 0;
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
- const frontmatterContent = generateFrontmatter();
117
- collectNodeContent({
118
- type: 1,
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
- const depthDifference = element.depth - firstHeaderElement.depth;
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
- const hasStrongNegativePattern = 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));
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 breakpoints = [
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 normalizedClasses = normalizeClasses(classes);
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 classes = classAttr.trim().split(" ").filter(Boolean);
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 void 0;
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
- const elementNode = node;
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, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
685
+ export { filterPlugin as a, frontmatterPlugin as i, readabilityPlugin as n, isolateMainPlugin as r, tailwindPlugin as t };
@@ -1,4 +1,4 @@
1
- import { createMarkdownProcessor, parseHtmlStream, processPluginsForEvent } from "./markdown-processor-f7XT0--8.mjs";
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
- const htmlContent = `${remainingHtml}${typeof value === "string" ? value : decoder.decode(value, { stream: true })}`;
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 { htmlToMarkdown, streamHtmlToMarkdown };
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 { BufferRegion, ELEMENT_NODE as ELEMENT_NODE$1, ElementNode, type ExtractedElement, HTMLToMarkdownOptions, HandlerContext, MarkdownChunk, MdreamProcessingState, MdreamRuntimeState, Node, NodeEvent, Plugin, PluginContext, PluginCreationOptions, ReadabilityContext, SplitterOptions, TEXT_NODE as TEXT_NODE$1, TagHandler, TailwindContext, TextNode, extractionPlugin as extractionPlugin$1 };
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-BOAJ1T5c.mjs";
2
- import "./_chunks/markdown-processor-f7XT0--8.mjs";
3
- import "./_chunks/plugin-DrovQriD.mjs";
4
- import { streamHtmlToMarkdown } from "./_chunks/src-C3QpB75q.mjs";
5
- import "./_chunks/extraction-BPaDGYvv.mjs";
6
- import { generateLlmsTxtArtifacts } from "./_chunks/llms-txt-DC12yO2l.mjs";
7
- import "./_chunks/plugins-C5_irVJs.mjs";
8
- import { withMinimalPreset } from "./_chunks/minimal-co1tIZYm.mjs";
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
- const llmsPath = join(outputDir, "llms.txt");
42
- await writeFile(llmsPath, result.llmsTxt, "utf-8");
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 __dirname = dirname(fileURLToPath(import.meta.url));
59
- const packageJsonPath = join(__dirname, "..", "package.json");
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={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`,"&apos;":`'`,"&nbsp;":` `},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
- 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())){let i=e.regionToggles.get(n);i&&t.push(...r)}return e.regionToggles.clear(),e.regionContentBuffers.clear(),t.join(``).trimStart()}const n=0,r=1,i=2,a=3,o=4,s=5,c=6,l=7,u=8,d=9,f=10,p=11,m=12,h=13,g=14,_=15,v=16,y=17,ee=18,te=19,ne=20,re=21,b=22,x=23,S=24,C=25,w=26,ie=27,T=28,ae=29,oe=30,se=31,E=32,D=33,O=34,k=35,A=36,j=37,ce=38,le=39,ue=40,de=41,fe=42,pe=43,me=44,he=45,ge=46,_e=47,ve=48,M=49,ye=50,be=51,N=52,P=53,F=54,xe=55,Se=56,Ce=57,we=58,Te=59,Ee=60,De=61,Oe=62,ke=63,Ae=64,je=65,Me=66,Ne=67,Pe=68,Fe=69,Ie=70,Le=71,Re=72,ze=73,Be=74,Ve=75,He=76,Ue=77,We=78,Ge=79,Ke=80,qe=81,Je=82,Ye=83,Xe=84,Ze=85,Qe=86,$e=87,et=88,tt=89,nt=90,rt=91,it=92,at=93,ot=94,st=95,ct=96,lt=97,ut=98,dt=99,ft=100,pt=101,mt=102,ht=103,gt=104,_t=105,vt=106,yt=107,bt=108,xt={"&amp;":`&`,"&lt;":`<`,"&gt;":`>`,"&quot;":`"`,"&#39;":`'`,"&apos;":`'`,"&nbsp;":` `},I=1,L=2,R=0,St=1,Ct={html:n,head:r,details:i,summary:a,title:o,meta:s,br:c,h1:l,h2:u,h3:d,h4:f,h5:p,h6:m,hr:h,strong:g,b:_,em:v,i:y,del:ee,sub:te,sup:ne,ins:re,blockquote:b,code:x,ul:S,li:C,a:w,img:ie,table:T,thead:ae,tr:oe,th:se,td:E,ol:D,pre:O,p:k,div:A,span:j,tbody:ce,tfoot:le,form:ue,nav:de,label:fe,button:pe,body:me,center:he,kbd:ge,footer:_e,path:ve,svg:M,article:ye,section:be,script:N,style:P,link:F,area:xe,base:Se,col:Ce,embed:we,input:Te,keygen:Ee,param:De,source:Oe,track:ke,wbr:Ae,select:je,textarea:Me,option:Ne,fieldset:Pe,legend:Fe,audio:Ie,video:Le,canvas:Re,iframe:ze,map:Be,dialog:Ve,meter:He,progress:Ue,template:We,abbr:Ge,mark:Ke,q:qe,samp:Je,small:Ye,noscript:Xe,noframes:Ze,xmp:Qe,plaintext:$e,aside:et,u:tt,cite:nt,dfn:rt,var:it,time:at,bdo:ot,ruby:st,rt:ct,rp:lt,dd:ut,dt,dl:pt,address:ft,figure:mt,object:ht,main:gt,header:_t,figcaption:vt,caption:yt},wt=`**`,Tt=`_`,Et=`~~`,Dt="```",Ot="`",kt=`---`,z=[0,0],At=[2,2],jt=[1,1],Mt=[1,0],B=[0,1];function Nt(e,t){if(!e)return e;if(e.startsWith(`//`))return`https:${e}`;if(e.startsWith(`#`))return e;if(t){if(e.startsWith(`/`)&&t){let n=t.endsWith(`/`)?t.slice(0,-1):t;return`${n}${e}`}if(e.startsWith(`./`))return`${t}/${e.slice(2)}`;if(!e.startsWith(`http`)){let n=e.startsWith(`/`)?e.slice(1):e;return`${t}/${n}`}}return e}function V(e){return e.depthMap[E]>0}function Pt(e){if(!e)return``;let t=e.split(` `).map(e=>e.split(`language-`)[1]).filter(Boolean);return t.length>0?t[0].trim():``}function H(e){return{enter:({node:t})=>t.depthMap[w]?`<h${e}>`:`${`#`.repeat(e)} `,exit:({node:t})=>{if(t.depthMap[w])return`</h${e}>`},collapsesInnerWhiteSpace:!0}}const Ft={enter:({node:e})=>e.depthMap[_]>1?``:wt,exit:({node:e})=>e.depthMap[_]>1?``:wt,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},It={enter:({node:e})=>e.depthMap[y]>1?``:Tt,exit:({node:e})=>e.depthMap[y]>1?``:Tt,collapsesInnerWhiteSpace:!0,spacing:z,isInline:!0},Lt={[r]:{spacing:z,collapsesInnerWhiteSpace:!0},[i]:{enter:()=>`<details>`,exit:()=>`</details>
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`![${n}](${r})`},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})=>`![${e.attributes?.alt||``}](${l(e.attributes?.src||``,t.options?.origin)})`,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[T]>0?!0:!(r.has(e)||i.has(t))}function cn(e,t,n){return!!e&&e!==`
11
- `&&e!==` `&&e!==`[`&&e!==`>`&&!t?.tagHandler?.isInline&&n.value[0]!==` `}function ln(e){let t=e.tagId,n=e.depthMap;if(t!==C&&n[C]>0||t!==b&&n[b]>0)return z;let r=t!==void 0&&(t>=l&&t<=m||t===k||t===A),i=e.parent;for(;i;){if(i.tagHandler?.collapsesInnerWhiteSpace){if(r&&i.tagId===j){i=i.parent;continue}return z}i=i.parent}return e.tagHandler?.spacing?e.tagHandler?.spacing:At}function un(n={}){let r={options:n,regionToggles:new Map,regionContentBuffers:new Map,depthMap:new Uint8Array(bt)};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===L&&n===R){let t=i;if(t.value){if(t.excludedFromMarkdown||t.value===` `&&c===`
12
- `)return;cn(c,a,t)&&(t.value=` ${t.value}`),e(t,t.value,r)}r.lastTextNode=t;return}if(i.type!==I)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===`
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===R?`enter`:`exit`,g=i.tagHandler;if(!d.length&&g?.[h]){let e=g[h](u);e&&d.push(e)}let _=ln(i),v=_[n]||0,y=Math.max(0,v-m);if(y>0){if(!o.length){for(let t of d)e(i,t,r);return}let t=`
15
- `.repeat(y);c===` `&&o?.length&&(o[o.length-1]=o[o.length-1].substring(0,o[o.length-1].length-1)),n===R?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[O]||i.parent.tagId===O)){let e=i.tagHandler?.isInline,t=i.tagHandler?.collapsesInnerWhiteSpace,a=i.tagHandler?.spacing&&Array.isArray(i.tagHandler.spacing),s=!e&&!t&&v>0,c=(!e||n===St)&&!s&&!(t&&n===R)&&!(a&&n===R);if(c){let e=p.length,t=p.trimEnd(),n=e-t.length;n>0&&o?.length&&o[o.length-1]===p&&(o[o.length-1]=t)}r.lastTextNode=void 0}d[0]?.[0]&&n===R&&c&&sn(c,d[0][0],r)&&e(i,` `,r);for(let t of d)e(i,t,r)}function o(e){let t={depthMap:r.depthMap,depth:0,plugins:r.options?.plugins||[]};Qt(e,t,e=>{on(e,r.options?.plugins,r,a)})}function s(){let e=t(r);return e.trimEnd()}function c(){let e=[];for(let[t,n]of Array.from(r.regionContentBuffers.entries())){let i=r.regionToggles.get(t);i&&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 dn(e,t={}){let n=un(t);return n.processHtml(e),n.getMarkdown()}const fn={htmlToMarkdown:dn};typeof window<`u`&&(window.mdream=fn);var pn=fn;
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 { BufferRegion, ELEMENT_NODE$1 as ELEMENT_NODE, ElementNode, ExtractedElement, HTMLToMarkdownOptions, HandlerContext, MarkdownChunk, MdreamProcessingState, MdreamRuntimeState, Node, NodeEvent, Plugin, PluginContext, PluginCreationOptions, ReadabilityContext, SplitterOptions, TEXT_NODE$1 as TEXT_NODE, TagHandler, TailwindContext, TextNode } from "./_chunks/types-DqiI86yW.mjs";
2
- import { createPlugin$1 as createPlugin } from "./_chunks/plugin-CgnpSqtP.mjs";
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-BOAJ1T5c.mjs";
2
- import { MarkdownProcessor, parseHtml } from "./_chunks/markdown-processor-f7XT0--8.mjs";
3
- import { createPlugin } from "./_chunks/plugin-DrovQriD.mjs";
4
- import { htmlToMarkdown, streamHtmlToMarkdown } from "./_chunks/src-C3QpB75q.mjs";
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 };
@@ -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-BOAJ1T5c.mjs";
2
- import "./_chunks/markdown-processor-f7XT0--8.mjs";
3
- import "./_chunks/plugin-DrovQriD.mjs";
4
- import "./_chunks/src-C3QpB75q.mjs";
5
- import "./_chunks/extraction-BPaDGYvv.mjs";
6
- import { generateLlmsTxtArtifacts } from "./_chunks/llms-txt-DC12yO2l.mjs";
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 };
@@ -1,5 +1,5 @@
1
- import { Plugin, extractionPlugin$1 as extractionPlugin } from "./_chunks/types-DqiI86yW.mjs";
2
- import { createPlugin$1 as createPlugin } from "./_chunks/plugin-CgnpSqtP.mjs";
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-BOAJ1T5c.mjs";
2
- import { createPlugin } from "./_chunks/plugin-DrovQriD.mjs";
3
- import { extractionPlugin } from "./_chunks/extraction-BPaDGYvv.mjs";
4
- import { filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin } from "./_chunks/plugins-C5_irVJs.mjs";
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 };
@@ -1,4 +1,4 @@
1
- import { HTMLToMarkdownOptions } from "../_chunks/types-DqiI86yW.mjs";
1
+ import { i as HTMLToMarkdownOptions } from "../_chunks/types-CT4ZxeOH.mjs";
2
2
 
3
3
  //#region src/preset/minimal.d.ts
4
4
 
@@ -1,7 +1,7 @@
1
- import "../_chunks/const-BOAJ1T5c.mjs";
2
- import "../_chunks/plugin-DrovQriD.mjs";
3
- import "../_chunks/extraction-BPaDGYvv.mjs";
4
- import "../_chunks/plugins-C5_irVJs.mjs";
5
- import { withMinimalPreset } from "../_chunks/minimal-co1tIZYm.mjs";
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 };
@@ -1,11 +1,16 @@
1
- import { MarkdownChunk, SplitterOptions } from "./_chunks/types-DqiI86yW.mjs";
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 };