quikdown 1.2.14 → 1.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/quikdown-airgap-v1.2.15.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_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 +1 -1
|
Binary file
|
package/dist/quikdown.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown - Lightweight Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -125,7 +125,7 @@ function isHRLine(trimmed) {
|
|
|
125
125
|
// ────────────────────────────────────────────────────────────────────
|
|
126
126
|
|
|
127
127
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
128
|
-
const quikdownVersion = '1.2.
|
|
128
|
+
const quikdownVersion = '1.2.15';
|
|
129
129
|
|
|
130
130
|
/** CSS class prefix used for all generated elements */
|
|
131
131
|
const CLASS_PREFIX = 'quikdown-';
|
package/dist/quikdown.dark.css
CHANGED
package/dist/quikdown.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown - Lightweight Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -123,7 +123,7 @@ function isHRLine(trimmed) {
|
|
|
123
123
|
// ────────────────────────────────────────────────────────────────────
|
|
124
124
|
|
|
125
125
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
126
|
-
const quikdownVersion = '1.2.
|
|
126
|
+
const quikdownVersion = '1.2.15';
|
|
127
127
|
|
|
128
128
|
/** CSS class prefix used for all generated elements */
|
|
129
129
|
const CLASS_PREFIX = 'quikdown-';
|
package/dist/quikdown.esm.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown - Lightweight Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
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={href:1,src:1,action:1,formaction:1},l={"&":"&","<":"<",">":">",'"':""","'":"'"},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"};function s(s,c={}){if(!s||"string"!=typeof s)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:$=!1,lazy_linefeeds:g=!1,allow_unsafe_html:u=!1}=c,f=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}}}(d,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=$?e=>` data-qd="${h(e)}"`:()=>"";function b(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 _=s;const x=[],q=[];_=_.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${x.length}§`,a=r?r.trim():"";return p&&p.render&&"function"==typeof p.render?x.push({lang:a,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!p.reverse}):x.push({lang:a,code:h(o.trimEnd()),custom:!1,fence:t}),l}),_=_.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${q.length}§`;return q.push(h(t)),n});const k=[],y=Array.isArray(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u:null;y&&(_=_.replace(/<!--[\s\S]*?-->/g,e=>{const t=k.length;return k.push(e),`${r}${t}§`}),_=_.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in y){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,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=k.length;return k.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),y&&k.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))l||(l=!0,a=[]),a.push(s);else{if(l){const e=i(a,t,n);e?o.push(e):o.push(...a),l=!1,a=[]}o.push(r[e])}}if(l&&a.length>0){const e=i(a,t,n);e?o.push(e):o.push(...a)}return o.join("\n")}(_,f,$),_=function(t,n,r){const o=t.split("\n"),l=[];let a=0;for(;a<o.length;){const t=o[a];if(/^\[\/\/\]: #/.test(t)){a++;continue}let s=0;for(;s<t.length&&s<7&&"#"===t[s];)s++;if(s>=1&&s<=6&&" "===t[s]){const e=t.slice(s+1).replace(/\s*#+\s*$/,""),o="h"+s;l.push(`<${o}${n(o)}${r("#".repeat(s))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}${r(t.trim())}>`),a++):/^>(\s|$)/.test(t)?(l.push(`<blockquote${n("blockquote")}${r(">")}>${t.replace(/^>\s*/,"")}</blockquote>`),a++):(l.push(t),a++)}let s=l.join("\n");return s=s.replace(/<\/blockquote>\n<blockquote[^>]*>/g,"\n"),s}(_,f,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],c=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,o,l]=c,p=Math.floor(e.length/2),d=/^\d+\./.test(o),$=d?"ol":"ul";let g=l,u="";const f=l.match(/^\[([x ])\]\s+(.*)$/i);if(f&&!d){const[,e,n]=f,o="x"===e.toLowerCase();g=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,u=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>p+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===p)s.push({type:$,level:p}),a.push(`<${$}${n($)}>`);else if(s.length===p+1){const e=s[s.length-1];e.type!==$&&(a.push(`</${e.type}>`),s.pop(),s.push({type:$,level:p}),a.push(`<${$}${n($)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${g}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,f,d,$),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=$&&t?` data-qd-alt="${h(t)}"`:"",l=$?` data-qd-src="${h(n)}"`:"";return`<img${f("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=$?` data-qd-text="${h(t)}"`:"";return`<a${f("a")} href="${r}"${o}${l}${m("[")}>${t}</a>`}),_=_.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls);return`${t}<a${f("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const w=[];_=_.replace(/<[^>]+>/g,e=>(w.push(e),`%%T${w.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])=>{_=_.replace(e,`<${t}${f(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>w[t]),g){const e=[];let t=0;_=_.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),_=_.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${f("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>_=_.replace(`§B${t}§`,e)),_="<p>"+_+"</p>"}else _=_.replace(/ {2}$/gm,`<br${f("br")}>`),_=_.replace(/\n\n+/g,(e,t)=>_.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),_="<p>"+_+"</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"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{_=_.replace(e,t)}),_=_.replace(/(<\/(?:h[1-6]|blockquote|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),x.forEach((e,t)=>{let r;if(e.custom&&p&&p.render)if(r=p.render(e.code,e.lang),void 0===r){const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?f("code"):t,o=$&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=$?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${f("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else $&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${h(e.fence)}" data-qd-lang="${h(e.lang)}" data-qd-source="${h(e.code)}"`));else{const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?f("code"):t,o=$&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=$?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${f("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;_=_.replace(o,r)}),q.forEach((e,t)=>{const n=`§IC${t}§`;_=_.replace(n,`<code${f("code")}${m("`")}>${e}</code>`)}),_.trim()}function c(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t,n){if(e.length<2)return null;let r=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){r=t;break}if(-1===r)return null;const o=e.slice(0,r),l=e.slice(r+1),a=e[r].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),s=n?` data-qd-align="${a.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<th${t("th",r)}>${o}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<td${t("td",r)}>${o}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}s.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[a,s]of Object.entries(n)){let n=s;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"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(a)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${a} { ${n} }\n`}return l},s.configure=function(e){return function(t){return s(t,e)}},s.version="1.2.14","undefined"!=typeof module&&module.exports&&(module.exports=s),"undefined"!=typeof window&&(window.quikdown=s);export{s as default};
|
|
7
|
+
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={href:1,src:1,action:1,formaction:1},l={"&":"&","<":"<",">":">",'"':""","'":"'"},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"};function s(s,c={}){if(!s||"string"!=typeof s)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:$=!1,lazy_linefeeds:g=!1,allow_unsafe_html:u=!1}=c,f=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}}}(d,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=$?e=>` data-qd="${h(e)}"`:()=>"";function b(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 _=s;const x=[],q=[];_=_.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${x.length}§`,a=r?r.trim():"";return p&&p.render&&"function"==typeof p.render?x.push({lang:a,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!p.reverse}):x.push({lang:a,code:h(o.trimEnd()),custom:!1,fence:t}),l}),_=_.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${q.length}§`;return q.push(h(t)),n});const k=[],y=Array.isArray(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u:null;y&&(_=_.replace(/<!--[\s\S]*?-->/g,e=>{const t=k.length;return k.push(e),`${r}${t}§`}),_=_.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in y){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,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=k.length;return k.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),y&&k.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))l||(l=!0,a=[]),a.push(s);else{if(l){const e=i(a,t,n);e?o.push(e):o.push(...a),l=!1,a=[]}o.push(r[e])}}if(l&&a.length>0){const e=i(a,t,n);e?o.push(e):o.push(...a)}return o.join("\n")}(_,f,$),_=function(t,n,r){const o=t.split("\n"),l=[];let a=0;for(;a<o.length;){const t=o[a];if(/^\[\/\/\]: #/.test(t)){a++;continue}let s=0;for(;s<t.length&&s<7&&"#"===t[s];)s++;if(s>=1&&s<=6&&" "===t[s]){const e=t.slice(s+1).replace(/\s*#+\s*$/,""),o="h"+s;l.push(`<${o}${n(o)}${r("#".repeat(s))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}${r(t.trim())}>`),a++):/^>(\s|$)/.test(t)?(l.push(`<blockquote${n("blockquote")}${r(">")}>${t.replace(/^>\s*/,"")}</blockquote>`),a++):(l.push(t),a++)}let s=l.join("\n");return s=s.replace(/<\/blockquote>\n<blockquote[^>]*>/g,"\n"),s}(_,f,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],c=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,o,l]=c,p=Math.floor(e.length/2),d=/^\d+\./.test(o),$=d?"ol":"ul";let g=l,u="";const f=l.match(/^\[([x ])\]\s+(.*)$/i);if(f&&!d){const[,e,n]=f,o="x"===e.toLowerCase();g=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,u=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>p+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===p)s.push({type:$,level:p}),a.push(`<${$}${n($)}>`);else if(s.length===p+1){const e=s[s.length-1];e.type!==$&&(a.push(`</${e.type}>`),s.pop(),s.push({type:$,level:p}),a.push(`<${$}${n($)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${g}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,f,d,$),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=$&&t?` data-qd-alt="${h(t)}"`:"",l=$?` data-qd-src="${h(n)}"`:"";return`<img${f("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=$?` data-qd-text="${h(t)}"`:"";return`<a${f("a")} href="${r}"${o}${l}${m("[")}>${t}</a>`}),_=_.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls);return`${t}<a${f("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const w=[];_=_.replace(/<[^>]+>/g,e=>(w.push(e),`%%T${w.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])=>{_=_.replace(e,`<${t}${f(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>w[t]),g){const e=[];let t=0;_=_.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),_=_.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${f("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>_=_.replace(`§B${t}§`,e)),_="<p>"+_+"</p>"}else _=_.replace(/ {2}$/gm,`<br${f("br")}>`),_=_.replace(/\n\n+/g,(e,t)=>_.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),_="<p>"+_+"</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"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{_=_.replace(e,t)}),_=_.replace(/(<\/(?:h[1-6]|blockquote|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),x.forEach((e,t)=>{let r;if(e.custom&&p&&p.render)if(r=p.render(e.code,e.lang),void 0===r){const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?f("code"):t,o=$&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=$?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${f("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else $&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${h(e.fence)}" data-qd-lang="${h(e.lang)}" data-qd-source="${h(e.code)}"`));else{const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?f("code"):t,o=$&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=$?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${f("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;_=_.replace(o,r)}),q.forEach((e,t)=>{const n=`§IC${t}§`;_=_.replace(n,`<code${f("code")}${m("`")}>${e}</code>`)}),_.trim()}function c(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t,n){if(e.length<2)return null;let r=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){r=t;break}if(-1===r)return null;const o=e.slice(0,r),l=e.slice(r+1),a=e[r].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),s=n?` data-qd-align="${a.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<th${t("th",r)}>${o}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<td${t("td",r)}>${o}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}s.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[a,s]of Object.entries(n)){let n=s;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"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(a)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${a} { ${n} }\n`}return l},s.configure=function(e){return function(t){return s(t,e)}},s.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=s),"undefined"!=typeof window&&(window.quikdown=s);export{s as default};
|
|
8
8
|
//# sourceMappingURL=quikdown.esm.min.js.map
|
|
Binary file
|
package/dist/quikdown.light.css
CHANGED
package/dist/quikdown.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown - Lightweight Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
// ────────────────────────────────────────────────────────────────────
|
|
130
130
|
|
|
131
131
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
132
|
-
const quikdownVersion = '1.2.
|
|
132
|
+
const quikdownVersion = '1.2.15';
|
|
133
133
|
|
|
134
134
|
/** CSS class prefix used for all generated elements */
|
|
135
135
|
const CLASS_PREFIX = 'quikdown-';
|
package/dist/quikdown.umd.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown - Lightweight Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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=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={href:1,src:1,action:1,formaction:1},l={"&":"&","<":"<",">":">",'"':""","'":"'"},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"};function s(s,c={}){if(!s||"string"!=typeof s)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:u=!1,lazy_linefeeds:f=!1,allow_unsafe_html:g=!1}=c,$=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}}}(d,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=u?e=>` data-qd="${h(e)}"`:()=>"";function b(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 _=s;const x=[],q=[];_=_.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${x.length}§`,a=r?r.trim():"";return p&&p.render&&"function"==typeof p.render?x.push({lang:a,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!p.reverse}):x.push({lang:a,code:h(o.trimEnd()),custom:!1,fence:t}),l}),_=_.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${q.length}§`;return q.push(h(t)),n});const y=[],k=Array.isArray(g)?Object.fromEntries(g.map(e=>[e,1])):g&&"object"==typeof g?g:null;k&&(_=_.replace(/<!--[\s\S]*?-->/g,e=>{const t=y.length;return y.push(e),`${r}${t}§`}),_=_.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in k){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,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=y.length;return y.push(t),`${r}${n}§`}return e})),!0!==g&&(_=h(_)),k&&y.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))l||(l=!0,a=[]),a.push(s);else{if(l){const e=i(a,t,n);e?o.push(e):o.push(...a),l=!1,a=[]}o.push(r[e])}}if(l&&a.length>0){const e=i(a,t,n);e?o.push(e):o.push(...a)}return o.join("\n")}(_,$,u),_=function(t,n,r){const o=t.split("\n"),l=[];let a=0;for(;a<o.length;){const t=o[a];if(/^\[\/\/\]: #/.test(t)){a++;continue}let s=0;for(;s<t.length&&s<7&&"#"===t[s];)s++;if(s>=1&&s<=6&&" "===t[s]){const e=t.slice(s+1).replace(/\s*#+\s*$/,""),o="h"+s;l.push(`<${o}${n(o)}${r("#".repeat(s))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}${r(t.trim())}>`),a++):/^>(\s|$)/.test(t)?(l.push(`<blockquote${n("blockquote")}${r(">")}>${t.replace(/^>\s*/,"")}</blockquote>`),a++):(l.push(t),a++)}let s=l.join("\n");return s=s.replace(/<\/blockquote>\n<blockquote[^>]*>/g,"\n"),s}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],c=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,o,l]=c,p=Math.floor(e.length/2),d=/^\d+\./.test(o),u=d?"ol":"ul";let f=l,g="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!d){const[,e,n]=$,o="x"===e.toLowerCase();f=`<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(;s.length>p+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===p)s.push({type:u,level:p}),a.push(`<${u}${n(u)}>`);else if(s.length===p+1){const e=s[s.length-1];e.type!==u&&(a.push(`</${e.type}>`),s.pop(),s.push({type:u,level:p}),a.push(`<${u}${n(u)}>`))}const h=g||n("li");a.push(`<li${h}${i(o)}>${f}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,d,u),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=u&&t?` data-qd-alt="${h(t)}"`:"",l=u?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=u?` data-qd-text="${h(t)}"`:"";return`<a${$("a")} href="${r}"${o}${l}${m("[")}>${t}</a>`}),_=_.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls);return`${t}<a${$("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const w=[];_=_.replace(/<[^>]+>/g,e=>(w.push(e),`%%T${w.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])=>{_=_.replace(e,`<${t}${$(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>w[t]),f){const e=[];let t=0;_=_.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),_=_.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${$("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>_=_.replace(`§B${t}§`,e)),_="<p>"+_+"</p>"}else _=_.replace(/ {2}$/gm,`<br${$("br")}>`),_=_.replace(/\n\n+/g,(e,t)=>_.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),_="<p>"+_+"</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"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{_=_.replace(e,t)}),_=_.replace(/(<\/(?:h[1-6]|blockquote|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),x.forEach((e,t)=>{let r;if(e.custom&&p&&p.render)if(r=p.render(e.code,e.lang),void 0===r){const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?$("code"):t,o=u&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=u?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else u&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${h(e.fence)}" data-qd-lang="${h(e.lang)}" data-qd-source="${h(e.code)}"`));else{const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?$("code"):t,o=u&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=u?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;_=_.replace(o,r)}),q.forEach((e,t)=>{const n=`§IC${t}§`;_=_.replace(n,`<code${$("code")}${m("`")}>${e}</code>`)}),_.trim()}function c(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t,n){if(e.length<2)return null;let r=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){r=t;break}if(-1===r)return null;const o=e.slice(0,r),l=e.slice(r+1),a=e[r].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),s=n?` data-qd-align="${a.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<th${t("th",r)}>${o}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<td${t("td",r)}>${o}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}return s.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[a,s]of Object.entries(n)){let n=s;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"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(a)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${a} { ${n} }\n`}return l},s.configure=function(e){return function(t){return s(t,e)}},s.version="1.2.14","undefined"!=typeof module&&module.exports&&(module.exports=s),"undefined"!=typeof window&&(window.quikdown=s),s});
|
|
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=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={href:1,src:1,action:1,formaction:1},l={"&":"&","<":"<",">":">",'"':""","'":"'"},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"};function s(s,c={}){if(!s||"string"!=typeof s)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:u=!1,lazy_linefeeds:f=!1,allow_unsafe_html:g=!1}=c,$=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}}}(d,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=u?e=>` data-qd="${h(e)}"`:()=>"";function b(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 _=s;const x=[],q=[];_=_.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${x.length}§`,a=r?r.trim():"";return p&&p.render&&"function"==typeof p.render?x.push({lang:a,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!p.reverse}):x.push({lang:a,code:h(o.trimEnd()),custom:!1,fence:t}),l}),_=_.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${q.length}§`;return q.push(h(t)),n});const y=[],k=Array.isArray(g)?Object.fromEntries(g.map(e=>[e,1])):g&&"object"==typeof g?g:null;k&&(_=_.replace(/<!--[\s\S]*?-->/g,e=>{const t=y.length;return y.push(e),`${r}${t}§`}),_=_.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in k){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,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=y.length;return y.push(t),`${r}${n}§`}return e})),!0!==g&&(_=h(_)),k&&y.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))l||(l=!0,a=[]),a.push(s);else{if(l){const e=i(a,t,n);e?o.push(e):o.push(...a),l=!1,a=[]}o.push(r[e])}}if(l&&a.length>0){const e=i(a,t,n);e?o.push(e):o.push(...a)}return o.join("\n")}(_,$,u),_=function(t,n,r){const o=t.split("\n"),l=[];let a=0;for(;a<o.length;){const t=o[a];if(/^\[\/\/\]: #/.test(t)){a++;continue}let s=0;for(;s<t.length&&s<7&&"#"===t[s];)s++;if(s>=1&&s<=6&&" "===t[s]){const e=t.slice(s+1).replace(/\s*#+\s*$/,""),o="h"+s;l.push(`<${o}${n(o)}${r("#".repeat(s))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}${r(t.trim())}>`),a++):/^>(\s|$)/.test(t)?(l.push(`<blockquote${n("blockquote")}${r(">")}>${t.replace(/^>\s*/,"")}</blockquote>`),a++):(l.push(t),a++)}let s=l.join("\n");return s=s.replace(/<\/blockquote>\n<blockquote[^>]*>/g,"\n"),s}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],c=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,o,l]=c,p=Math.floor(e.length/2),d=/^\d+\./.test(o),u=d?"ol":"ul";let f=l,g="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!d){const[,e,n]=$,o="x"===e.toLowerCase();f=`<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(;s.length>p+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===p)s.push({type:u,level:p}),a.push(`<${u}${n(u)}>`);else if(s.length===p+1){const e=s[s.length-1];e.type!==u&&(a.push(`</${e.type}>`),s.pop(),s.push({type:u,level:p}),a.push(`<${u}${n(u)}>`))}const h=g||n("li");a.push(`<li${h}${i(o)}>${f}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,d,u),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=u&&t?` data-qd-alt="${h(t)}"`:"",l=u?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=u?` data-qd-text="${h(t)}"`:"";return`<a${$("a")} href="${r}"${o}${l}${m("[")}>${t}</a>`}),_=_.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const r=b(n,c.allow_unsafe_urls);return`${t}<a${$("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const w=[];_=_.replace(/<[^>]+>/g,e=>(w.push(e),`%%T${w.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])=>{_=_.replace(e,`<${t}${$(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>w[t]),f){const e=[];let t=0;_=_.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),_=_.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${$("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>_=_.replace(`§B${t}§`,e)),_="<p>"+_+"</p>"}else _=_.replace(/ {2}$/gm,`<br${$("br")}>`),_=_.replace(/\n\n+/g,(e,t)=>_.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),_="<p>"+_+"</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"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{_=_.replace(e,t)}),_=_.replace(/(<\/(?:h[1-6]|blockquote|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),x.forEach((e,t)=>{let r;if(e.custom&&p&&p.render)if(r=p.render(e.code,e.lang),void 0===r){const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?$("code"):t,o=u&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=u?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else u&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${h(e.fence)}" data-qd-lang="${h(e.lang)}" data-qd-source="${h(e.code)}"`));else{const t=!d&&e.lang?` class="language-${h(e.lang)}"`:"",n=d?$("code"):t,o=u&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=u?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;_=_.replace(o,r)}),q.forEach((e,t)=>{const n=`§IC${t}§`;_=_.replace(n,`<code${$("code")}${m("`")}>${e}</code>`)}),_.trim()}function c(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t,n){if(e.length<2)return null;let r=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){r=t;break}if(-1===r)return null;const o=e.slice(0,r),l=e.slice(r+1),a=e[r].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),s=n?` data-qd-align="${a.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<th${t("th",r)}>${o}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=a[n]&&"left"!==a[n]?`text-align:${a[n]}`:"",o=c(e.trim(),t);i+=`<td${t("td",r)}>${o}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}return s.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[a,s]of Object.entries(n)){let n=s;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"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(a)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${a} { ${n} }\n`}return l},s.configure=function(e){return function(t){return s(t,e)}},s.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=s),"undefined"!=typeof window&&(window.quikdown=s),s});
|
|
8
8
|
//# sourceMappingURL=quikdown.umd.min.js.map
|
|
Binary file
|
package/dist/quikdown_ast.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast - AST Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.2.
|
|
18
|
+
const quikdownVersion = '1.2.15';
|
|
19
19
|
|
|
20
20
|
// Safety limit to prevent infinite loops in list parsing
|
|
21
21
|
const MAX_LOOP_ITERATIONS = 1000;
|
package/dist/quikdown_ast.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast - AST Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.2.
|
|
16
|
+
const quikdownVersion = '1.2.15';
|
|
17
17
|
|
|
18
18
|
// Safety limit to prevent infinite loops in list parsing
|
|
19
19
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast - AST Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
function t(t,n={}){if(!t||"string"!=typeof t)return{type:"document",children:[]};return{type:"document",children:e(t.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function e(t,s){const l=[],r=t.split("\n");let h=0;for(;h<r.length;){const t=r[h];if(""===t.trim()){h++;continue}const s=t.match(/^(```|~~~)(.*)$/);if(s){const[,t,e]=s,n=e.trim(),i=[];for(h++;h<r.length;){if(r[h].match(/^(```|~~~)\s*$/)){h++;break}i.push(r[h]),h++}l.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),h++;continue}const o=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(o){const[,t,e]=o;l.push({type:"heading",level:t.length,children:c(e)}),h++;continue}if(t.includes("|")){const t=n(r,h);if(t){l.push(t.node),h=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];for(;h<r.length&&r[h].match(/^>\s*/);)t.push(r[h].replace(/^>\s*/,"")),h++;l.push({type:"blockquote",children:e(t.join("\n"))});continue}if(t.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const t=i(r,h);l.push(t.node),h=t.nextIndex;continue}const u=[];for(;h<r.length;){const t=r[h];if(""===t.trim())break;if(/^(```|~~~)/.test(t))break;if(/^#{1,6}\s/.test(t))break;if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))break;if(/^>\s*/.test(t))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(t))break;if(t.includes("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;u.push(t),h++}u.length>0&&l.push({type:"paragraph",children:c(u.join("\n"))})}return l}function n(t,e,n){if(e+1>=t.length)return null;const i=t[e],l=t[e+1];if(!/^\|?[\s\-:|]+\|?$/.test(l)||!l.includes("-"))return null;const r=s(i);if(0===r.length)return null;const h=s(l).map(t=>{const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":"left"}),o=r.map(t=>c(t.trim())),u=[];let a=e+2;for(;a<t.length;){const e=t[a];if(!e.includes("|")||""===e.trim())break;const n=s(e);u.push(n.map(t=>c(t.trim()))),a++}return{node:{type:"table",headers:o,rows:u,alignments:h},nextIndex:a}}function s(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|")}function i(t,e,n){const s=[];let l=e,r=0;const h=t[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),o=/^\d+\./.test(h[2]),u=h[1].length;for(;l<t.length&&r<1e3;){r++;const e=t[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!e)break;const[,n,h,a]=e,p=n.length;if(p<u)break;const d=/^\d+\./.test(h);if(p===u&&d!==o)break;if(p>u){const e=[];let n=0;for(;l<t.length&&n<1e3;){n++;const s=t[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;e.push(s),l++}if(e.length>0&&s.length>0){const t=i(e,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(t.node)}continue}const f={type:"list_item",checked:null,children:null},g=a.match(/^\[([x ])\]\s*(.*)$/i);g&&!o?(f.checked="x"===g[1].toLowerCase(),f.children=c(g[2])):f.children=c(a),s.push(f),l++}return{node:{type:"list",ordered:o,items:s},nextIndex:l}}function c(t,e){if(!t)return[];const n=[];let s=t;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const t=s.indexOf("\n"),e=s.slice(0,t),i=s.slice(t+1);if(e.endsWith(" ")||e.endsWith("\\")){const t=e.replace(/\\$/,"").replace(/ +$/,"");t&&n.push(...l(t)),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 i=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),s=s.slice(i[0].length);continue}const c=s.match(/^`([^`]+)`/);if(c){n.push({type:"code",value:c[1]}),s=s.slice(c[0].length);continue}const r=s.match(/^(\*\*|__)(.+?)\1/);if(r){n.push({type:"strong",children:l(r[2])}),s=s.slice(r[0].length);continue}const h=s.match(/^~~(.+?)~~/);if(h){n.push({type:"del",children:l(h[1])}),s=s.slice(h[0].length);continue}const o=t[t.length-s.length-1]||"",u=!/[A-Za-z0-9_]/.test(o),a=s.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&s.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(a){n.push({type:"em",children:l(a[1])}),s=s.slice(a[0].length);continue}const p=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){n.push({type:"link",url:p[1],children:[{type:"text",value:p[1]}]}),s=s.slice(p[0].length);continue}const d=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===d){n.push({type:"text",value:s});break}0===d?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,d)}),s=s.slice(d))}return function(t){const e=[];for(const n of t)"text"===n.type&&e.length>0&&"text"===e[e.length-1].type?e[e.length-1].value+=n.value:e.push(n);return e}(n)}function l(t,e){return c(t.replace(/\n/g," "))}t.version="1.2.
|
|
7
|
+
function t(t,n={}){if(!t||"string"!=typeof t)return{type:"document",children:[]};return{type:"document",children:e(t.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function e(t,s){const l=[],r=t.split("\n");let h=0;for(;h<r.length;){const t=r[h];if(""===t.trim()){h++;continue}const s=t.match(/^(```|~~~)(.*)$/);if(s){const[,t,e]=s,n=e.trim(),i=[];for(h++;h<r.length;){if(r[h].match(/^(```|~~~)\s*$/)){h++;break}i.push(r[h]),h++}l.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),h++;continue}const o=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(o){const[,t,e]=o;l.push({type:"heading",level:t.length,children:c(e)}),h++;continue}if(t.includes("|")){const t=n(r,h);if(t){l.push(t.node),h=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];for(;h<r.length&&r[h].match(/^>\s*/);)t.push(r[h].replace(/^>\s*/,"")),h++;l.push({type:"blockquote",children:e(t.join("\n"))});continue}if(t.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const t=i(r,h);l.push(t.node),h=t.nextIndex;continue}const u=[];for(;h<r.length;){const t=r[h];if(""===t.trim())break;if(/^(```|~~~)/.test(t))break;if(/^#{1,6}\s/.test(t))break;if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))break;if(/^>\s*/.test(t))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(t))break;if(t.includes("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;u.push(t),h++}u.length>0&&l.push({type:"paragraph",children:c(u.join("\n"))})}return l}function n(t,e,n){if(e+1>=t.length)return null;const i=t[e],l=t[e+1];if(!/^\|?[\s\-:|]+\|?$/.test(l)||!l.includes("-"))return null;const r=s(i);if(0===r.length)return null;const h=s(l).map(t=>{const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":"left"}),o=r.map(t=>c(t.trim())),u=[];let a=e+2;for(;a<t.length;){const e=t[a];if(!e.includes("|")||""===e.trim())break;const n=s(e);u.push(n.map(t=>c(t.trim()))),a++}return{node:{type:"table",headers:o,rows:u,alignments:h},nextIndex:a}}function s(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|")}function i(t,e,n){const s=[];let l=e,r=0;const h=t[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),o=/^\d+\./.test(h[2]),u=h[1].length;for(;l<t.length&&r<1e3;){r++;const e=t[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!e)break;const[,n,h,a]=e,p=n.length;if(p<u)break;const d=/^\d+\./.test(h);if(p===u&&d!==o)break;if(p>u){const e=[];let n=0;for(;l<t.length&&n<1e3;){n++;const s=t[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;e.push(s),l++}if(e.length>0&&s.length>0){const t=i(e,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(t.node)}continue}const f={type:"list_item",checked:null,children:null},g=a.match(/^\[([x ])\]\s*(.*)$/i);g&&!o?(f.checked="x"===g[1].toLowerCase(),f.children=c(g[2])):f.children=c(a),s.push(f),l++}return{node:{type:"list",ordered:o,items:s},nextIndex:l}}function c(t,e){if(!t)return[];const n=[];let s=t;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const t=s.indexOf("\n"),e=s.slice(0,t),i=s.slice(t+1);if(e.endsWith(" ")||e.endsWith("\\")){const t=e.replace(/\\$/,"").replace(/ +$/,"");t&&n.push(...l(t)),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 i=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),s=s.slice(i[0].length);continue}const c=s.match(/^`([^`]+)`/);if(c){n.push({type:"code",value:c[1]}),s=s.slice(c[0].length);continue}const r=s.match(/^(\*\*|__)(.+?)\1/);if(r){n.push({type:"strong",children:l(r[2])}),s=s.slice(r[0].length);continue}const h=s.match(/^~~(.+?)~~/);if(h){n.push({type:"del",children:l(h[1])}),s=s.slice(h[0].length);continue}const o=t[t.length-s.length-1]||"",u=!/[A-Za-z0-9_]/.test(o),a=s.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&s.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(a){n.push({type:"em",children:l(a[1])}),s=s.slice(a[0].length);continue}const p=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){n.push({type:"link",url:p[1],children:[{type:"text",value:p[1]}]}),s=s.slice(p[0].length);continue}const d=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===d){n.push({type:"text",value:s});break}0===d?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,d)}),s=s.slice(d))}return function(t){const e=[];for(const n of t)"text"===n.type&&e.length>0&&"text"===e[e.length-1].type?e[e.length-1].value+=n.value:e.push(n);return e}(n)}function l(t,e){return c(t.replace(/\n/g," "))}t.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=t),"undefined"!=typeof window&&(window.quikdown_ast=t);export{t as default};
|
|
8
8
|
//# sourceMappingURL=quikdown_ast.esm.min.js.map
|
|
Binary file
|
package/dist/quikdown_ast.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast - AST Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.2.
|
|
22
|
+
const quikdownVersion = '1.2.15';
|
|
23
23
|
|
|
24
24
|
// Safety limit to prevent infinite loops in list parsing
|
|
25
25
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast - AST Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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_ast=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 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 p=t+2;for(;p<e.length;){const t=e[p];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),p++}return{node:{type:"table",headers:h,rows:u,alignments:o},nextIndex:p}}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,p]=t,d=n.length;if(d<u)break;const f=/^\d+\./.test(o);if(d===u&&f!==h)break;if(d>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 a={type:"list_item",checked:null,children:null},g=p.match(/^\[([x ])\]\s*(.*)$/i);g&&!h?(a.checked="x"===g[1].toLowerCase(),a.children=c(g[2])):a.children=c(p),s.push(a),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 t=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"image",alt:t[1],url:t[2].trim()}),s=s.slice(t[0].length);continue}const i=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),s=s.slice(i[0].length);continue}const c=s.match(/^`([^`]+)`/);if(c){n.push({type:"code",value:c[1]}),s=s.slice(c[0].length);continue}const r=s.match(/^(\*\*|__)(.+?)\1/);if(r){n.push({type:"strong",children:l(r[2])}),s=s.slice(r[0].length);continue}const o=s.match(/^~~(.+?)~~/);if(o){n.push({type:"del",children:l(o[1])}),s=s.slice(o[0].length);continue}const h=e[e.length-s.length-1]||"",u=!/[A-Za-z0-9_]/.test(h),p=s.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&s.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(p){n.push({type:"em",children:l(p[1])}),s=s.slice(p[0].length);continue}const d=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){n.push({type:"link",url:d[1],children:[{type:"text",value:d[1]}]}),s=s.slice(d[0].length);continue}const f=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===f){n.push({type:"text",value:s});break}0===f?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,f)}),s=s.slice(f))}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," "))}return e.version="1.2.
|
|
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_ast=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 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 p=t+2;for(;p<e.length;){const t=e[p];if(!t.includes("|")||""===t.trim())break;const n=s(t);u.push(n.map(e=>c(e.trim()))),p++}return{node:{type:"table",headers:h,rows:u,alignments:o},nextIndex:p}}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,p]=t,d=n.length;if(d<u)break;const f=/^\d+\./.test(o);if(d===u&&f!==h)break;if(d>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 a={type:"list_item",checked:null,children:null},g=p.match(/^\[([x ])\]\s*(.*)$/i);g&&!h?(a.checked="x"===g[1].toLowerCase(),a.children=c(g[2])):a.children=c(p),s.push(a),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 t=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"image",alt:t[1],url:t[2].trim()}),s=s.slice(t[0].length);continue}const i=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),s=s.slice(i[0].length);continue}const c=s.match(/^`([^`]+)`/);if(c){n.push({type:"code",value:c[1]}),s=s.slice(c[0].length);continue}const r=s.match(/^(\*\*|__)(.+?)\1/);if(r){n.push({type:"strong",children:l(r[2])}),s=s.slice(r[0].length);continue}const o=s.match(/^~~(.+?)~~/);if(o){n.push({type:"del",children:l(o[1])}),s=s.slice(o[0].length);continue}const h=e[e.length-s.length-1]||"",u=!/[A-Za-z0-9_]/.test(h),p=s.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&s.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(p){n.push({type:"em",children:l(p[1])}),s=s.slice(p[0].length);continue}const d=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){n.push({type:"link",url:d[1],children:[{type:"text",value:d[1]}]}),s=s.slice(d[0].length);continue}const f=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===f){n.push({type:"text",value:s});break}0===f?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,f)}),s=s.slice(f))}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," "))}return e.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e),e});
|
|
8
8
|
//# sourceMappingURL=quikdown_ast.umd.min.js.map
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast_html - AST to HTML Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.
|
|
18
|
+
const quikdownVersion$1 = '1.2.15';
|
|
19
19
|
|
|
20
20
|
// Safety limit to prevent infinite loops in list parsing
|
|
21
21
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -512,7 +512,7 @@ if (typeof window !== 'undefined') {
|
|
|
512
512
|
|
|
513
513
|
|
|
514
514
|
// Version will be injected at build time
|
|
515
|
-
const quikdownVersion = '1.2.
|
|
515
|
+
const quikdownVersion = '1.2.15';
|
|
516
516
|
|
|
517
517
|
// Constants
|
|
518
518
|
const CLASS_PREFIX = 'quikdown-';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast_html - AST to HTML Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.
|
|
16
|
+
const quikdownVersion$1 = '1.2.15';
|
|
17
17
|
|
|
18
18
|
// Safety limit to prevent infinite loops in list parsing
|
|
19
19
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -510,7 +510,7 @@ if (typeof window !== 'undefined') {
|
|
|
510
510
|
|
|
511
511
|
|
|
512
512
|
// Version will be injected at build time
|
|
513
|
-
const quikdownVersion = '1.2.
|
|
513
|
+
const quikdownVersion = '1.2.15';
|
|
514
514
|
|
|
515
515
|
// Constants
|
|
516
516
|
const CLASS_PREFIX = 'quikdown-';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast_html - AST to HTML Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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,r){const l=[],c=e.split("\n");let o=0;for(;o<c.length;){const e=c[o];if(""===e.trim()){o++;continue}const r=e.match(/^(```|~~~)(.*)$/);if(r){const[,e,t]=r,n=t.trim(),i=[];for(o++;o<c.length;){if(c[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(c[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 a=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(a){const[,e,t]=a;l.push({type:"heading",level:e.length,children:s(t)}),o++;continue}if(e.includes("|")){const e=n(c,o);if(e){l.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<c.length&&c[o].match(/^>\s*/);)e.push(c[o].replace(/^>\s*/,"")),o++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(c,o);l.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<c.length;){const e=c[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<c.length&&/^\|?[\s\-:|]+\|?$/.test(c[o+1]))break;u.push(e),o++}u.length>0&&l.push({type:"paragraph",children:s(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 c=r(i);if(0===c.length)return null;const o=r(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=c.map(e=>s(e.trim())),u=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=r(t);u.push(n.map(e=>s(e.trim()))),h++}return{node:{type:"table",headers:a,rows:u,alignments:o},nextIndex:h}}function r(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 r=[];let l=t,c=0;const o=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;l<e.length&&c<1e3;){c++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,h]=t,d=n.length;if(d<u)break;const f=/^\d+\./.test(o);if(d===u&&f!==a)break;if(d>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const r=e[l],i=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(r),l++}if(t.length>0&&r.length>0){const e=i(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=h.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=s(g[2])):p.children=s(h),r.push(p),l++}return{node:{type:"list",ordered:a,items:r},nextIndex:l}}function s(e,t){if(!e)return[];const n=[];let r=e;for(;r.length>0;){if(r.match(/^(.+?)(?: {2}|\\\n|\n)/)&&r.includes("\n")){const e=r.indexOf("\n"),t=r.slice(0,e),i=r.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),r=i;continue}}const t=r.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"image",alt:t[1],url:t[2].trim()}),r=r.slice(t[0].length);continue}const i=r.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),r=r.slice(i[0].length);continue}const s=r.match(/^`([^`]+)`/);if(s){n.push({type:"code",value:s[1]}),r=r.slice(s[0].length);continue}const c=r.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),r=r.slice(c[0].length);continue}const o=r.match(/^~~(.+?)~~/);if(o){n.push({type:"del",children:l(o[1])}),r=r.slice(o[0].length);continue}const a=e[e.length-r.length-1]||"",u=!/[A-Za-z0-9_]/.test(a),h=r.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&r.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(h){n.push({type:"em",children:l(h[1])}),r=r.slice(h[0].length);continue}const d=r.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){n.push({type:"link",url:d[1],children:[{type:"text",value:d[1]}]}),r=r.slice(d[0].length);continue}const f=r.search(/[`*_~![\\n]|https?:\/\//);if(-1===f){n.push({type:"text",value:r});break}0===f?(n.push({type:"text",value:r[0]}),r=r.slice(1)):(n.push({type:"text",value:r.slice(0,f)}),r=r.slice(f))}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 s(e.replace(/\n/g," "))}e.version="1.2.14","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const c="quikdown-",o={"&":"&","<":"<",">":">",'"':""","'":"'"},a={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;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"};function u(e){return e?String(e).replace(/[&<>"']/g,e=>o[e]):""}function h(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&/gi,"&").replace(/</gi,"<").replace(/>/gi,">").replace(/"/gi,'"').replace(/'|'/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const s=i.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(s.startsWith(e))return"data:"===e&&s.startsWith("data:image/")?n:"#";return n}function d(t,n={}){if(!t)return{type:"document",children:[]};if("object"==typeof t&&t.type)return t;if("string"==typeof t){const r=t.trim();if(r.startsWith("{")||r.startsWith("["))try{const e=JSON.parse(r);return"document"===e.type?e:Array.isArray(e)?{type:"document",children:e}:e}catch(e){}if(r.includes("type:")&&(r.includes("children:")||r.includes("value:")))try{const e=f(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function f(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return f(e,t+1,n);const s=r.search(/\S/);if(s<n&&s>=0)return{value:null,nextLine:t};if(i.startsWith("- "))return function(e,t,n){const r=[];let i=t;for(;i<e.length;){const t=e[i],s=t.trim();if(""===s){i++;continue}const l=t.search(/\S/);if(l<n&&l>=0)break;if(l>n&&r.length>0){i++;continue}if(!s.startsWith("- "))break;const c=s.slice(2);if(c.includes(":")){const t={},s=c.indexOf(":"),o=c.slice(0,s).trim(),a=c.slice(s+1).trim();if(""===a||a.startsWith("\n")){const n=f(e,i+1,l+2);t[o]=n.value,i=n.nextLine}else t[o]=p(a),i++;for(;i<e.length;){const r=e[i],s=r.trim();if(""===s){i++;continue}const l=r.search(/\S/);if(l<=n)break;if(s.startsWith("- "))break;const c=s.indexOf(":");if(c>0){const n=s.slice(0,c).trim(),r=s.slice(c+1).trim();if(""===r||r.startsWith("\n")){const r=f(e,i+1,l+2);t[n]=r.value,i=r.nextLine}else t[n]=p(r),i++}else i++}r.push(t)}else r.push(p(c)),i++}return{value:r,nextLine:i}}(e,t,s);if("[]"===i)return{value:[],nextLine:t+1};if("{}"===i)return{value:{},nextLine:t+1};return i.indexOf(":")>0?function(e,t,n){const r={};let i=t;for(;i<e.length;){const t=e[i],s=t.trim();if(""===s){i++;continue}const l=t.search(/\S/);if(l<n&&l>=0)break;const c=s.indexOf(":");if(c<=0){i++;continue}const o=s.slice(0,c).trim(),a=s.slice(c+1).trim();if(""===a||"|"===a||">"===a){const t=f(e,i+1,l+2);r[o]=t.value,i=t.nextLine}else r[o]=p(a),i++}return{value:r,nextLine:i}}(e,t,s):{value:p(i),nextLine:t+1}}function p(e){if(!e)return null;const t=e.trim();return"null"===t||"~"===t?null:"true"===t||"false"!==t&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1).replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t)}function g(e,t={}){return m(d(e,t),t)}function m(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=a[t];return e||n?(n&&n.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${n?e?`${e}${n}`:n:e}"`):""}{const e=` class="${c}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return $(e,r,t)}function $(e,t,n){if(!e)return"";switch(e.type){case"document":return x(e.children,t,n);case"paragraph":return`<p>${x(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${x(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${u(e.lang)}"`:"",s=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${s}>${u(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${x(e.children,t,n)}</blockquote>`;case"list":const l=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>$(e,t,n)).join("");return`<${l}${t(l)}>${o}</${l}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${c}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${c}task-item"`}><input type="checkbox"${r}${i} disabled> ${x(e.children,t,n)}</li>`}return`<li${t("li")}>${x(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[];let i=`<table${t("table")}>\n`;e.headers&&e.headers.length>0&&(i+="<thead>\n<tr>\n",e.headers.forEach((e,s)=>{const l=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<th${t("th",l)}>${x(e,t,n)}</th>\n`}),i+="</tr>\n</thead>\n");e.rows&&e.rows.length>0&&(i+="<tbody>\n",e.rows.forEach(e=>{i+="<tr>\n",e.forEach((e,s)=>{const l=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<td${t("td",l)}>${x(e,t,n)}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n");return i+="</table>",i}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return u(e.value||"");case"strong":return`<strong${t("strong")}>${x(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${x(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${x(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${u(e.value||"")}</code>`;case"link":const a=h(e.url,n.allow_unsafe_urls),d=/^https?:\/\//i.test(a)?' rel="noopener noreferrer"':"";return`<a${t("a")} href="${a}"${d}>${x(e.children,t,n)}</a>`;case"image":const f=h(e.url,n.allow_unsafe_urls);return`<img${t("img")} src="${f}" alt="${u(e.alt||"")}">`;case"br":return"<br>";default:return e.children?x(e.children,t,n):void 0!==e.value?u(String(e.value)):""}}function x(e,t,n){return e?Array.isArray(e)?e.map(e=>$(e,t,n)).join(""):$(e,t,n):""}g.toAst=d,g.renderAst=m,g.version="1.2.14","undefined"!=typeof module&&module.exports&&(module.exports=g),"undefined"!=typeof window&&(window.quikdown_ast_html=g);export{g 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,r){const l=[],c=e.split("\n");let o=0;for(;o<c.length;){const e=c[o];if(""===e.trim()){o++;continue}const r=e.match(/^(```|~~~)(.*)$/);if(r){const[,e,t]=r,n=t.trim(),i=[];for(o++;o<c.length;){if(c[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(c[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 a=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(a){const[,e,t]=a;l.push({type:"heading",level:e.length,children:s(t)}),o++;continue}if(e.includes("|")){const e=n(c,o);if(e){l.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<c.length&&c[o].match(/^>\s*/);)e.push(c[o].replace(/^>\s*/,"")),o++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(c,o);l.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<c.length;){const e=c[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<c.length&&/^\|?[\s\-:|]+\|?$/.test(c[o+1]))break;u.push(e),o++}u.length>0&&l.push({type:"paragraph",children:s(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 c=r(i);if(0===c.length)return null;const o=r(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=c.map(e=>s(e.trim())),u=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=r(t);u.push(n.map(e=>s(e.trim()))),h++}return{node:{type:"table",headers:a,rows:u,alignments:o},nextIndex:h}}function r(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 r=[];let l=t,c=0;const o=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;l<e.length&&c<1e3;){c++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,h]=t,d=n.length;if(d<u)break;const f=/^\d+\./.test(o);if(d===u&&f!==a)break;if(d>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const r=e[l],i=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(r),l++}if(t.length>0&&r.length>0){const e=i(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=h.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=s(g[2])):p.children=s(h),r.push(p),l++}return{node:{type:"list",ordered:a,items:r},nextIndex:l}}function s(e,t){if(!e)return[];const n=[];let r=e;for(;r.length>0;){if(r.match(/^(.+?)(?: {2}|\\\n|\n)/)&&r.includes("\n")){const e=r.indexOf("\n"),t=r.slice(0,e),i=r.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),r=i;continue}}const t=r.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"image",alt:t[1],url:t[2].trim()}),r=r.slice(t[0].length);continue}const i=r.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(i){n.push({type:"link",url:i[2].trim(),children:l(i[1])}),r=r.slice(i[0].length);continue}const s=r.match(/^`([^`]+)`/);if(s){n.push({type:"code",value:s[1]}),r=r.slice(s[0].length);continue}const c=r.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),r=r.slice(c[0].length);continue}const o=r.match(/^~~(.+?)~~/);if(o){n.push({type:"del",children:l(o[1])}),r=r.slice(o[0].length);continue}const a=e[e.length-r.length-1]||"",u=!/[A-Za-z0-9_]/.test(a),h=r.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||u&&r.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(h){n.push({type:"em",children:l(h[1])}),r=r.slice(h[0].length);continue}const d=r.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){n.push({type:"link",url:d[1],children:[{type:"text",value:d[1]}]}),r=r.slice(d[0].length);continue}const f=r.search(/[`*_~![\\n]|https?:\/\//);if(-1===f){n.push({type:"text",value:r});break}0===f?(n.push({type:"text",value:r[0]}),r=r.slice(1)):(n.push({type:"text",value:r.slice(0,f)}),r=r.slice(f))}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 s(e.replace(/\n/g," "))}e.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const c="quikdown-",o={"&":"&","<":"<",">":">",'"':""","'":"'"},a={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;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"};function u(e){return e?String(e).replace(/[&<>"']/g,e=>o[e]):""}function h(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&/gi,"&").replace(/</gi,"<").replace(/>/gi,">").replace(/"/gi,'"').replace(/'|'/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const s=i.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(s.startsWith(e))return"data:"===e&&s.startsWith("data:image/")?n:"#";return n}function d(t,n={}){if(!t)return{type:"document",children:[]};if("object"==typeof t&&t.type)return t;if("string"==typeof t){const r=t.trim();if(r.startsWith("{")||r.startsWith("["))try{const e=JSON.parse(r);return"document"===e.type?e:Array.isArray(e)?{type:"document",children:e}:e}catch(e){}if(r.includes("type:")&&(r.includes("children:")||r.includes("value:")))try{const e=f(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function f(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return f(e,t+1,n);const s=r.search(/\S/);if(s<n&&s>=0)return{value:null,nextLine:t};if(i.startsWith("- "))return function(e,t,n){const r=[];let i=t;for(;i<e.length;){const t=e[i],s=t.trim();if(""===s){i++;continue}const l=t.search(/\S/);if(l<n&&l>=0)break;if(l>n&&r.length>0){i++;continue}if(!s.startsWith("- "))break;const c=s.slice(2);if(c.includes(":")){const t={},s=c.indexOf(":"),o=c.slice(0,s).trim(),a=c.slice(s+1).trim();if(""===a||a.startsWith("\n")){const n=f(e,i+1,l+2);t[o]=n.value,i=n.nextLine}else t[o]=p(a),i++;for(;i<e.length;){const r=e[i],s=r.trim();if(""===s){i++;continue}const l=r.search(/\S/);if(l<=n)break;if(s.startsWith("- "))break;const c=s.indexOf(":");if(c>0){const n=s.slice(0,c).trim(),r=s.slice(c+1).trim();if(""===r||r.startsWith("\n")){const r=f(e,i+1,l+2);t[n]=r.value,i=r.nextLine}else t[n]=p(r),i++}else i++}r.push(t)}else r.push(p(c)),i++}return{value:r,nextLine:i}}(e,t,s);if("[]"===i)return{value:[],nextLine:t+1};if("{}"===i)return{value:{},nextLine:t+1};return i.indexOf(":")>0?function(e,t,n){const r={};let i=t;for(;i<e.length;){const t=e[i],s=t.trim();if(""===s){i++;continue}const l=t.search(/\S/);if(l<n&&l>=0)break;const c=s.indexOf(":");if(c<=0){i++;continue}const o=s.slice(0,c).trim(),a=s.slice(c+1).trim();if(""===a||"|"===a||">"===a){const t=f(e,i+1,l+2);r[o]=t.value,i=t.nextLine}else r[o]=p(a),i++}return{value:r,nextLine:i}}(e,t,s):{value:p(i),nextLine:t+1}}function p(e){if(!e)return null;const t=e.trim();return"null"===t||"~"===t?null:"true"===t||"false"!==t&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1).replace(/\\n/g,"\n").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t)}function g(e,t={}){return m(d(e,t),t)}function m(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=a[t];return e||n?(n&&n.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${n?e?`${e}${n}`:n:e}"`):""}{const e=` class="${c}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return $(e,r,t)}function $(e,t,n){if(!e)return"";switch(e.type){case"document":return x(e.children,t,n);case"paragraph":return`<p>${x(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${x(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${u(e.lang)}"`:"",s=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${s}>${u(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${x(e.children,t,n)}</blockquote>`;case"list":const l=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>$(e,t,n)).join("");return`<${l}${t(l)}>${o}</${l}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${c}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${c}task-item"`}><input type="checkbox"${r}${i} disabled> ${x(e.children,t,n)}</li>`}return`<li${t("li")}>${x(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[];let i=`<table${t("table")}>\n`;e.headers&&e.headers.length>0&&(i+="<thead>\n<tr>\n",e.headers.forEach((e,s)=>{const l=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<th${t("th",l)}>${x(e,t,n)}</th>\n`}),i+="</tr>\n</thead>\n");e.rows&&e.rows.length>0&&(i+="<tbody>\n",e.rows.forEach(e=>{i+="<tr>\n",e.forEach((e,s)=>{const l=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<td${t("td",l)}>${x(e,t,n)}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n");return i+="</table>",i}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return u(e.value||"");case"strong":return`<strong${t("strong")}>${x(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${x(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${x(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${u(e.value||"")}</code>`;case"link":const a=h(e.url,n.allow_unsafe_urls),d=/^https?:\/\//i.test(a)?' rel="noopener noreferrer"':"";return`<a${t("a")} href="${a}"${d}>${x(e.children,t,n)}</a>`;case"image":const f=h(e.url,n.allow_unsafe_urls);return`<img${t("img")} src="${f}" alt="${u(e.alt||"")}">`;case"br":return"<br>";default:return e.children?x(e.children,t,n):void 0!==e.value?u(String(e.value)):""}}function x(e,t,n){return e?Array.isArray(e)?e.map(e=>$(e,t,n)).join(""):$(e,t,n):""}g.toAst=d,g.renderAst=m,g.version="1.2.15","undefined"!=typeof module&&module.exports&&(module.exports=g),"undefined"!=typeof window&&(window.quikdown_ast_html=g);export{g as default};
|
|
8
8
|
//# sourceMappingURL=quikdown_ast_html.esm.min.js.map
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* quikdown_ast_html - AST to HTML Markdown Parser
|
|
3
|
-
* @version 1.2.
|
|
3
|
+
* @version 1.2.15
|
|
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.
|
|
22
|
+
const quikdownVersion$1 = '1.2.15';
|
|
23
23
|
|
|
24
24
|
// Safety limit to prevent infinite loops in list parsing
|
|
25
25
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
|
|
517
517
|
|
|
518
518
|
// Version will be injected at build time
|
|
519
|
-
const quikdownVersion = '1.2.
|
|
519
|
+
const quikdownVersion = '1.2.15';
|
|
520
520
|
|
|
521
521
|
// Constants
|
|
522
522
|
const CLASS_PREFIX = 'quikdown-';
|