quikdown 1.2.17 → 1.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -30
- package/dist/quikdown-airgap-v1.2.19.zip +0 -0
- package/dist/quikdown.cjs +2 -2
- package/dist/quikdown.dark.css +1 -1
- package/dist/quikdown.esm.js +2 -2
- package/dist/quikdown.esm.min.js +2 -2
- package/dist/quikdown.esm.min.js.gz +0 -0
- package/dist/quikdown.light.css +1 -1
- package/dist/quikdown.umd.js +2 -2
- package/dist/quikdown.umd.min.js +2 -2
- package/dist/quikdown.umd.min.js.gz +0 -0
- package/dist/quikdown_ast.cjs +2 -2
- package/dist/quikdown_ast.esm.js +2 -2
- package/dist/quikdown_ast.esm.min.js +2 -2
- package/dist/quikdown_ast.esm.min.js.gz +0 -0
- package/dist/quikdown_ast.umd.js +2 -2
- package/dist/quikdown_ast.umd.min.js +2 -2
- package/dist/quikdown_ast.umd.min.js.gz +0 -0
- package/dist/quikdown_ast_html.cjs +3 -3
- package/dist/quikdown_ast_html.esm.js +3 -3
- package/dist/quikdown_ast_html.esm.min.js +2 -2
- package/dist/quikdown_ast_html.esm.min.js.gz +0 -0
- package/dist/quikdown_ast_html.umd.js +3 -3
- package/dist/quikdown_ast_html.umd.min.js +2 -2
- package/dist/quikdown_ast_html.umd.min.js.gz +0 -0
- package/dist/quikdown_bd.cjs +2 -2
- package/dist/quikdown_bd.esm.js +2 -2
- package/dist/quikdown_bd.esm.min.js +2 -2
- package/dist/quikdown_bd.esm.min.js.gz +0 -0
- package/dist/quikdown_bd.umd.js +2 -2
- package/dist/quikdown_bd.umd.min.js +2 -2
- package/dist/quikdown_bd.umd.min.js.gz +0 -0
- package/dist/quikdown_edit.cjs +3 -3
- package/dist/quikdown_edit.esm.js +3 -3
- package/dist/quikdown_edit.esm.min.js +3 -3
- package/dist/quikdown_edit.esm.min.js.gz +0 -0
- package/dist/quikdown_edit.umd.js +3 -3
- package/dist/quikdown_edit.umd.min.js +3 -3
- package/dist/quikdown_edit.umd.min.js.gz +0 -0
- package/dist/quikdown_edit_standalone.esm.js +3 -3
- package/dist/quikdown_edit_standalone.esm.min.js +1 -1
- package/dist/quikdown_edit_standalone.esm.min.js.gz +0 -0
- package/dist/quikdown_edit_standalone.umd.js +3 -3
- package/dist/quikdown_edit_standalone.umd.min.js +1 -1
- package/dist/quikdown_edit_standalone.umd.min.js.gz +0 -0
- package/dist/quikdown_json.cjs +3 -3
- package/dist/quikdown_json.esm.js +3 -3
- package/dist/quikdown_json.esm.min.js +2 -2
- package/dist/quikdown_json.esm.min.js.gz +0 -0
- package/dist/quikdown_json.umd.js +3 -3
- package/dist/quikdown_json.umd.min.js +2 -2
- package/dist/quikdown_json.umd.min.js.gz +0 -0
- package/dist/quikdown_mcp.cjs +2 -2
- package/dist/quikdown_mcp.esm.js +2 -2
- package/dist/quikdown_yaml.cjs +3 -3
- package/dist/quikdown_yaml.esm.js +3 -3
- package/dist/quikdown_yaml.esm.min.js +2 -2
- package/dist/quikdown_yaml.esm.min.js.gz +0 -0
- package/dist/quikdown_yaml.umd.js +3 -3
- package/dist/quikdown_yaml.umd.min.js +2 -2
- package/dist/quikdown_yaml.umd.min.js.gz +0 -0
- package/package.json +14 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_bd - Bidirectional Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.19
|
|
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_bd=t()}(this,function(){"use strict";function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",o="§BE",l={href:1,src:1,action:1,formaction:1},c={"&":"&","<":"<",">":">",'"':""","'":"'"},a={h1:"font-size:2em;margin:.67em 0;text-align:left",h2:"font-size:1.5em;margin:.83em 0",h3:"font-size:1.25em;margin:1em 0",h4:"font-size:1em;margin:1.33em 0",h5:"font-size:.875em;margin:1.67em 0",h6:"font-size:.85em;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function s(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+(?:"([^"]*)"|"([^&]*?)")\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]??t[3]};const n=e.match(/^(.*)\s+(?:'([^']*)'|'([^&]*?)')\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]??n[3]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(4,-4),title:null}:{url:e,title:null}}function i(e){return e.replace(/[*_`~]/g,"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}function u(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function d(e){let t=0,n=0;for(;n<e.length&&e.startsWith(">",n);)n+=4,t++," "===e[n]&&n++;return{depth:t,content:e.slice(n)}}function f(t){const r=t.trim();return""===r||(!!/^#{1,6}\s/.test(r)||(!!e(r)||(!!/^>/.test(r)||(!!/^[-*+]\s/.test(r)||(!!/^\d+\.\s/.test(r)||(!!r.startsWith("|")||!!r.startsWith(n)))))))}const $={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const o=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let l="";const c=[],s=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:u,content:d}=e[i];if(!(u<=0)){if(o&&0===i){const e=o[1].toUpperCase(),n=e.toLowerCase();if(s){const e=a.alert,t=a["alert-"+n];l+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else l+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=$[e];l+=s?`<p style="${a["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,c.push("alert");continue}for(;c.length>u;){l+="alert"===c.pop()?"</div>":"</blockquote>"}for(;c.length<u;)0===c.length&&o?c.push("alert"):(l+=`<blockquote${n("blockquote")}${r(">")}>`,c.push("blockquote"));l+=d,i<e.length-1&&(l+="\n")}}for(;c.length>0;){l+="alert"===c.pop()?"</div>":"</blockquote>"}return l.trimEnd()}function p(e){if(0===e.length)return!1;const t=e.match(/^([ \t]+)(.*)$/);if(!t)return!1;if(t[1].replace(/\t/g," ").length<4)return!1;const n=t[2];return!(/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/^>/.test(n)||/^#{1,6}\s/.test(n))}function h(e){if(e.startsWith(" "))return e.slice(4);if("\t"===e[0])return e.slice(1);const t=e.match(/^[ \t]+(.*)$/);return t?t[1]:e}function m(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function b($,m={}){if(!$||"string"!=typeof $)return"";const{fence_plugin:b,inline_styles:q=!1,bidirectional:x=!1,lazy_linefeeds:_=!1,allow_unsafe_html:k=!1,heading_ids:A=!1}=m,w=function(e,n){return function(r,o=""){if(e){let e=n[r];return e||o?(o&&o.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${o?e?`${e}${o}`:o:e}"`):""}{const e=` class="${t}${r}"`;return o?`${e} style="${o}"`:e}}}(q,a),N=new Map;function E(e){return e.replace(/[&<>"']/g,e=>c[e])}const T=x?e=>` data-qd="${E(e)}"`:()=>"";function v(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),o=["javascript:","vbscript:","data:"];for(const e of o)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let C=$;const L=[],z=[];C=C.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${L.length}§`,c=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?L.push({lang:c,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):L.push({lang:c,code:E(o.trimEnd()),custom:!1,fence:t}),l});const j=[];C=C.replace(/\\`/g,()=>{const e=`${o}${j.length}§`;return j.push("`"),e}),C=C.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${z.length}§`;return z.push(E(t)),n}),C=C.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${o}${j.length}§`;return j.push(E(t)),n});const S=[],W=Array.isArray(k)?Object.fromEntries(k.map(e=>[e,1])):k&&"object"==typeof k?k:null;W&&(C=C.replace(/<!--[\s\S]*?-->/g,e=>{const t=S.length;return S.push(e),`${r}${t}§`}),C=C.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in W){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,o]=t,c=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,a=[];let s;for(;null!==(s=c.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)a.push(e);else{let n=t;e.toLowerCase()in l&&(n=v(t)),a.push(`${e}="${n}"`)}}return n+(a.length?" "+a.join(" "):"")+o}(e),n=S.length;return S.push(t),`${r}${n}§`}return e})),!0!==k&&(C=E(C)),W&&S.forEach((e,t)=>{C=C.replace(`${r}${t}§`,e)}),C=function(e,t,n){const r=e.split("\n"),o=[];let l=0;for(;l<r.length;){if(!p(r[l])){o.push(r[l]),l++;continue}const e=[];for(;l<r.length;){const t=r[l];if(""===t){if(l+1<r.length&&p(r[l+1])){e.push(""),l++;continue}break}if(!p(t))break;e.push(h(t)),l++}const c=e.join("\n");o.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${c}</code></pre>`)}return o.join("\n")}(C,w,T),C=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,c=[];for(let e=0;e<r.length;e++){const a=r[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))l||(l=!0,c=[]),c.push(a);else{if(l){const e=y(c,t,n);e?o.push(e):o.push(...c),l=!1,c=[]}o.push(r[e])}}if(l&&c.length>0){const e=y(c,t,n);e?o.push(e):o.push(...c)}return o.join("\n")}(C,w,x),C=function(t,n,r,o,l,c){const a=t.split("\n"),s=[];let $=0;for(;$<a.length;){const t=a[$];if(/^\[\/\/\]: #/.test(t)){$++;continue}let p=0;for(;p<t.length&&p<7&&"#"===t[p];)p++;if(p>=1&&p<=6&&" "===t[p]){const e=t.slice(p+1).replace(/\s*#+\s*$/,""),a="h"+p;let d="";if(o){d=` id="${c(u(i(e),l))}"`}s.push(`<${a}${n(a)}${d}${r("#".repeat(p))}>${e}</${a}>`),$++;continue}if(e(t))s.push(`<hr${n("hr")}${r(t.trim())}>`),$++;else{if(d(t).depth>0){const e=[];let t=0;for(;$<a.length;){const n=d(a[$]);if(n.depth>0)e.push(n),t=n.depth,$++;else{if(!(t>0)||f(a[$]))break;e.push({depth:t,content:a[$]}),$++}}s.push(g(e,n,r));continue}s.push(t),$++}}return s.join("\n")}(C,w,T,A,N,E),C=function(e,n,r,o){const l=e.split("\n"),c=[],a=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,u=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let $=l,g="";const p=l.match(/^\[([x ])\]\s+(.*)$/i);if(p&&!d){const[,e,n]=p,o="x"===e.toLowerCase();$=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;a.length>u+1;){const e=a.pop();c.push(`</${e.type}>`)}if(a.length===u)a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`);else if(a.length===u+1){const e=a[a.length-1];e.type!==f&&(c.push(`</${e.type}>`),a.pop(),a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`))}const h=g||n("li");c.push(`<li${h}${i(o)}>${$}</li>`)}else{for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}c.push(o)}}for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}return c.join("\n")}(C,w,q,x),C=C.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=v(r,m.allow_unsafe_urls),c=o?` title="${E(o)}"`:"",a=x&&t?` data-qd-alt="${E(t)}"`:"",i=x?` data-qd-src="${E(r)}"`:"",u=x&&o?` data-qd-title="${E(o)}"`:"";return`<img${w("img")} src="${l}" alt="${t}"${c}${a}${i}${u}${T("!")}>`}),C=C.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=v(r,m.allow_unsafe_urls),c=/^https?:\/\//i.test(l)?' rel="noopener noreferrer"':"",a=o?` title="${E(o)}"`:"",i=x?` data-qd-text="${E(t)}"`:"",u=x&&o?` data-qd-title="${E(o)}"`:"";return`<a${w("a")} href="${l}"${c}${a}${i}${u}${T("[")}>${t}</a>`}),C=C.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:o}=function(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n&&(e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break;t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}(n),l=v(r,m.allow_unsafe_urls);return`${t}<a${w("a")} href="${l}" rel="noopener noreferrer">${r}</a>${o}`});const O=[];C=C.replace(/<[^>]+>/g,e=>(O.push(e),`%%T${O.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{C=C.replace(e,`<${t}${w(t)}${T(n)}>$1</${t}>`)}),C=C.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),C=C.replace(/\\\n/g,`<br${w("br")}>`),_){const e=[];let t=0;C=C.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),C=C.replace(/\n\n+/g,"§P§").replace(/(<\/(?:h[1-6]|blockquote|pre)>)\n/g,"$1§N§").replace(/(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)\n/g,"$1§N§").replace(/\n(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)/g,"§N§$1").replace(/\n(§B\d+§)/g,"§N§$1").replace(/(§B\d+§)\n/g,"$1§N§").replace(/\n/g,`<br${w("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>C=C.replace(`§B${t}§`,e)),C="<p>"+C+"</p>"}else C=C.replace(/ {2}$/gm,`<br${w("br")}>`),C=C.replace(/\n\n+/g,(e,t)=>C.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),C="<p>"+C+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[/<p>(<div[^>]*>)/g,"$1"],[/(<\/div>)<\/p>/g,"$1"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{C=C.replace(e,t)}),C=C.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),L.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=x&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=x?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${E(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${E(e.fence)}" data-qd-lang="${E(e.lang)}" data-qd-source="${E(e.code)}"`));else{const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=x&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=x?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;C=C.replace(o,r)}),z.forEach((e,t)=>{const n=`§IC${t}§`;C=C.replace(n,`<code${w("code")}${T("`")}>${e}</code>`)}),j.forEach((e,t)=>{C=C.replace(`${o}${t}§`,e)}),C.trim()}function q(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`\n]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function y(e,t,n){if(e.length<2)return null;let r,o,l,c=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){c=t;break}if(-1===c)r=[e[0]],o=e.slice(1),l=m(e[0]).map(()=>"left");else{r=e.slice(0,c),o=e.slice(c+1);const t=m(e[c]);l=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const a=l.length,s=n?` data-qd-align="${l.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<th${t("th",o)}>${c}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",o.length>0&&(i+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<td${t("td",o)}>${c}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}function x(e,t={}){return b(e,{...t,bidirectional:!0})}return b.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[c,a]of Object.entries(n)){let n=a;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${c} { ${n} }\n`}return l},b.configure=function(e){return function(t){return b(t,e)}},b.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown=b),Object.keys(b).forEach(e=>{"configure"!==e&&(x[e]=b[e])}),x.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 r(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const l=e.tagName.toLowerCase(),c=e.getAttribute("data-qd");let a="";for(const t of e.childNodes)a+=r(t,{parentTag:l,...n});switch(l){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(l[1]);return`${c||"#".repeat(n)} ${a.trim()}\n\n`;case"strong":case"b":if(!a)return"";const r=c||"**";return`${r}${a}${r}`;case"em":case"i":if(!a)return"";const s=c||"*";return`${s}${a}${s}`;case"del":case"s":case"strike":if(!a)return"";const i=c||"~~";return`${i}${a}${i}`;case"code":if(!a)return"";const u=c||"`";return`${u}${a}${u}`;case"pre":const d=e.getAttribute("data-qd-fence")||c||"```",f=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&f)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||d;return`${e}${n.lang||f}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const $=e.getAttribute("data-qd-source");if($)return`${d}${f}\n${$}\n${d}\n\n`;const g=e.querySelector("code");return`${d}${f}\n${(g?g.textContent:a).trimEnd()}\n${d}\n\n`;case"blockquote":const p=c||">";return a.trim().split("\n").map(e=>`${p} ${e}`).join("\n")+"\n\n";case"hr":return`${c||"---"}\n\n`;case"br":return`${c||" "}\n`;case"a":const h=e.getAttribute("data-qd-text")||a.trim(),m=e.getAttribute("href")||"";return h!==m||c?`[${h}](${m})`:`<${m}>`;case"img":return`${c||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return o(e,"ol"===l)+"\n";case"li":case"span":default:return a;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),r=n?n.split(","):[],o=e.querySelector("thead");if(o){const e=o.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=r[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const l=e.querySelector("tbody");if(l)for(const e of l.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(a.trim()){const e=a.split("\n");let t=a.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"),q=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||q||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const y=e.getAttribute("data-qd-source");if(y&&q)return`${q}${b||""}\n${y}\n${q}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",r=e.getAttribute("data-qd-source");if(r){const e=document.createElement("textarea");e.innerHTML=r;return`${t}${n}\n${e.value}\n${t}\n\n`}const o=e.querySelector("pre.mermaid");if(o){const e=o.getAttribute("data-qd-source");if(e){const r=document.createElement("textarea");r.innerHTML=e;return`${t}${n}\n${r.value}\n${t}\n\n`}}const l=e.querySelector(".mermaid-source");if(l){const e=document.createElement("div");e.innerHTML=l.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const c=e.querySelector(".mermaid");if(c&&c.textContent.includes("graph"))return`${t}${n}\n${c.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 a}}function o(e,t,n=0){let l="",c=1;const a=" ".repeat(n);for(const s of e.children){if("LI"!==s.tagName)continue;let e=s.getAttribute("data-qd")||(t?`${c}.`:"-");const i=s.querySelector('input[type="checkbox"]');if(i){const t=i.checked?"x":" ";e="-";let n="";for(const e of s.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=r(e));l+=`${a}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of s.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=o(e,"OL"===e.tagName,n+1):t+=r(e);l+=`${a}${e} ${t.trim()}\n`}c++}return l}let l=r(n);return l=l.replace(/\n{3,}/g,"\n\n"),l=l.trim(),l},x.configure=function(e){const t=b.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=x),"undefined"!=typeof window&&(window.quikdown_bd=x),x});
|
|
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_bd=t()}(this,function(){"use strict";function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",o="§BE",l={href:1,src:1,action:1,formaction:1},c={"&":"&","<":"<",">":">",'"':""","'":"'"},a={h1:"font-size:2em;margin:.67em 0;text-align:left",h2:"font-size:1.5em;margin:.83em 0",h3:"font-size:1.25em;margin:1em 0",h4:"font-size:1em;margin:1.33em 0",h5:"font-size:.875em;margin:1.67em 0",h6:"font-size:.85em;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function s(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+(?:"([^"]*)"|"([^&]*?)")\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]??t[3]};const n=e.match(/^(.*)\s+(?:'([^']*)'|'([^&]*?)')\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]??n[3]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(4,-4),title:null}:{url:e,title:null}}function i(e){return e.replace(/[*_`~]/g,"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}function u(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function d(e){let t=0,n=0;for(;n<e.length&&e.startsWith(">",n);)n+=4,t++," "===e[n]&&n++;return{depth:t,content:e.slice(n)}}function f(t){const r=t.trim();return""===r||(!!/^#{1,6}\s/.test(r)||(!!e(r)||(!!/^>/.test(r)||(!!/^[-*+]\s/.test(r)||(!!/^\d+\.\s/.test(r)||(!!r.startsWith("|")||!!r.startsWith(n)))))))}const $={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const o=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let l="";const c=[],s=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:u,content:d}=e[i];if(!(u<=0)){if(o&&0===i){const e=o[1].toUpperCase(),n=e.toLowerCase();if(s){const e=a.alert,t=a["alert-"+n];l+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else l+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=$[e];l+=s?`<p style="${a["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,c.push("alert");continue}for(;c.length>u;){l+="alert"===c.pop()?"</div>":"</blockquote>"}for(;c.length<u;)0===c.length&&o?c.push("alert"):(l+=`<blockquote${n("blockquote")}${r(">")}>`,c.push("blockquote"));l+=d,i<e.length-1&&(l+="\n")}}for(;c.length>0;){l+="alert"===c.pop()?"</div>":"</blockquote>"}return l.trimEnd()}function p(e){if(0===e.length)return!1;const t=e.match(/^([ \t]+)(.*)$/);if(!t)return!1;if(t[1].replace(/\t/g," ").length<4)return!1;const n=t[2];return!(/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/^>/.test(n)||/^#{1,6}\s/.test(n))}function h(e){if(e.startsWith(" "))return e.slice(4);if("\t"===e[0])return e.slice(1);const t=e.match(/^[ \t]+(.*)$/);return t?t[1]:e}function m(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function b($,m={}){if(!$||"string"!=typeof $)return"";const{fence_plugin:b,inline_styles:q=!1,bidirectional:x=!1,lazy_linefeeds:_=!1,allow_unsafe_html:k=!1,heading_ids:A=!1}=m,w=function(e,n){return function(r,o=""){if(e){let e=n[r];return e||o?(o&&o.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${o?e?`${e}${o}`:o:e}"`):""}{const e=` class="${t}${r}"`;return o?`${e} style="${o}"`:e}}}(q,a),N=new Map;function E(e){return e.replace(/[&<>"']/g,e=>c[e])}const T=x?e=>` data-qd="${E(e)}"`:()=>"";function v(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),o=["javascript:","vbscript:","data:"];for(const e of o)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let C=$;const L=[],z=[];C=C.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${L.length}§`,c=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?L.push({lang:c,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):L.push({lang:c,code:E(o.trimEnd()),custom:!1,fence:t}),l});const j=[];C=C.replace(/\\`/g,()=>{const e=`${o}${j.length}§`;return j.push("`"),e}),C=C.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${z.length}§`;return z.push(E(t)),n}),C=C.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${o}${j.length}§`;return j.push(E(t)),n});const S=[],W=Array.isArray(k)?Object.fromEntries(k.map(e=>[e,1])):k&&"object"==typeof k?k:null;W&&(C=C.replace(/<!--[\s\S]*?-->/g,e=>{const t=S.length;return S.push(e),`${r}${t}§`}),C=C.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in W){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,o]=t,c=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,a=[];let s;for(;null!==(s=c.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)a.push(e);else{let n=t;e.toLowerCase()in l&&(n=v(t)),a.push(`${e}="${n}"`)}}return n+(a.length?" "+a.join(" "):"")+o}(e),n=S.length;return S.push(t),`${r}${n}§`}return e})),!0!==k&&(C=E(C)),W&&S.forEach((e,t)=>{C=C.replace(`${r}${t}§`,e)}),C=function(e,t,n){const r=e.split("\n"),o=[];let l=0;for(;l<r.length;){if(!p(r[l])){o.push(r[l]),l++;continue}const e=[];for(;l<r.length;){const t=r[l];if(""===t){if(l+1<r.length&&p(r[l+1])){e.push(""),l++;continue}break}if(!p(t))break;e.push(h(t)),l++}const c=e.join("\n");o.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${c}</code></pre>`)}return o.join("\n")}(C,w,T),C=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,c=[];for(let e=0;e<r.length;e++){const a=r[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))l||(l=!0,c=[]),c.push(a);else{if(l){const e=y(c,t,n);e?o.push(e):o.push(...c),l=!1,c=[]}o.push(r[e])}}if(l&&c.length>0){const e=y(c,t,n);e?o.push(e):o.push(...c)}return o.join("\n")}(C,w,x),C=function(t,n,r,o,l,c){const a=t.split("\n"),s=[];let $=0;for(;$<a.length;){const t=a[$];if(/^\[\/\/\]: #/.test(t)){$++;continue}let p=0;for(;p<t.length&&p<7&&"#"===t[p];)p++;if(p>=1&&p<=6&&" "===t[p]){const e=t.slice(p+1).replace(/\s*#+\s*$/,""),a="h"+p;let d="";if(o){d=` id="${c(u(i(e),l))}"`}s.push(`<${a}${n(a)}${d}${r("#".repeat(p))}>${e}</${a}>`),$++;continue}if(e(t))s.push(`<hr${n("hr")}${r(t.trim())}>`),$++;else{if(d(t).depth>0){const e=[];let t=0;for(;$<a.length;){const n=d(a[$]);if(n.depth>0)e.push(n),t=n.depth,$++;else{if(!(t>0)||f(a[$]))break;e.push({depth:t,content:a[$]}),$++}}s.push(g(e,n,r));continue}s.push(t),$++}}return s.join("\n")}(C,w,T,A,N,E),C=function(e,n,r,o){const l=e.split("\n"),c=[],a=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,u=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let $=l,g="";const p=l.match(/^\[([x ])\]\s+(.*)$/i);if(p&&!d){const[,e,n]=p,o="x"===e.toLowerCase();$=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;a.length>u+1;){const e=a.pop();c.push(`</${e.type}>`)}if(a.length===u)a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`);else if(a.length===u+1){const e=a[a.length-1];e.type!==f&&(c.push(`</${e.type}>`),a.pop(),a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`))}const h=g||n("li");c.push(`<li${h}${i(o)}>${$}</li>`)}else{for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}c.push(o)}}for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}return c.join("\n")}(C,w,q,x),C=C.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=v(r,m.allow_unsafe_urls),c=o?` title="${E(o)}"`:"",a=x&&t?` data-qd-alt="${E(t)}"`:"",i=x?` data-qd-src="${E(r)}"`:"",u=x&&o?` data-qd-title="${E(o)}"`:"";return`<img${w("img")} src="${l}" alt="${t}"${c}${a}${i}${u}${T("!")}>`}),C=C.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=v(r,m.allow_unsafe_urls),c=/^https?:\/\//i.test(l)?' rel="noopener noreferrer"':"",a=o?` title="${E(o)}"`:"",i=x?` data-qd-text="${E(t)}"`:"",u=x&&o?` data-qd-title="${E(o)}"`:"";return`<a${w("a")} href="${l}"${c}${a}${i}${u}${T("[")}>${t}</a>`}),C=C.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:o}=function(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n&&(e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break;t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}(n),l=v(r,m.allow_unsafe_urls);return`${t}<a${w("a")} href="${l}" rel="noopener noreferrer">${r}</a>${o}`});const O=[];C=C.replace(/<[^>]+>/g,e=>(O.push(e),`%%T${O.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{C=C.replace(e,`<${t}${w(t)}${T(n)}>$1</${t}>`)}),C=C.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),C=C.replace(/\\\n/g,`<br${w("br")}>`),_){const e=[];let t=0;C=C.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),C=C.replace(/\n\n+/g,"§P§").replace(/(<\/(?:h[1-6]|blockquote|pre)>)\n/g,"$1§N§").replace(/(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)\n/g,"$1§N§").replace(/\n(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)/g,"§N§$1").replace(/\n(§B\d+§)/g,"§N§$1").replace(/(§B\d+§)\n/g,"$1§N§").replace(/\n/g,`<br${w("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>C=C.replace(`§B${t}§`,e)),C="<p>"+C+"</p>"}else C=C.replace(/ {2}$/gm,`<br${w("br")}>`),C=C.replace(/\n\n+/g,(e,t)=>C.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),C="<p>"+C+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[/<p>(<div[^>]*>)/g,"$1"],[/(<\/div>)<\/p>/g,"$1"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{C=C.replace(e,t)}),C=C.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),L.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=x&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=x?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${E(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${E(e.fence)}" data-qd-lang="${E(e.lang)}" data-qd-source="${E(e.code)}"`));else{const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=x&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=x?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;C=C.replace(o,r)}),z.forEach((e,t)=>{const n=`§IC${t}§`;C=C.replace(n,`<code${w("code")}${T("`")}>${e}</code>`)}),j.forEach((e,t)=>{C=C.replace(`${o}${t}§`,e)}),C.trim()}function q(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`\n]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function y(e,t,n){if(e.length<2)return null;let r,o,l,c=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){c=t;break}if(-1===c)r=[e[0]],o=e.slice(1),l=m(e[0]).map(()=>"left");else{r=e.slice(0,c),o=e.slice(c+1);const t=m(e[c]);l=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const a=l.length,s=n?` data-qd-align="${l.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<th${t("th",o)}>${c}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",o.length>0&&(i+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<td${t("td",o)}>${c}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}function x(e,t={}){return b(e,{...t,bidirectional:!0})}return b.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[c,a]of Object.entries(n)){let n=a;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${c} { ${n} }\n`}return l},b.configure=function(e){return function(t){return b(t,e)}},b.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown=b),Object.keys(b).forEach(e=>{"configure"!==e&&(x[e]=b[e])}),x.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 r(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const l=e.tagName.toLowerCase(),c=e.getAttribute("data-qd");let a="";for(const t of e.childNodes)a+=r(t,{parentTag:l,...n});switch(l){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(l[1]);return`${c||"#".repeat(n)} ${a.trim()}\n\n`;case"strong":case"b":if(!a)return"";const r=c||"**";return`${r}${a}${r}`;case"em":case"i":if(!a)return"";const s=c||"*";return`${s}${a}${s}`;case"del":case"s":case"strike":if(!a)return"";const i=c||"~~";return`${i}${a}${i}`;case"code":if(!a)return"";const u=c||"`";return`${u}${a}${u}`;case"pre":const d=e.getAttribute("data-qd-fence")||c||"```",f=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&f)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||d;return`${e}${n.lang||f}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const $=e.getAttribute("data-qd-source");if($)return`${d}${f}\n${$}\n${d}\n\n`;const g=e.querySelector("code");return`${d}${f}\n${(g?g.textContent:a).trimEnd()}\n${d}\n\n`;case"blockquote":const p=c||">";return a.trim().split("\n").map(e=>`${p} ${e}`).join("\n")+"\n\n";case"hr":return`${c||"---"}\n\n`;case"br":return`${c||" "}\n`;case"a":const h=e.getAttribute("data-qd-text")||a.trim(),m=e.getAttribute("href")||"";return h!==m||c?`[${h}](${m})`:`<${m}>`;case"img":return`${c||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return o(e,"ol"===l)+"\n";case"li":case"span":default:return a;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),r=n?n.split(","):[],o=e.querySelector("thead");if(o){const e=o.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=r[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const l=e.querySelector("tbody");if(l)for(const e of l.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(a.trim()){const e=a.split("\n");let t=a.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"),q=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||q||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const y=e.getAttribute("data-qd-source");if(y&&q)return`${q}${b||""}\n${y}\n${q}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",r=e.getAttribute("data-qd-source");if(r){const e=document.createElement("textarea");e.innerHTML=r;return`${t}${n}\n${e.value}\n${t}\n\n`}const o=e.querySelector("pre.mermaid");if(o){const e=o.getAttribute("data-qd-source");if(e){const r=document.createElement("textarea");r.innerHTML=e;return`${t}${n}\n${r.value}\n${t}\n\n`}}const l=e.querySelector(".mermaid-source");if(l){const e=document.createElement("div");e.innerHTML=l.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const c=e.querySelector(".mermaid");if(c&&c.textContent.includes("graph"))return`${t}${n}\n${c.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 a}}function o(e,t,n=0){let l="",c=1;const a=" ".repeat(n);for(const s of e.children){if("LI"!==s.tagName)continue;let e=s.getAttribute("data-qd")||(t?`${c}.`:"-");const i=s.querySelector('input[type="checkbox"]');if(i){const t=i.checked?"x":" ";e="-";let n="";for(const e of s.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=r(e));l+=`${a}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of s.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=o(e,"OL"===e.tagName,n+1):t+=r(e);l+=`${a}${e} ${t.trim()}\n`}c++}return l}let l=r(n);return l=l.replace(/\n{3,}/g,"\n\n"),l=l.trim(),l},x.configure=function(e){const t=b.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=x),"undefined"!=typeof window&&(window.quikdown_bd=x),x});
|
|
8
8
|
//# sourceMappingURL=quikdown_bd.umd.min.js.map
|
|
Binary file
|
package/dist/quikdown_edit.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Quikdown Editor - Drop-in Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.19
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -201,7 +201,7 @@ function looksLikeTableRow(line) {
|
|
|
201
201
|
// ────────────────────────────────────────────────────────────────────
|
|
202
202
|
|
|
203
203
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
204
|
-
const quikdownVersion = '1.2.
|
|
204
|
+
const quikdownVersion = '1.2.19';
|
|
205
205
|
|
|
206
206
|
/** CSS class prefix used for all generated elements */
|
|
207
207
|
const CLASS_PREFIX = 'quikdown-';
|
|
@@ -3448,7 +3448,7 @@ async function getRenderedContent(previewPanel, options = {}) {
|
|
|
3448
3448
|
|
|
3449
3449
|
|
|
3450
3450
|
/** Build-time version stamp (injected by rollup replaceVersion plugin) */
|
|
3451
|
-
const quikdownEditorVersion = '1.2.
|
|
3451
|
+
const quikdownEditorVersion = '1.2.19';
|
|
3452
3452
|
|
|
3453
3453
|
/**
|
|
3454
3454
|
* Curated safe HTML tag whitelist.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Quikdown Editor - Drop-in Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.19
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -199,7 +199,7 @@ function looksLikeTableRow(line) {
|
|
|
199
199
|
// ────────────────────────────────────────────────────────────────────
|
|
200
200
|
|
|
201
201
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
202
|
-
const quikdownVersion = '1.2.
|
|
202
|
+
const quikdownVersion = '1.2.19';
|
|
203
203
|
|
|
204
204
|
/** CSS class prefix used for all generated elements */
|
|
205
205
|
const CLASS_PREFIX = 'quikdown-';
|
|
@@ -3446,7 +3446,7 @@ async function getRenderedContent(previewPanel, options = {}) {
|
|
|
3446
3446
|
|
|
3447
3447
|
|
|
3448
3448
|
/** Build-time version stamp (injected by rollup replaceVersion plugin) */
|
|
3449
|
-
const quikdownEditorVersion = '1.2.
|
|
3449
|
+
const quikdownEditorVersion = '1.2.19';
|
|
3450
3450
|
|
|
3451
3451
|
/**
|
|
3452
3452
|
* Curated safe HTML tag whitelist.
|