md2x 0.4.0 → 0.5.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/dist/chunks/chunk-2LPNL4GA.js +1 -0
- package/dist/chunks/chunk-3P5X57NT.js +262 -0
- package/dist/chunks/chunk-3VL755NO.js +1 -0
- package/dist/chunks/chunk-5DPTQTJJ.js +1 -0
- package/dist/chunks/chunk-5DRL26RK.js +108 -0
- package/dist/chunks/chunk-AK6TXLWO.js +1 -0
- package/dist/chunks/chunk-CN4F5HOV.js +5 -0
- package/dist/chunks/chunk-CVKZIRZW.js +5 -0
- package/dist/chunks/chunk-DFROP2PD.js +11 -0
- package/dist/chunks/chunk-DJGIYXVP.js +3 -0
- package/dist/chunks/chunk-IENSDROB.js +1 -0
- package/dist/chunks/chunk-LLCWR7UA.js +1 -0
- package/dist/chunks/chunk-MHCTK6WW.js +1 -0
- package/dist/chunks/chunk-NM6J3ND7.js +1 -0
- package/dist/chunks/chunk-PARPCLXM.js +1 -0
- package/dist/chunks/chunk-PUOHPY5L.js +16 -0
- package/dist/chunks/chunk-PXO7VHRW.js +723 -0
- package/dist/chunks/chunk-R65AQGTF.js +1 -0
- package/dist/chunks/chunk-R6G2575A.js +3 -0
- package/dist/chunks/chunk-TRGQPVRY.js +2 -0
- package/dist/chunks/chunk-URO5RPHJ.js +9 -0
- package/dist/chunks/chunk-YFL3W3OS.js +1 -0
- package/dist/chunks/chunk-Z4LVGK7Y.js +1 -0
- package/dist/chunks/docx-exporter-FGXU5MTK.js +1 -0
- package/dist/chunks/rehype-highlight-Y4Q4RX67.js +1 -0
- package/dist/chunks/rehype-katex-FXTCTSUE.js +1 -0
- package/dist/chunks/rehype-stringify-4CQSSRDL.js +1 -0
- package/dist/chunks/remark-gfm-BUZ4SLP3.js +1 -0
- package/dist/chunks/remark-math-HEZQAPFK.js +1 -0
- package/dist/chunks/remark-parse-QC7TSXTK.js +1 -0
- package/dist/chunks/remark-rehype-C2LX643P.js +1 -0
- package/dist/chunks/remark-super-sub-EP2AQS54.js +1 -0
- package/dist/chunks/theme-manager-AZBU2SLL.js +1 -0
- package/dist/chunks/theme-to-css-GLV3WYDU.js +85 -0
- package/dist/chunks/unified-PU53JLVJ.js +1 -0
- package/dist/chunks/unist-util-visit-SBSD62C6.js +1 -0
- package/dist/index.js +1 -0
- package/dist/md2x.js +37 -0
- package/dist/renderer/puppeteer-render.html +1 -2812
- package/package.json +4 -4
- package/dist/index.mjs +0 -131248
- package/dist/md2x.mjs +0 -131485
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import{c as We}from"./chunk-5DRL26RK.js";import*as he from"fs";import*as M from"path";import{createRequire as pn}from"module";import{fileURLToPath as Je,pathToFileURL as _e}from"url";import*as P from"fs";import*as Ve from"os";import*as E from"path";import{fileURLToPath as an,pathToFileURL as Se}from"url";function ln(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:E.dirname(an(import.meta.url))}var Te=null;function sn(){let e=ln();return E.join(e,"renderer","puppeteer-render.html")}function cn(e){switch(e){case"Letter":return{widthIn:8.5,heightIn:11};case"Legal":return{widthIn:8.5,heightIn:14};case"A3":return{widthIn:11.69,heightIn:16.54};case"A5":return{widthIn:5.83,heightIn:8.27};case"A4":default:return{widthIn:8.27,heightIn:11.69}}}function un(e){switch(e){case"A3":return{top:"25mm",bottom:"25mm",left:"20mm",right:"20mm"};case"A5":return{top:"15mm",bottom:"15mm",left:"12mm",right:"12mm"};case"Legal":return{top:"25mm",bottom:"25mm",left:"20mm",right:"20mm"};case"Letter":case"A4":default:return{top:"20mm",bottom:"20mm",left:"15mm",right:"15mm"}}}function ue(e){if(typeof e=="number")return e/96;let r=String(e??"").trim();if(!r)return null;let n=r.match(/^(-?\d+(?:\.\d+)?)(px|in|mm|cm)$/i);if(!n)return null;let t=parseFloat(n[1]);if(!Number.isFinite(t))return null;let i=n[2].toLowerCase();return i==="in"?t:i==="cm"?t/2.54:i==="mm"?t/25.4:i==="px"?t/96:null}async function fe(){try{Te=await import("puppeteer")}catch{return console.warn("Puppeteer dependency not found. Diagrams/HTML/SVG will be skipped."),console.warn("If you are using the published CLI, run via `npx md2x ...` (it installs Puppeteer automatically)."),console.warn("If you are running from this repo, install CLI deps first: `npm -C node i` (or `pnpm -C node i`)."),null}let e=null,r=null,n=null,t=[],i=a=>{t.push(a),t.length>60&&t.shift()},l=()=>{let a=[E.join(process.cwd(),".md2x-"),E.join(Ve.tmpdir(),"md2x-")];for(let s of a)try{return P.mkdirSync(E.dirname(s),{recursive:!0}),P.mkdtempSync(s)}catch{}throw new Error("Unable to create a writable temp directory for Chromium runtime files")},o=async a=>{if(!r||!a)return;let s=Se(a+E.sep).href;await r.evaluate(c=>{let f=window;if(typeof f.__md2xSetBaseHref=="function"){f.__md2xSetBaseHref(c);return}let u=document.querySelector("base");u||(u=document.createElement("base"),document.head.appendChild(u)),u.href=c},s)};return{async initialize(){if(!Te)return;let a=sn();if(!P.existsSync(a))throw new Error(`Missing renderer assets: ${a}
|
|
2
|
+
Run \`npm run node\` to build the CLI (it generates node/dist/renderer/*).`);n=l();let s=E.join(n,"chrome-profile");P.mkdirSync(s,{recursive:!0}),e=await Te.launch({headless:!0,userDataDir:s,env:{...process.env,HOME:n,XDG_CACHE_HOME:E.join(n,"xdg-cache"),XDG_CONFIG_HOME:E.join(n,"xdg-config"),XDG_DATA_HOME:E.join(n,"xdg-data")},args:["--no-sandbox","--disable-setuid-sandbox","--disable-web-security","--allow-file-access-from-files","--disable-breakpad","--disable-crash-reporter","--disable-features=Crashpad","--no-first-run","--no-default-browser-check"]}),r=await e.newPage(),r.on("console",c=>{i(`[console.${c.type()}] ${c.text()}`)}),r.on("pageerror",c=>{let f=c instanceof Error?c.message:String(c);i(`[pageerror] ${f}`)}),r.on("requestfailed",c=>{let f=c.failure();i(`[requestfailed] ${c.url()} ${f?.errorText??""}`.trim())}),await r.setViewport({width:2e3,height:2e3}),await r.goto(Se(a).href,{waitUntil:"domcontentloaded"});try{await r.waitForFunction(()=>window.__md2xRenderReady===!0,{timeout:3e4})}catch(c){let f=`Renderer page did not become ready within 30s.
|
|
3
|
+
Common causes:
|
|
4
|
+
- \`puppeteer-render.html\` has a <base> that breaks relative script loading
|
|
5
|
+
- missing/broken \`node/dist/renderer/puppeteer-render-worker.js\`
|
|
6
|
+
- browser console error during initialization
|
|
7
|
+
`,u=t.length?`
|
|
8
|
+
Last browser logs:
|
|
9
|
+
${t.join(`
|
|
10
|
+
`)}
|
|
11
|
+
`:"",d=c instanceof Error?c.message:String(c);throw new Error(`${f}
|
|
12
|
+
Original error: ${d}${u}`)}},async render(a,s,c,f){if(!r)return null;try{return await o(c),await r.evaluate(async(d,p,g)=>{let x=window.__md2xRender;if(typeof x!="function")throw new Error("Renderer function not available on page");return await x(d,p,g)},a,s,f??null)}catch(u){let d=u instanceof Error?u.message:String(u);return console.warn(`Failed to render ${a}: ${d}`),null}},async exportToPdf(a,s,c={},f){if(!r)throw new Error("Browser not initialized");let u=await e.newPage(),d=null;try{let g=`<!DOCTYPE html>
|
|
13
|
+
<html>
|
|
14
|
+
<head>
|
|
15
|
+
<meta charset="UTF-8">
|
|
16
|
+
<title>${c.title||"Document"}</title>
|
|
17
|
+
<style>${s}</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="markdown-content">${a}</div>
|
|
21
|
+
</body>
|
|
22
|
+
</html>`;f?(d=E.join(f,`__md2x_temp_${Date.now()}.html`),P.writeFileSync(d,g,"utf-8"),await u.goto(Se(d).href,{waitUntil:"networkidle0"})):await u.setContent(g,{waitUntil:"networkidle0"});let h=c.format||"A4",x=c.landscape||!1,w=c.scale||1,{widthIn:y,heightIn:$}=cn(h),W=x?y:$,F=un(h),V=ue(c.margin?.top??F.top)??ue(F.top),z=ue(c.margin?.bottom??F.bottom)??ue(F.bottom),U=(W-V-z)*96/w;await u.evaluate(S=>{let K=document.getElementById("markdown-content");if(!K)return;let Ae=window.getComputedStyle(K),Ce=parseFloat(Ae.paddingTop||"0")||0,ee=parseFloat(Ae.paddingBottom||"0")||0,re=Math.max(0,S-Ce-ee);K.querySelectorAll(".md2x-diagram img.md2x-diagram, img.md2x-diagram").forEach(ce=>{let Y=ce,Ge=Y.getBoundingClientRect().height||Y.naturalHeight||0;Ge&&(Ge<=re+.5||(Y.style.maxHeight=`${re}px`,Y.style.height="auto",Y.style.width="auto",Y.style.maxWidth="100%",Y.style.objectFit="contain"))})},U),await u.evaluate(()=>{let S=document.getElementById("markdown-content");if(!S)return;let K=S.clientWidth;if(!K)return;S.querySelectorAll(':scope > div[style*="width"]').forEach(Ce=>{let ee=Ce,re=ee.style.width?.match(/^(\d+(?:\.\d+)?)px$/);if(!re)return;let se=parseFloat(re[1]);if(!Number.isFinite(se)||se<=0)return;let ce=Math.min(1,K/se);ce>=.999||(ee.style.transformOrigin="top left",ee.style.transform=`scale(${ce})`)})});let L={printBackground:c.printBackground!==!1,scale:c.scale||1,displayHeaderFooter:c.displayHeaderFooter||!1,headerTemplate:c.headerTemplate||"",footerTemplate:c.footerTemplate||"",margin:{top:c.margin?.top??F.top,bottom:c.margin?.bottom??F.bottom,left:c.margin?.left??F.left,right:c.margin?.right??F.right}};c.width&&c.height?(L.width=c.width,L.height=c.height):(L.format=c.format||"A4",L.landscape=c.landscape||!1);let I=await u.pdf(L);return Buffer.from(I)}finally{if(await u.close(),d)try{P.unlinkSync(d)}catch{}}},async close(){if(e&&(await e.close(),e=null,r=null),n){try{P.rmSync(n,{recursive:!0,force:!0})}catch{}n=null}}}}import*as j from"fs";import*as A from"path";import{pathToFileURL as Ke}from"url";function fn(e){if(j.existsSync(A.join(e,"themes")))return e;let r=A.resolve(e,"../../src");if(j.existsSync(A.join(r,"themes")))return r;let n=A.resolve(process.cwd(),"src");if(j.existsSync(A.join(n,"themes")))return n;throw new Error("Unable to locate themes assets (expected themes/ directory).")}function dn(e){j.mkdirSync(A.dirname(e),{recursive:!0})}var ke=class{constructor(){this.documentPath="";this.documentDir="";this.baseUrl="";this.needsUriRewrite=!1}setDocumentPath(r,n){this.documentPath=r,this.documentDir=A.dirname(r),this.baseUrl=n??Ke(this.documentDir+A.sep).href,this.needsUriRewrite=!1}resolvePath(r){return r.startsWith("file://")?new URL(r).pathname:A.isAbsolute(r)?r:A.resolve(this.documentDir||process.cwd(),r)}toResourceUrl(r){return Ke(r).href}async readFile(r,n){let t=await j.promises.readFile(r);return n?.binary?t.toString("base64"):t.toString("utf8")}async readRelativeFile(r,n){let t=this.resolvePath(r);return await this.readFile(t,n)}async fetchRemote(r){let n=await fetch(r,{signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);let t=await n.arrayBuffer();return new Uint8Array(t)}};function de(e){let r=fn(e.moduleDir),n=new Map;n.set("selectedTheme",e.selectedThemeId),e.settings&&n.set("markdownViewerSettings",e.settings);let t=null,i=new ke;return i.setDocumentPath(A.join(process.cwd(),"__md2x__.md")),{platform:{platform:"node",cache:{async init(){},async calculateHash(){return""},async generateKey(){return""},async get(){return null},async set(){return!1},async clear(){return!0},async getStats(){return null}},renderer:{async init(){},setThemeConfig(){},getThemeConfig(){return null},async render(){throw new Error("RendererService not available in Node platform")}},storage:{async get(o){let a={};for(let s of o)n.has(s)&&(a[s]=n.get(s));return a},async set(o){for(let[a,s]of Object.entries(o))n.set(a,s)},async remove(o){for(let a of o)n.delete(a)}},file:{async download(o,a,s){let c=typeof o=="string"?Buffer.from(o,"base64"):Buffer.from(await o.arrayBuffer());if(s?.onProgress&&s.onProgress({uploaded:c.length,total:c.length}),e.output.kind==="buffer"){t=c;return}dn(a),await j.promises.writeFile(a,c)}},resource:{async fetch(o){let a=o;if(a.startsWith("file://")){let c=new URL(a);return await j.promises.readFile(c.pathname,"utf8")}a.startsWith("./")&&(a=a.slice(2)),a.startsWith("/")&&(a=a.slice(1));let s=A.join(r,a);return await j.promises.readFile(s,"utf8")},getURL(o){return`./${o}`}},i18n:{translate(o){return o},getUILanguage(){return"en"}},message:{async send(){return null},addListener(){}},document:i},getCapturedBuffer:()=>t}}function Ee(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:M.dirname(Je(import.meta.url))}function Oe(){typeof globalThis.atob!="function"&&(globalThis.atob=e=>Buffer.from(e,"base64").toString("binary")),typeof globalThis.btoa!="function"&&(globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"))}async function Pe(e){let n=await globalThis.platform.resource.fetch(`themes/presets/${e}.json`),t=JSON.parse(n),i=t?.fontScheme?.body?.fontFamily,l=t?.fontScheme?.body?.fontSize?parseFloat(t.fontScheme.body.fontSize):void 0;return{fontFamily:typeof i=="string"?i:void 0,fontSize:typeof l=="number"&&Number.isFinite(l)?l:void 0}}function mn(e,r,n){return e?{async render(t,i){let l=await e.render(t,i,r,n);return l||null}}:null}function Fe(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hn(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(///g,"/").replace(/</gi,"<").replace(/>/gi,">").replace(/&/gi,"&").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}async function gn(e,r,n,t,i){if(i!=="img"||!r)return e;let l=We.filter(f=>f.nodeSelector.includes("code")).map(f=>f.language).filter(f=>f!==null),o=["graphviz","gv","vegalite"],a=[...l,...o].join("|");if(!a)return e;let s=new RegExp(`<pre><code class="(?:hljs )?language-(${a})">([\\s\\S]*?)<\\/code><\\/pre>`,"gi"),c=[...e.matchAll(s)];for(let f of c){let[u,d,p]=f,g=hn(p),h=d.toLowerCase();(h==="graphviz"||h==="gv")&&(h="dot"),h==="vegalite"&&(h="vega-lite");try{let x=await r.render(h,g,n,t);if(x&&x.base64){let w=`<div class="md2x-diagram"><img class="md2x-diagram" src="data:image/${x.format};base64,${x.base64}" alt="${Fe(`${d} diagram`)}" style="max-width: 100%;" /></div>`;e=e.replace(u,w)}}catch(x){console.warn(`Failed to render ${d} diagram:`,x)}}return e}async function Xe(e,r,n,t,i){let{unified:l}=await import("./unified-PU53JLVJ.js"),o=(await import("./remark-parse-QC7TSXTK.js")).default,a=(await import("./remark-gfm-BUZ4SLP3.js")).default,s=(await import("./remark-math-HEZQAPFK.js")).default,c=(await import("./remark-super-sub-EP2AQS54.js")).default,f=(await import("./remark-rehype-C2LX643P.js")).default,u=(await import("./rehype-katex-FXTCTSUE.js")).default,d=(await import("./rehype-highlight-Y4Q4RX67.js")).default,p=(await import("./rehype-stringify-4CQSSRDL.js")).default,{visit:g}=await import("./unist-util-visit-SBSD62C6.js");function h(){return $=>{g($,"element",W=>{if(W.tagName!=="p")return;let F=W.children||[];if(F.length===0)return;let V=0,z=-1,U=!1,L=!1;for(let I=0;I<F.length;I++){let S=F[I];S.type==="element"&&S.tagName==="img"?(V++,z=I,L=!0):L&&(S.type==="text"&&S.value.trim()!==""||S.type==="element"&&S.tagName!=="br")&&(U=!0)}if(V===1&&!U&&z>=0){let I=F[z];I.properties=I.properties||{};let S=I.properties.className||[];I.properties.className=Array.isArray(S)?[...S,"block-image"]:[S,"block-image"]}})}}let w=await l().use(o).use(a,{singleTilde:!1}).use(s).use(c).use(f,{allowDangerousHtml:!0}).use(u).use(d).use(h).use(p,{allowDangerousHtml:!0}).process(e),y=String(w);return y=await gn(y,r,n,t,i),y}var pe=class{async exportToBuffer(r,n={}){Oe();let t=n.theme||"default",i=n.basePath??process.cwd(),l=Ee(),{platform:o,getCapturedBuffer:a}=de({moduleDir:l,selectedThemeId:t,output:{kind:"buffer"},settings:{docxHrAsPageBreak:n.hrAsPageBreak??!0}}),s=globalThis.platform;globalThis.platform=o;let c=M.join(i,"__md2x__.md"),f=null;try{f=await fe(),f&&await f.initialize();let u=await Pe(t),d=mn(f,i,u),{default:p}=await import("./docx-exporter-FGXU5MTK.js"),g=new p(d);g.setBaseUrl?.(_e(c).href);let h=await g.exportToDocx(r,"__md2x__.docx",null);if(!h.success)throw new Error(h.error||"DOCX export failed");let x=a();if(!x)throw new Error("DOCX export produced no output buffer");return x}finally{try{f&&await f.close()}finally{globalThis.platform=s}}}};async function Qe(e){let r=globalThis.platform;await(await import("./theme-manager-AZBU2SLL.js")).default.initialize();let t=await r.resource.fetch(`themes/presets/${e}.json`),i=JSON.parse(t),l=await r.resource.fetch(`themes/layout-schemes/${i.layoutScheme}.json`),o=JSON.parse(l),a=await r.resource.fetch(`themes/color-schemes/${i.colorScheme}.json`),s=JSON.parse(a),c=await r.resource.fetch(`themes/table-styles/${i.tableStyle}.json`),f=JSON.parse(c),u=await r.resource.fetch(`themes/code-themes/${i.codeTheme}.json`),d=JSON.parse(u),{themeToCSS:p}=await import("./theme-to-css-GLV3WYDU.js");return p(i,o,s,f,d)}async function Ze(e=!0){return`
|
|
23
|
+
/* Base PDF Styles */
|
|
24
|
+
* {
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body {
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 0;
|
|
31
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
|
32
|
+
line-height: 1.6;
|
|
33
|
+
color: #333;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.markdown-body, #markdown-content {
|
|
37
|
+
max-width: 100%;
|
|
38
|
+
padding: 20px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Wide content auto-scaling for PDF */
|
|
42
|
+
/* Use transform scale to fit wide content within page width */
|
|
43
|
+
/* The actual scale value will be set dynamically via JavaScript */
|
|
44
|
+
#markdown-content > div[style*="width"] {
|
|
45
|
+
transform-origin: top left;
|
|
46
|
+
break-inside: avoid;
|
|
47
|
+
page-break-inside: avoid;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Headings */
|
|
51
|
+
h1, h2, h3, h4, h5, h6 {
|
|
52
|
+
margin-top: 24px;
|
|
53
|
+
margin-bottom: 16px;
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
line-height: 1.25;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
h1 { font-size: 2em; border-bottom: 1px solid #eaecef; padding-bottom: 0.3em; }
|
|
59
|
+
h2 { font-size: 1.5em; border-bottom: 1px solid #eaecef; padding-bottom: 0.3em; }
|
|
60
|
+
h3 { font-size: 1.25em; }
|
|
61
|
+
h4 { font-size: 1em; }
|
|
62
|
+
h5 { font-size: 0.875em; }
|
|
63
|
+
h6 { font-size: 0.85em; color: #6a737d; }
|
|
64
|
+
|
|
65
|
+
/* Paragraphs */
|
|
66
|
+
p {
|
|
67
|
+
margin-top: 0;
|
|
68
|
+
margin-bottom: 16px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Links */
|
|
72
|
+
a {
|
|
73
|
+
color: #0366d6;
|
|
74
|
+
text-decoration: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
a:hover {
|
|
78
|
+
text-decoration: underline;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Lists */
|
|
82
|
+
ul, ol {
|
|
83
|
+
padding-left: 2em;
|
|
84
|
+
margin-top: 0;
|
|
85
|
+
margin-bottom: 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
li {
|
|
89
|
+
margin-bottom: 4px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
li + li {
|
|
93
|
+
margin-top: 4px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Code */
|
|
97
|
+
code {
|
|
98
|
+
padding: 0.2em 0.4em;
|
|
99
|
+
margin: 0;
|
|
100
|
+
font-size: 85%;
|
|
101
|
+
background-color: rgba(27, 31, 35, 0.05);
|
|
102
|
+
border-radius: 3px;
|
|
103
|
+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
pre {
|
|
107
|
+
padding: 16px;
|
|
108
|
+
/* PDFs can't scroll horizontally; wrap long lines instead of clipping. */
|
|
109
|
+
white-space: pre-wrap;
|
|
110
|
+
overflow-wrap: anywhere;
|
|
111
|
+
word-break: break-word;
|
|
112
|
+
font-size: 85%;
|
|
113
|
+
line-height: 1.45;
|
|
114
|
+
background-color: #f6f8fa;
|
|
115
|
+
border-radius: 3px;
|
|
116
|
+
margin-top: 0;
|
|
117
|
+
margin-bottom: 16px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
pre code {
|
|
121
|
+
padding: 0;
|
|
122
|
+
margin: 0;
|
|
123
|
+
font-size: 100%;
|
|
124
|
+
background-color: transparent;
|
|
125
|
+
border: 0;
|
|
126
|
+
/* Inherit wrapping behavior from <pre> for PDFs */
|
|
127
|
+
white-space: inherit;
|
|
128
|
+
overflow-wrap: inherit;
|
|
129
|
+
word-break: inherit;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Blockquotes */
|
|
133
|
+
blockquote {
|
|
134
|
+
padding: 0 1em;
|
|
135
|
+
color: #6a737d;
|
|
136
|
+
border-left: 0.25em solid #dfe2e5;
|
|
137
|
+
margin: 0 0 16px 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
blockquote > :first-child {
|
|
141
|
+
margin-top: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
blockquote > :last-child {
|
|
145
|
+
margin-bottom: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Tables */
|
|
149
|
+
table {
|
|
150
|
+
border-collapse: collapse;
|
|
151
|
+
border-spacing: 0;
|
|
152
|
+
margin-top: 0;
|
|
153
|
+
margin-bottom: 16px;
|
|
154
|
+
width: auto;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
th, td {
|
|
158
|
+
padding: 6px 13px;
|
|
159
|
+
border: 1px solid #dfe2e5;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
th {
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
background-color: #f6f8fa;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
tr:nth-child(2n) {
|
|
168
|
+
background-color: #f6f8fa;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Images */
|
|
172
|
+
img {
|
|
173
|
+
max-width: 100%;
|
|
174
|
+
height: auto;
|
|
175
|
+
box-sizing: content-box;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Diagrams (rendered images) */
|
|
179
|
+
.md2x-diagram {
|
|
180
|
+
text-align: center;
|
|
181
|
+
break-inside: avoid;
|
|
182
|
+
page-break-inside: avoid;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.md2x-diagram .md2x-diagram-inner {
|
|
186
|
+
display: inline-block;
|
|
187
|
+
max-width: 100%;
|
|
188
|
+
text-align: left;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.md2x-diagram .md2x-diagram-mount {
|
|
192
|
+
display: inline-block;
|
|
193
|
+
max-width: 100%;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.md2x-diagram .vega-embed {
|
|
197
|
+
display: inline-block;
|
|
198
|
+
max-width: 100%;
|
|
199
|
+
width: auto !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.md2x-diagram .md2x-diagram-inner svg,
|
|
203
|
+
.md2x-diagram .md2x-diagram-inner > svg {
|
|
204
|
+
display: block;
|
|
205
|
+
margin-left: auto;
|
|
206
|
+
margin-right: auto;
|
|
207
|
+
max-width: 100%;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.md2x-diagram img,
|
|
211
|
+
img.md2x-diagram {
|
|
212
|
+
display: block;
|
|
213
|
+
max-width: 100%;
|
|
214
|
+
height: auto;
|
|
215
|
+
margin-left: auto;
|
|
216
|
+
margin-right: auto;
|
|
217
|
+
break-inside: avoid;
|
|
218
|
+
page-break-inside: avoid;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#markdown-content svg {
|
|
222
|
+
display: block;
|
|
223
|
+
margin-left: auto;
|
|
224
|
+
margin-right: auto;
|
|
225
|
+
break-inside: avoid;
|
|
226
|
+
page-break-inside: avoid;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* Block-level images: marked by rehypeBlockImages plugin */
|
|
230
|
+
img.block-image {
|
|
231
|
+
display: block;
|
|
232
|
+
margin: 16px 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Task Lists */
|
|
236
|
+
.task-list-item {
|
|
237
|
+
list-style-type: none;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.task-list-item input {
|
|
241
|
+
margin: 0 0.2em 0.25em -1.6em;
|
|
242
|
+
vertical-align: middle;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* KaTeX Math */
|
|
246
|
+
.katex {
|
|
247
|
+
font-size: 1.1em;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.katex-display {
|
|
251
|
+
margin: 1em 0;
|
|
252
|
+
overflow-x: auto;
|
|
253
|
+
overflow-y: hidden;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Syntax Highlighting - GitHub style */
|
|
257
|
+
.hljs {
|
|
258
|
+
display: block;
|
|
259
|
+
overflow-x: auto;
|
|
260
|
+
color: #24292e;
|
|
261
|
+
background: #f6f8fa;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.hljs-comment,
|
|
265
|
+
.hljs-quote {
|
|
266
|
+
color: #6a737d;
|
|
267
|
+
font-style: italic;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.hljs-keyword,
|
|
271
|
+
.hljs-selector-tag,
|
|
272
|
+
.hljs-subst {
|
|
273
|
+
color: #d73a49;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.hljs-number,
|
|
277
|
+
.hljs-literal,
|
|
278
|
+
.hljs-variable,
|
|
279
|
+
.hljs-template-variable,
|
|
280
|
+
.hljs-tag .hljs-attr {
|
|
281
|
+
color: #005cc5;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.hljs-string,
|
|
285
|
+
.hljs-doctag {
|
|
286
|
+
color: #032f62;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.hljs-title,
|
|
290
|
+
.hljs-section,
|
|
291
|
+
.hljs-selector-id {
|
|
292
|
+
color: #6f42c1;
|
|
293
|
+
font-weight: bold;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.hljs-type,
|
|
297
|
+
.hljs-class .hljs-title {
|
|
298
|
+
color: #6f42c1;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.hljs-tag,
|
|
302
|
+
.hljs-name,
|
|
303
|
+
.hljs-attribute {
|
|
304
|
+
color: #22863a;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.hljs-regexp,
|
|
308
|
+
.hljs-link {
|
|
309
|
+
color: #032f62;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.hljs-symbol,
|
|
313
|
+
.hljs-bullet {
|
|
314
|
+
color: #e36209;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.hljs-built_in,
|
|
318
|
+
.hljs-builtin-name {
|
|
319
|
+
color: #005cc5;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.hljs-meta {
|
|
323
|
+
color: #6a737d;
|
|
324
|
+
font-weight: bold;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.hljs-deletion {
|
|
328
|
+
color: #b31d28;
|
|
329
|
+
background-color: #ffeef0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.hljs-addition {
|
|
333
|
+
color: #22863a;
|
|
334
|
+
background-color: #f0fff4;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.hljs-emphasis {
|
|
338
|
+
font-style: italic;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.hljs-strong {
|
|
342
|
+
font-weight: bold;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
${e?`
|
|
346
|
+
/* Horizontal Rule as Page Break */
|
|
347
|
+
hr {
|
|
348
|
+
height: 0;
|
|
349
|
+
padding: 0;
|
|
350
|
+
margin: 0;
|
|
351
|
+
background-color: transparent;
|
|
352
|
+
border: 0;
|
|
353
|
+
page-break-after: always;
|
|
354
|
+
break-after: page;
|
|
355
|
+
visibility: hidden;
|
|
356
|
+
}`:`
|
|
357
|
+
/* Horizontal Rule */
|
|
358
|
+
hr {
|
|
359
|
+
height: 0.25em;
|
|
360
|
+
padding: 0;
|
|
361
|
+
margin: 24px 0;
|
|
362
|
+
background-color: #e1e4e8;
|
|
363
|
+
border: 0;
|
|
364
|
+
}`}
|
|
365
|
+
`}function er(){let e=M.dirname(Je(import.meta.url)),r=M.join(e,"vendor","katex","katex.min.css"),n=r;he.existsSync(r)||(n=pn(import.meta.url).resolve("katex/dist/katex.min.css"));let t=M.dirname(n),i=_e(M.join(t,"fonts")+M.sep).href,l=he.readFileSync(n,"utf-8");return l=l.replace(/url\((['"]?)(?:\.\/)?fonts\//g,`url($1${i}`),l}var me=class{async exportToBuffer(r,n={}){Oe();let t=n.theme||"default",i=n.basePath??process.cwd(),l=Ee(),{platform:o}=de({moduleDir:l,selectedThemeId:t,output:{kind:"buffer"}}),a=globalThis.platform;globalThis.platform=o;let s=null;try{if(s=await fe(),!s)throw new Error("Failed to create browser renderer. Puppeteer is required for PDF export.");await s.initialize();let c=await Pe(t),f=await Xe(r,s,i,c,"img"),u="";try{u=er()}catch(h){console.warn("Failed to load KaTeX CSS for PDF export:",h)}let d=await Ze(n.hrAsPageBreak??!0),p="";try{p=await Qe(t)}catch(h){console.warn("Failed to load theme CSS, using base styles only:",h)}let g=u+`
|
|
366
|
+
`+d+`
|
|
367
|
+
`+p;return await s.exportToPdf(f,g,n.pdf,i)}finally{try{s&&await s.close()}finally{globalThis.platform=a}}}},ne=class{async exportToString(r,n={}){Oe();let t=n.theme||"default",i=n.basePath??process.cwd(),l=Ee(),o=n.diagramMode||"live",{platform:a}=de({moduleDir:l,selectedThemeId:t,output:{kind:"buffer"}}),s=globalThis.platform;globalThis.platform=a;let c=null;try{let f=await Pe(t);o==="img"&&(c=await fe(),c&&await c.initialize());let u=await Xe(r,c,i,f,o);if(!(n.standalone!==!1))return u;let p="";try{p=er()}catch(L){console.warn("Failed to load KaTeX CSS for HTML export:",L)}let g=await Ze(n.hrAsPageBreak??!1),h="";try{h=await Qe(t)}catch(L){console.warn("Failed to load theme CSS for HTML export, using base styles only:",L)}let x=p+`
|
|
368
|
+
`+g+`
|
|
369
|
+
`+h,w=n.title||"Document",$=n.baseTag!==!1&&!!i?_e(i+M.sep).href:"",W=$?` <base href="${Fe($)}" />
|
|
370
|
+
`:"",F={mermaid:"https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js",vizGlobal:"https://cdn.jsdelivr.net/npm/@viz-js/viz@3.24.0/dist/viz-global.js",viz:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.js",vizRender:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/full.render.js",infographic:"https://cdn.jsdelivr.net/npm/@antv/infographic@0.2.7/dist/infographic.min.js"},V={5:{vega:"https://cdn.jsdelivr.net/npm/vega@5/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@5/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@6/build/vega-embed.min.js"},6:{vega:"https://cdn.jsdelivr.net/npm/vega@6/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@6/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@7/build/vega-embed.min.js"}},z=n.cdn??{},U=o!=="live"?"":`
|
|
371
|
+
<!-- md2x live diagram renderer (CDN) -->
|
|
372
|
+
<script>
|
|
373
|
+
(function () {
|
|
374
|
+
const themeConfig = ${JSON.stringify(f??null)};
|
|
375
|
+
const baseHref = ${JSON.stringify($)};
|
|
376
|
+
const cdnOverrides = ${JSON.stringify(z)};
|
|
377
|
+
const cdnBaseDefaults = ${JSON.stringify(F)};
|
|
378
|
+
const cdnVegaDefaultsByMajor = ${JSON.stringify(V)};
|
|
379
|
+
|
|
380
|
+
function loadScript(src) {
|
|
381
|
+
return new Promise((resolve, reject) => {
|
|
382
|
+
const s = document.createElement('script');
|
|
383
|
+
s.src = src;
|
|
384
|
+
s.async = false;
|
|
385
|
+
s.onload = () => resolve();
|
|
386
|
+
s.onerror = () => reject(new Error('Failed to load script: ' + src));
|
|
387
|
+
document.head.appendChild(s);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function getLangFromCodeClass(codeEl) {
|
|
392
|
+
const cls = (codeEl && codeEl.className) ? String(codeEl.className) : '';
|
|
393
|
+
const m = cls.match(/\\blanguage-([a-z0-9-]+)\\b/i);
|
|
394
|
+
return m ? m[1] : '';
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function normalizeLang(lang) {
|
|
398
|
+
const l = String(lang || '').toLowerCase();
|
|
399
|
+
if (l === 'graphviz' || l === 'gv') return 'dot';
|
|
400
|
+
if (l === 'vegalite') return 'vega-lite';
|
|
401
|
+
return l;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function guessVegaLiteSchemaMajorFromSpec(spec) {
|
|
405
|
+
if (!spec || typeof spec !== 'object') return null;
|
|
406
|
+
const schema = spec.$schema;
|
|
407
|
+
if (typeof schema !== 'string') return null;
|
|
408
|
+
const m = schema.match(/\\/vega-lite\\/v(\\d+)(?:\\.|\\.json|$)/i) || schema.match(/\\/v(\\d+)\\.json$/i);
|
|
409
|
+
if (!m) return null;
|
|
410
|
+
const major = parseInt(m[1], 10);
|
|
411
|
+
return Number.isFinite(major) ? major : null;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function guessVegaLiteSchemaMajorFromText(text) {
|
|
415
|
+
const t = String(text || '');
|
|
416
|
+
const m = t.match(/\\/vega-lite\\/v(\\d+)(?:\\.|\\.json|$)/i) || t.match(/\\/v(\\d+)\\.json$/i);
|
|
417
|
+
if (!m) return null;
|
|
418
|
+
const major = parseInt(m[1], 10);
|
|
419
|
+
return Number.isFinite(major) ? major : null;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function detectVegaLiteMajorFromDocument() {
|
|
423
|
+
// Scan vega-lite blocks and pick a major version based on $schema.
|
|
424
|
+
const blocks = Array.from(document.querySelectorAll('pre > code'));
|
|
425
|
+
let detected = null;
|
|
426
|
+
for (const codeEl of blocks) {
|
|
427
|
+
const langRaw = getLangFromCodeClass(codeEl);
|
|
428
|
+
const lang = normalizeLang(langRaw);
|
|
429
|
+
if (lang !== 'vega-lite') continue;
|
|
430
|
+
|
|
431
|
+
const text = (codeEl && codeEl.textContent) ? codeEl.textContent : '';
|
|
432
|
+
if (!text.trim()) continue;
|
|
433
|
+
|
|
434
|
+
// Prefer a regex scan first so we can still detect schema versions for
|
|
435
|
+
// code blocks that aren't strictly valid JSON (e.g. trailing commas).
|
|
436
|
+
const majorFromText = guessVegaLiteSchemaMajorFromText(text);
|
|
437
|
+
if (majorFromText && (majorFromText === 5 || majorFromText === 6)) {
|
|
438
|
+
detected = majorFromText;
|
|
439
|
+
if (majorFromText === 6) return 6;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
try {
|
|
444
|
+
const spec = JSON.parse(text);
|
|
445
|
+
const major = guessVegaLiteSchemaMajorFromSpec(spec);
|
|
446
|
+
if (major && (major === 5 || major === 6)) {
|
|
447
|
+
detected = major;
|
|
448
|
+
// If any block is v6, prefer v6. Otherwise keep v5.
|
|
449
|
+
if (major === 6) return 6;
|
|
450
|
+
}
|
|
451
|
+
} catch {
|
|
452
|
+
// ignore parse errors
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return detected || 6;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function ensureCdnLibsLoaded() {
|
|
459
|
+
const major = detectVegaLiteMajorFromDocument();
|
|
460
|
+
const vegaDefaults = cdnVegaDefaultsByMajor[String(major)] || cdnVegaDefaultsByMajor['6'];
|
|
461
|
+
const cdn = Object.assign({}, cdnBaseDefaults, vegaDefaults, cdnOverrides || {});
|
|
462
|
+
|
|
463
|
+
// Load order matters.
|
|
464
|
+
await loadScript(cdn.mermaid);
|
|
465
|
+
if (cdn.vizGlobal) {
|
|
466
|
+
await loadScript(cdn.vizGlobal);
|
|
467
|
+
} else {
|
|
468
|
+
await loadScript(cdn.viz);
|
|
469
|
+
await loadScript(cdn.vizRender);
|
|
470
|
+
}
|
|
471
|
+
await loadScript(cdn.vega);
|
|
472
|
+
await loadScript(cdn.vegaLite);
|
|
473
|
+
await loadScript(cdn.vegaEmbed);
|
|
474
|
+
await loadScript(cdn.infographic);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function replacePreWithContainer(preEl, kind) {
|
|
478
|
+
const wrapper = document.createElement('div');
|
|
479
|
+
wrapper.className = 'md2x-diagram';
|
|
480
|
+
wrapper.setAttribute('data-md2x-diagram-kind', kind);
|
|
481
|
+
wrapper.style.maxWidth = '100%';
|
|
482
|
+
const inner = document.createElement('div');
|
|
483
|
+
inner.className = 'md2x-diagram-inner';
|
|
484
|
+
inner.style.display = 'inline-block';
|
|
485
|
+
inner.style.maxWidth = '100%';
|
|
486
|
+
const mount = document.createElement('div');
|
|
487
|
+
mount.className = 'md2x-diagram-mount';
|
|
488
|
+
mount.style.maxWidth = '100%';
|
|
489
|
+
inner.appendChild(mount);
|
|
490
|
+
wrapper.appendChild(inner);
|
|
491
|
+
preEl.replaceWith(wrapper);
|
|
492
|
+
return mount;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function getText(codeEl) {
|
|
496
|
+
return (codeEl && codeEl.textContent) ? codeEl.textContent : '';
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
async function renderMermaid(code, mount, id) {
|
|
500
|
+
const mermaid = window.mermaid;
|
|
501
|
+
if (!mermaid) return;
|
|
502
|
+
mermaid.initialize({
|
|
503
|
+
startOnLoad: false,
|
|
504
|
+
theme: 'default',
|
|
505
|
+
securityLevel: 'loose',
|
|
506
|
+
fontFamily: themeConfig && themeConfig.fontFamily ? themeConfig.fontFamily : undefined,
|
|
507
|
+
});
|
|
508
|
+
const out = await mermaid.render('md2x-mermaid-' + id, code);
|
|
509
|
+
mount.innerHTML = out && out.svg ? out.svg : '';
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
async function renderDot(code, mount) {
|
|
513
|
+
const VizGlobal = window.Viz;
|
|
514
|
+
// Preferred: @viz-js/viz global build
|
|
515
|
+
if (VizGlobal && typeof VizGlobal.instance === 'function') {
|
|
516
|
+
const viz = await VizGlobal.instance();
|
|
517
|
+
const svgEl = viz.renderSVGElement(code, { graphAttributes: { bgcolor: 'transparent' } });
|
|
518
|
+
mount.appendChild(svgEl);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Legacy: viz.js
|
|
523
|
+
if (typeof window.Viz === 'function') {
|
|
524
|
+
const viz = new window.Viz();
|
|
525
|
+
const svgEl = await viz.renderSVGElement(code);
|
|
526
|
+
mount.appendChild(svgEl);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function applyDefaultVegaLiteSort(spec) {
|
|
531
|
+
// If users mark a field as ordinal, a common expectation is "use the data order"
|
|
532
|
+
// (e.g. '1\u6708'...'12\u6708'). Vega-Lite defaults to sorting discrete domains, which can
|
|
533
|
+
// produce surprising orders for stringified numbers. We only change behavior
|
|
534
|
+
// when the author hasn't specified an explicit sort.
|
|
535
|
+
const applyOne = (s) => {
|
|
536
|
+
if (!s || typeof s !== 'object') return;
|
|
537
|
+
const enc = s.encoding;
|
|
538
|
+
const x = enc && enc.x;
|
|
539
|
+
if (x && typeof x === 'object' && x.type === 'ordinal' && !('sort' in x)) {
|
|
540
|
+
x.sort = null;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
const walk = (s) => {
|
|
545
|
+
if (!s || typeof s !== 'object') return;
|
|
546
|
+
applyOne(s);
|
|
547
|
+
|
|
548
|
+
const arrays = ['layer', 'hconcat', 'vconcat', 'concat'];
|
|
549
|
+
for (const key of arrays) {
|
|
550
|
+
const childArr = s[key];
|
|
551
|
+
if (Array.isArray(childArr)) {
|
|
552
|
+
for (const child of childArr) walk(child);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
if (s.spec) walk(s.spec);
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
walk(spec);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
async function renderVegaLite(code, mount) {
|
|
562
|
+
const vegaEmbed = window.vegaEmbed;
|
|
563
|
+
if (typeof vegaEmbed !== 'function') return;
|
|
564
|
+
let spec;
|
|
565
|
+
try {
|
|
566
|
+
spec = JSON.parse(code);
|
|
567
|
+
} catch {
|
|
568
|
+
mount.textContent = 'Invalid Vega-Lite JSON.';
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
applyDefaultVegaLiteSort(spec);
|
|
572
|
+
await vegaEmbed(mount, spec, {
|
|
573
|
+
actions: false,
|
|
574
|
+
renderer: 'svg',
|
|
575
|
+
defaultStyle: true,
|
|
576
|
+
logLevel: (window.vega && window.vega.Warn) ? window.vega.Warn : undefined,
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
async function renderInfographic(code, mount) {
|
|
581
|
+
const lib = window.AntVInfographic;
|
|
582
|
+
if (!lib || !lib.Infographic) return;
|
|
583
|
+
|
|
584
|
+
try {
|
|
585
|
+
if (typeof lib.setDefaultFont === 'function') {
|
|
586
|
+
const ff = themeConfig && themeConfig.fontFamily ? themeConfig.fontFamily : undefined;
|
|
587
|
+
if (ff) lib.setDefaultFont(ff);
|
|
588
|
+
}
|
|
589
|
+
} catch {}
|
|
590
|
+
|
|
591
|
+
const opts = {
|
|
592
|
+
container: mount,
|
|
593
|
+
width: 900,
|
|
594
|
+
height: 600,
|
|
595
|
+
padding: 24,
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
if (themeConfig && themeConfig.diagramStyle === 'handDrawn') {
|
|
599
|
+
opts.themeConfig = { stylize: { type: 'rough', roughness: 0.5, bowing: 0.5 } };
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const ig = new lib.Infographic(opts);
|
|
603
|
+
await new Promise((resolve, reject) => {
|
|
604
|
+
const timeout = setTimeout(() => reject(new Error('Infographic render timeout after 10s')), 10000);
|
|
605
|
+
ig.on && ig.on('rendered', () => { clearTimeout(timeout); resolve(); });
|
|
606
|
+
ig.on && ig.on('error', (err) => { clearTimeout(timeout); reject(err); });
|
|
607
|
+
try {
|
|
608
|
+
ig.render(code);
|
|
609
|
+
} catch (e) {
|
|
610
|
+
clearTimeout(timeout);
|
|
611
|
+
reject(e);
|
|
612
|
+
}
|
|
613
|
+
}).catch(() => {
|
|
614
|
+
// keep container content on errors
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
async function main() {
|
|
619
|
+
// Best-effort base href: some renderers may load assets relative to document.
|
|
620
|
+
try {
|
|
621
|
+
if (baseHref) {
|
|
622
|
+
let base = document.querySelector('base');
|
|
623
|
+
if (!base) {
|
|
624
|
+
base = document.createElement('base');
|
|
625
|
+
document.head.appendChild(base);
|
|
626
|
+
}
|
|
627
|
+
base.href = baseHref;
|
|
628
|
+
}
|
|
629
|
+
} catch {}
|
|
630
|
+
|
|
631
|
+
try {
|
|
632
|
+
await ensureCdnLibsLoaded();
|
|
633
|
+
} catch (e) {
|
|
634
|
+
// If CDN scripts fail to load, keep code blocks as-is.
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const blocks = Array.from(document.querySelectorAll('pre > code'));
|
|
639
|
+
let idx = 0;
|
|
640
|
+
for (const codeEl of blocks) {
|
|
641
|
+
const pre = codeEl && codeEl.parentElement;
|
|
642
|
+
if (!pre) continue;
|
|
643
|
+
const langRaw = getLangFromCodeClass(codeEl);
|
|
644
|
+
if (!langRaw) continue;
|
|
645
|
+
const lang = normalizeLang(langRaw);
|
|
646
|
+
const code = getText(codeEl);
|
|
647
|
+
if (!code.trim()) continue;
|
|
648
|
+
|
|
649
|
+
try {
|
|
650
|
+
if (lang === 'mermaid') {
|
|
651
|
+
const mount = replacePreWithContainer(pre, 'mermaid');
|
|
652
|
+
await renderMermaid(code, mount, idx++);
|
|
653
|
+
} else if (lang === 'dot') {
|
|
654
|
+
const mount = replacePreWithContainer(pre, 'dot');
|
|
655
|
+
await renderDot(code, mount);
|
|
656
|
+
} else if (lang === 'vega-lite') {
|
|
657
|
+
const mount = replacePreWithContainer(pre, 'vega-lite');
|
|
658
|
+
await renderVegaLite(code, mount);
|
|
659
|
+
} else if (lang === 'infographic') {
|
|
660
|
+
const mount = replacePreWithContainer(pre, 'infographic');
|
|
661
|
+
await renderInfographic(code, mount);
|
|
662
|
+
}
|
|
663
|
+
} catch {
|
|
664
|
+
// Keep original code block on error
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (document.readyState === 'loading') {
|
|
670
|
+
document.addEventListener('DOMContentLoaded', () => { main(); }, { once: true });
|
|
671
|
+
} else {
|
|
672
|
+
main();
|
|
673
|
+
}
|
|
674
|
+
})();
|
|
675
|
+
</script>`;return`<!DOCTYPE html>
|
|
676
|
+
<html lang="en">
|
|
677
|
+
<head>
|
|
678
|
+
<meta charset="UTF-8" />
|
|
679
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
680
|
+
${W} <title>${Fe(w)}</title>
|
|
681
|
+
<style>${x}</style>
|
|
682
|
+
</head>
|
|
683
|
+
<body>
|
|
684
|
+
<div id="markdown-content" class="markdown-body">${u}</div>
|
|
685
|
+
${U}
|
|
686
|
+
</body>
|
|
687
|
+
</html>`}finally{try{c&&await c.close()}finally{globalThis.platform=s}}}async exportToBuffer(r,n={}){let t=await this.exportToString(r,n);return Buffer.from(t,"utf8")}};import*as B from"fs";import*as k from"path";function gr(e){return typeof e>"u"||e===null}function xn(e){return typeof e=="object"&&e!==null}function yn(e){return Array.isArray(e)?e:gr(e)?[]:[e]}function bn(e,r){var n,t,i,l;if(r)for(l=Object.keys(r),n=0,t=l.length;n<t;n+=1)i=l[n],e[i]=r[i];return e}function wn(e,r){var n="",t;for(t=0;t<r;t+=1)n+=e;return n}function vn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var An=gr,Cn=xn,Sn=yn,Tn=wn,kn=vn,Fn=bn,v={isNothing:An,isObject:Cn,toArray:Sn,repeat:Tn,isNegativeZero:kn,extend:Fn};function xr(e,r){var n="",t=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!r&&e.mark.snippet&&(n+=`
|
|
688
|
+
|
|
689
|
+
`+e.mark.snippet),t+" "+n):t}function te(e,r){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=r,this.message=xr(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}te.prototype=Object.create(Error.prototype);te.prototype.constructor=te;te.prototype.toString=function(r){return this.name+": "+xr(this,r)};var _=te;function Le(e,r,n,t,i){var l="",o="",a=Math.floor(i/2)-1;return t-r>a&&(l=" ... ",r=t-a+l.length),n-t>a&&(o=" ...",n=t+a-o.length),{str:l+e.slice(r,n).replace(/\t/g,"\u2192")+o,pos:t-r+l.length}}function Ie(e,r){return v.repeat(" ",r-e.length)+e}function _n(e,r){if(r=Object.create(r||null),!e.buffer)return null;r.maxLength||(r.maxLength=79),typeof r.indent!="number"&&(r.indent=1),typeof r.linesBefore!="number"&&(r.linesBefore=3),typeof r.linesAfter!="number"&&(r.linesAfter=2);for(var n=/\r?\n|\r|\0/g,t=[0],i=[],l,o=-1;l=n.exec(e.buffer);)i.push(l.index),t.push(l.index+l[0].length),e.position<=l.index&&o<0&&(o=t.length-2);o<0&&(o=t.length-1);var a="",s,c,f=Math.min(e.line+r.linesAfter,i.length).toString().length,u=r.maxLength-(r.indent+f+3);for(s=1;s<=r.linesBefore&&!(o-s<0);s++)c=Le(e.buffer,t[o-s],i[o-s],e.position-(t[o]-t[o-s]),u),a=v.repeat(" ",r.indent)+Ie((e.line-s+1).toString(),f)+" | "+c.str+`
|
|
690
|
+
`+a;for(c=Le(e.buffer,t[o],i[o],e.position,u),a+=v.repeat(" ",r.indent)+Ie((e.line+1).toString(),f)+" | "+c.str+`
|
|
691
|
+
`,a+=v.repeat("-",r.indent+f+3+c.pos)+`^
|
|
692
|
+
`,s=1;s<=r.linesAfter&&!(o+s>=i.length);s++)c=Le(e.buffer,t[o+s],i[o+s],e.position-(t[o]-t[o+s]),u),a+=v.repeat(" ",r.indent)+Ie((e.line+s+1).toString(),f)+" | "+c.str+`
|
|
693
|
+
`;return a.replace(/\n$/,"")}var En=_n,On=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Pn=["scalar","sequence","mapping"];function Ln(e){var r={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(t){r[String(t)]=n})}),r}function In(e,r){if(r=r||{},Object.keys(r).forEach(function(n){if(On.indexOf(n)===-1)throw new _('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=r,this.tag=e,this.kind=r.kind||null,this.resolve=r.resolve||function(){return!0},this.construct=r.construct||function(n){return n},this.instanceOf=r.instanceOf||null,this.predicate=r.predicate||null,this.represent=r.represent||null,this.representName=r.representName||null,this.defaultStyle=r.defaultStyle||null,this.multi=r.multi||!1,this.styleAliases=Ln(r.styleAliases||null),Pn.indexOf(this.kind)===-1)throw new _('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var C=In;function rr(e,r){var n=[];return e[r].forEach(function(t){var i=n.length;n.forEach(function(l,o){l.tag===t.tag&&l.kind===t.kind&&l.multi===t.multi&&(i=o)}),n[i]=t}),n}function jn(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},r,n;function t(i){i.multi?(e.multi[i.kind].push(i),e.multi.fallback.push(i)):e[i.kind][i.tag]=e.fallback[i.tag]=i}for(r=0,n=arguments.length;r<n;r+=1)arguments[r].forEach(t);return e}function Me(e){return this.extend(e)}Me.prototype.extend=function(r){var n=[],t=[];if(r instanceof C)t.push(r);else if(Array.isArray(r))t=t.concat(r);else if(r&&(Array.isArray(r.implicit)||Array.isArray(r.explicit)))r.implicit&&(n=n.concat(r.implicit)),r.explicit&&(t=t.concat(r.explicit));else throw new _("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(l){if(!(l instanceof C))throw new _("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(l.loadKind&&l.loadKind!=="scalar")throw new _("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(l.multi)throw new _("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),t.forEach(function(l){if(!(l instanceof C))throw new _("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(Me.prototype);return i.implicit=(this.implicit||[]).concat(n),i.explicit=(this.explicit||[]).concat(t),i.compiledImplicit=rr(i,"implicit"),i.compiledExplicit=rr(i,"explicit"),i.compiledTypeMap=jn(i.compiledImplicit,i.compiledExplicit),i};var yr=Me,br=new C("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),wr=new C("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),vr=new C("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Ar=new yr({explicit:[br,wr,vr]});function Mn(e){if(e===null)return!0;var r=e.length;return r===1&&e==="~"||r===4&&(e==="null"||e==="Null"||e==="NULL")}function Dn(){return null}function Rn(e){return e===null}var Cr=new C("tag:yaml.org,2002:null",{kind:"scalar",resolve:Mn,construct:Dn,predicate:Rn,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Bn(e){if(e===null)return!1;var r=e.length;return r===4&&(e==="true"||e==="True"||e==="TRUE")||r===5&&(e==="false"||e==="False"||e==="FALSE")}function Nn(e){return e==="true"||e==="True"||e==="TRUE"}function Hn(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Sr=new C("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Bn,construct:Nn,predicate:Hn,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function $n(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function zn(e){return 48<=e&&e<=55}function Un(e){return 48<=e&&e<=57}function Yn(e){if(e===null)return!1;var r=e.length,n=0,t=!1,i;if(!r)return!1;if(i=e[n],(i==="-"||i==="+")&&(i=e[++n]),i==="0"){if(n+1===r)return!0;if(i=e[++n],i==="b"){for(n++;n<r;n++)if(i=e[n],i!=="_"){if(i!=="0"&&i!=="1")return!1;t=!0}return t&&i!=="_"}if(i==="x"){for(n++;n<r;n++)if(i=e[n],i!=="_"){if(!$n(e.charCodeAt(n)))return!1;t=!0}return t&&i!=="_"}if(i==="o"){for(n++;n<r;n++)if(i=e[n],i!=="_"){if(!zn(e.charCodeAt(n)))return!1;t=!0}return t&&i!=="_"}}if(i==="_")return!1;for(;n<r;n++)if(i=e[n],i!=="_"){if(!Un(e.charCodeAt(n)))return!1;t=!0}return!(!t||i==="_")}function qn(e){var r=e,n=1,t;if(r.indexOf("_")!==-1&&(r=r.replace(/_/g,"")),t=r[0],(t==="-"||t==="+")&&(t==="-"&&(n=-1),r=r.slice(1),t=r[0]),r==="0")return 0;if(t==="0"){if(r[1]==="b")return n*parseInt(r.slice(2),2);if(r[1]==="x")return n*parseInt(r.slice(2),16);if(r[1]==="o")return n*parseInt(r.slice(2),8)}return n*parseInt(r,10)}function Gn(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!v.isNegativeZero(e)}var Tr=new C("tag:yaml.org,2002:int",{kind:"scalar",resolve:Yn,construct:qn,predicate:Gn,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Wn=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Vn(e){return!(e===null||!Wn.test(e)||e[e.length-1]==="_")}function Kn(e){var r,n;return r=e.replace(/_/g,"").toLowerCase(),n=r[0]==="-"?-1:1,"+-".indexOf(r[0])>=0&&(r=r.slice(1)),r===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:r===".nan"?NaN:n*parseFloat(r,10)}var Jn=/^[-+]?[0-9]+e/;function Xn(e,r){var n;if(isNaN(e))switch(r){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(r){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(r){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(v.isNegativeZero(e))return"-0.0";return n=e.toString(10),Jn.test(n)?n.replace("e",".e"):n}function Qn(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||v.isNegativeZero(e))}var kr=new C("tag:yaml.org,2002:float",{kind:"scalar",resolve:Vn,construct:Kn,predicate:Qn,represent:Xn,defaultStyle:"lowercase"}),Fr=Ar.extend({implicit:[Cr,Sr,Tr,kr]}),_r=Fr,Er=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Or=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Zn(e){return e===null?!1:Er.exec(e)!==null||Or.exec(e)!==null}function ei(e){var r,n,t,i,l,o,a,s=0,c=null,f,u,d;if(r=Er.exec(e),r===null&&(r=Or.exec(e)),r===null)throw new Error("Date resolve error");if(n=+r[1],t=+r[2]-1,i=+r[3],!r[4])return new Date(Date.UTC(n,t,i));if(l=+r[4],o=+r[5],a=+r[6],r[7]){for(s=r[7].slice(0,3);s.length<3;)s+="0";s=+s}return r[9]&&(f=+r[10],u=+(r[11]||0),c=(f*60+u)*6e4,r[9]==="-"&&(c=-c)),d=new Date(Date.UTC(n,t,i,l,o,a,s)),c&&d.setTime(d.getTime()-c),d}function ri(e){return e.toISOString()}var Pr=new C("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Zn,construct:ei,instanceOf:Date,represent:ri});function ni(e){return e==="<<"||e===null}var Lr=new C("tag:yaml.org,2002:merge",{kind:"scalar",resolve:ni}),He=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
694
|
+
\r`;function ii(e){if(e===null)return!1;var r,n,t=0,i=e.length,l=He;for(n=0;n<i;n++)if(r=l.indexOf(e.charAt(n)),!(r>64)){if(r<0)return!1;t+=6}return t%8===0}function ti(e){var r,n,t=e.replace(/[\r\n=]/g,""),i=t.length,l=He,o=0,a=[];for(r=0;r<i;r++)r%4===0&&r&&(a.push(o>>16&255),a.push(o>>8&255),a.push(o&255)),o=o<<6|l.indexOf(t.charAt(r));return n=i%4*6,n===0?(a.push(o>>16&255),a.push(o>>8&255),a.push(o&255)):n===18?(a.push(o>>10&255),a.push(o>>2&255)):n===12&&a.push(o>>4&255),new Uint8Array(a)}function oi(e){var r="",n=0,t,i,l=e.length,o=He;for(t=0;t<l;t++)t%3===0&&t&&(r+=o[n>>18&63],r+=o[n>>12&63],r+=o[n>>6&63],r+=o[n&63]),n=(n<<8)+e[t];return i=l%3,i===0?(r+=o[n>>18&63],r+=o[n>>12&63],r+=o[n>>6&63],r+=o[n&63]):i===2?(r+=o[n>>10&63],r+=o[n>>4&63],r+=o[n<<2&63],r+=o[64]):i===1&&(r+=o[n>>2&63],r+=o[n<<4&63],r+=o[64],r+=o[64]),r}function ai(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Ir=new C("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ii,construct:ti,predicate:ai,represent:oi}),li=Object.prototype.hasOwnProperty,si=Object.prototype.toString;function ci(e){if(e===null)return!0;var r=[],n,t,i,l,o,a=e;for(n=0,t=a.length;n<t;n+=1){if(i=a[n],o=!1,si.call(i)!=="[object Object]")return!1;for(l in i)if(li.call(i,l))if(!o)o=!0;else return!1;if(!o)return!1;if(r.indexOf(l)===-1)r.push(l);else return!1}return!0}function ui(e){return e!==null?e:[]}var jr=new C("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ci,construct:ui}),fi=Object.prototype.toString;function di(e){if(e===null)return!0;var r,n,t,i,l,o=e;for(l=new Array(o.length),r=0,n=o.length;r<n;r+=1){if(t=o[r],fi.call(t)!=="[object Object]"||(i=Object.keys(t),i.length!==1))return!1;l[r]=[i[0],t[i[0]]]}return!0}function pi(e){if(e===null)return[];var r,n,t,i,l,o=e;for(l=new Array(o.length),r=0,n=o.length;r<n;r+=1)t=o[r],i=Object.keys(t),l[r]=[i[0],t[i[0]]];return l}var Mr=new C("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:di,construct:pi}),mi=Object.prototype.hasOwnProperty;function hi(e){if(e===null)return!0;var r,n=e;for(r in n)if(mi.call(n,r)&&n[r]!==null)return!1;return!0}function gi(e){return e!==null?e:{}}var Dr=new C("tag:yaml.org,2002:set",{kind:"mapping",resolve:hi,construct:gi}),$e=_r.extend({implicit:[Pr,Lr],explicit:[Ir,jr,Mr,Dr]}),H=Object.prototype.hasOwnProperty,ge=1,Rr=2,Br=3,xe=4,je=1,xi=2,nr=3,yi=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,bi=/[\x85\u2028\u2029]/,wi=/[,\[\]\{\}]/,Nr=/^(?:!|!!|![a-z\-]+!)$/i,Hr=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function ir(e){return Object.prototype.toString.call(e)}function D(e){return e===10||e===13}function G(e){return e===9||e===32}function O(e){return e===9||e===32||e===10||e===13}function X(e){return e===44||e===91||e===93||e===123||e===125}function vi(e){var r;return 48<=e&&e<=57?e-48:(r=e|32,97<=r&&r<=102?r-97+10:-1)}function Ai(e){return e===120?2:e===117?4:e===85?8:0}function Ci(e){return 48<=e&&e<=57?e-48:-1}function tr(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
695
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Si(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function $r(e,r,n){r==="__proto__"?Object.defineProperty(e,r,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[r]=n}var zr=new Array(256),Ur=new Array(256);for(q=0;q<256;q++)zr[q]=tr(q)?1:0,Ur[q]=tr(q);var q;function Ti(e,r){this.input=e,this.filename=r.filename||null,this.schema=r.schema||$e,this.onWarning=r.onWarning||null,this.legacy=r.legacy||!1,this.json=r.json||!1,this.listener=r.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Yr(e,r){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=En(n),new _(r,n)}function m(e,r){throw Yr(e,r)}function ye(e,r){e.onWarning&&e.onWarning.call(null,Yr(e,r))}var or={YAML:function(r,n,t){var i,l,o;r.version!==null&&m(r,"duplication of %YAML directive"),t.length!==1&&m(r,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(t[0]),i===null&&m(r,"ill-formed argument of the YAML directive"),l=parseInt(i[1],10),o=parseInt(i[2],10),l!==1&&m(r,"unacceptable YAML version of the document"),r.version=t[0],r.checkLineBreaks=o<2,o!==1&&o!==2&&ye(r,"unsupported YAML version of the document")},TAG:function(r,n,t){var i,l;t.length!==2&&m(r,"TAG directive accepts exactly two arguments"),i=t[0],l=t[1],Nr.test(i)||m(r,"ill-formed tag handle (first argument) of the TAG directive"),H.call(r.tagMap,i)&&m(r,'there is a previously declared suffix for "'+i+'" tag handle'),Hr.test(l)||m(r,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{m(r,"tag prefix is malformed: "+l)}r.tagMap[i]=l}};function N(e,r,n,t){var i,l,o,a;if(r<n){if(a=e.input.slice(r,n),t)for(i=0,l=a.length;i<l;i+=1)o=a.charCodeAt(i),o===9||32<=o&&o<=1114111||m(e,"expected valid JSON character");else yi.test(a)&&m(e,"the stream contains non-printable characters");e.result+=a}}function ar(e,r,n,t){var i,l,o,a;for(v.isObject(n)||m(e,"cannot merge mappings; the provided source object is unacceptable"),i=Object.keys(n),o=0,a=i.length;o<a;o+=1)l=i[o],H.call(r,l)||($r(r,l,n[l]),t[l]=!0)}function Q(e,r,n,t,i,l,o,a,s){var c,f;if(Array.isArray(i))for(i=Array.prototype.slice.call(i),c=0,f=i.length;c<f;c+=1)Array.isArray(i[c])&&m(e,"nested arrays are not supported inside keys"),typeof i=="object"&&ir(i[c])==="[object Object]"&&(i[c]="[object Object]");if(typeof i=="object"&&ir(i)==="[object Object]"&&(i="[object Object]"),i=String(i),r===null&&(r={}),t==="tag:yaml.org,2002:merge")if(Array.isArray(l))for(c=0,f=l.length;c<f;c+=1)ar(e,r,l[c],n);else ar(e,r,l,n);else!e.json&&!H.call(n,i)&&H.call(r,i)&&(e.line=o||e.line,e.lineStart=a||e.lineStart,e.position=s||e.position,m(e,"duplicated mapping key")),$r(r,i,l),delete n[i];return r}function ze(e){var r;r=e.input.charCodeAt(e.position),r===10?e.position++:r===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):m(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function b(e,r,n){for(var t=0,i=e.input.charCodeAt(e.position);i!==0;){for(;G(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(r&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(D(i))for(ze(e),i=e.input.charCodeAt(e.position),t++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&t!==0&&e.lineIndent<n&&ye(e,"deficient indentation"),t}function ve(e){var r=e.position,n;return n=e.input.charCodeAt(r),!!((n===45||n===46)&&n===e.input.charCodeAt(r+1)&&n===e.input.charCodeAt(r+2)&&(r+=3,n=e.input.charCodeAt(r),n===0||O(n)))}function Ue(e,r){r===1?e.result+=" ":r>1&&(e.result+=v.repeat(`
|
|
696
|
+
`,r-1))}function ki(e,r,n){var t,i,l,o,a,s,c,f,u=e.kind,d=e.result,p;if(p=e.input.charCodeAt(e.position),O(p)||X(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(i=e.input.charCodeAt(e.position+1),O(i)||n&&X(i)))return!1;for(e.kind="scalar",e.result="",l=o=e.position,a=!1;p!==0;){if(p===58){if(i=e.input.charCodeAt(e.position+1),O(i)||n&&X(i))break}else if(p===35){if(t=e.input.charCodeAt(e.position-1),O(t))break}else{if(e.position===e.lineStart&&ve(e)||n&&X(p))break;if(D(p))if(s=e.line,c=e.lineStart,f=e.lineIndent,b(e,!1,-1),e.lineIndent>=r){a=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=o,e.line=s,e.lineStart=c,e.lineIndent=f;break}}a&&(N(e,l,o,!1),Ue(e,e.line-s),l=o=e.position,a=!1),G(p)||(o=e.position+1),p=e.input.charCodeAt(++e.position)}return N(e,l,o,!1),e.result?!0:(e.kind=u,e.result=d,!1)}function Fi(e,r){var n,t,i;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,t=i=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(N(e,t,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)t=e.position,e.position++,i=e.position;else return!0;else D(n)?(N(e,t,i,!0),Ue(e,b(e,!1,r)),t=i=e.position):e.position===e.lineStart&&ve(e)?m(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);m(e,"unexpected end of the stream within a single quoted scalar")}function _i(e,r){var n,t,i,l,o,a;if(a=e.input.charCodeAt(e.position),a!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=t=e.position;(a=e.input.charCodeAt(e.position))!==0;){if(a===34)return N(e,n,e.position,!0),e.position++,!0;if(a===92){if(N(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),D(a))b(e,!1,r);else if(a<256&&zr[a])e.result+=Ur[a],e.position++;else if((o=Ai(a))>0){for(i=o,l=0;i>0;i--)a=e.input.charCodeAt(++e.position),(o=vi(a))>=0?l=(l<<4)+o:m(e,"expected hexadecimal character");e.result+=Si(l),e.position++}else m(e,"unknown escape sequence");n=t=e.position}else D(a)?(N(e,n,t,!0),Ue(e,b(e,!1,r)),n=t=e.position):e.position===e.lineStart&&ve(e)?m(e,"unexpected end of the document within a double quoted scalar"):(e.position++,t=e.position)}m(e,"unexpected end of the stream within a double quoted scalar")}function Ei(e,r){var n=!0,t,i,l,o=e.tag,a,s=e.anchor,c,f,u,d,p,g=Object.create(null),h,x,w,y;if(y=e.input.charCodeAt(e.position),y===91)f=93,p=!1,a=[];else if(y===123)f=125,p=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),y=e.input.charCodeAt(++e.position);y!==0;){if(b(e,!0,r),y=e.input.charCodeAt(e.position),y===f)return e.position++,e.tag=o,e.anchor=s,e.kind=p?"mapping":"sequence",e.result=a,!0;n?y===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries"),x=h=w=null,u=d=!1,y===63&&(c=e.input.charCodeAt(e.position+1),O(c)&&(u=d=!0,e.position++,b(e,!0,r))),t=e.line,i=e.lineStart,l=e.position,Z(e,r,ge,!1,!0),x=e.tag,h=e.result,b(e,!0,r),y=e.input.charCodeAt(e.position),(d||e.line===t)&&y===58&&(u=!0,y=e.input.charCodeAt(++e.position),b(e,!0,r),Z(e,r,ge,!1,!0),w=e.result),p?Q(e,a,g,x,h,w,t,i,l):u?a.push(Q(e,null,g,x,h,w,t,i,l)):a.push(h),b(e,!0,r),y=e.input.charCodeAt(e.position),y===44?(n=!0,y=e.input.charCodeAt(++e.position)):n=!1}m(e,"unexpected end of the stream within a flow collection")}function Oi(e,r){var n,t,i=je,l=!1,o=!1,a=r,s=0,c=!1,f,u;if(u=e.input.charCodeAt(e.position),u===124)t=!1;else if(u===62)t=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)je===i?i=u===43?nr:xi:m(e,"repeat of a chomping mode identifier");else if((f=Ci(u))>=0)f===0?m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):o?m(e,"repeat of an indentation width identifier"):(a=r+f-1,o=!0);else break;if(G(u)){do u=e.input.charCodeAt(++e.position);while(G(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!D(u)&&u!==0)}for(;u!==0;){for(ze(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!o||e.lineIndent<a)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>a&&(a=e.lineIndent),D(u)){s++;continue}if(e.lineIndent<a){i===nr?e.result+=v.repeat(`
|
|
697
|
+
`,l?1+s:s):i===je&&l&&(e.result+=`
|
|
698
|
+
`);break}for(t?G(u)?(c=!0,e.result+=v.repeat(`
|
|
699
|
+
`,l?1+s:s)):c?(c=!1,e.result+=v.repeat(`
|
|
700
|
+
`,s+1)):s===0?l&&(e.result+=" "):e.result+=v.repeat(`
|
|
701
|
+
`,s):e.result+=v.repeat(`
|
|
702
|
+
`,l?1+s:s),l=!0,o=!0,s=0,n=e.position;!D(u)&&u!==0;)u=e.input.charCodeAt(++e.position);N(e,n,e.position,!1)}return!0}function lr(e,r){var n,t=e.tag,i=e.anchor,l=[],o,a=!1,s;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),s=e.input.charCodeAt(e.position);s!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),!(s!==45||(o=e.input.charCodeAt(e.position+1),!O(o))));){if(a=!0,e.position++,b(e,!0,-1)&&e.lineIndent<=r){l.push(null),s=e.input.charCodeAt(e.position);continue}if(n=e.line,Z(e,r,Br,!1,!0),l.push(e.result),b(e,!0,-1),s=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>r)&&s!==0)m(e,"bad indentation of a sequence entry");else if(e.lineIndent<r)break}return a?(e.tag=t,e.anchor=i,e.kind="sequence",e.result=l,!0):!1}function Pi(e,r,n){var t,i,l,o,a,s,c=e.tag,f=e.anchor,u={},d=Object.create(null),p=null,g=null,h=null,x=!1,w=!1,y;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),y=e.input.charCodeAt(e.position);y!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),t=e.input.charCodeAt(e.position+1),l=e.line,(y===63||y===58)&&O(t))y===63?(x&&(Q(e,u,d,p,g,null,o,a,s),p=g=h=null),w=!0,x=!0,i=!0):x?(x=!1,i=!0):m(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,y=t;else{if(o=e.line,a=e.lineStart,s=e.position,!Z(e,n,Rr,!1,!0))break;if(e.line===l){for(y=e.input.charCodeAt(e.position);G(y);)y=e.input.charCodeAt(++e.position);if(y===58)y=e.input.charCodeAt(++e.position),O(y)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(Q(e,u,d,p,g,null,o,a,s),p=g=h=null),w=!0,x=!1,i=!1,p=e.tag,g=e.result;else if(w)m(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=c,e.anchor=f,!0}else if(w)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=c,e.anchor=f,!0}if((e.line===l||e.lineIndent>r)&&(x&&(o=e.line,a=e.lineStart,s=e.position),Z(e,r,xe,!0,i)&&(x?g=e.result:h=e.result),x||(Q(e,u,d,p,g,h,o,a,s),p=g=h=null),b(e,!0,-1),y=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>r)&&y!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<r)break}return x&&Q(e,u,d,p,g,null,o,a,s),w&&(e.tag=c,e.anchor=f,e.kind="mapping",e.result=u),w}function Li(e){var r,n=!1,t=!1,i,l,o;if(o=e.input.charCodeAt(e.position),o!==33)return!1;if(e.tag!==null&&m(e,"duplication of a tag property"),o=e.input.charCodeAt(++e.position),o===60?(n=!0,o=e.input.charCodeAt(++e.position)):o===33?(t=!0,i="!!",o=e.input.charCodeAt(++e.position)):i="!",r=e.position,n){do o=e.input.charCodeAt(++e.position);while(o!==0&&o!==62);e.position<e.length?(l=e.input.slice(r,e.position),o=e.input.charCodeAt(++e.position)):m(e,"unexpected end of the stream within a verbatim tag")}else{for(;o!==0&&!O(o);)o===33&&(t?m(e,"tag suffix cannot contain exclamation marks"):(i=e.input.slice(r-1,e.position+1),Nr.test(i)||m(e,"named tag handle cannot contain such characters"),t=!0,r=e.position+1)),o=e.input.charCodeAt(++e.position);l=e.input.slice(r,e.position),wi.test(l)&&m(e,"tag suffix cannot contain flow indicator characters")}l&&!Hr.test(l)&&m(e,"tag name cannot contain such characters: "+l);try{l=decodeURIComponent(l)}catch{m(e,"tag name is malformed: "+l)}return n?e.tag=l:H.call(e.tagMap,i)?e.tag=e.tagMap[i]+l:i==="!"?e.tag="!"+l:i==="!!"?e.tag="tag:yaml.org,2002:"+l:m(e,'undeclared tag handle "'+i+'"'),!0}function Ii(e){var r,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&m(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),r=e.position;n!==0&&!O(n)&&!X(n);)n=e.input.charCodeAt(++e.position);return e.position===r&&m(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(r,e.position),!0}function ji(e){var r,n,t;if(t=e.input.charCodeAt(e.position),t!==42)return!1;for(t=e.input.charCodeAt(++e.position),r=e.position;t!==0&&!O(t)&&!X(t);)t=e.input.charCodeAt(++e.position);return e.position===r&&m(e,"name of an alias node must contain at least one character"),n=e.input.slice(r,e.position),H.call(e.anchorMap,n)||m(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],b(e,!0,-1),!0}function Z(e,r,n,t,i){var l,o,a,s=1,c=!1,f=!1,u,d,p,g,h,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,l=o=a=xe===n||Br===n,t&&b(e,!0,-1)&&(c=!0,e.lineIndent>r?s=1:e.lineIndent===r?s=0:e.lineIndent<r&&(s=-1)),s===1)for(;Li(e)||Ii(e);)b(e,!0,-1)?(c=!0,a=l,e.lineIndent>r?s=1:e.lineIndent===r?s=0:e.lineIndent<r&&(s=-1)):a=!1;if(a&&(a=c||i),(s===1||xe===n)&&(ge===n||Rr===n?h=r:h=r+1,x=e.position-e.lineStart,s===1?a&&(lr(e,x)||Pi(e,x,h))||Ei(e,h)?f=!0:(o&&Oi(e,h)||Fi(e,h)||_i(e,h)?f=!0:ji(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&m(e,"alias node should not have any properties")):ki(e,h,ge===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):s===0&&(f=a&&lr(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&m(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,d=e.implicitTypes.length;u<d;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(H.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,p=e.typeMap.multi[e.kind||"fallback"],u=0,d=p.length;u<d;u+=1)if(e.tag.slice(0,p[u].tag.length)===p[u].tag){g=p[u];break}g||m(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&m(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):m(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function Mi(e){var r=e.position,n,t,i,l=!1,o;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(o=e.input.charCodeAt(e.position))!==0&&(b(e,!0,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||o!==37));){for(l=!0,o=e.input.charCodeAt(++e.position),n=e.position;o!==0&&!O(o);)o=e.input.charCodeAt(++e.position);for(t=e.input.slice(n,e.position),i=[],t.length<1&&m(e,"directive name must not be less than one character in length");o!==0;){for(;G(o);)o=e.input.charCodeAt(++e.position);if(o===35){do o=e.input.charCodeAt(++e.position);while(o!==0&&!D(o));break}if(D(o))break;for(n=e.position;o!==0&&!O(o);)o=e.input.charCodeAt(++e.position);i.push(e.input.slice(n,e.position))}o!==0&&ze(e),H.call(or,t)?or[t](e,t,i):ye(e,'unknown document directive "'+t+'"')}if(b(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,b(e,!0,-1)):l&&m(e,"directives end mark is expected"),Z(e,e.lineIndent-1,xe,!1,!0),b(e,!0,-1),e.checkLineBreaks&&bi.test(e.input.slice(r,e.position))&&ye(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ve(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,b(e,!0,-1));return}if(e.position<e.length-1)m(e,"end of the stream or a document separator is expected");else return}function qr(e,r){e=String(e),r=r||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
703
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new Ti(e,r),t=e.indexOf("\0");for(t!==-1&&(n.position=t,m(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Mi(n);return n.documents}function Di(e,r,n){r!==null&&typeof r=="object"&&typeof n>"u"&&(n=r,r=null);var t=qr(e,n);if(typeof r!="function")return t;for(var i=0,l=t.length;i<l;i+=1)r(t[i])}function Ri(e,r){var n=qr(e,r);if(n.length!==0){if(n.length===1)return n[0];throw new _("expected a single document in the stream, but found more")}}var Bi=Di,Ni=Ri,Gr={loadAll:Bi,load:Ni},Wr=Object.prototype.toString,Vr=Object.prototype.hasOwnProperty,Ye=65279,Hi=9,oe=10,$i=13,zi=32,Ui=33,Yi=34,De=35,qi=37,Gi=38,Wi=39,Vi=42,Kr=44,Ki=45,be=58,Ji=61,Xi=62,Qi=63,Zi=64,Jr=91,Xr=93,et=96,Qr=123,rt=124,Zr=125,T={};T[0]="\\0";T[7]="\\a";T[8]="\\b";T[9]="\\t";T[10]="\\n";T[11]="\\v";T[12]="\\f";T[13]="\\r";T[27]="\\e";T[34]='\\"';T[92]="\\\\";T[133]="\\N";T[160]="\\_";T[8232]="\\L";T[8233]="\\P";var nt=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],it=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function tt(e,r){var n,t,i,l,o,a,s;if(r===null)return{};for(n={},t=Object.keys(r),i=0,l=t.length;i<l;i+=1)o=t[i],a=String(r[o]),o.slice(0,2)==="!!"&&(o="tag:yaml.org,2002:"+o.slice(2)),s=e.compiledTypeMap.fallback[o],s&&Vr.call(s.styleAliases,a)&&(a=s.styleAliases[a]),n[o]=a;return n}function ot(e){var r,n,t;if(r=e.toString(16).toUpperCase(),e<=255)n="x",t=2;else if(e<=65535)n="u",t=4;else if(e<=4294967295)n="U",t=8;else throw new _("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+v.repeat("0",t-r.length)+r}var at=1,ae=2;function lt(e){this.schema=e.schema||$e,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=v.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=tt(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?ae:at,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function sr(e,r){for(var n=v.repeat(" ",r),t=0,i=-1,l="",o,a=e.length;t<a;)i=e.indexOf(`
|
|
704
|
+
`,t),i===-1?(o=e.slice(t),t=a):(o=e.slice(t,i+1),t=i+1),o.length&&o!==`
|
|
705
|
+
`&&(l+=n),l+=o;return l}function Re(e,r){return`
|
|
706
|
+
`+v.repeat(" ",e.indent*r)}function st(e,r){var n,t,i;for(n=0,t=e.implicitTypes.length;n<t;n+=1)if(i=e.implicitTypes[n],i.resolve(r))return!0;return!1}function we(e){return e===zi||e===Hi}function le(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Ye||65536<=e&&e<=1114111}function cr(e){return le(e)&&e!==Ye&&e!==$i&&e!==oe}function ur(e,r,n){var t=cr(e),i=t&&!we(e);return(n?t:t&&e!==Kr&&e!==Jr&&e!==Xr&&e!==Qr&&e!==Zr)&&e!==De&&!(r===be&&!i)||cr(r)&&!we(r)&&e===De||r===be&&i}function ct(e){return le(e)&&e!==Ye&&!we(e)&&e!==Ki&&e!==Qi&&e!==be&&e!==Kr&&e!==Jr&&e!==Xr&&e!==Qr&&e!==Zr&&e!==De&&e!==Gi&&e!==Vi&&e!==Ui&&e!==rt&&e!==Ji&&e!==Xi&&e!==Wi&&e!==Yi&&e!==qi&&e!==Zi&&e!==et}function ut(e){return!we(e)&&e!==be}function ie(e,r){var n=e.charCodeAt(r),t;return n>=55296&&n<=56319&&r+1<e.length&&(t=e.charCodeAt(r+1),t>=56320&&t<=57343)?(n-55296)*1024+t-56320+65536:n}function en(e){var r=/^\n* /;return r.test(e)}var rn=1,Be=2,nn=3,tn=4,J=5;function ft(e,r,n,t,i,l,o,a){var s,c=0,f=null,u=!1,d=!1,p=t!==-1,g=-1,h=ct(ie(e,0))&&ut(ie(e,e.length-1));if(r||o)for(s=0;s<e.length;c>=65536?s+=2:s++){if(c=ie(e,s),!le(c))return J;h=h&&ur(c,f,a),f=c}else{for(s=0;s<e.length;c>=65536?s+=2:s++){if(c=ie(e,s),c===oe)u=!0,p&&(d=d||s-g-1>t&&e[g+1]!==" ",g=s);else if(!le(c))return J;h=h&&ur(c,f,a),f=c}d=d||p&&s-g-1>t&&e[g+1]!==" "}return!u&&!d?h&&!o&&!i(e)?rn:l===ae?J:Be:n>9&&en(e)?J:o?l===ae?J:Be:d?tn:nn}function dt(e,r,n,t,i){e.dump=(function(){if(r.length===0)return e.quotingType===ae?'""':"''";if(!e.noCompatMode&&(nt.indexOf(r)!==-1||it.test(r)))return e.quotingType===ae?'"'+r+'"':"'"+r+"'";var l=e.indent*Math.max(1,n),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),a=t||e.flowLevel>-1&&n>=e.flowLevel;function s(c){return st(e,c)}switch(ft(r,a,e.indent,o,s,e.quotingType,e.forceQuotes&&!t,i)){case rn:return r;case Be:return"'"+r.replace(/'/g,"''")+"'";case nn:return"|"+fr(r,e.indent)+dr(sr(r,l));case tn:return">"+fr(r,e.indent)+dr(sr(pt(r,o),l));case J:return'"'+mt(r)+'"';default:throw new _("impossible error: invalid scalar style")}})()}function fr(e,r){var n=en(e)?String(r):"",t=e[e.length-1]===`
|
|
707
|
+
`,i=t&&(e[e.length-2]===`
|
|
708
|
+
`||e===`
|
|
709
|
+
`),l=i?"+":t?"":"-";return n+l+`
|
|
710
|
+
`}function dr(e){return e[e.length-1]===`
|
|
711
|
+
`?e.slice(0,-1):e}function pt(e,r){for(var n=/(\n+)([^\n]*)/g,t=(function(){var c=e.indexOf(`
|
|
712
|
+
`);return c=c!==-1?c:e.length,n.lastIndex=c,pr(e.slice(0,c),r)})(),i=e[0]===`
|
|
713
|
+
`||e[0]===" ",l,o;o=n.exec(e);){var a=o[1],s=o[2];l=s[0]===" ",t+=a+(!i&&!l&&s!==""?`
|
|
714
|
+
`:"")+pr(s,r),i=l}return t}function pr(e,r){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,t,i=0,l,o=0,a=0,s="";t=n.exec(e);)a=t.index,a-i>r&&(l=o>i?o:a,s+=`
|
|
715
|
+
`+e.slice(i,l),i=l+1),o=a;return s+=`
|
|
716
|
+
`,e.length-i>r&&o>i?s+=e.slice(i,o)+`
|
|
717
|
+
`+e.slice(o+1):s+=e.slice(i),s.slice(1)}function mt(e){for(var r="",n=0,t,i=0;i<e.length;n>=65536?i+=2:i++)n=ie(e,i),t=T[n],!t&&le(n)?(r+=e[i],n>=65536&&(r+=e[i+1])):r+=t||ot(n);return r}function ht(e,r,n){var t="",i=e.tag,l,o,a;for(l=0,o=n.length;l<o;l+=1)a=n[l],e.replacer&&(a=e.replacer.call(n,String(l),a)),(R(e,r,a,!1,!1)||typeof a>"u"&&R(e,r,null,!1,!1))&&(t!==""&&(t+=","+(e.condenseFlow?"":" ")),t+=e.dump);e.tag=i,e.dump="["+t+"]"}function mr(e,r,n,t){var i="",l=e.tag,o,a,s;for(o=0,a=n.length;o<a;o+=1)s=n[o],e.replacer&&(s=e.replacer.call(n,String(o),s)),(R(e,r+1,s,!0,!0,!1,!0)||typeof s>"u"&&R(e,r+1,null,!0,!0,!1,!0))&&((!t||i!=="")&&(i+=Re(e,r)),e.dump&&oe===e.dump.charCodeAt(0)?i+="-":i+="- ",i+=e.dump);e.tag=l,e.dump=i||"[]"}function gt(e,r,n){var t="",i=e.tag,l=Object.keys(n),o,a,s,c,f;for(o=0,a=l.length;o<a;o+=1)f="",t!==""&&(f+=", "),e.condenseFlow&&(f+='"'),s=l[o],c=n[s],e.replacer&&(c=e.replacer.call(n,s,c)),R(e,r,s,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),R(e,r,c,!1,!1)&&(f+=e.dump,t+=f));e.tag=i,e.dump="{"+t+"}"}function xt(e,r,n,t){var i="",l=e.tag,o=Object.keys(n),a,s,c,f,u,d;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys=="function")o.sort(e.sortKeys);else if(e.sortKeys)throw new _("sortKeys must be a boolean or a function");for(a=0,s=o.length;a<s;a+=1)d="",(!t||i!=="")&&(d+=Re(e,r)),c=o[a],f=n[c],e.replacer&&(f=e.replacer.call(n,c,f)),R(e,r+1,c,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&oe===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,u&&(d+=Re(e,r)),R(e,r+1,f,!0,u)&&(e.dump&&oe===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,i+=d));e.tag=l,e.dump=i||"{}"}function hr(e,r,n){var t,i,l,o,a,s;for(i=n?e.explicitTypes:e.implicitTypes,l=0,o=i.length;l<o;l+=1)if(a=i[l],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof r=="object"&&r instanceof a.instanceOf)&&(!a.predicate||a.predicate(r))){if(n?a.multi&&a.representName?e.tag=a.representName(r):e.tag=a.tag:e.tag="?",a.represent){if(s=e.styleMap[a.tag]||a.defaultStyle,Wr.call(a.represent)==="[object Function]")t=a.represent(r,s);else if(Vr.call(a.represent,s))t=a.represent[s](r,s);else throw new _("!<"+a.tag+'> tag resolver accepts not "'+s+'" style');e.dump=t}return!0}return!1}function R(e,r,n,t,i,l,o){e.tag=null,e.dump=n,hr(e,n,!1)||hr(e,n,!0);var a=Wr.call(e.dump),s=t,c;t&&(t=e.flowLevel<0||e.flowLevel>r);var f=a==="[object Object]"||a==="[object Array]",u,d;if(f&&(u=e.duplicates.indexOf(n),d=u!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&r>0)&&(i=!1),d&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&d&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),a==="[object Object]")t&&Object.keys(e.dump).length!==0?(xt(e,r,e.dump,i),d&&(e.dump="&ref_"+u+e.dump)):(gt(e,r,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(a==="[object Array]")t&&e.dump.length!==0?(e.noArrayIndent&&!o&&r>0?mr(e,r-1,e.dump,i):mr(e,r,e.dump,i),d&&(e.dump="&ref_"+u+e.dump)):(ht(e,r,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(a==="[object String]")e.tag!=="?"&&dt(e,e.dump,r,l,s);else{if(a==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new _("unacceptable kind of an object to dump "+a)}e.tag!==null&&e.tag!=="?"&&(c=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",e.dump=c+" "+e.dump)}return!0}function yt(e,r){var n=[],t=[],i,l;for(Ne(e,n,t),i=0,l=t.length;i<l;i+=1)r.duplicates.push(n[t[i]]);r.usedDuplicates=new Array(l)}function Ne(e,r,n){var t,i,l;if(e!==null&&typeof e=="object")if(i=r.indexOf(e),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(r.push(e),Array.isArray(e))for(i=0,l=e.length;i<l;i+=1)Ne(e[i],r,n);else for(t=Object.keys(e),i=0,l=t.length;i<l;i+=1)Ne(e[t[i]],r,n)}function bt(e,r){r=r||{};var n=new lt(r);n.noRefs||yt(e,n);var t=e;return n.replacer&&(t=n.replacer.call({"":t},"",t)),R(n,0,t,!0,!0)?n.dump+`
|
|
718
|
+
`:""}var wt=bt,vt={dump:wt};function qe(e,r){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}var At=C,Ct=yr,St=Ar,Tt=Fr,kt=_r,Ft=$e,_t=Gr.load,Et=Gr.loadAll,Ot=vt.dump,Pt=_,Lt={binary:Ir,float:kr,map:vr,null:Cr,pairs:Mr,set:Dr,timestamp:Pr,bool:Sr,int:Tr,merge:Lr,omap:jr,seq:wr,str:br},It=qe("safeLoad","load"),jt=qe("safeLoadAll","loadAll"),Mt=qe("safeDump","dump"),on={Type:At,Schema:Ct,FAILSAFE_SCHEMA:St,JSON_SCHEMA:Tt,CORE_SCHEMA:kt,DEFAULT_SCHEMA:Ft,load:_t,loadAll:Et,dump:Ot,YAMLException:Pt,types:Lt,safeLoad:It,safeLoadAll:jt,safeDump:Mt};function Dt(e){let n=String(e).match(/^---\s*[\r\n]([\s\S]*?)[\r\n](?:---|\.\.\.)\s*(?:[\r\n]([\s\S]*))?$/);if(!n)return{content:e,data:{},hasFrontMatter:!1};try{let t=on.load(n[1]),i=n[2]||"",l=Object.keys(t).length>0;return{content:i,data:t,hasFrontMatter:l}}catch{return{content:e,data:{},hasFrontMatter:!1}}}function Rt(e){let r={};if(typeof e.theme=="string"&&(r.theme=e.theme),typeof e.hrAsPageBreak=="boolean"&&(r.hrAsPageBreak=e.hrAsPageBreak),typeof e.format=="string"){let n=e.format.toLowerCase();(n==="pdf"||n==="docx"||n==="html")&&(r.format=n)}if(typeof e.title=="string"&&(r.title=e.title),typeof e.standalone=="boolean"&&(r.standalone=e.standalone),typeof e.baseTag=="boolean"&&(r.baseTag=e.baseTag),typeof e.diagramMode=="string"){let n=e.diagramMode.toLowerCase();(n==="img"||n==="live"||n==="none")&&(r.diagramMode=n)}return e.cdn&&typeof e.cdn=="object"&&(r.cdn=e.cdn),e.pdf&&typeof e.pdf=="object"&&(r.pdf=e.pdf),r}async function Bt(e,r={}){return new pe().exportToBuffer(e,r)}async function Nt(e,r={}){return new me().exportToBuffer(e,r)}async function io(e,r={}){return new ne().exportToString(e,r)}async function Ht(e,r={}){return new ne().exportToBuffer(e,r)}function $t(e){let r=k.extname(e).toLowerCase();return r===".pdf"?"pdf":r===".docx"?"docx":r===".html"||r===".htm"?"html":null}async function zt(e,r={}){let n=r.skipFrontMatter?{content:e,data:{},hasFrontMatter:!1}:Dt(e),t=n.hasFrontMatter?Rt(n.data):{},i=r.format??t.format??"pdf",l=r.theme??t.theme??"default",o=r.diagramMode??t.diagramMode??"live",a=r.hrAsPageBreak??t.hrAsPageBreak??i!=="html",s=r.basePath??process.cwd(),c=n.content,f;return i==="pdf"?f=await Nt(c,{theme:l,basePath:s,hrAsPageBreak:a,pdf:{...r.pdf,...t.pdf,title:r.title??t.title??"Document"}}):i==="docx"?f=await Bt(c,{theme:l,basePath:s,hrAsPageBreak:a}):f=await Ht(c,{theme:l,basePath:s,diagramMode:o,hrAsPageBreak:a,title:r.title??t.title??"Document",standalone:r.standalone??t.standalone,baseTag:r.baseTag??t.baseTag,cdn:r.cdn??t.cdn}),{buffer:f,format:i}}async function to(e,r,n={}){let t=k.resolve(e);if(!B.existsSync(t))throw new Error(`Input file not found: ${t}`);let i=B.readFileSync(t,"utf-8"),l=n.format;!l&&r&&(l=$t(r)??void 0);let o=k.basename(t,k.extname(t)),a=await zt(i,{...n,format:l,basePath:n.basePath??k.dirname(t),title:n.title??o}),s;if(r)s=k.resolve(r);else{let f=k.dirname(t),u=k.basename(t,k.extname(t)),d=a.format==="pdf"?".pdf":a.format==="docx"?".docx":".html";s=k.join(f,`${u}${d}`)}let c=k.dirname(s);return B.existsSync(c)||B.mkdirSync(c,{recursive:!0}),B.writeFileSync(s,a.buffer),{buffer:a.buffer,outputPath:s,format:a.format}}export{pe as a,me as b,ne as c,Dt as d,Rt as e,Bt as f,Nt as g,io as h,Ht as i,zt as j,to as k};
|
|
719
|
+
/*! Bundled license information:
|
|
720
|
+
|
|
721
|
+
js-yaml/dist/js-yaml.mjs:
|
|
722
|
+
(*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
|
|
723
|
+
*/
|