quikdown 1.2.11 → 1.2.12

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.
Files changed (52) hide show
  1. package/dist/quikdown.cjs +2 -2
  2. package/dist/quikdown.dark.css +1 -1
  3. package/dist/quikdown.esm.js +2 -2
  4. package/dist/quikdown.esm.min.js +2 -2
  5. package/dist/quikdown.esm.min.js.gz +0 -0
  6. package/dist/quikdown.light.css +1 -1
  7. package/dist/quikdown.umd.js +2 -2
  8. package/dist/quikdown.umd.min.js +2 -2
  9. package/dist/quikdown.umd.min.js.gz +0 -0
  10. package/dist/quikdown_ast.cjs +2 -2
  11. package/dist/quikdown_ast.esm.js +2 -2
  12. package/dist/quikdown_ast.esm.min.js +2 -2
  13. package/dist/quikdown_ast.esm.min.js.gz +0 -0
  14. package/dist/quikdown_ast.umd.js +2 -2
  15. package/dist/quikdown_ast.umd.min.js +2 -2
  16. package/dist/quikdown_ast.umd.min.js.gz +0 -0
  17. package/dist/quikdown_ast_html.cjs +3 -3
  18. package/dist/quikdown_ast_html.esm.js +3 -3
  19. package/dist/quikdown_ast_html.esm.min.js +2 -2
  20. package/dist/quikdown_ast_html.esm.min.js.gz +0 -0
  21. package/dist/quikdown_ast_html.umd.js +3 -3
  22. package/dist/quikdown_ast_html.umd.min.js +2 -2
  23. package/dist/quikdown_ast_html.umd.min.js.gz +0 -0
  24. package/dist/quikdown_bd.cjs +2 -2
  25. package/dist/quikdown_bd.esm.js +2 -2
  26. package/dist/quikdown_bd.esm.min.js +2 -2
  27. package/dist/quikdown_bd.esm.min.js.gz +0 -0
  28. package/dist/quikdown_bd.umd.js +2 -2
  29. package/dist/quikdown_bd.umd.min.js +2 -2
  30. package/dist/quikdown_bd.umd.min.js.gz +0 -0
  31. package/dist/quikdown_edit.cjs +2 -2
  32. package/dist/quikdown_edit.esm.js +2 -2
  33. package/dist/quikdown_edit.esm.min.js +2 -2
  34. package/dist/quikdown_edit.esm.min.js.gz +0 -0
  35. package/dist/quikdown_edit.umd.js +2 -2
  36. package/dist/quikdown_edit.umd.min.js +2 -2
  37. package/dist/quikdown_edit.umd.min.js.gz +0 -0
  38. package/dist/quikdown_json.cjs +3 -3
  39. package/dist/quikdown_json.esm.js +3 -3
  40. package/dist/quikdown_json.esm.min.js +2 -2
  41. package/dist/quikdown_json.esm.min.js.gz +0 -0
  42. package/dist/quikdown_json.umd.js +3 -3
  43. package/dist/quikdown_json.umd.min.js +2 -2
  44. package/dist/quikdown_json.umd.min.js.gz +0 -0
  45. package/dist/quikdown_yaml.cjs +3 -3
  46. package/dist/quikdown_yaml.esm.js +3 -3
  47. package/dist/quikdown_yaml.esm.min.js +2 -2
  48. package/dist/quikdown_yaml.esm.min.js.gz +0 -0
  49. package/dist/quikdown_yaml.umd.js +3 -3
  50. package/dist/quikdown_yaml.umd.min.js +2 -2
  51. package/dist/quikdown_yaml.umd.min.js.gz +0 -0
  52. package/package.json +1 -3
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Quikdown Editor - Drop-in Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -9,5 +9,5 @@
9
9
  * Quikdown Editor - A drop-in markdown editor control
10
10
  * @version 1.0.5
11
11
  * @license BSD-2-Clause
12
- */u.emitStyles=function(e="quikdown-",t="light"){const n=h,o={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},r={_textColor:"#333"};let a="";for(const[i,s]of Object.entries(n)){let n=s;if("dark"===t&&o){for(const[e,t]of Object.entries(o))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(i)&&(n+=`;color:${o._textColor}`)}else if("light"===t&&r){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(i)&&(n+=`;color:${r._textColor}`)}a+=`.${e}${i} { ${n} }\n`}return a},u.configure=function(e){return function(t){return u(t,e)}},u.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=u),"undefined"!=typeof window&&(window.quikdown=u),Object.keys(u).forEach(e=>{"configure"!==e&&(g[e]=u[e])}),g.toMarkdown=function(e,t={}){let n;if("string"==typeof e)n=document.createElement("div"),n.innerHTML=e;else{if(!(e instanceof Element))return"";n=e}function o(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const a=e.tagName.toLowerCase(),i=e.getAttribute("data-qd");let s="";for(const t of e.childNodes)s+=o(t,{parentTag:a,...n});switch(a){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(a[1]);return`${i||"#".repeat(n)} ${s.trim()}\n\n`;case"strong":case"b":if(!s)return"";const o=i||"**";return`${o}${s}${o}`;case"em":case"i":if(!s)return"";const l=i||"*";return`${l}${s}${l}`;case"del":case"s":case"strike":if(!s)return"";const d=i||"~~";return`${d}${s}${d}`;case"code":if(!s)return"";const c=i||"`";return`${c}${s}${c}`;case"pre":const h=e.getAttribute("data-qd-fence")||i||"```",u=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&u)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||h;return`${e}${n.lang||u}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const p=e.getAttribute("data-qd-source");if(p)return`${h}${u}\n${p}\n${h}\n\n`;const m=e.querySelector("code");return`${h}${u}\n${(m?m.textContent:s).trimEnd()}\n${h}\n\n`;case"blockquote":const g=i||">";return s.trim().split("\n").map(e=>`${g} ${e}`).join("\n")+"\n\n";case"hr":return`${i||"---"}\n\n`;case"br":return`${i||" "}\n`;case"a":const f=e.getAttribute("data-qd-text")||s.trim(),w=e.getAttribute("href")||"";return f!==w||i?`[${f}](${w})`:`<${w}>`;case"img":return`${i||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return r(e,"ol"===a)+"\n";case"li":case"span":default:return s;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),o=n?n.split(","):[],r=e.querySelector("thead");if(r){const e=r.querySelector("tr");if(e){const n=[];for(const t of e.querySelectorAll("th"))n.push(t.textContent.trim());t+="| "+n.join(" | ")+" |\n";t+="| "+n.map((e,t)=>{const n=o[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const a=e.querySelector("tbody");if(a)for(const e of a.querySelectorAll("tr")){const n=[];for(const t of e.querySelectorAll("td"))n.push(t.textContent.trim());n.length>0&&(t+="| "+n.join(" | ")+" |\n")}return t.trim()}(e)+"\n\n";case"p":if(s.trim()){const e=s.split("\n");let t=s.trim();if(e.length>1){let n=0;for(let t=e.length-1;t>=0&&""===e[t].trim();t--)n++;if(n>0)return t+="\n ",t+"\n"}return t+"\n\n"}return"";case"div":const b=e.getAttribute("data-qd-lang"),y=e.getAttribute("data-qd-fence");if(b&&t.fence_plugin&&t.fence_plugin.reverse)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||y||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const x=e.getAttribute("data-qd-source");if(x&&y)return`${y}${b||""}\n${x}\n${y}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",o=e.getAttribute("data-qd-source");if(o){const e=document.createElement("textarea");e.innerHTML=o;return`${t}${n}\n${e.value}\n${t}\n\n`}const r=e.querySelector("pre.mermaid");if(r){const e=r.getAttribute("data-qd-source");if(e){const o=document.createElement("textarea");o.innerHTML=e;return`${t}${n}\n${o.value}\n${t}\n\n`}}const a=e.querySelector(".mermaid-source");if(a){const e=document.createElement("div");e.innerHTML=a.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const i=e.querySelector(".mermaid");if(i&&i.textContent.includes("graph"))return`${t}${n}\n${i.textContent.trim()}\n${t}\n\n`}if(e.classList&&e.classList.contains("mermaid")){const t=e.getAttribute("data-qd-fence")||"```";return`${t}${e.getAttribute("data-qd-lang")||"mermaid"}\n${e.textContent.trim()}\n${t}\n\n`}return s}}function r(e,t,n=0){let a="",i=1;const s=" ".repeat(n);for(const l of e.children){if("LI"!==l.tagName)continue;let e=l.getAttribute("data-qd")||(t?`${i}.`:"-");const d=l.querySelector('input[type="checkbox"]');if(d){const t=d.checked?"x":" ";e="-";let n="";for(const e of l.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=o(e));a+=`${s}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of l.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=r(e,"OL"===e.tagName,n+1):t+=o(e);a+=`${s}${e} ${t.trim()}\n`}i++}return a}let a=o(n);return a=a.replace(/\n{3,}/g,"\n\n"),a=a.trim(),a},g.configure=function(e){const t=u.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=g),"undefined"!=typeof window&&(window.quikdown_bd=g);const y={b:1,i:1,em:1,strong:1,del:1,s:1,u:1,mark:1,sup:1,sub:1,kbd:1,abbr:1,var:1,samp:1,cite:1,small:1,ins:1,dfn:1,ruby:1,rt:1,rp:1,time:1,wbr:1,img:1,picture:1,source:1,video:1,audio:1,figure:1,figcaption:1,a:1,br:1,hr:1,div:1,span:1,p:1,details:1,summary:1,section:1,article:1,aside:1,header:1,footer:1,nav:1,main:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,ul:1,ol:1,li:1,dl:1,dt:1,dd:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,blockquote:1,pre:1,code:1},x={mode:"split",showToolbar:!0,showRemoveHR:!1,showLazyLinefeeds:!1,theme:"auto",lazy_linefeeds:!1,inline_styles:!1,debounceDelay:20,placeholder:"Start typing markdown...",plugins:{highlightjs:!1,mermaid:!1},preloadFences:null,customFences:{},enableComplexFences:!0,showUndoRedo:!1,undoStackSize:100,allowUnsafeHTML:!1,showAllowUnsafeHTML:!1},q={highlightjs:{check:()=>void 0!==window.hljs,script:"https://unpkg.com/@highlightjs/cdn-assets/highlight.min.js",css:"https://unpkg.com/@highlightjs/cdn-assets/styles/github.min.css",cssDark:"https://unpkg.com/@highlightjs/cdn-assets/styles/github-dark.min.css"},mermaid:{check:()=>void 0!==window.mermaid,script:"https://unpkg.com/mermaid/dist/mermaid.min.js",afterLoad:()=>{window.mermaid&&window.mermaid.initialize({startOnLoad:!1})}},math:{check:()=>void 0!==window.MathJax,script:"https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js",beforeLoad:()=>{window.MathJax||(window.MathJax={loader:{load:["input/tex","output/svg"]},tex:{packages:{"[+]":["ams"]},inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0},options:{renderActions:{addMenu:[]},ignoreHtmlClass:"tex2jax_ignore",processHtmlClass:"tex2jax_process"},svg:{fontCache:"none"},startup:{typeset:!1}})}},geojson:{check:()=>void 0!==window.L,script:"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js",css:"https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"},stl:{check:()=>void 0!==window.THREE,script:"https://unpkg.com/three@0.147.0/build/three.min.js"}};class v{constructor(e,t={}){if(this.container="string"==typeof e?document.querySelector(e):e,!this.container)throw new Error("QuikdownEditor: Invalid container");this.options={...x,...t},this._markdown="",this._html="",this.currentMode=this.options.mode,this.updateTimer=null,this._undoStack=[],this._redoStack=[],this._isUndoRedo=!1,this.initPromise=this.init()}async init(){await this.loadPlugins(),this.buildUI(),this.attachEvents(),this.applyTheme(),this.setMode(this.currentMode),this.options.initialContent&&this.setMarkdown(this.options.initialContent)}buildUI(){this.container.innerHTML="",this.container.classList.add("qde-container"),this.options.showToolbar&&(this.toolbar=this.createToolbar(),this.container.appendChild(this.toolbar)),this.editorArea=document.createElement("div"),this.editorArea.className="qde-editor",this.sourcePanel=document.createElement("div"),this.sourcePanel.className="qde-source",this.sourceTextarea=document.createElement("textarea"),this.sourceTextarea.className="qde-textarea",this.sourceTextarea.spellcheck=!1,this.sourceTextarea.placeholder=this.options.placeholder,this.sourcePanel.appendChild(this.sourceTextarea),this.previewPanel=document.createElement("div"),this.previewPanel.className="qde-preview",this.previewPanel.contentEditable=!0,this.previewPanel.spellcheck=!1,this.editorArea.appendChild(this.sourcePanel),this.editorArea.appendChild(this.previewPanel),this.container.appendChild(this.editorArea),this.injectStyles()}createToolbar(){const e=document.createElement("div");e.className="qde-toolbar";const t={source:"Source",split:"Split",preview:"Rendered"};["source","split","preview"].forEach(n=>{const o=document.createElement("button");o.className="qde-btn",o.dataset.mode=n,o.textContent=t[n],o.title=`Switch to ${t[n]} view`,e.appendChild(o)});const n=document.createElement("button");if(n.className="qde-btn qde-split-toggle",n.textContent="Preview",n.title="Toggle between source and preview in split mode",e.appendChild(n),this.options.showUndoRedo){const t=document.createElement("button");t.className="qde-btn disabled",t.dataset.action="undo",t.textContent="Undo",t.title="Undo (Ctrl+Z)",e.appendChild(t);const n=document.createElement("button");n.className="qde-btn disabled",n.dataset.action="redo",n.textContent="Redo",n.title="Redo (Ctrl+Shift+Z / Ctrl+Y)",e.appendChild(n)}const o=document.createElement("span");o.className="qde-spacer",e.appendChild(o);if([{action:"copy-markdown",text:"Copy MD",title:"Copy markdown to clipboard"},{action:"copy-html",text:"Copy HTML",title:"Copy HTML to clipboard"},{action:"copy-rendered",text:"Copy Rendered",title:"Copy rich text to clipboard"}].forEach(({action:t,text:n,title:o})=>{const r=document.createElement("button");r.className="qde-btn",r.dataset.action=t,r.textContent=n,r.title=o,e.appendChild(r)}),this.options.showRemoveHR){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="remove-hr",t.textContent="Remove HR",t.title="Remove all horizontal rules (---) from markdown",e.appendChild(t)}if(this.options.showLazyLinefeeds){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="lazy-linefeeds",t.textContent="Fix Linefeeds",t.title="Convert single newlines to paragraph breaks (one-time transform)",e.appendChild(t)}if(this.options.showAllowUnsafeHTML){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="toggle-html-mode",t.textContent=this._getHtmlModeLabel(this.options.allowUnsafeHTML),t.title=this._getHtmlModeTooltip(this.options.allowUnsafeHTML),e.appendChild(t)}return e}injectStyles(){if(document.getElementById("qde-styles"))return;const e=document.createElement("style");e.id="qde-styles",e.textContent='\n .qde-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n border: 1px solid #ddd;\n border-radius: 4px;\n overflow: hidden;\n background: white;\n color: #1f2937;\n }\n \n .qde-toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n padding: 8px;\n background: #f5f5f5;\n border-bottom: 1px solid #ddd;\n gap: 4px;\n }\n \n .qde-btn {\n padding: 6px 12px;\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n cursor: pointer;\n font-size: 14px;\n transition: all 0.2s;\n }\n \n .qde-btn:hover {\n background: #e9e9e9;\n border-color: #999;\n }\n \n .qde-btn.active {\n background: #007bff;\n color: white;\n border-color: #0056b3;\n }\n\n .qde-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n }\n .qde-btn[data-action="toggle-html-mode"] {\n position: relative;\n }\n .qde-btn[data-action="toggle-html-mode"]:hover::after {\n content: attr(title);\n position: absolute;\n bottom: calc(100% + 6px);\n left: 50%;\n transform: translateX(-50%);\n padding: 5px 10px;\n background: #1f2937;\n color: #fff;\n font-size: 0.75rem;\n font-weight: 400;\n white-space: nowrap;\n border-radius: 4px;\n pointer-events: none;\n z-index: 10;\n }\n \n .qde-spacer {\n flex: 1;\n }\n \n .qde-editor {\n display: flex;\n flex: 1;\n overflow: hidden;\n }\n \n .qde-source, .qde-preview {\n flex: 1 1 0;\n min-width: 0; /* allow flex shrinking below content size */\n min-height: 0;\n overflow: auto;\n padding: 16px;\n box-sizing: border-box;\n }\n\n .qde-source {\n border-right: 1px solid #ddd;\n /* Source pane is just a container for the textarea — make it\n a positioning context so the textarea can fill it absolutely */\n position: relative;\n padding: 0; /* textarea brings its own padding */\n }\n\n .qde-textarea {\n display: block;\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 16px;\n box-sizing: border-box;\n font-family: \'Monaco\', \'Courier New\', monospace;\n font-size: 14px;\n line-height: 1.5;\n background: transparent;\n color: inherit;\n /* Wrap long lines so the textarea only scrolls VERTICALLY.\n pre-wrap preserves intentional line breaks/whitespace\n while soft-wrapping at the right edge. */\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-x: hidden;\n overflow-y: auto;\n }\n \n .qde-preview {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n outline: none;\n cursor: text; /* Standard text cursor */\n overflow-x: hidden; /* never scroll horizontally; clip wide content */\n }\n\n /* Code blocks and inline code — self-contained so the editor\n does not depend on any external stylesheet for these. */\n .qde-preview pre {\n background: #f4f4f4;\n color: #1f2937;\n padding: 10px;\n border-radius: 4px;\n overflow-x: auto;\n margin: 0.6em 0;\n font-size: 0.9em;\n line-height: 1.5;\n font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code",\n "Roboto Mono", Consolas, "Courier New", monospace;\n }\n .qde-preview code {\n padding: 2px 4px;\n font-size: 0.9em;\n border-radius: 3px;\n background: #f0f0f0;\n color: #1f2937;\n font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code",\n "Roboto Mono", Consolas, "Courier New", monospace;\n }\n .qde-preview pre code {\n padding: 0;\n font-size: inherit;\n border-radius: 0;\n background: transparent;\n color: inherit;\n }\n\n /* Wide fence content (Leaflet maps, large SVGs, STL canvases,\n iframes, raw <img>) must never overflow the preview pane */\n .qde-preview .geojson-container,\n .qde-preview .qde-stl-container,\n .qde-preview .qde-svg-container,\n .qde-preview .leaflet-container,\n .qde-preview iframe,\n .qde-preview img,\n .qde-preview > svg {\n max-width: 100%;\n }\n .qde-preview img {\n display: inline;\n }\n .qde-preview .leaflet-container { box-sizing: border-box; }\n\n /* Standard markdown tables (the .quikdown-table class) need to\n scroll horizontally inside their own wrapper rather than\n making the whole preview pane scroll */\n .qde-preview table.quikdown-table,\n .qde-preview table.qde-csv-table {\n display: block;\n max-width: 100%;\n overflow-x: auto;\n }\n\n /* Fence-specific styles */\n .qde-svg-container {\n max-width: 100%;\n overflow: auto;\n }\n\n .qde-svg-container svg {\n max-width: 100%;\n height: auto;\n }\n \n .qde-html-container {\n /* HTML containers inherit background */\n margin: 12px 0;\n }\n \n .qde-math-container {\n text-align: center;\n margin: 16px 0;\n overflow-x: auto;\n }\n \n /* All tables in preview (both regular markdown and CSV) */\n .qde-preview table {\n width: 100%;\n border-collapse: collapse;\n margin: 12px 0;\n font-size: 14px;\n }\n \n .qde-preview table th,\n .qde-preview table td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n \n /* Support for alignment classes from quikdown */\n .qde-preview .quikdown-left { text-align: left; }\n .qde-preview .quikdown-center { text-align: center; }\n .qde-preview .quikdown-right { text-align: right; }\n \n .qde-preview table th {\n background: #f5f5f5;\n font-weight: bold;\n }\n \n .qde-preview table tr:nth-child(even) {\n background: #f9f9f9;\n }\n \n /* Specific to CSV-generated tables */\n .qde-data-table {\n /* Can add specific CSV table styles here if needed */\n }\n \n .qde-json {\n /* Let highlight.js handle styling */\n overflow-x: auto;\n }\n \n .qde-error {\n background: #fee;\n border: 1px solid #fcc;\n color: #c00;\n padding: 8px;\n border-radius: 4px;\n font-family: monospace;\n font-size: 12px;\n }\n \n /* Read-only complex fence blocks in preview */\n .qde-preview [contenteditable="false"] {\n cursor: auto; /* Use automatic cursor (arrow for non-text) */\n user-select: text;\n position: relative;\n }\n \n /* Reset headings inside the preview to plain browser defaults so\n parent-page styles (site navs, marketing pages, design systems)\n cannot bleed in. Business-casual: black text, decreasing sizes,\n no decorative borders. See docs/quikdown-editor.md for how\n embedders can override these with their own stylesheet. */\n .qde-preview h1 { font-size: 2em; }\n .qde-preview h2 { font-size: 1.5em; }\n .qde-preview h3 { font-size: 1.25em; }\n .qde-preview h4 { font-size: 1em; }\n .qde-preview h5 { font-size: 0.875em; }\n .qde-preview h6 { font-size: 0.85em; }\n .qde-preview h1,\n .qde-preview h2,\n .qde-preview h3,\n .qde-preview h4,\n .qde-preview h5,\n .qde-preview h6 {\n font-weight: bold;\n color: inherit;\n border: none;\n margin: 0.6em 0 0.3em 0;\n line-height: 1.25;\n }\n .qde-preview p {\n margin: 0.35em 0;\n }\n .qde-preview ul,\n .qde-preview ol {\n padding-left: 1.8em;\n margin: 0.4em 0;\n }\n .qde-preview li {\n margin: 0.15em 0;\n }\n .qde-preview blockquote {\n margin: 0.5em 0;\n padding-left: 1em;\n }\n\n /* Ensure proper cursor for editable text elements */\n .qde-preview p,\n .qde-preview h1,\n .qde-preview h2,\n .qde-preview h3,\n .qde-preview h4,\n .qde-preview h5,\n .qde-preview h6,\n .qde-preview li,\n .qde-preview td,\n .qde-preview th,\n .qde-preview blockquote,\n .qde-preview pre[contenteditable="true"],\n .qde-preview code[contenteditable="true"] {\n cursor: text;\n }\n \n \n /* Non-editable complex renderers */\n .qde-preview .qde-svg-container[contenteditable="false"],\n .qde-preview .qde-html-container[contenteditable="false"],\n .qde-preview .qde-math-container[contenteditable="false"],\n .qde-preview .mermaid[contenteditable="false"] {\n opacity: 0.98;\n }\n \n /* Subtle hover effect for read-only blocks */\n .qde-preview [contenteditable="false"]:hover::after {\n content: "Read-only";\n position: absolute;\n top: 2px;\n right: 2px;\n font-size: 10px;\n color: #999;\n background: rgba(255, 255, 255, 0.9);\n padding: 2px 4px;\n border-radius: 2px;\n pointer-events: none;\n }\n \n /* Fix list padding in preview */\n .qde-preview ul,\n .qde-preview ol {\n padding-left: 2em;\n margin: 0.5em 0;\n }\n \n .qde-preview li {\n margin: 0.25em 0;\n }\n \n /* Mode-specific visibility */\n .qde-mode-source .qde-preview { display: none; }\n .qde-mode-source .qde-source { border-right: none; }\n .qde-mode-preview .qde-source { display: none; }\n .qde-mode-split .qde-source,\n .qde-mode-split .qde-preview { display: block; }\n \n /* Dark theme */\n .qde-dark {\n background: #1e1e1e;\n color: #e0e0e0;\n border-color: #444;\n }\n \n .qde-dark .qde-toolbar {\n background: #2d2d2d;\n border-color: #444;\n }\n \n .qde-dark .qde-btn {\n background: #3a3a3a;\n color: #e0e0e0;\n border-color: #555;\n }\n \n .qde-dark .qde-btn:hover {\n background: #4a4a4a;\n }\n \n .qde-dark .qde-source {\n border-color: #444;\n }\n \n .qde-dark .qde-textarea {\n background: #1e1e1e;\n color: #e0e0e0;\n }\n \n .qde-dark .qde-preview {\n background: #1e1e1e;\n color: #e0e0e0;\n }\n \n /* Dark mode code blocks */\n .qde-dark .qde-preview pre {\n background: #2d2d3a;\n color: #e6e6f0;\n }\n .qde-dark .qde-preview code {\n background: #2a2a3a;\n color: #e6e6f0;\n }\n .qde-dark .qde-preview pre code {\n background: transparent;\n color: inherit;\n }\n\n /* Dark mode table styles */\n .qde-dark .qde-preview table th,\n .qde-dark .qde-preview table td {\n border-color: #3a3a3a;\n }\n \n .qde-dark .qde-preview table th {\n background: #2d2d2d;\n }\n \n .qde-dark .qde-preview table tr:nth-child(even) {\n background: #252525;\n }\n \n /* Mobile split toggle — hidden by default */\n .qde-split-toggle { display: none; }\n\n /* Mobile responsive — compact toolbar for all small screens */\n @media (max-width: 720px) {\n .qde-toolbar {\n padding: 6px;\n gap: 3px;\n }\n .qde-btn {\n padding: 5px 8px;\n font-size: 12px;\n }\n .qde-source, .qde-preview {\n padding: 10px;\n }\n .qde-textarea {\n padding: 10px;\n }\n /* Undo/Redo: show circular arrows instead of text */\n .qde-btn[data-action="undo"] { font-size: 0; }\n .qde-btn[data-action="undo"]::after { content: "\\21B6"; font-size: 14px; }\n .qde-btn[data-action="redo"] { font-size: 0; }\n .qde-btn[data-action="redo"]::after { content: "\\21B7"; font-size: 14px; }\n /* Hide secondary utility buttons to reduce clutter */\n .qde-btn[data-action="remove-hr"],\n .qde-btn[data-action="lazy-linefeeds"],\n .qde-btn[data-action="copy-rendered"] { display: none; }\n }\n\n /* Portrait mobile: drop split mode entirely */\n @media (max-width: 720px) and (orientation: portrait) {\n .qde-btn[data-mode="split"] { display: none; }\n .qde-split-toggle { display: none !important; }\n /* Fallback: if still in split mode, show source only */\n .qde-mode-split .qde-source { border-right: none; }\n .qde-mode-split .qde-preview { display: none; }\n .qde-mode-split.qde-split-preview .qde-source { display: none; }\n .qde-mode-split.qde-split-preview .qde-preview { display: block; }\n }\n ',document.head.appendChild(e)}attachEvents(){if(this.sourceTextarea.addEventListener("input",()=>{this.handleSourceInput()}),this.previewPanel.addEventListener("input",()=>{this.handlePreviewInput()}),this.toolbar&&this.toolbar.addEventListener("click",e=>{const t=e.target.closest(".qde-btn");if(t){if(t.classList.contains("qde-split-toggle")){this.container.classList.toggle("qde-split-preview");const e=this.container.classList.contains("qde-split-preview");return void(t.textContent=e?"Source":"Preview")}t.dataset.mode?this.setMode(t.dataset.mode):t.dataset.action&&this.handleAction(t.dataset.action)}}),document.addEventListener("keydown",e=>{if(e.ctrlKey||e.metaKey)switch(e.key){case"1":e.preventDefault(),this.setMode("source");break;case"2":e.preventDefault(),this.setMode("split");break;case"3":e.preventDefault(),this.setMode("preview");break;case"z":case"Z":e.shiftKey?(e.preventDefault(),this.redo()):(e.preventDefault(),this.undo());break;case"y":case"Y":e.preventDefault(),this.redo()}}),"function"==typeof window.matchMedia){const e=window.matchMedia("(max-width: 720px) and (orientation: portrait)"),t=()=>{e.matches&&"split"===this.currentMode&&this.setMode("source")};Promise.resolve().then(t),e.addEventListener("change",t)}}handleSourceInput(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateFromMarkdown(this.sourceTextarea.value)},this.options.debounceDelay)}handlePreviewInput(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateFromHTML()},this.options.debounceDelay)}updateFromMarkdown(e){if(this._isUndoRedo||this._pushUndoState(e||""),this._isUndoRedo=!1,this._markdown=e||"",this._markdown.trim()){const t=this.options.allowUnsafeHTML,n="limited"===t?y:t;if(this._html=g(e,{fence_plugin:this.createFencePlugin(),lazy_linefeeds:this.options.lazy_linefeeds,inline_styles:this.options.inline_styles,allow_unsafe_html:n}),"source"!==this.currentMode&&(this.previewPanel.innerHTML=this._html,this.makeFencesNonEditable(),window.MathJax&&window.MathJax.typesetPromise)){const e=this.previewPanel.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(e=>{console.warn("MathJax batch processing failed:",e)})}}else this._html="","source"!==this.currentMode&&(this.previewPanel.innerHTML='<div style="color: #999; font-style: italic; padding: 16px;">Start typing markdown in the source panel...</div>');this.options.onChange&&this.options.onChange(this._markdown,this._html)}updateFromHTML(){const e=this.previewPanel.cloneNode(!0);this.preprocessSpecialElements(e),this._html=this.previewPanel.innerHTML;const t=g.toMarkdown(e,{fence_plugin:this.createFencePlugin()});this._isUndoRedo||this._pushUndoState(t),this._isUndoRedo=!1,this._markdown=t,"preview"!==this.currentMode&&(this.sourceTextarea.value=this._markdown),this.options.onChange&&this.options.onChange(this._markdown,this._html),this._updateUndoButtons()}preprocessSpecialElements(e){if(!e)return;e.querySelectorAll('[contenteditable="false"][data-qd-source]').forEach(e=>{const t=e.getAttribute("data-qd-source"),n=e.getAttribute("data-qd-fence")||"```",o=e.getAttribute("data-qd-lang")||"",r=document.createElement("pre");r.setAttribute("data-qd-fence",n),o&&r.setAttribute("data-qd-lang",o);const a=document.createElement("code");a.textContent=t,r.appendChild(a),e.parentNode.replaceChild(r,e)});e.querySelectorAll("table.qde-csv-table[data-qd-lang]").forEach(e=>{const t=e.getAttribute("data-qd-lang");if(!t||!["csv","psv","tsv"].includes(t))return;const n="csv"===t?",":"psv"===t?"|":"\t";let o="";const r=[];e.querySelectorAll("thead th").forEach(e=>{const t=e.textContent.trim(),o=t.includes(n)||t.includes('"')||t.includes("\n");r.push(o?`"${t.replace(/"/g,'""')}"`:t)}),o+=r.join(n)+"\n";e.querySelectorAll("tbody tr").forEach(e=>{const t=[];e.querySelectorAll("td").forEach(e=>{const o=e.textContent.trim(),r=o.includes(n)||o.includes('"')||o.includes("\n");t.push(r?`"${o.replace(/"/g,'""')}"`:o)}),o+=t.join(n)+"\n"});const a=document.createElement("pre");a.setAttribute("data-qd-fence","```"),a.setAttribute("data-qd-lang",t);const i=document.createElement("code");i.textContent=o.trim(),a.appendChild(i),e.parentNode.replaceChild(a,e)})}createFencePlugin(){return{render:(e,t)=>{if(this.options.customFences&&this.options.customFences[t])try{return this.options.customFences[t](e,t)}catch(n){return console.error(`Custom fence plugin error for ${t}:`,n),`<pre><code class="language-${t}">${this.escapeHtml(e)}</code></pre>`}if(!!this.options.enableComplexFences)switch(t){case"svg":return this.renderSVG(e);case"html":return this.renderHTML(e);case"math":case"tex":case"latex":return this.renderMath(e,t);case"csv":case"psv":case"tsv":return this.renderTable(e,t);case"json":case"json5":return this.renderJSON(e,t);case"katex":return this.renderMath(e,"katex");case"mermaid":if(window.mermaid)return this.renderMermaid(e);break;case"geojson":return this.renderGeoJSON(e);case"stl":return this.renderSTL(e)}if(window.hljs&&t&&hljs.getLanguage(t)){return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}"><code class="hljs language-${t}">${hljs.highlight(e,{language:t}).value}</code></pre>`}},reverse:e=>{const t=e.getAttribute("data-qd-lang")||"";let n;if(e.querySelector("code.hljs")){const t=e.querySelector("code.hljs");n=t.textContent||t.innerText||""}else if(e.querySelector("code")){const t=e.querySelector("code");n=t.textContent||t.innerText||""}else n=e.textContent||e.innerText||"";return{content:n,lang:t,fence:"```"}}}}renderSVG(e){try{const t=(new DOMParser).parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG");const n=t.documentElement;n.querySelectorAll("script").forEach(e=>e.remove());const o=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let r;for(;r=o.nextNode();)for(let e=r.attributes.length-1;e>=0;e--){const t=r.attributes[e];(t.name.startsWith("on")||t.value.includes("javascript:"))&&r.removeAttribute(t.name)}const a=document.createElement("div");return a.className="qde-svg-container",a.contentEditable="false",a.setAttribute("data-qd-fence","```"),a.setAttribute("data-qd-lang","svg"),a.setAttribute("data-qd-source",e),a.innerHTML=(new XMLSerializer).serializeToString(n),a.outerHTML}catch(e){const t=document.createElement("pre");return t.className="qde-error",t.contentEditable="false",t.setAttribute("data-qd-fence","```"),t.setAttribute("data-qd-lang","svg"),t.textContent=`Invalid SVG: ${e.message}`,t.outerHTML}}renderHTML(e){const t=`html-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(window.DOMPurify){const t=DOMPurify.sanitize(e),n=document.createElement("div");return n.className="qde-html-container",n.contentEditable="false",n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html"),n.setAttribute("data-qd-source",e),n.innerHTML=t,n.outerHTML}this.lazyLoadLibrary("DOMPurify",()=>window.DOMPurify,"https://unpkg.com/dompurify/dist/purify.min.js").then(n=>{if(n){const n=document.getElementById(t);if(n){const t=DOMPurify.sanitize(e);n.innerHTML=t,n.setAttribute("data-qd-source",e),n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html")}}});const n=document.createElement("div");n.id=t,n.className="qde-html-container",n.contentEditable="false",n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html"),n.setAttribute("data-qd-source",e);const o=document.createElement("pre");return o.textContent=e,n.appendChild(o),n.outerHTML}renderMath(e,t){const n=`math-${Math.random().toString(36).substring(2,15)}`,o=document.createElement("div");o.id=n,o.className="math-display",o.contentEditable="false",o.setAttribute("data-source-type","math");const r=e.replace(/\r?\n/g," ").replace(/\s+/g," ").trim();return o.textContent=`$$${r}$$`,o.style.textAlign="center",o.style.margin="1em 0",window.MathJax&&window.MathJax.typesetPromise||this.ensureMathJaxLoaded(),o.outerHTML}ensureMathJaxLoaded(){if(void 0===window.MathJax&&!window.mathJaxLoading){window.mathJaxLoading=!0,window.MathJax||(window.MathJax={loader:{load:["input/tex","output/svg"]},tex:{packages:{"[+]":["ams"]},inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0},options:{renderActions:{addMenu:[]},ignoreHtmlClass:"tex2jax_ignore",processHtmlClass:"tex2jax_process"},svg:{fontCache:"none"},startup:{typeset:!1}});const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js",e.async=!0,e.onload=()=>{if(window.mathJaxLoading=!1,window.MathJax&&window.MathJax.typesetPromise){const e=document.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(e=>{console.warn("Initial MathJax processing failed:",e)})}},e.onerror=()=>{window.mathJaxLoading=!1,console.error("Failed to load MathJax")},document.head.appendChild(e)}}renderTable(e,t){const n=this.escapeHtml(e);try{const o="csv"===t?",":"psv"===t?"|":"\t",r=e.trim().split("\n");if(0===r.length)return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}" data-qd-source="${n}">${n}</pre>`;let a=`<table class="qde-data-table qde-csv-table" data-qd-fence="\`\`\`" data-qd-lang="${t}">`;const i=this.parseCSVLine(r[0],o);if(a+="<thead><tr>",i.forEach(e=>{a+=`<th>${this.escapeHtml(e.trim())}</th>`}),a+="</tr></thead>",r.length>1){a+="<tbody>";for(let e=1;e<r.length;e++){const t=this.parseCSVLine(r[e],o);a+="<tr>",t.forEach(e=>{a+=`<td>${this.escapeHtml(e.trim())}</td>`}),a+="</tr>"}a+="</tbody>"}return a+="</table>",a}catch(e){return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}" data-qd-source="${n}">${n}</pre>`}}parseCSVLine(e,t){const n=[];let o="",r=!1;for(let a=0;a<e.length;a++){const i=e[a],s=e[a+1];'"'===i?r&&'"'===s?(o+='"',a++):r=!r:i!==t||r?o+=i:(n.push(o),o="")}return n.push(o),n}renderJSON(e,t){if(window.hljs&&hljs.getLanguage("json"))try{let n=e;try{const t=JSON.parse(e);n=JSON.stringify(t,null,2)}catch(e){}return`<pre class="qde-json" data-qd-fence="\`\`\`" data-qd-lang="${t}"><code class="hljs language-json">${hljs.highlight(n,{language:"json"}).value}</code></pre>`}catch(e){}return`<pre class="qde-json" data-qd-fence="\`\`\`" data-qd-lang="${t}">${this.escapeHtml(e)}</pre>`}renderGeoJSON(e){const t=`map-${Math.random().toString(36).substr(2,15)}`,n=()=>{const n=document.getElementById(t+"-container");if(n&&window.L)try{const o=JSON.parse(e),r=document.createElement("div");r.id=t,r.style.cssText="width: 100%; height: 300px;",n.innerHTML="",n.appendChild(r);const a=L.map(t);n._map=a;const i=L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"",crossOrigin:"anonymous"});i.addTo(a);const s=L.geoJSON(o);s.addTo(a),s.getBounds().isValid()?a.fitBounds(s.getBounds()):a.setView([0,0],2),n._tileLayer=i,n._geoJsonLayer=s,i.on("load",()=>{n.setAttribute("data-tiles-loaded","true")})}catch(e){n.innerHTML=`<pre class="qde-error">GeoJSON error: ${this.escapeHtml(e.message)}</pre>`}};window.L?setTimeout(n,0):(window._qde_leaflet_loading||(window._qde_leaflet_loading=this.lazyLoadLibrary("Leaflet",()=>window.L,"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js","https://unpkg.com/leaflet@1.9.4/dist/leaflet.css").catch(e=>(console.warn("Failed to load Leaflet:",e),window._qde_leaflet_loading=null,!1))),window._qde_leaflet_loading.then(e=>{if(e)n();else{const e=document.getElementById(t+"-container");e&&(e.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">Failed to load map library</div>')}}).catch(()=>{}));const o=document.createElement("div");return o.className="geojson-container",o.id=t+"-container",o.style.cssText="width: 100%; height: 300px; border: 1px solid #ddd; border-radius: 4px; margin: 0.5em 0; background: #f0f0f0;",o.contentEditable="false",o.setAttribute("data-source-type","geojson"),o.setAttribute("data-original-source",this.escapeHtml(e)),o.setAttribute("data-qd-fence","```"),o.setAttribute("data-qd-lang","geojson"),o.setAttribute("data-qd-source",e),o.textContent="Loading map...",o.outerHTML}renderSTL(e){const t=`qde-stl-viewer-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,n=()=>{const n=document.getElementById(t);if(n)try{const t=window.THREE,o=new t.Scene;o.background=new t.Color(15790320);const r=new t.PerspectiveCamera(75,n.clientWidth/400,.1,1e3),a=new t.WebGLRenderer({antialias:!0});a.setSize(n.clientWidth,400),n.innerHTML="",n.appendChild(a.domElement),n._threeScene=o,n._threeCamera=r,n._threeRenderer=a;const i=this.parseSTL(e),s=new t.MeshLambertMaterial({color:26367}),l=new t.Mesh(i,s);o.add(l);const d=new t.AmbientLight(4210752,.6);o.add(d);const c=new t.DirectionalLight(16777215,.8);c.position.set(1,1,1).normalize(),o.add(c);const h=(new t.Box3).setFromObject(l),u=h.getCenter(new t.Vector3),p=h.getSize(new t.Vector3),m=Math.max(p.x,p.y,p.z);r.position.set(u.x+m,u.y+m,u.z+m),r.lookAt(u);const g=()=>{requestAnimationFrame(g),l.rotation.y+=.01,a.render(o,r)};g()}catch(e){console.error("STL rendering error:",e),n.innerHTML=`<pre class="qde-error">STL error: ${this.escapeHtml(e.message)}</pre>`}};return window.THREE?setTimeout(n,0):(window._qde_three_loading||(window._qde_three_loading=this.lazyLoadLibrary("Three.js",()=>window.THREE,"https://unpkg.com/three@0.147.0/build/three.min.js").catch(e=>(console.warn("Failed to load Three.js for STL rendering"),window._qde_three_loading=null,!1))),window._qde_three_loading.then(e=>{if(e)n();else{const e=document.getElementById(t);e&&(e.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">Failed to load Three.js for STL rendering</div>')}})),`<div id="${t}" class="qde-stl-container" data-stl-id="${t}" data-qd-fence="\`\`\`" data-qd-lang="stl" data-qd-source="${this.escapeHtml(e)}" contenteditable="false" style="height: 400px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">Loading 3D model...</div>`}parseSTL(e){const t=window.THREE,n=new t.BufferGeometry,o=[],r=[],a=e.split("\n");let i=null;for(let e of a)if(e=e.trim(),e.startsWith("facet normal")){const t=e.split(/\s+/);i=[parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]}else if(e.startsWith("vertex")){const t=e.split(/\s+/);o.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),i&&r.push(i[0],i[1],i[2])}return n.setAttribute("position",new t.Float32BufferAttribute(o,3)),n.setAttribute("normal",new t.Float32BufferAttribute(r,3)),n}renderMermaid(e){const t=`mermaid-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;setTimeout(()=>{const n=document.getElementById(t);n&&window.mermaid&&mermaid.render(t+"-svg",e).then(e=>{n.innerHTML=e.svg}).catch(e=>{n.innerHTML=`<pre>Error rendering diagram: ${e.message}</pre>`})},0);const n=document.createElement("div");return n.id=t,n.className="mermaid",n.contentEditable="false",n.setAttribute("data-qd-source",e),n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","mermaid"),n.textContent="Loading diagram...",n.outerHTML}escapeHtml(e){return(e??"").replace(/[&"'<>]/g,e=>({"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;"}[e]))}makeFencesNonEditable(){this.previewPanel}async loadPlugins(){const e=new Set;this.options.plugins&&(this.options.plugins.highlightjs&&e.add("highlightjs"),this.options.plugins.mermaid&&e.add("mermaid"));const t=this.options.preloadFences;if("all"===t)Object.keys(q).forEach(t=>e.add(t));else if(Array.isArray(t))for(const n of t)"string"==typeof n?q[n]?e.add(n):console.warn(`QuikdownEditor: unknown preloadFences entry "${n}"`):n&&"object"==typeof n&&n.script&&(e.add("__custom__:"+(n.name||n.script)),q["__custom__:"+(n.name||n.script)]={check:()=>!1,script:n.script,css:n.css});else t&&console.warn('QuikdownEditor: preloadFences should be "all", an array, or null');const n=[];for(const t of e){const e=q[t];if(!e||e.check())continue;e.beforeLoad&&e.beforeLoad();const o=(async()=>{try{const t=[];e.script&&t.push(this.loadScript(e.script)),e.css&&t.push(this.loadCSS(e.css,"qde-hljs-light")),e.cssDark&&t.push(this.loadCSS(e.cssDark,"qde-hljs-dark")),await Promise.all(t),e.css&&e.cssDark&&this._syncHljsTheme(),e.afterLoad&&e.afterLoad()}catch(e){console.warn(`QuikdownEditor: failed to preload ${t}:`,e)}})();n.push(o)}await Promise.all(n)}async lazyLoadLibrary(e,t,n,o=null){if(t())return!0;try{const e=[];return n&&e.push(this.loadScript(n)),o&&e.push(this.loadCSS(o)),await Promise.all(e),t()}catch(t){return console.error(`Failed to load ${e}:`,t),!1}}loadScript(e){return new Promise((t,n)=>{const o=document.createElement("script");o.src=e,o.onload=t,o.onerror=n,document.head.appendChild(o)})}loadCSS(e,t){return new Promise(n=>{const o=document.createElement("link");o.rel="stylesheet",o.href=e,t&&(o.id=t),o.onload=n,document.head.appendChild(o),setTimeout(n,1e3)})}_syncHljsTheme(){const e=this.container.classList.contains("qde-dark"),t=document.getElementById("qde-hljs-light"),n=document.getElementById("qde-hljs-dark");t&&(t.disabled=e),n&&(n.disabled=!e)}applyTheme(){const e=this.options.theme;if(this._autoThemeListener&&(window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",this._autoThemeListener),this._autoThemeListener=null),"auto"===e){const e=window.matchMedia("(prefers-color-scheme: dark)");this.container.classList.toggle("qde-dark",e.matches),this._autoThemeListener=e=>{this.container.classList.toggle("qde-dark",e.matches),this._syncHljsTheme()},e.addEventListener("change",this._autoThemeListener)}else this.container.classList.toggle("qde-dark","dark"===e);this._syncHljsTheme()}setTheme(e){["light","dark","auto"].includes(e)&&(this.options.theme=e,this.applyTheme())}getTheme(){return this.options.theme}setLazyLinefeeds(e){this.options.lazy_linefeeds=e,this._markdown&&this.updateFromMarkdown(this._markdown)}getLazyLinefeeds(){return this.options.lazy_linefeeds}setDebounceDelay(e){this.options.debounceDelay=Math.max(0,e)}getDebounceDelay(){return this.options.debounceDelay}setMode(e){if(!["source","preview","split"].includes(e))return;const t=this.container.classList.contains("qde-dark"),n=this.currentMode;if(this.currentMode=e,this.container.className=`qde-container qde-mode-${e}`,t&&this.container.classList.add("qde-dark"),this.toolbar){const e=this.toolbar.querySelector(".qde-split-toggle");e&&(e.textContent="Preview")}if(this.toolbar&&this.toolbar.querySelectorAll(".qde-btn[data-mode]").forEach(t=>{t.classList.toggle("active",t.dataset.mode===e)}),"source"!==e&&"source"===n&&this._html&&(this.previewPanel.innerHTML=this._html,setTimeout(()=>this.makeFencesNonEditable(),0),"undefined"!=typeof window&&window.MathJax&&window.MathJax.typesetPromise)){const e=this.previewPanel.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(()=>{})}this.options.onModeChange&&this.options.onModeChange(e)}_pushUndoState(e){if(e===this._markdown)return;this._undoStack.push(this._markdown);const t=this.options.undoStackSize||100;this._undoStack.length>t&&this._undoStack.splice(0,this._undoStack.length-t),this._redoStack=[],this._updateUndoButtons()}undo(){if(!this.canUndo())return;this._redoStack.push(this._markdown);const e=this._undoStack.pop();this._isUndoRedo=!0,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e),this._updateUndoButtons()}redo(){if(!this.canRedo())return;this._undoStack.push(this._markdown);const e=this._redoStack.pop();this._isUndoRedo=!0,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e),this._updateUndoButtons()}canUndo(){return this._undoStack.length>0}canRedo(){return this._redoStack.length>0}clearHistory(){this._undoStack=[],this._redoStack=[],this._updateUndoButtons()}_updateUndoButtons(){if(!this.toolbar)return;const e=this.toolbar.querySelector('[data-action="undo"]'),t=this.toolbar.querySelector('[data-action="redo"]');e&&e.classList.toggle("disabled",!this.canUndo()),t&&t.classList.toggle("disabled",!this.canRedo())}handleAction(e){switch(e){case"copy-markdown":this.copy("markdown");break;case"copy-html":this.copy("html");break;case"copy-rendered":this.copyRendered();break;case"remove-hr":this.removeHR();break;case"lazy-linefeeds":this.convertLazyLinefeeds();break;case"undo":this.undo();break;case"redo":this.redo();break;case"toggle-html-mode":this.cycleAllowUnsafeHTML()}}async copy(e){const t="markdown"===e?this._markdown:this._html;try{await navigator.clipboard.writeText(t);const n=this.toolbar.querySelector(`[data-action="copy-${e}"]`);if(n){const e=n.textContent;n.textContent="Copied!",setTimeout(()=>{n.textContent=e},1500)}}catch(e){console.error("Failed to copy:",e)}}get markdown(){return this._markdown}set markdown(e){this.setMarkdown(e)}get html(){return this._html}get mode(){return this.currentMode}async setMarkdown(e){this.initPromise&&await this.initPromise,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e)}getMarkdown(){return this._markdown}getHTML(){return this._html}async removeHR(){const e=v.removeHRFromMarkdown(this._markdown);await this.setMarkdown(e);const t=this.toolbar?.querySelector('[data-action="remove-hr"]');if(t){const e=t.textContent;t.textContent="Removed!",setTimeout(()=>{t.textContent=e},1500)}}static removeHRFromMarkdown(t){const r=(t||"").split("\n"),i=[];let s=!1,l=null,d=0;for(let t=0;t<r.length;t++){const c=r[t],h=c.trim();if(s)o(h,l,d)&&(s=!1,l=null,d=0),i.push(c);else{{const e=n(h);if(e){s=!0,l=e.char,d=e.len,i.push(c);continue}}if(/^\|.*\|$/.test(h)||/^[-| :]+$/.test(h)&&h.includes("|"))i.push(c);else{if(e(h)){const e=t>0?r[t-1].trim():"",n=t<r.length-1?r[t+1].trim():"";if(a(e)||a(n)){i.push(c);continue}continue}i.push(c)}}}return i.join("\n")}async convertLazyLinefeeds(){const e=v.convertLazyLinefeeds(this._markdown);await this.setMarkdown(e);const t=this.toolbar?.querySelector('[data-action="lazy-linefeeds"]');if(t){const e=t.textContent;t.textContent="Converted!",setTimeout(()=>{t.textContent=e},1500)}}static convertLazyLinefeeds(e){const t=(e||"").split("\n"),a=[];let i=!1,s=null,l=0;for(const e of t){const t=e,d=t.trim();if(i){o(d,s,l)?(i=!1,s=null,l=0,a.push({line:t,kind:"fence-close"})):a.push({line:t,kind:"fence-body"});continue}{const e=n(d);if(e){i=!0,s=e.char,l=e.len,a.push({line:t,kind:"fence-open"});continue}}if(""===d){a.push({line:"",kind:"blank"});continue}let c=r(d);"paragraph"===c&&/^(?: {4}|\t| {2,}[-*+]| {2,}\d+\.)/.test(t)&&(c="list-cont"),a.push({line:t,kind:"content",category:c})}const d=[];let c=null;function h(e,t){return!(!e||!t)&&(!("list-ul"!==e.category&&"list-ol"!==e.category&&"list-cont"!==e.category||"list-ul"!==t.category&&"list-ol"!==t.category&&"list-cont"!==t.category)||("blockquote"===e.category&&"blockquote"===t.category||"table"===e.category&&"table"===t.category))}for(const e of a)"fence-open"!==e.kind&&"fence-body"!==e.kind&&"fence-close"!==e.kind?"blank"!==e.kind&&(c&&(h(c,e)||""!==d[d.length-1]&&d.push("")),d.push(e.line),c=e):("fence-open"===e.kind&&c&&d.length>0&&""!==d[d.length-1]&&d.push(""),d.push(e.line),"fence-close"===e.kind&&(c={kind:"content",category:"fence"}));for(;d.length>0&&""===d[d.length-1];)d.pop();return d.join("\n")}async copyRendered(){try{if((await b(this.previewPanel)).success){const e=this.toolbar?.querySelector('[data-action="copy-rendered"]');if(e){const t=e.textContent;e.textContent="Copied!",setTimeout(()=>{e.textContent=t},1500)}}}catch(e){console.error("Failed to copy rendered content:",e)}}_getHtmlModeLabel(e){return!0===e?"HTML: Raw":"limited"===e?"HTML: Safe":"HTML: Off"}_getHtmlModeTooltip(e){return!0===e?"All HTML passes through — no protection":"limited"===e?"Safe tags render, dangerous tags escaped":"All HTML tags shown as text"}cycleAllowUnsafeHTML(){const e=this.options.allowUnsafeHTML;let t;t=!1===e?"limited":"limited"===e,this.setAllowUnsafeHTML(t)}setAllowUnsafeHTML(e){if(!1===e||!0===e||"limited"===e){if(this.options.allowUnsafeHTML=e,this.toolbar){const t=this.toolbar.querySelector('[data-action="toggle-html-mode"]');t&&(t.textContent=this._getHtmlModeLabel(e),t.title=this._getHtmlModeTooltip(e))}this.updateFromMarkdown(this._markdown)}}getAllowUnsafeHTML(){return this.options.allowUnsafeHTML}destroy(){clearTimeout(this.updateTimer),this.container.innerHTML="",this.container.classList.remove("qde-container","qde-dark");if(0===document.querySelectorAll(".qde-container").length){const e=document.getElementById("qde-styles");e&&e.remove()}}}return v.SAFE_HTML_TAGS=y,"undefined"!=typeof module&&module.exports&&(module.exports=v),"undefined"!=typeof window&&(window.QuikdownEditor=v),v});
12
+ */u.emitStyles=function(e="quikdown-",t="light"){const n=h,o={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},r={_textColor:"#333"};let a="";for(const[i,s]of Object.entries(n)){let n=s;if("dark"===t&&o){for(const[e,t]of Object.entries(o))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(i)&&(n+=`;color:${o._textColor}`)}else if("light"===t&&r){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(i)&&(n+=`;color:${r._textColor}`)}a+=`.${e}${i} { ${n} }\n`}return a},u.configure=function(e){return function(t){return u(t,e)}},u.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=u),"undefined"!=typeof window&&(window.quikdown=u),Object.keys(u).forEach(e=>{"configure"!==e&&(g[e]=u[e])}),g.toMarkdown=function(e,t={}){let n;if("string"==typeof e)n=document.createElement("div"),n.innerHTML=e;else{if(!(e instanceof Element))return"";n=e}function o(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const a=e.tagName.toLowerCase(),i=e.getAttribute("data-qd");let s="";for(const t of e.childNodes)s+=o(t,{parentTag:a,...n});switch(a){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(a[1]);return`${i||"#".repeat(n)} ${s.trim()}\n\n`;case"strong":case"b":if(!s)return"";const o=i||"**";return`${o}${s}${o}`;case"em":case"i":if(!s)return"";const l=i||"*";return`${l}${s}${l}`;case"del":case"s":case"strike":if(!s)return"";const d=i||"~~";return`${d}${s}${d}`;case"code":if(!s)return"";const c=i||"`";return`${c}${s}${c}`;case"pre":const h=e.getAttribute("data-qd-fence")||i||"```",u=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&u)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||h;return`${e}${n.lang||u}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const p=e.getAttribute("data-qd-source");if(p)return`${h}${u}\n${p}\n${h}\n\n`;const m=e.querySelector("code");return`${h}${u}\n${(m?m.textContent:s).trimEnd()}\n${h}\n\n`;case"blockquote":const g=i||">";return s.trim().split("\n").map(e=>`${g} ${e}`).join("\n")+"\n\n";case"hr":return`${i||"---"}\n\n`;case"br":return`${i||" "}\n`;case"a":const f=e.getAttribute("data-qd-text")||s.trim(),w=e.getAttribute("href")||"";return f!==w||i?`[${f}](${w})`:`<${w}>`;case"img":return`${i||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return r(e,"ol"===a)+"\n";case"li":case"span":default:return s;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),o=n?n.split(","):[],r=e.querySelector("thead");if(r){const e=r.querySelector("tr");if(e){const n=[];for(const t of e.querySelectorAll("th"))n.push(t.textContent.trim());t+="| "+n.join(" | ")+" |\n";t+="| "+n.map((e,t)=>{const n=o[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const a=e.querySelector("tbody");if(a)for(const e of a.querySelectorAll("tr")){const n=[];for(const t of e.querySelectorAll("td"))n.push(t.textContent.trim());n.length>0&&(t+="| "+n.join(" | ")+" |\n")}return t.trim()}(e)+"\n\n";case"p":if(s.trim()){const e=s.split("\n");let t=s.trim();if(e.length>1){let n=0;for(let t=e.length-1;t>=0&&""===e[t].trim();t--)n++;if(n>0)return t+="\n ",t+"\n"}return t+"\n\n"}return"";case"div":const b=e.getAttribute("data-qd-lang"),y=e.getAttribute("data-qd-fence");if(b&&t.fence_plugin&&t.fence_plugin.reverse)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||y||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const x=e.getAttribute("data-qd-source");if(x&&y)return`${y}${b||""}\n${x}\n${y}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",o=e.getAttribute("data-qd-source");if(o){const e=document.createElement("textarea");e.innerHTML=o;return`${t}${n}\n${e.value}\n${t}\n\n`}const r=e.querySelector("pre.mermaid");if(r){const e=r.getAttribute("data-qd-source");if(e){const o=document.createElement("textarea");o.innerHTML=e;return`${t}${n}\n${o.value}\n${t}\n\n`}}const a=e.querySelector(".mermaid-source");if(a){const e=document.createElement("div");e.innerHTML=a.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const i=e.querySelector(".mermaid");if(i&&i.textContent.includes("graph"))return`${t}${n}\n${i.textContent.trim()}\n${t}\n\n`}if(e.classList&&e.classList.contains("mermaid")){const t=e.getAttribute("data-qd-fence")||"```";return`${t}${e.getAttribute("data-qd-lang")||"mermaid"}\n${e.textContent.trim()}\n${t}\n\n`}return s}}function r(e,t,n=0){let a="",i=1;const s=" ".repeat(n);for(const l of e.children){if("LI"!==l.tagName)continue;let e=l.getAttribute("data-qd")||(t?`${i}.`:"-");const d=l.querySelector('input[type="checkbox"]');if(d){const t=d.checked?"x":" ";e="-";let n="";for(const e of l.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=o(e));a+=`${s}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of l.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=r(e,"OL"===e.tagName,n+1):t+=o(e);a+=`${s}${e} ${t.trim()}\n`}i++}return a}let a=o(n);return a=a.replace(/\n{3,}/g,"\n\n"),a=a.trim(),a},g.configure=function(e){const t=u.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=g),"undefined"!=typeof window&&(window.quikdown_bd=g);const y={b:1,i:1,em:1,strong:1,del:1,s:1,u:1,mark:1,sup:1,sub:1,kbd:1,abbr:1,var:1,samp:1,cite:1,small:1,ins:1,dfn:1,ruby:1,rt:1,rp:1,time:1,wbr:1,img:1,picture:1,source:1,video:1,audio:1,figure:1,figcaption:1,a:1,br:1,hr:1,div:1,span:1,p:1,details:1,summary:1,section:1,article:1,aside:1,header:1,footer:1,nav:1,main:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,ul:1,ol:1,li:1,dl:1,dt:1,dd:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,blockquote:1,pre:1,code:1},x={mode:"split",showToolbar:!0,showRemoveHR:!1,showLazyLinefeeds:!1,theme:"auto",lazy_linefeeds:!1,inline_styles:!1,debounceDelay:20,placeholder:"Start typing markdown...",plugins:{highlightjs:!1,mermaid:!1},preloadFences:null,customFences:{},enableComplexFences:!0,showUndoRedo:!1,undoStackSize:100,allowUnsafeHTML:!1,showAllowUnsafeHTML:!1},q={highlightjs:{check:()=>void 0!==window.hljs,script:"https://unpkg.com/@highlightjs/cdn-assets/highlight.min.js",css:"https://unpkg.com/@highlightjs/cdn-assets/styles/github.min.css",cssDark:"https://unpkg.com/@highlightjs/cdn-assets/styles/github-dark.min.css"},mermaid:{check:()=>void 0!==window.mermaid,script:"https://unpkg.com/mermaid/dist/mermaid.min.js",afterLoad:()=>{window.mermaid&&window.mermaid.initialize({startOnLoad:!1})}},math:{check:()=>void 0!==window.MathJax,script:"https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js",beforeLoad:()=>{window.MathJax||(window.MathJax={loader:{load:["input/tex","output/svg"]},tex:{packages:{"[+]":["ams"]},inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0},options:{renderActions:{addMenu:[]},ignoreHtmlClass:"tex2jax_ignore",processHtmlClass:"tex2jax_process"},svg:{fontCache:"none"},startup:{typeset:!1}})}},geojson:{check:()=>void 0!==window.L,script:"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js",css:"https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"},stl:{check:()=>void 0!==window.THREE,script:"https://unpkg.com/three@0.147.0/build/three.min.js"}};class v{constructor(e,t={}){if(this.container="string"==typeof e?document.querySelector(e):e,!this.container)throw new Error("QuikdownEditor: Invalid container");this.options={...x,...t},this._markdown="",this._html="",this.currentMode=this.options.mode,this.updateTimer=null,this._undoStack=[],this._redoStack=[],this._isUndoRedo=!1,this.initPromise=this.init()}async init(){await this.loadPlugins(),this.buildUI(),this.attachEvents(),this.applyTheme(),this.setMode(this.currentMode),this.options.initialContent&&this.setMarkdown(this.options.initialContent)}buildUI(){this.container.innerHTML="",this.container.classList.add("qde-container"),this.options.showToolbar&&(this.toolbar=this.createToolbar(),this.container.appendChild(this.toolbar)),this.editorArea=document.createElement("div"),this.editorArea.className="qde-editor",this.sourcePanel=document.createElement("div"),this.sourcePanel.className="qde-source",this.sourceTextarea=document.createElement("textarea"),this.sourceTextarea.className="qde-textarea",this.sourceTextarea.spellcheck=!1,this.sourceTextarea.placeholder=this.options.placeholder,this.sourcePanel.appendChild(this.sourceTextarea),this.previewPanel=document.createElement("div"),this.previewPanel.className="qde-preview",this.previewPanel.contentEditable=!0,this.previewPanel.spellcheck=!1,this.editorArea.appendChild(this.sourcePanel),this.editorArea.appendChild(this.previewPanel),this.container.appendChild(this.editorArea),this.injectStyles()}createToolbar(){const e=document.createElement("div");e.className="qde-toolbar";const t={source:"Source",split:"Split",preview:"Rendered"};["source","split","preview"].forEach(n=>{const o=document.createElement("button");o.className="qde-btn",o.dataset.mode=n,o.textContent=t[n],o.title=`Switch to ${t[n]} view`,e.appendChild(o)});const n=document.createElement("button");if(n.className="qde-btn qde-split-toggle",n.textContent="Preview",n.title="Toggle between source and preview in split mode",e.appendChild(n),this.options.showUndoRedo){const t=document.createElement("button");t.className="qde-btn disabled",t.dataset.action="undo",t.textContent="Undo",t.title="Undo (Ctrl+Z)",e.appendChild(t);const n=document.createElement("button");n.className="qde-btn disabled",n.dataset.action="redo",n.textContent="Redo",n.title="Redo (Ctrl+Shift+Z / Ctrl+Y)",e.appendChild(n)}const o=document.createElement("span");o.className="qde-spacer",e.appendChild(o);if([{action:"copy-markdown",text:"Copy MD",title:"Copy markdown to clipboard"},{action:"copy-html",text:"Copy HTML",title:"Copy HTML to clipboard"},{action:"copy-rendered",text:"Copy Rendered",title:"Copy rich text to clipboard"}].forEach(({action:t,text:n,title:o})=>{const r=document.createElement("button");r.className="qde-btn",r.dataset.action=t,r.textContent=n,r.title=o,e.appendChild(r)}),this.options.showRemoveHR){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="remove-hr",t.textContent="Remove HR",t.title="Remove all horizontal rules (---) from markdown",e.appendChild(t)}if(this.options.showLazyLinefeeds){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="lazy-linefeeds",t.textContent="Fix Linefeeds",t.title="Convert single newlines to paragraph breaks (one-time transform)",e.appendChild(t)}if(this.options.showAllowUnsafeHTML){const t=document.createElement("button");t.className="qde-btn",t.dataset.action="toggle-html-mode",t.textContent=this._getHtmlModeLabel(this.options.allowUnsafeHTML),t.title=this._getHtmlModeTooltip(this.options.allowUnsafeHTML),e.appendChild(t)}return e}injectStyles(){if(document.getElementById("qde-styles"))return;const e=document.createElement("style");e.id="qde-styles",e.textContent='\n .qde-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n border: 1px solid #ddd;\n border-radius: 4px;\n overflow: hidden;\n background: white;\n color: #1f2937;\n }\n \n .qde-toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n padding: 8px;\n background: #f5f5f5;\n border-bottom: 1px solid #ddd;\n gap: 4px;\n }\n \n .qde-btn {\n padding: 6px 12px;\n border: 1px solid #ccc;\n background: white;\n border-radius: 3px;\n cursor: pointer;\n font-size: 14px;\n transition: all 0.2s;\n }\n \n .qde-btn:hover {\n background: #e9e9e9;\n border-color: #999;\n }\n \n .qde-btn.active {\n background: #007bff;\n color: white;\n border-color: #0056b3;\n }\n\n .qde-btn.disabled {\n opacity: 0.4;\n pointer-events: none;\n }\n .qde-btn[data-action="toggle-html-mode"] {\n position: relative;\n }\n .qde-btn[data-action="toggle-html-mode"]:hover::after {\n content: attr(title);\n position: absolute;\n bottom: calc(100% + 6px);\n left: 50%;\n transform: translateX(-50%);\n padding: 5px 10px;\n background: #1f2937;\n color: #fff;\n font-size: 0.75rem;\n font-weight: 400;\n white-space: nowrap;\n border-radius: 4px;\n pointer-events: none;\n z-index: 10;\n }\n \n .qde-spacer {\n flex: 1;\n }\n \n .qde-editor {\n display: flex;\n flex: 1;\n overflow: hidden;\n }\n \n .qde-source, .qde-preview {\n flex: 1 1 0;\n min-width: 0; /* allow flex shrinking below content size */\n min-height: 0;\n overflow: auto;\n padding: 16px;\n box-sizing: border-box;\n }\n\n .qde-source {\n border-right: 1px solid #ddd;\n /* Source pane is just a container for the textarea — make it\n a positioning context so the textarea can fill it absolutely */\n position: relative;\n padding: 0; /* textarea brings its own padding */\n }\n\n .qde-textarea {\n display: block;\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 16px;\n box-sizing: border-box;\n font-family: \'Monaco\', \'Courier New\', monospace;\n font-size: 14px;\n line-height: 1.5;\n background: transparent;\n color: inherit;\n /* Wrap long lines so the textarea only scrolls VERTICALLY.\n pre-wrap preserves intentional line breaks/whitespace\n while soft-wrapping at the right edge. */\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-x: hidden;\n overflow-y: auto;\n }\n \n .qde-preview {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n font-size: 16px;\n line-height: 1.6;\n outline: none;\n cursor: text; /* Standard text cursor */\n overflow-x: hidden; /* never scroll horizontally; clip wide content */\n }\n\n /* Code blocks and inline code — self-contained so the editor\n does not depend on any external stylesheet for these. */\n .qde-preview pre {\n background: #f4f4f4;\n color: #1f2937;\n padding: 10px;\n border-radius: 4px;\n overflow-x: auto;\n margin: 0.6em 0;\n font-size: 0.9em;\n line-height: 1.5;\n font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code",\n "Roboto Mono", Consolas, "Courier New", monospace;\n }\n .qde-preview code {\n padding: 2px 4px;\n font-size: 0.9em;\n border-radius: 3px;\n background: #f0f0f0;\n color: #1f2937;\n font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code",\n "Roboto Mono", Consolas, "Courier New", monospace;\n }\n .qde-preview pre code {\n padding: 0;\n font-size: inherit;\n border-radius: 0;\n background: transparent;\n color: inherit;\n }\n\n /* Wide fence content (Leaflet maps, large SVGs, STL canvases,\n iframes, raw <img>) must never overflow the preview pane */\n .qde-preview .geojson-container,\n .qde-preview .qde-stl-container,\n .qde-preview .qde-svg-container,\n .qde-preview .leaflet-container,\n .qde-preview iframe,\n .qde-preview img,\n .qde-preview > svg {\n max-width: 100%;\n }\n .qde-preview img {\n display: inline;\n }\n .qde-preview .leaflet-container { box-sizing: border-box; }\n\n /* Standard markdown tables (the .quikdown-table class) need to\n scroll horizontally inside their own wrapper rather than\n making the whole preview pane scroll */\n .qde-preview table.quikdown-table,\n .qde-preview table.qde-csv-table {\n display: block;\n max-width: 100%;\n overflow-x: auto;\n }\n\n /* Fence-specific styles */\n .qde-svg-container {\n max-width: 100%;\n overflow: auto;\n }\n\n .qde-svg-container svg {\n max-width: 100%;\n height: auto;\n }\n \n .qde-html-container {\n /* HTML containers inherit background */\n margin: 12px 0;\n }\n \n .qde-math-container {\n text-align: center;\n margin: 16px 0;\n overflow-x: auto;\n }\n \n /* All tables in preview (both regular markdown and CSV) */\n .qde-preview table {\n width: 100%;\n border-collapse: collapse;\n margin: 12px 0;\n font-size: 14px;\n }\n \n .qde-preview table th,\n .qde-preview table td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n \n /* Support for alignment classes from quikdown */\n .qde-preview .quikdown-left { text-align: left; }\n .qde-preview .quikdown-center { text-align: center; }\n .qde-preview .quikdown-right { text-align: right; }\n \n .qde-preview table th {\n background: #f5f5f5;\n font-weight: bold;\n }\n \n .qde-preview table tr:nth-child(even) {\n background: #f9f9f9;\n }\n \n /* Specific to CSV-generated tables */\n .qde-data-table {\n /* Can add specific CSV table styles here if needed */\n }\n \n .qde-json {\n /* Let highlight.js handle styling */\n overflow-x: auto;\n }\n \n .qde-error {\n background: #fee;\n border: 1px solid #fcc;\n color: #c00;\n padding: 8px;\n border-radius: 4px;\n font-family: monospace;\n font-size: 12px;\n }\n \n /* Read-only complex fence blocks in preview */\n .qde-preview [contenteditable="false"] {\n cursor: auto; /* Use automatic cursor (arrow for non-text) */\n user-select: text;\n position: relative;\n }\n \n /* Reset headings inside the preview to plain browser defaults so\n parent-page styles (site navs, marketing pages, design systems)\n cannot bleed in. Business-casual: black text, decreasing sizes,\n no decorative borders. See docs/quikdown-editor.md for how\n embedders can override these with their own stylesheet. */\n .qde-preview h1 { font-size: 2em; }\n .qde-preview h2 { font-size: 1.5em; }\n .qde-preview h3 { font-size: 1.25em; }\n .qde-preview h4 { font-size: 1em; }\n .qde-preview h5 { font-size: 0.875em; }\n .qde-preview h6 { font-size: 0.85em; }\n .qde-preview h1,\n .qde-preview h2,\n .qde-preview h3,\n .qde-preview h4,\n .qde-preview h5,\n .qde-preview h6 {\n font-weight: bold;\n color: inherit;\n border: none;\n margin: 0.6em 0 0.3em 0;\n line-height: 1.25;\n }\n .qde-preview p {\n margin: 0.35em 0;\n }\n .qde-preview ul,\n .qde-preview ol {\n padding-left: 1.8em;\n margin: 0.4em 0;\n }\n .qde-preview li {\n margin: 0.15em 0;\n }\n .qde-preview blockquote {\n margin: 0.5em 0;\n padding-left: 1em;\n }\n\n /* Ensure proper cursor for editable text elements */\n .qde-preview p,\n .qde-preview h1,\n .qde-preview h2,\n .qde-preview h3,\n .qde-preview h4,\n .qde-preview h5,\n .qde-preview h6,\n .qde-preview li,\n .qde-preview td,\n .qde-preview th,\n .qde-preview blockquote,\n .qde-preview pre[contenteditable="true"],\n .qde-preview code[contenteditable="true"] {\n cursor: text;\n }\n \n \n /* Non-editable complex renderers */\n .qde-preview .qde-svg-container[contenteditable="false"],\n .qde-preview .qde-html-container[contenteditable="false"],\n .qde-preview .qde-math-container[contenteditable="false"],\n .qde-preview .mermaid[contenteditable="false"] {\n opacity: 0.98;\n }\n \n /* Subtle hover effect for read-only blocks */\n .qde-preview [contenteditable="false"]:hover::after {\n content: "Read-only";\n position: absolute;\n top: 2px;\n right: 2px;\n font-size: 10px;\n color: #999;\n background: rgba(255, 255, 255, 0.9);\n padding: 2px 4px;\n border-radius: 2px;\n pointer-events: none;\n }\n \n /* Fix list padding in preview */\n .qde-preview ul,\n .qde-preview ol {\n padding-left: 2em;\n margin: 0.5em 0;\n }\n \n .qde-preview li {\n margin: 0.25em 0;\n }\n \n /* Mode-specific visibility */\n .qde-mode-source .qde-preview { display: none; }\n .qde-mode-source .qde-source { border-right: none; }\n .qde-mode-preview .qde-source { display: none; }\n .qde-mode-split .qde-source,\n .qde-mode-split .qde-preview { display: block; }\n \n /* Dark theme */\n .qde-dark {\n background: #1e1e1e;\n color: #e0e0e0;\n border-color: #444;\n }\n \n .qde-dark .qde-toolbar {\n background: #2d2d2d;\n border-color: #444;\n }\n \n .qde-dark .qde-btn {\n background: #3a3a3a;\n color: #e0e0e0;\n border-color: #555;\n }\n \n .qde-dark .qde-btn:hover {\n background: #4a4a4a;\n }\n \n .qde-dark .qde-source {\n border-color: #444;\n }\n \n .qde-dark .qde-textarea {\n background: #1e1e1e;\n color: #e0e0e0;\n }\n \n .qde-dark .qde-preview {\n background: #1e1e1e;\n color: #e0e0e0;\n }\n \n /* Dark mode code blocks */\n .qde-dark .qde-preview pre {\n background: #2d2d3a;\n color: #e6e6f0;\n }\n .qde-dark .qde-preview code {\n background: #2a2a3a;\n color: #e6e6f0;\n }\n .qde-dark .qde-preview pre code {\n background: transparent;\n color: inherit;\n }\n\n /* Dark mode table styles */\n .qde-dark .qde-preview table th,\n .qde-dark .qde-preview table td {\n border-color: #3a3a3a;\n }\n \n .qde-dark .qde-preview table th {\n background: #2d2d2d;\n }\n \n .qde-dark .qde-preview table tr:nth-child(even) {\n background: #252525;\n }\n \n /* Mobile split toggle — hidden by default */\n .qde-split-toggle { display: none; }\n\n /* Mobile responsive — compact toolbar for all small screens */\n @media (max-width: 720px) {\n .qde-toolbar {\n padding: 6px;\n gap: 3px;\n }\n .qde-btn {\n padding: 5px 8px;\n font-size: 12px;\n }\n .qde-source, .qde-preview {\n padding: 10px;\n }\n .qde-textarea {\n padding: 10px;\n }\n /* Undo/Redo: show circular arrows instead of text */\n .qde-btn[data-action="undo"] { font-size: 0; }\n .qde-btn[data-action="undo"]::after { content: "\\21B6"; font-size: 14px; }\n .qde-btn[data-action="redo"] { font-size: 0; }\n .qde-btn[data-action="redo"]::after { content: "\\21B7"; font-size: 14px; }\n /* Hide secondary utility buttons to reduce clutter */\n .qde-btn[data-action="remove-hr"],\n .qde-btn[data-action="lazy-linefeeds"],\n .qde-btn[data-action="copy-rendered"] { display: none; }\n }\n\n /* Portrait mobile: drop split mode entirely */\n @media (max-width: 720px) and (orientation: portrait) {\n .qde-btn[data-mode="split"] { display: none; }\n .qde-split-toggle { display: none !important; }\n /* Fallback: if still in split mode, show source only */\n .qde-mode-split .qde-source { border-right: none; }\n .qde-mode-split .qde-preview { display: none; }\n .qde-mode-split.qde-split-preview .qde-source { display: none; }\n .qde-mode-split.qde-split-preview .qde-preview { display: block; }\n }\n ',document.head.appendChild(e)}attachEvents(){if(this.sourceTextarea.addEventListener("input",()=>{this.handleSourceInput()}),this.previewPanel.addEventListener("input",()=>{this.handlePreviewInput()}),this.toolbar&&this.toolbar.addEventListener("click",e=>{const t=e.target.closest(".qde-btn");if(t){if(t.classList.contains("qde-split-toggle")){this.container.classList.toggle("qde-split-preview");const e=this.container.classList.contains("qde-split-preview");return void(t.textContent=e?"Source":"Preview")}t.dataset.mode?this.setMode(t.dataset.mode):t.dataset.action&&this.handleAction(t.dataset.action)}}),document.addEventListener("keydown",e=>{if(e.ctrlKey||e.metaKey)switch(e.key){case"1":e.preventDefault(),this.setMode("source");break;case"2":e.preventDefault(),this.setMode("split");break;case"3":e.preventDefault(),this.setMode("preview");break;case"z":case"Z":e.shiftKey?(e.preventDefault(),this.redo()):(e.preventDefault(),this.undo());break;case"y":case"Y":e.preventDefault(),this.redo()}}),"function"==typeof window.matchMedia){const e=window.matchMedia("(max-width: 720px) and (orientation: portrait)"),t=()=>{e.matches&&"split"===this.currentMode&&this.setMode("source")};Promise.resolve().then(t),e.addEventListener("change",t)}}handleSourceInput(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateFromMarkdown(this.sourceTextarea.value)},this.options.debounceDelay)}handlePreviewInput(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.updateFromHTML()},this.options.debounceDelay)}updateFromMarkdown(e){if(this._isUndoRedo||this._pushUndoState(e||""),this._isUndoRedo=!1,this._markdown=e||"",this._markdown.trim()){const t=this.options.allowUnsafeHTML,n="limited"===t?y:t;if(this._html=g(e,{fence_plugin:this.createFencePlugin(),lazy_linefeeds:this.options.lazy_linefeeds,inline_styles:this.options.inline_styles,allow_unsafe_html:n}),"source"!==this.currentMode&&(this.previewPanel.innerHTML=this._html,this.makeFencesNonEditable(),window.MathJax&&window.MathJax.typesetPromise)){const e=this.previewPanel.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(e=>{console.warn("MathJax batch processing failed:",e)})}}else this._html="","source"!==this.currentMode&&(this.previewPanel.innerHTML='<div style="color: #999; font-style: italic; padding: 16px;">Start typing markdown in the source panel...</div>');this.options.onChange&&this.options.onChange(this._markdown,this._html)}updateFromHTML(){const e=this.previewPanel.cloneNode(!0);this.preprocessSpecialElements(e),this._html=this.previewPanel.innerHTML;const t=g.toMarkdown(e,{fence_plugin:this.createFencePlugin()});this._isUndoRedo||this._pushUndoState(t),this._isUndoRedo=!1,this._markdown=t,"preview"!==this.currentMode&&(this.sourceTextarea.value=this._markdown),this.options.onChange&&this.options.onChange(this._markdown,this._html),this._updateUndoButtons()}preprocessSpecialElements(e){if(!e)return;e.querySelectorAll('[contenteditable="false"][data-qd-source]').forEach(e=>{const t=e.getAttribute("data-qd-source"),n=e.getAttribute("data-qd-fence")||"```",o=e.getAttribute("data-qd-lang")||"",r=document.createElement("pre");r.setAttribute("data-qd-fence",n),o&&r.setAttribute("data-qd-lang",o);const a=document.createElement("code");a.textContent=t,r.appendChild(a),e.parentNode.replaceChild(r,e)});e.querySelectorAll("table.qde-csv-table[data-qd-lang]").forEach(e=>{const t=e.getAttribute("data-qd-lang");if(!t||!["csv","psv","tsv"].includes(t))return;const n="csv"===t?",":"psv"===t?"|":"\t";let o="";const r=[];e.querySelectorAll("thead th").forEach(e=>{const t=e.textContent.trim(),o=t.includes(n)||t.includes('"')||t.includes("\n");r.push(o?`"${t.replace(/"/g,'""')}"`:t)}),o+=r.join(n)+"\n";e.querySelectorAll("tbody tr").forEach(e=>{const t=[];e.querySelectorAll("td").forEach(e=>{const o=e.textContent.trim(),r=o.includes(n)||o.includes('"')||o.includes("\n");t.push(r?`"${o.replace(/"/g,'""')}"`:o)}),o+=t.join(n)+"\n"});const a=document.createElement("pre");a.setAttribute("data-qd-fence","```"),a.setAttribute("data-qd-lang",t);const i=document.createElement("code");i.textContent=o.trim(),a.appendChild(i),e.parentNode.replaceChild(a,e)})}createFencePlugin(){return{render:(e,t)=>{if(this.options.customFences&&this.options.customFences[t])try{return this.options.customFences[t](e,t)}catch(n){return console.error(`Custom fence plugin error for ${t}:`,n),`<pre><code class="language-${t}">${this.escapeHtml(e)}</code></pre>`}if(!!this.options.enableComplexFences)switch(t){case"svg":return this.renderSVG(e);case"html":return this.renderHTML(e);case"math":case"tex":case"latex":return this.renderMath(e,t);case"csv":case"psv":case"tsv":return this.renderTable(e,t);case"json":case"json5":return this.renderJSON(e,t);case"katex":return this.renderMath(e,"katex");case"mermaid":if(window.mermaid)return this.renderMermaid(e);break;case"geojson":return this.renderGeoJSON(e);case"stl":return this.renderSTL(e)}if(window.hljs&&t&&hljs.getLanguage(t)){return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}"><code class="hljs language-${t}">${hljs.highlight(e,{language:t}).value}</code></pre>`}},reverse:e=>{const t=e.getAttribute("data-qd-lang")||"";let n;if(e.querySelector("code.hljs")){const t=e.querySelector("code.hljs");n=t.textContent||t.innerText||""}else if(e.querySelector("code")){const t=e.querySelector("code");n=t.textContent||t.innerText||""}else n=e.textContent||e.innerText||"";return{content:n,lang:t,fence:"```"}}}}renderSVG(e){try{const t=(new DOMParser).parseFromString(e,"image/svg+xml");if(t.querySelector("parsererror"))throw new Error("Invalid SVG");const n=t.documentElement;n.querySelectorAll("script").forEach(e=>e.remove());const o=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let r;for(;r=o.nextNode();)for(let e=r.attributes.length-1;e>=0;e--){const t=r.attributes[e];(t.name.startsWith("on")||t.value.includes("javascript:"))&&r.removeAttribute(t.name)}const a=document.createElement("div");return a.className="qde-svg-container",a.contentEditable="false",a.setAttribute("data-qd-fence","```"),a.setAttribute("data-qd-lang","svg"),a.setAttribute("data-qd-source",e),a.innerHTML=(new XMLSerializer).serializeToString(n),a.outerHTML}catch(e){const t=document.createElement("pre");return t.className="qde-error",t.contentEditable="false",t.setAttribute("data-qd-fence","```"),t.setAttribute("data-qd-lang","svg"),t.textContent=`Invalid SVG: ${e.message}`,t.outerHTML}}renderHTML(e){const t=`html-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(window.DOMPurify){const t=DOMPurify.sanitize(e),n=document.createElement("div");return n.className="qde-html-container",n.contentEditable="false",n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html"),n.setAttribute("data-qd-source",e),n.innerHTML=t,n.outerHTML}this.lazyLoadLibrary("DOMPurify",()=>window.DOMPurify,"https://unpkg.com/dompurify/dist/purify.min.js").then(n=>{if(n){const n=document.getElementById(t);if(n){const t=DOMPurify.sanitize(e);n.innerHTML=t,n.setAttribute("data-qd-source",e),n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html")}}});const n=document.createElement("div");n.id=t,n.className="qde-html-container",n.contentEditable="false",n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","html"),n.setAttribute("data-qd-source",e);const o=document.createElement("pre");return o.textContent=e,n.appendChild(o),n.outerHTML}renderMath(e,t){const n=`math-${Math.random().toString(36).substring(2,15)}`,o=document.createElement("div");o.id=n,o.className="math-display",o.contentEditable="false",o.setAttribute("data-source-type","math");const r=e.replace(/\r?\n/g," ").replace(/\s+/g," ").trim();return o.textContent=`$$${r}$$`,o.style.textAlign="center",o.style.margin="1em 0",window.MathJax&&window.MathJax.typesetPromise||this.ensureMathJaxLoaded(),o.outerHTML}ensureMathJaxLoaded(){if(void 0===window.MathJax&&!window.mathJaxLoading){window.mathJaxLoading=!0,window.MathJax||(window.MathJax={loader:{load:["input/tex","output/svg"]},tex:{packages:{"[+]":["ams"]},inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"],["\\[","\\]"]],processEscapes:!0,processEnvironments:!0},options:{renderActions:{addMenu:[]},ignoreHtmlClass:"tex2jax_ignore",processHtmlClass:"tex2jax_process"},svg:{fontCache:"none"},startup:{typeset:!1}});const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js",e.async=!0,e.onload=()=>{if(window.mathJaxLoading=!1,window.MathJax&&window.MathJax.typesetPromise){const e=document.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(e=>{console.warn("Initial MathJax processing failed:",e)})}},e.onerror=()=>{window.mathJaxLoading=!1,console.error("Failed to load MathJax")},document.head.appendChild(e)}}renderTable(e,t){const n=this.escapeHtml(e);try{const o="csv"===t?",":"psv"===t?"|":"\t",r=e.trim().split("\n");if(0===r.length)return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}" data-qd-source="${n}">${n}</pre>`;let a=`<table class="qde-data-table qde-csv-table" data-qd-fence="\`\`\`" data-qd-lang="${t}">`;const i=this.parseCSVLine(r[0],o);if(a+="<thead><tr>",i.forEach(e=>{a+=`<th>${this.escapeHtml(e.trim())}</th>`}),a+="</tr></thead>",r.length>1){a+="<tbody>";for(let e=1;e<r.length;e++){const t=this.parseCSVLine(r[e],o);a+="<tr>",t.forEach(e=>{a+=`<td>${this.escapeHtml(e.trim())}</td>`}),a+="</tr>"}a+="</tbody>"}return a+="</table>",a}catch(e){return`<pre data-qd-fence="\`\`\`" data-qd-lang="${t}" data-qd-source="${n}">${n}</pre>`}}parseCSVLine(e,t){const n=[];let o="",r=!1;for(let a=0;a<e.length;a++){const i=e[a],s=e[a+1];'"'===i?r&&'"'===s?(o+='"',a++):r=!r:i!==t||r?o+=i:(n.push(o),o="")}return n.push(o),n}renderJSON(e,t){if(window.hljs&&hljs.getLanguage("json"))try{let n=e;try{const t=JSON.parse(e);n=JSON.stringify(t,null,2)}catch(e){}return`<pre class="qde-json" data-qd-fence="\`\`\`" data-qd-lang="${t}"><code class="hljs language-json">${hljs.highlight(n,{language:"json"}).value}</code></pre>`}catch(e){}return`<pre class="qde-json" data-qd-fence="\`\`\`" data-qd-lang="${t}">${this.escapeHtml(e)}</pre>`}renderGeoJSON(e){const t=`map-${Math.random().toString(36).substr(2,15)}`,n=()=>{const n=document.getElementById(t+"-container");if(n&&window.L)try{const o=JSON.parse(e),r=document.createElement("div");r.id=t,r.style.cssText="width: 100%; height: 300px;",n.innerHTML="",n.appendChild(r);const a=L.map(t);n._map=a;const i=L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"",crossOrigin:"anonymous"});i.addTo(a);const s=L.geoJSON(o);s.addTo(a),s.getBounds().isValid()?a.fitBounds(s.getBounds()):a.setView([0,0],2),n._tileLayer=i,n._geoJsonLayer=s,i.on("load",()=>{n.setAttribute("data-tiles-loaded","true")})}catch(e){n.innerHTML=`<pre class="qde-error">GeoJSON error: ${this.escapeHtml(e.message)}</pre>`}};window.L?setTimeout(n,0):(window._qde_leaflet_loading||(window._qde_leaflet_loading=this.lazyLoadLibrary("Leaflet",()=>window.L,"https://unpkg.com/leaflet@1.9.4/dist/leaflet.js","https://unpkg.com/leaflet@1.9.4/dist/leaflet.css").catch(e=>(console.warn("Failed to load Leaflet:",e),window._qde_leaflet_loading=null,!1))),window._qde_leaflet_loading.then(e=>{if(e)n();else{const e=document.getElementById(t+"-container");e&&(e.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">Failed to load map library</div>')}}).catch(()=>{}));const o=document.createElement("div");return o.className="geojson-container",o.id=t+"-container",o.style.cssText="width: 100%; height: 300px; border: 1px solid #ddd; border-radius: 4px; margin: 0.5em 0; background: #f0f0f0;",o.contentEditable="false",o.setAttribute("data-source-type","geojson"),o.setAttribute("data-original-source",this.escapeHtml(e)),o.setAttribute("data-qd-fence","```"),o.setAttribute("data-qd-lang","geojson"),o.setAttribute("data-qd-source",e),o.textContent="Loading map...",o.outerHTML}renderSTL(e){const t=`qde-stl-viewer-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,n=()=>{const n=document.getElementById(t);if(n)try{const t=window.THREE,o=new t.Scene;o.background=new t.Color(15790320);const r=new t.PerspectiveCamera(75,n.clientWidth/400,.1,1e3),a=new t.WebGLRenderer({antialias:!0});a.setSize(n.clientWidth,400),n.innerHTML="",n.appendChild(a.domElement),n._threeScene=o,n._threeCamera=r,n._threeRenderer=a;const i=this.parseSTL(e),s=new t.MeshLambertMaterial({color:26367}),l=new t.Mesh(i,s);o.add(l);const d=new t.AmbientLight(4210752,.6);o.add(d);const c=new t.DirectionalLight(16777215,.8);c.position.set(1,1,1).normalize(),o.add(c);const h=(new t.Box3).setFromObject(l),u=h.getCenter(new t.Vector3),p=h.getSize(new t.Vector3),m=Math.max(p.x,p.y,p.z);r.position.set(u.x+m,u.y+m,u.z+m),r.lookAt(u);const g=()=>{requestAnimationFrame(g),l.rotation.y+=.01,a.render(o,r)};g()}catch(e){console.error("STL rendering error:",e),n.innerHTML=`<pre class="qde-error">STL error: ${this.escapeHtml(e.message)}</pre>`}};return window.THREE?setTimeout(n,0):(window._qde_three_loading||(window._qde_three_loading=this.lazyLoadLibrary("Three.js",()=>window.THREE,"https://unpkg.com/three@0.147.0/build/three.min.js").catch(e=>(console.warn("Failed to load Three.js for STL rendering"),window._qde_three_loading=null,!1))),window._qde_three_loading.then(e=>{if(e)n();else{const e=document.getElementById(t);e&&(e.innerHTML='<div style="padding: 20px; text-align: center; color: #666;">Failed to load Three.js for STL rendering</div>')}})),`<div id="${t}" class="qde-stl-container" data-stl-id="${t}" data-qd-fence="\`\`\`" data-qd-lang="stl" data-qd-source="${this.escapeHtml(e)}" contenteditable="false" style="height: 400px; background: #f0f0f0; display: flex; align-items: center; justify-content: center;">Loading 3D model...</div>`}parseSTL(e){const t=window.THREE,n=new t.BufferGeometry,o=[],r=[],a=e.split("\n");let i=null;for(let e of a)if(e=e.trim(),e.startsWith("facet normal")){const t=e.split(/\s+/);i=[parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]}else if(e.startsWith("vertex")){const t=e.split(/\s+/);o.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),i&&r.push(i[0],i[1],i[2])}return n.setAttribute("position",new t.Float32BufferAttribute(o,3)),n.setAttribute("normal",new t.Float32BufferAttribute(r,3)),n}renderMermaid(e){const t=`mermaid-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;setTimeout(()=>{const n=document.getElementById(t);n&&window.mermaid&&mermaid.render(t+"-svg",e).then(e=>{n.innerHTML=e.svg}).catch(e=>{n.innerHTML=`<pre>Error rendering diagram: ${e.message}</pre>`})},0);const n=document.createElement("div");return n.id=t,n.className="mermaid",n.contentEditable="false",n.setAttribute("data-qd-source",e),n.setAttribute("data-qd-fence","```"),n.setAttribute("data-qd-lang","mermaid"),n.textContent="Loading diagram...",n.outerHTML}escapeHtml(e){return(e??"").replace(/[&"'<>]/g,e=>({"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;"}[e]))}makeFencesNonEditable(){this.previewPanel}async loadPlugins(){const e=new Set;this.options.plugins&&(this.options.plugins.highlightjs&&e.add("highlightjs"),this.options.plugins.mermaid&&e.add("mermaid"));const t=this.options.preloadFences;if("all"===t)Object.keys(q).forEach(t=>e.add(t));else if(Array.isArray(t))for(const n of t)"string"==typeof n?q[n]?e.add(n):console.warn(`QuikdownEditor: unknown preloadFences entry "${n}"`):n&&"object"==typeof n&&n.script&&(e.add("__custom__:"+(n.name||n.script)),q["__custom__:"+(n.name||n.script)]={check:()=>!1,script:n.script,css:n.css});else t&&console.warn('QuikdownEditor: preloadFences should be "all", an array, or null');const n=[];for(const t of e){const e=q[t];if(!e||e.check())continue;e.beforeLoad&&e.beforeLoad();const o=(async()=>{try{const t=[];e.script&&t.push(this.loadScript(e.script)),e.css&&t.push(this.loadCSS(e.css,"qde-hljs-light")),e.cssDark&&t.push(this.loadCSS(e.cssDark,"qde-hljs-dark")),await Promise.all(t),e.css&&e.cssDark&&this._syncHljsTheme(),e.afterLoad&&e.afterLoad()}catch(e){console.warn(`QuikdownEditor: failed to preload ${t}:`,e)}})();n.push(o)}await Promise.all(n)}async lazyLoadLibrary(e,t,n,o=null){if(t())return!0;try{const e=[];return n&&e.push(this.loadScript(n)),o&&e.push(this.loadCSS(o)),await Promise.all(e),t()}catch(t){return console.error(`Failed to load ${e}:`,t),!1}}loadScript(e){return new Promise((t,n)=>{const o=document.createElement("script");o.src=e,o.onload=t,o.onerror=n,document.head.appendChild(o)})}loadCSS(e,t){return new Promise(n=>{const o=document.createElement("link");o.rel="stylesheet",o.href=e,t&&(o.id=t),o.onload=n,document.head.appendChild(o),setTimeout(n,1e3)})}_syncHljsTheme(){const e=this.container.classList.contains("qde-dark"),t=document.getElementById("qde-hljs-light"),n=document.getElementById("qde-hljs-dark");t&&(t.disabled=e),n&&(n.disabled=!e)}applyTheme(){const e=this.options.theme;if(this._autoThemeListener&&(window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",this._autoThemeListener),this._autoThemeListener=null),"auto"===e){const e=window.matchMedia("(prefers-color-scheme: dark)");this.container.classList.toggle("qde-dark",e.matches),this._autoThemeListener=e=>{this.container.classList.toggle("qde-dark",e.matches),this._syncHljsTheme()},e.addEventListener("change",this._autoThemeListener)}else this.container.classList.toggle("qde-dark","dark"===e);this._syncHljsTheme()}setTheme(e){["light","dark","auto"].includes(e)&&(this.options.theme=e,this.applyTheme())}getTheme(){return this.options.theme}setLazyLinefeeds(e){this.options.lazy_linefeeds=e,this._markdown&&this.updateFromMarkdown(this._markdown)}getLazyLinefeeds(){return this.options.lazy_linefeeds}setDebounceDelay(e){this.options.debounceDelay=Math.max(0,e)}getDebounceDelay(){return this.options.debounceDelay}setMode(e){if(!["source","preview","split"].includes(e))return;const t=this.container.classList.contains("qde-dark"),n=this.currentMode;if(this.currentMode=e,this.container.className=`qde-container qde-mode-${e}`,t&&this.container.classList.add("qde-dark"),this.toolbar){const e=this.toolbar.querySelector(".qde-split-toggle");e&&(e.textContent="Preview")}if(this.toolbar&&this.toolbar.querySelectorAll(".qde-btn[data-mode]").forEach(t=>{t.classList.toggle("active",t.dataset.mode===e)}),"source"!==e&&"source"===n&&this._html&&(this.previewPanel.innerHTML=this._html,setTimeout(()=>this.makeFencesNonEditable(),0),"undefined"!=typeof window&&window.MathJax&&window.MathJax.typesetPromise)){const e=this.previewPanel.querySelectorAll(".math-display");e.length>0&&window.MathJax.typesetPromise(Array.from(e)).catch(()=>{})}this.options.onModeChange&&this.options.onModeChange(e)}_pushUndoState(e){if(e===this._markdown)return;this._undoStack.push(this._markdown);const t=this.options.undoStackSize||100;this._undoStack.length>t&&this._undoStack.splice(0,this._undoStack.length-t),this._redoStack=[],this._updateUndoButtons()}undo(){if(!this.canUndo())return;this._redoStack.push(this._markdown);const e=this._undoStack.pop();this._isUndoRedo=!0,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e),this._updateUndoButtons()}redo(){if(!this.canRedo())return;this._undoStack.push(this._markdown);const e=this._redoStack.pop();this._isUndoRedo=!0,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e),this._updateUndoButtons()}canUndo(){return this._undoStack.length>0}canRedo(){return this._redoStack.length>0}clearHistory(){this._undoStack=[],this._redoStack=[],this._updateUndoButtons()}_updateUndoButtons(){if(!this.toolbar)return;const e=this.toolbar.querySelector('[data-action="undo"]'),t=this.toolbar.querySelector('[data-action="redo"]');e&&e.classList.toggle("disabled",!this.canUndo()),t&&t.classList.toggle("disabled",!this.canRedo())}handleAction(e){switch(e){case"copy-markdown":this.copy("markdown");break;case"copy-html":this.copy("html");break;case"copy-rendered":this.copyRendered();break;case"remove-hr":this.removeHR();break;case"lazy-linefeeds":this.convertLazyLinefeeds();break;case"undo":this.undo();break;case"redo":this.redo();break;case"toggle-html-mode":this.cycleAllowUnsafeHTML()}}async copy(e){const t="markdown"===e?this._markdown:this._html;try{await navigator.clipboard.writeText(t);const n=this.toolbar.querySelector(`[data-action="copy-${e}"]`);if(n){const e=n.textContent;n.textContent="Copied!",setTimeout(()=>{n.textContent=e},1500)}}catch(e){console.error("Failed to copy:",e)}}get markdown(){return this._markdown}set markdown(e){this.setMarkdown(e)}get html(){return this._html}get mode(){return this.currentMode}async setMarkdown(e){this.initPromise&&await this.initPromise,this._markdown=e,this.sourceTextarea&&(this.sourceTextarea.value=e),this.updateFromMarkdown(e)}getMarkdown(){return this._markdown}getHTML(){return this._html}async removeHR(){const e=v.removeHRFromMarkdown(this._markdown);await this.setMarkdown(e);const t=this.toolbar?.querySelector('[data-action="remove-hr"]');if(t){const e=t.textContent;t.textContent="Removed!",setTimeout(()=>{t.textContent=e},1500)}}static removeHRFromMarkdown(t){const r=(t||"").split("\n"),i=[];let s=!1,l=null,d=0;for(let t=0;t<r.length;t++){const c=r[t],h=c.trim();if(s)o(h,l,d)&&(s=!1,l=null,d=0),i.push(c);else{{const e=n(h);if(e){s=!0,l=e.char,d=e.len,i.push(c);continue}}if(/^\|.*\|$/.test(h)||/^[-| :]+$/.test(h)&&h.includes("|"))i.push(c);else{if(e(h)){const e=t>0?r[t-1].trim():"",n=t<r.length-1?r[t+1].trim():"";if(a(e)||a(n)){i.push(c);continue}continue}i.push(c)}}}return i.join("\n")}async convertLazyLinefeeds(){const e=v.convertLazyLinefeeds(this._markdown);await this.setMarkdown(e);const t=this.toolbar?.querySelector('[data-action="lazy-linefeeds"]');if(t){const e=t.textContent;t.textContent="Converted!",setTimeout(()=>{t.textContent=e},1500)}}static convertLazyLinefeeds(e){const t=(e||"").split("\n"),a=[];let i=!1,s=null,l=0;for(const e of t){const t=e,d=t.trim();if(i){o(d,s,l)?(i=!1,s=null,l=0,a.push({line:t,kind:"fence-close"})):a.push({line:t,kind:"fence-body"});continue}{const e=n(d);if(e){i=!0,s=e.char,l=e.len,a.push({line:t,kind:"fence-open"});continue}}if(""===d){a.push({line:"",kind:"blank"});continue}let c=r(d);"paragraph"===c&&/^(?: {4}|\t| {2,}[-*+]| {2,}\d+\.)/.test(t)&&(c="list-cont"),a.push({line:t,kind:"content",category:c})}const d=[];let c=null;function h(e,t){return!(!e||!t)&&(!("list-ul"!==e.category&&"list-ol"!==e.category&&"list-cont"!==e.category||"list-ul"!==t.category&&"list-ol"!==t.category&&"list-cont"!==t.category)||("blockquote"===e.category&&"blockquote"===t.category||"table"===e.category&&"table"===t.category))}for(const e of a)"fence-open"!==e.kind&&"fence-body"!==e.kind&&"fence-close"!==e.kind?"blank"!==e.kind&&(c&&(h(c,e)||""!==d[d.length-1]&&d.push("")),d.push(e.line),c=e):("fence-open"===e.kind&&c&&d.length>0&&""!==d[d.length-1]&&d.push(""),d.push(e.line),"fence-close"===e.kind&&(c={kind:"content",category:"fence"}));for(;d.length>0&&""===d[d.length-1];)d.pop();return d.join("\n")}async copyRendered(){try{if((await b(this.previewPanel)).success){const e=this.toolbar?.querySelector('[data-action="copy-rendered"]');if(e){const t=e.textContent;e.textContent="Copied!",setTimeout(()=>{e.textContent=t},1500)}}}catch(e){console.error("Failed to copy rendered content:",e)}}_getHtmlModeLabel(e){return!0===e?"HTML: Raw":"limited"===e?"HTML: Safe":"HTML: Off"}_getHtmlModeTooltip(e){return!0===e?"All HTML passes through — no protection":"limited"===e?"Safe tags render, dangerous tags escaped":"All HTML tags shown as text"}cycleAllowUnsafeHTML(){const e=this.options.allowUnsafeHTML;let t;t=!1===e?"limited":"limited"===e,this.setAllowUnsafeHTML(t)}setAllowUnsafeHTML(e){if(!1===e||!0===e||"limited"===e){if(this.options.allowUnsafeHTML=e,this.toolbar){const t=this.toolbar.querySelector('[data-action="toggle-html-mode"]');t&&(t.textContent=this._getHtmlModeLabel(e),t.title=this._getHtmlModeTooltip(e))}this.updateFromMarkdown(this._markdown)}}getAllowUnsafeHTML(){return this.options.allowUnsafeHTML}destroy(){clearTimeout(this.updateTimer),this.container.innerHTML="",this.container.classList.remove("qde-container","qde-dark");if(0===document.querySelectorAll(".qde-container").length){const e=document.getElementById("qde-styles");e&&e.remove()}}}return v.SAFE_HTML_TAGS=y,"undefined"!=typeof module&&module.exports&&(module.exports=v),"undefined"!=typeof window&&(window.QuikdownEditor=v),v});
13
13
  //# sourceMappingURL=quikdown_edit.umd.min.js.map
Binary file
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_json - JSON Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  // Version will be injected at build time
18
- const quikdownVersion$1 = '1.2.11';
18
+ const quikdownVersion$1 = '1.2.12';
19
19
 
20
20
  // Safety limit to prevent infinite loops in list parsing
21
21
  const MAX_LOOP_ITERATIONS = 1000;
@@ -509,7 +509,7 @@ if (typeof window !== 'undefined') {
509
509
 
510
510
 
511
511
  // Version will be injected at build time
512
- const quikdownVersion = '1.2.11';
512
+ const quikdownVersion = '1.2.12';
513
513
 
514
514
  /**
515
515
  * Convert markdown to JSON
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_json - JSON Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  // Version will be injected at build time
16
- const quikdownVersion$1 = '1.2.11';
16
+ const quikdownVersion$1 = '1.2.12';
17
17
 
18
18
  // Safety limit to prevent infinite loops in list parsing
19
19
  const MAX_LOOP_ITERATIONS = 1000;
@@ -507,7 +507,7 @@ if (typeof window !== 'undefined') {
507
507
 
508
508
 
509
509
  // Version will be injected at build time
510
- const quikdownVersion = '1.2.11';
510
+ const quikdownVersion = '1.2.12';
511
511
 
512
512
  /**
513
513
  * Convert markdown to JSON
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_json - JSON Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const l=[],r=e.split("\n");let o=0;for(;o<r.length;){const e=r[o];if(""===e.trim()){o++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),i=[];for(o++;o<r.length;){if(r[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(r[o]),o++}l.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),o++;continue}const h=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(h){const[,e,t]=h;l.push({type:"heading",level:e.length,children:c(t)}),o++;continue}if(e.includes("|")){const e=n(r,o);if(e){l.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<r.length&&r[o].match(/^>\s*/);)e.push(r[o].replace(/^>\s*/,"")),o++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(r,o);l.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<r.length;){const e=r[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[o+1]))break;u.push(e),o++}u.length>0&&l.push({type:"paragraph",children:c(u.join("\n"))})}return l}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],l=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(l)||!l.includes("-"))return null;const r=s(i);if(0===r.length)return null;const o=s(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),h=r.map(e=>c(e.trim())),u=[];let d=t+2;for(;d<e.length;){const t=e[d];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),d++}return{node:{type:"table",headers:h,rows:u,alignments:o},nextIndex:d}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function i(e,t,n){const s=[];let l=t,r=0;const o=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(o[2]),u=o[1].length;for(;l<e.length&&r<1e3;){r++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,d]=t,p=n.length;if(p<u)break;const a=/^\d+\./.test(o);if(p===u&&a!==h)break;if(p>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const s=e[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),l++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const f={type:"list_item",checked:null,children:null},m=d.match(/^\[([x ])\]\s*(.*)$/i);m&&!h?(f.checked="x"===m[1].toLowerCase(),f.children=c(m[2])):f.children=c(d),s.push(f),l++}return{node:{type:"list",ordered:h,items:s},nextIndex:l}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:l(o[2])}),s=s.slice(o[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function r(t,n={}){const s=e(t,n),i=void 0!==n.indent?n.indent:2;return JSON.stringify(s,null,i)}r.parse=e,r.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown_json=r);export{r as default};
7
+ function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const l=[],r=e.split("\n");let o=0;for(;o<r.length;){const e=r[o];if(""===e.trim()){o++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),i=[];for(o++;o<r.length;){if(r[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(r[o]),o++}l.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),o++;continue}const h=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(h){const[,e,t]=h;l.push({type:"heading",level:e.length,children:c(t)}),o++;continue}if(e.includes("|")){const e=n(r,o);if(e){l.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<r.length&&r[o].match(/^>\s*/);)e.push(r[o].replace(/^>\s*/,"")),o++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(r,o);l.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<r.length;){const e=r[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[o+1]))break;u.push(e),o++}u.length>0&&l.push({type:"paragraph",children:c(u.join("\n"))})}return l}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],l=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(l)||!l.includes("-"))return null;const r=s(i);if(0===r.length)return null;const o=s(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),h=r.map(e=>c(e.trim())),u=[];let d=t+2;for(;d<e.length;){const t=e[d];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),d++}return{node:{type:"table",headers:h,rows:u,alignments:o},nextIndex:d}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function i(e,t,n){const s=[];let l=t,r=0;const o=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(o[2]),u=o[1].length;for(;l<e.length&&r<1e3;){r++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,d]=t,p=n.length;if(p<u)break;const a=/^\d+\./.test(o);if(p===u&&a!==h)break;if(p>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const s=e[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),l++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const f={type:"list_item",checked:null,children:null},m=d.match(/^\[([x ])\]\s*(.*)$/i);m&&!h?(f.checked="x"===m[1].toLowerCase(),f.children=c(m[2])):f.children=c(d),s.push(f),l++}return{node:{type:"list",ordered:h,items:s},nextIndex:l}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:l(o[2])}),s=s.slice(o[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function r(t,n={}){const s=e(t,n),i=void 0!==n.indent?n.indent:2;return JSON.stringify(s,null,i)}r.parse=e,r.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown_json=r);export{r as default};
8
8
  //# sourceMappingURL=quikdown_json.esm.min.js.map
Binary file
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_json - JSON Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  // Version will be injected at build time
22
- const quikdownVersion$1 = '1.2.11';
22
+ const quikdownVersion$1 = '1.2.12';
23
23
 
24
24
  // Safety limit to prevent infinite loops in list parsing
25
25
  const MAX_LOOP_ITERATIONS = 1000;
@@ -513,7 +513,7 @@
513
513
 
514
514
 
515
515
  // Version will be injected at build time
516
- const quikdownVersion = '1.2.11';
516
+ const quikdownVersion = '1.2.12';
517
517
 
518
518
  /**
519
519
  * Convert markdown to JSON
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_json - JSON Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown_json=t()}(this,function(){"use strict";function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const o=[],l=e.split("\n");let r=0;for(;r<l.length;){const e=l[r];if(""===e.trim()){r++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),i=[];for(r++;r<l.length;){if(l[r].match(/^(```|~~~)\s*$/)){r++;break}i.push(l[r]),r++}o.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){o.push({type:"hr"}),r++;continue}const h=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(h){const[,e,t]=h;o.push({type:"heading",level:e.length,children:c(t)}),r++;continue}if(e.includes("|")){const e=n(l,r);if(e){o.push(e.node),r=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;r<l.length&&l[r].match(/^>\s*/);)e.push(l[r].replace(/^>\s*/,"")),r++;o.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(l,r);o.push(e.node),r=e.nextIndex;continue}const u=[];for(;r<l.length;){const e=l[r];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&r+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[r+1]))break;u.push(e),r++}u.length>0&&o.push({type:"paragraph",children:c(u.join("\n"))})}return o}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],o=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(o)||!o.includes("-"))return null;const l=s(i);if(0===l.length)return null;const r=s(o).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),h=l.map(e=>c(e.trim())),u=[];let d=t+2;for(;d<e.length;){const t=e[d];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),d++}return{node:{type:"table",headers:h,rows:u,alignments:r},nextIndex:d}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function i(e,t,n){const s=[];let o=t,l=0;const r=e[o].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(r[2]),u=r[1].length;for(;o<e.length&&l<1e3;){l++;const t=e[o].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,r,d]=t,f=n.length;if(f<u)break;const p=/^\d+\./.test(r);if(f===u&&p!==h)break;if(f>u){const t=[];let n=0;for(;o<e.length&&n<1e3;){n++;const s=e[o],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),o++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const a={type:"list_item",checked:null,children:null},m=d.match(/^\[([x ])\]\s*(.*)$/i);m&&!h?(a.checked="x"===m[1].toLowerCase(),a.children=c(m[2])):a.children=c(d),s.push(a),o++}return{node:{type:"list",ordered:h,items:s},nextIndex:o}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...o(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:o(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:o(c[2])}),s=s.slice(c[0].length);continue}const l=s.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:o(l[1])}),s=s.slice(l[0].length);continue}const r=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(r){n.push({type:"em",children:o(r[2])}),s=s.slice(r[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function o(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function l(t,n={}){const s=e(t,n),i=void 0!==n.indent?n.indent:2;return JSON.stringify(s,null,i)}return l.parse=e,l.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=l),"undefined"!=typeof window&&(window.quikdown_json=l),l});
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown_json=t()}(this,function(){"use strict";function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const o=[],l=e.split("\n");let r=0;for(;r<l.length;){const e=l[r];if(""===e.trim()){r++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),i=[];for(r++;r<l.length;){if(l[r].match(/^(```|~~~)\s*$/)){r++;break}i.push(l[r]),r++}o.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){o.push({type:"hr"}),r++;continue}const h=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(h){const[,e,t]=h;o.push({type:"heading",level:e.length,children:c(t)}),r++;continue}if(e.includes("|")){const e=n(l,r);if(e){o.push(e.node),r=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;r<l.length&&l[r].match(/^>\s*/);)e.push(l[r].replace(/^>\s*/,"")),r++;o.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(l,r);o.push(e.node),r=e.nextIndex;continue}const u=[];for(;r<l.length;){const e=l[r];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&r+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[r+1]))break;u.push(e),r++}u.length>0&&o.push({type:"paragraph",children:c(u.join("\n"))})}return o}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],o=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(o)||!o.includes("-"))return null;const l=s(i);if(0===l.length)return null;const r=s(o).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),h=l.map(e=>c(e.trim())),u=[];let d=t+2;for(;d<e.length;){const t=e[d];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),d++}return{node:{type:"table",headers:h,rows:u,alignments:r},nextIndex:d}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function i(e,t,n){const s=[];let o=t,l=0;const r=e[o].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(r[2]),u=r[1].length;for(;o<e.length&&l<1e3;){l++;const t=e[o].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,r,d]=t,f=n.length;if(f<u)break;const p=/^\d+\./.test(r);if(f===u&&p!==h)break;if(f>u){const t=[];let n=0;for(;o<e.length&&n<1e3;){n++;const s=e[o],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),o++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const a={type:"list_item",checked:null,children:null},m=d.match(/^\[([x ])\]\s*(.*)$/i);m&&!h?(a.checked="x"===m[1].toLowerCase(),a.children=c(m[2])):a.children=c(d),s.push(a),o++}return{node:{type:"list",ordered:h,items:s},nextIndex:o}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...o(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:o(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:o(c[2])}),s=s.slice(c[0].length);continue}const l=s.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:o(l[1])}),s=s.slice(l[0].length);continue}const r=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(r){n.push({type:"em",children:o(r[2])}),s=s.slice(r[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function o(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function l(t,n={}){const s=e(t,n),i=void 0!==n.indent?n.indent:2;return JSON.stringify(s,null,i)}return l.parse=e,l.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=l),"undefined"!=typeof window&&(window.quikdown_json=l),l});
8
8
  //# sourceMappingURL=quikdown_json.umd.min.js.map
Binary file
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_yaml - YAML Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  // Version will be injected at build time
18
- const quikdownVersion$1 = '1.2.11';
18
+ const quikdownVersion$1 = '1.2.12';
19
19
 
20
20
  // Safety limit to prevent infinite loops in list parsing
21
21
  const MAX_LOOP_ITERATIONS = 1000;
@@ -508,7 +508,7 @@ if (typeof window !== 'undefined') {
508
508
 
509
509
 
510
510
  // Version will be injected at build time
511
- const quikdownVersion = '1.2.11';
511
+ const quikdownVersion = '1.2.12';
512
512
 
513
513
  /**
514
514
  * Convert markdown to YAML
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_yaml - YAML Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  // Version will be injected at build time
16
- const quikdownVersion$1 = '1.2.11';
16
+ const quikdownVersion$1 = '1.2.12';
17
17
 
18
18
  // Safety limit to prevent infinite loops in list parsing
19
19
  const MAX_LOOP_ITERATIONS = 1000;
@@ -506,7 +506,7 @@ if (typeof window !== 'undefined') {
506
506
 
507
507
 
508
508
  // Version will be injected at build time
509
- const quikdownVersion = '1.2.11';
509
+ const quikdownVersion = '1.2.12';
510
510
 
511
511
  /**
512
512
  * Convert markdown to YAML
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_yaml - YAML Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const c=[],l=e.split("\n");let o=0;for(;o<l.length;){const e=l[o];if(""===e.trim()){o++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),r=[];for(o++;o<l.length;){if(l[o].match(/^(```|~~~)\s*$/)){o++;break}r.push(l[o]),o++}c.push({type:"code_block",lang:n||null,content:r.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){c.push({type:"hr"}),o++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;c.push({type:"heading",level:e.length,children:i(t)}),o++;continue}if(e.includes("|")){const e=n(l,o);if(e){c.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<l.length&&l[o].match(/^>\s*/);)e.push(l[o].replace(/^>\s*/,"")),o++;c.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=r(l,o);c.push(e.node),o=e.nextIndex;continue}const h=[];for(;o<l.length;){const e=l[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[o+1]))break;h.push(e),o++}h.length>0&&c.push({type:"paragraph",children:i(h.join("\n"))})}return c}function n(e,t,n){if(t+1>=e.length)return null;const r=e[t],c=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(c)||!c.includes("-"))return null;const l=s(r);if(0===l.length)return null;const o=s(c).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),u=l.map(e=>i(e.trim())),h=[];let f=t+2;for(;f<e.length;){const t=e[f];if(!t.includes("|")||""===t.trim())break;const n=s(t);h.push(n.map(e=>i(e.trim()))),f++}return{node:{type:"table",headers:u,rows:h,alignments:o},nextIndex:f}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function r(e,t,n){const s=[];let c=t,l=0;const o=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),u=/^\d+\./.test(o[2]),h=o[1].length;for(;c<e.length&&l<1e3;){l++;const t=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,f]=t,p=n.length;if(p<h)break;const a=/^\d+\./.test(o);if(p===h&&a!==u)break;if(p>h){const t=[];let n=0;for(;c<e.length&&n<1e3;){n++;const s=e[c],r=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!r)break;if(r[1].length<h)break;if(r[1].length===h)break;t.push(s),c++}if(t.length>0&&s.length>0){const e=r(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const d={type:"list_item",checked:null,children:null},g=f.match(/^\[([x ])\]\s*(.*)$/i);g&&!u?(d.checked="x"===g[1].toLowerCase(),d.children=i(g[2])):d.children=i(f),s.push(d),c++}return{node:{type:"list",ordered:u,items:s},nextIndex:c}}function i(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),r=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...c(e)),n.push({type:"br"}),s=r;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:c(t[1])}),s=s.slice(t[0].length);continue}const r=s.match(/^`([^`]+)`/);if(r){n.push({type:"code",value:r[1]}),s=s.slice(r[0].length);continue}const i=s.match(/^(\*\*|__)(.+?)\1/);if(i){n.push({type:"strong",children:c(i[2])}),s=s.slice(i[0].length);continue}const l=s.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:c(l[1])}),s=s.slice(l[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:c(o[2])}),s=s.slice(o[0].length);continue}const u=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(u){n.push({type:"link",url:u[1],children:[{type:"text",value:u[1]}]}),s=s.slice(u[0].length);continue}const h=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===h){n.push({type:"text",value:s});break}0===h?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,h)}),s=s.slice(h))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function c(e,t){return i(e.replace(/\n/g," "))}e.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function l(t,n={}){return o(e(t,n),0)}function o(e,t){const n=" ".repeat(t);if(null==e)return"null";if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return String(e);if("string"==typeof e)return h(e);if(Array.isArray(e)){if(0===e.length)return"[]";const s=[];for(const r of e)if("object"!=typeof r||null===r||Array.isArray(r)){const e=o(r,t+1);s.push(`${n}- ${e}`)}else{const e=Object.entries(r);if(e.length>0){const[r,i]=e[0],c=u(i,t+1);s.push(`${n}- ${r}: ${c}`);for(let r=1;r<e.length;r++){const[i,c]=e[r],l=u(c,t+1);s.push(`${n} ${i}: ${l}`)}}else s.push(`${n}- {}`)}return"\n"+s.join("\n")}if("object"==typeof e){const s=Object.entries(e);if(0===s.length)return"{}";const r=[];for(const[e,i]of s){const s=u(i,t);r.push(`${n}${e}: ${s}`)}return r.join("\n")}return String(e)}function u(e,t){if(null==e)return"null";if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return String(e);if("string"==typeof e)return h(e);if(Array.isArray(e))return 0===e.length?"[]":o(e,t+1);if("object"==typeof e){return 0===Object.entries(e).length?"{}":"\n"+o(e,t+1)}return String(e)}function h(e){if(!(""===e||e.includes("\n")||e.includes(":")||e.includes("#")||e.includes("'")||e.includes('"')||e.startsWith(" ")||e.endsWith(" ")||e.startsWith("-")||e.startsWith("[")||e.startsWith("{")||"true"===e||"false"===e||"null"===e||"yes"===e||"no"===e||"on"===e||"off"===e||/^\d+$/.test(e)||/^\d+\.\d+$/.test(e)))return e;if(e.includes("\n")){return`"${e.replace(/\n/g,"\\n").replace(/"/g,'\\"')}"`}return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}l.parse=e,l.stringify=function(e){return o(e,0)},l.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=l),"undefined"!=typeof window&&(window.quikdown_yaml=l);export{l as default};
7
+ function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const c=[],l=e.split("\n");let o=0;for(;o<l.length;){const e=l[o];if(""===e.trim()){o++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.trim(),r=[];for(o++;o<l.length;){if(l[o].match(/^(```|~~~)\s*$/)){o++;break}r.push(l[o]),o++}c.push({type:"code_block",lang:n||null,content:r.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){c.push({type:"hr"}),o++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;c.push({type:"heading",level:e.length,children:i(t)}),o++;continue}if(e.includes("|")){const e=n(l,o);if(e){c.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<l.length&&l[o].match(/^>\s*/);)e.push(l[o].replace(/^>\s*/,"")),o++;c.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=r(l,o);c.push(e.node),o=e.nextIndex;continue}const h=[];for(;o<l.length;){const e=l[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[o+1]))break;h.push(e),o++}h.length>0&&c.push({type:"paragraph",children:i(h.join("\n"))})}return c}function n(e,t,n){if(t+1>=e.length)return null;const r=e[t],c=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(c)||!c.includes("-"))return null;const l=s(r);if(0===l.length)return null;const o=s(c).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),u=l.map(e=>i(e.trim())),h=[];let f=t+2;for(;f<e.length;){const t=e[f];if(!t.includes("|")||""===t.trim())break;const n=s(t);h.push(n.map(e=>i(e.trim()))),f++}return{node:{type:"table",headers:u,rows:h,alignments:o},nextIndex:f}}function s(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function r(e,t,n){const s=[];let c=t,l=0;const o=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),u=/^\d+\./.test(o[2]),h=o[1].length;for(;c<e.length&&l<1e3;){l++;const t=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,f]=t,p=n.length;if(p<h)break;const a=/^\d+\./.test(o);if(p===h&&a!==u)break;if(p>h){const t=[];let n=0;for(;c<e.length&&n<1e3;){n++;const s=e[c],r=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!r)break;if(r[1].length<h)break;if(r[1].length===h)break;t.push(s),c++}if(t.length>0&&s.length>0){const e=r(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const d={type:"list_item",checked:null,children:null},g=f.match(/^\[([x ])\]\s*(.*)$/i);g&&!u?(d.checked="x"===g[1].toLowerCase(),d.children=i(g[2])):d.children=i(f),s.push(d),c++}return{node:{type:"list",ordered:u,items:s},nextIndex:c}}function i(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),r=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...c(e)),n.push({type:"br"}),s=r;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:c(t[1])}),s=s.slice(t[0].length);continue}const r=s.match(/^`([^`]+)`/);if(r){n.push({type:"code",value:r[1]}),s=s.slice(r[0].length);continue}const i=s.match(/^(\*\*|__)(.+?)\1/);if(i){n.push({type:"strong",children:c(i[2])}),s=s.slice(i[0].length);continue}const l=s.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:c(l[1])}),s=s.slice(l[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:c(o[2])}),s=s.slice(o[0].length);continue}const u=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(u){n.push({type:"link",url:u[1],children:[{type:"text",value:u[1]}]}),s=s.slice(u[0].length);continue}const h=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===h){n.push({type:"text",value:s});break}0===h?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,h)}),s=s.slice(h))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function c(e,t){return i(e.replace(/\n/g," "))}e.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);function l(t,n={}){return o(e(t,n),0)}function o(e,t){const n=" ".repeat(t);if(null==e)return"null";if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return String(e);if("string"==typeof e)return h(e);if(Array.isArray(e)){if(0===e.length)return"[]";const s=[];for(const r of e)if("object"!=typeof r||null===r||Array.isArray(r)){const e=o(r,t+1);s.push(`${n}- ${e}`)}else{const e=Object.entries(r);if(e.length>0){const[r,i]=e[0],c=u(i,t+1);s.push(`${n}- ${r}: ${c}`);for(let r=1;r<e.length;r++){const[i,c]=e[r],l=u(c,t+1);s.push(`${n} ${i}: ${l}`)}}else s.push(`${n}- {}`)}return"\n"+s.join("\n")}if("object"==typeof e){const s=Object.entries(e);if(0===s.length)return"{}";const r=[];for(const[e,i]of s){const s=u(i,t);r.push(`${n}${e}: ${s}`)}return r.join("\n")}return String(e)}function u(e,t){if(null==e)return"null";if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return String(e);if("string"==typeof e)return h(e);if(Array.isArray(e))return 0===e.length?"[]":o(e,t+1);if("object"==typeof e){return 0===Object.entries(e).length?"{}":"\n"+o(e,t+1)}return String(e)}function h(e){if(!(""===e||e.includes("\n")||e.includes(":")||e.includes("#")||e.includes("'")||e.includes('"')||e.startsWith(" ")||e.endsWith(" ")||e.startsWith("-")||e.startsWith("[")||e.startsWith("{")||"true"===e||"false"===e||"null"===e||"yes"===e||"no"===e||"on"===e||"off"===e||/^\d+$/.test(e)||/^\d+\.\d+$/.test(e)))return e;if(e.includes("\n")){return`"${e.replace(/\n/g,"\\n").replace(/"/g,'\\"')}"`}return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}l.parse=e,l.stringify=function(e){return o(e,0)},l.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=l),"undefined"!=typeof window&&(window.quikdown_yaml=l);export{l as default};
8
8
  //# sourceMappingURL=quikdown_yaml.esm.min.js.map
Binary file
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_yaml - YAML Markdown Parser
3
- * @version 1.2.11
3
+ * @version 1.2.12
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  // Version will be injected at build time
22
- const quikdownVersion$1 = '1.2.11';
22
+ const quikdownVersion$1 = '1.2.12';
23
23
 
24
24
  // Safety limit to prevent infinite loops in list parsing
25
25
  const MAX_LOOP_ITERATIONS = 1000;
@@ -512,7 +512,7 @@
512
512
 
513
513
 
514
514
  // Version will be injected at build time
515
- const quikdownVersion = '1.2.11';
515
+ const quikdownVersion = '1.2.12';
516
516
 
517
517
  /**
518
518
  * Convert markdown to YAML