quikdown 1.2.11 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +2 -2
- package/dist/quikdown_edit.esm.js +2 -2
- package/dist/quikdown_edit.esm.min.js +2 -2
- package/dist/quikdown_edit.esm.min.js.gz +0 -0
- package/dist/quikdown_edit.umd.js +2 -2
- package/dist/quikdown_edit.umd.min.js +2 -2
- package/dist/quikdown_edit.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 -3
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -114,7 +114,7 @@ function isDashHRLine(trimmed) {
|
|
|
114
114
|
// ────────────────────────────────────────────────────────────────────
|
|
115
115
|
|
|
116
116
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
117
|
-
const quikdownVersion = '1.2.
|
|
117
|
+
const quikdownVersion = '1.2.12';
|
|
118
118
|
|
|
119
119
|
/** CSS class prefix used for all generated elements */
|
|
120
120
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -112,7 +112,7 @@ function isDashHRLine(trimmed) {
|
|
|
112
112
|
// ────────────────────────────────────────────────────────────────────
|
|
113
113
|
|
|
114
114
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
115
|
-
const quikdownVersion = '1.2.
|
|
115
|
+
const quikdownVersion = '1.2.12';
|
|
116
116
|
|
|
117
117
|
/** CSS class prefix used for all generated elements */
|
|
118
118
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
function e(e){if(e.length<3)return!1;for(let t=0;t<e.length;t++){const n=e[t];if("-"!==n){if(" "===n||"\t"===n){for(let n=t+1;n<e.length;n++)if(" "!==e[n]&&"\t"!==e[n])return!1;return t>=3}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;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 c(c,s={}){if(!c||"string"!=typeof c)return"";const{fence_plugin:p,inline_styles:g=!1,bidirectional:d=!1,lazy_linefeeds:f=!1,allow_unsafe_html:u=!1}=s,$=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}}}(g,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=d?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 _=c;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=[],w=Array.isArray(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u:null;w&&(_=_.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 w){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,c=[];let s;for(;null!==(s=a.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)c.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),c.push(`${e}="${n}"`)}}return n+(c.length?" "+c.join(" "):"")+l}(e),n=k.length;return k.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),w&&k.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t){const n=e.split("\n"),r=[];let o=!1,l=[];for(let e=0;e<n.length;e++){const a=n[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))o||(o=!0,l=[]),l.push(a);else{if(o){const e=i(l,t);e?r.push(e):r.push(...l),o=!1,l=[]}r.push(n[e])}}if(o&&l.length>0){const e=i(l,t);e?r.push(e):r.push(...l)}return r.join("\n")}(_,$),_=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 c=0;for(;c<t.length&&c<7&&"#"===t[c];)c++;if(c>=1&&c<=6&&" "===t[c]){const e=t.slice(c+1).replace(/\s*#+\s*$/,""),o="h"+c;l.push(`<${o}${n(o)}${r("#".repeat(c))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}>`),a++):/^>\s+/.test(t)?(l.push(`<blockquote${n("blockquote")}>${t.replace(/^>\s+/,"")}</blockquote>`),a++):(l.push(t),a++)}let c=l.join("\n");return c=c.replace(/<\/blockquote>\n<blockquote>/g,"\n"),c}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],c=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,p=Math.floor(e.length/2),g=/^\d+\./.test(o),d=g?"ol":"ul";let f=l,u="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!g){const[,e,n]=$,o="x"===e.toLowerCase();f=`<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(;c.length>p+1;){const e=c.pop();a.push(`</${e.type}>`)}if(c.length===p)c.push({type:d,level:p}),a.push(`<${d}${n(d)}>`);else if(c.length===p+1){const e=c[c.length-1];e.type!==d&&(a.push(`</${e.type}>`),c.pop(),c.push({type:d,level:p}),a.push(`<${d}${n(d)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${f}</li>`)}else{for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,g,d),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=d&&t?` data-qd-alt="${h(t)}"`:"",l=d?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=d?` 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,s.allow_unsafe_urls);return`${t}<a${$("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const y=[];_=_.replace(/<[^>]+>/g,e=>(y.push(e),`%%T${y.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{_=_.replace(e,`<${t}${$(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>y[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=!g&&e.lang?` class="language-${e.lang}"`:"",n=g?$("code"):t,o=d&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=d?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else d&&(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=!g&&e.lang?` class="language-${e.lang}"`:"",n=g?$("code"):t,o=d&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=d?` 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 s(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const r=e.slice(0,n),o=e.slice(n+1),l=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let a=`<table${t("table")}>\n`;return a+=`<thead${t("thead")}>\n`,r.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<th${t("th",r)}>${o}</th>\n`}),a+="</tr>\n"}),a+="</thead>\n",o.length>0&&(a+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<td${t("td",r)}>${o}</td>\n`}),a+="</tr>\n"}),a+="</tbody>\n"),a+="</table>",a}c.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,c]of Object.entries(n)){let n=c;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},c.configure=function(e){return function(t){return c(t,e)}},c.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=c),"undefined"!=typeof window&&(window.quikdown=c);export{c as default};
|
|
7
|
+
function e(e){if(e.length<3)return!1;for(let t=0;t<e.length;t++){const n=e[t];if("-"!==n){if(" "===n||"\t"===n){for(let n=t+1;n<e.length;n++)if(" "!==e[n]&&"\t"!==e[n])return!1;return t>=3}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;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 c(c,s={}){if(!c||"string"!=typeof c)return"";const{fence_plugin:p,inline_styles:g=!1,bidirectional:d=!1,lazy_linefeeds:f=!1,allow_unsafe_html:u=!1}=s,$=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}}}(g,a);function h(e){return e.replace(/[&<>"']/g,e=>l[e])}const m=d?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 _=c;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=[],w=Array.isArray(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u:null;w&&(_=_.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 w){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,c=[];let s;for(;null!==(s=a.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)c.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),c.push(`${e}="${n}"`)}}return n+(c.length?" "+c.join(" "):"")+l}(e),n=k.length;return k.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),w&&k.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t){const n=e.split("\n"),r=[];let o=!1,l=[];for(let e=0;e<n.length;e++){const a=n[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))o||(o=!0,l=[]),l.push(a);else{if(o){const e=i(l,t);e?r.push(e):r.push(...l),o=!1,l=[]}r.push(n[e])}}if(o&&l.length>0){const e=i(l,t);e?r.push(e):r.push(...l)}return r.join("\n")}(_,$),_=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 c=0;for(;c<t.length&&c<7&&"#"===t[c];)c++;if(c>=1&&c<=6&&" "===t[c]){const e=t.slice(c+1).replace(/\s*#+\s*$/,""),o="h"+c;l.push(`<${o}${n(o)}${r("#".repeat(c))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}>`),a++):/^>\s+/.test(t)?(l.push(`<blockquote${n("blockquote")}>${t.replace(/^>\s+/,"")}</blockquote>`),a++):(l.push(t),a++)}let c=l.join("\n");return c=c.replace(/<\/blockquote>\n<blockquote>/g,"\n"),c}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],c=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,p=Math.floor(e.length/2),g=/^\d+\./.test(o),d=g?"ol":"ul";let f=l,u="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!g){const[,e,n]=$,o="x"===e.toLowerCase();f=`<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(;c.length>p+1;){const e=c.pop();a.push(`</${e.type}>`)}if(c.length===p)c.push({type:d,level:p}),a.push(`<${d}${n(d)}>`);else if(c.length===p+1){const e=c[c.length-1];e.type!==d&&(a.push(`</${e.type}>`),c.pop(),c.push({type:d,level:p}),a.push(`<${d}${n(d)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${f}</li>`)}else{for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,g,d),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=d&&t?` data-qd-alt="${h(t)}"`:"",l=d?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=d?` 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,s.allow_unsafe_urls);return`${t}<a${$("a")} href="${r}" rel="noopener noreferrer">${n}</a>`});const y=[];_=_.replace(/<[^>]+>/g,e=>(y.push(e),`%%T${y.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{_=_.replace(e,`<${t}${$(t)}${m(n)}>$1</${t}>`)}),_=_.replace(/%%T(\d+)%%/g,(e,t)=>y[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=!g&&e.lang?` class="language-${e.lang}"`:"",n=g?$("code"):t,o=d&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=d?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else d&&(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=!g&&e.lang?` class="language-${e.lang}"`:"",n=g?$("code"):t,o=d&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=d?` 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 s(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const r=e.slice(0,n),o=e.slice(n+1),l=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let a=`<table${t("table")}>\n`;return a+=`<thead${t("thead")}>\n`,r.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<th${t("th",r)}>${o}</th>\n`}),a+="</tr>\n"}),a+="</thead>\n",o.length>0&&(a+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<td${t("td",r)}>${o}</td>\n`}),a+="</tr>\n"}),a+="</tbody>\n"),a+="</table>",a}c.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,c]of Object.entries(n)){let n=c;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},c.configure=function(e){return function(t){return c(t,e)}},c.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=c),"undefined"!=typeof window&&(window.quikdown=c);export{c 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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
// ────────────────────────────────────────────────────────────────────
|
|
119
119
|
|
|
120
120
|
/** Build-time version stamp (injected by tools/updateVersion) */
|
|
121
|
-
const quikdownVersion = '1.2.
|
|
121
|
+
const quikdownVersion = '1.2.12';
|
|
122
122
|
|
|
123
123
|
/** CSS class prefix used for all generated elements */
|
|
124
124
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown=t()}(this,function(){"use strict";function e(e){if(e.length<3)return!1;for(let t=0;t<e.length;t++){const n=e[t];if("-"!==n){if(" "===n||"\t"===n){for(let n=t+1;n<e.length;n++)if(" "!==e[n]&&"\t"!==e[n])return!1;return t>=3}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;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 c(c,s={}){if(!c||"string"!=typeof c)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:f=!1,lazy_linefeeds:g=!1,allow_unsafe_html:u=!1}=s,$=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=f?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 _=c;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(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u: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,c=[];let s;for(;null!==(s=a.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)c.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),c.push(`${e}="${n}"`)}}return n+(c.length?" "+c.join(" "):"")+l}(e),n=y.length;return y.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),k&&y.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t){const n=e.split("\n"),r=[];let o=!1,l=[];for(let e=0;e<n.length;e++){const a=n[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))o||(o=!0,l=[]),l.push(a);else{if(o){const e=i(l,t);e?r.push(e):r.push(...l),o=!1,l=[]}r.push(n[e])}}if(o&&l.length>0){const e=i(l,t);e?r.push(e):r.push(...l)}return r.join("\n")}(_,$),_=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 c=0;for(;c<t.length&&c<7&&"#"===t[c];)c++;if(c>=1&&c<=6&&" "===t[c]){const e=t.slice(c+1).replace(/\s*#+\s*$/,""),o="h"+c;l.push(`<${o}${n(o)}${r("#".repeat(c))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}>`),a++):/^>\s+/.test(t)?(l.push(`<blockquote${n("blockquote")}>${t.replace(/^>\s+/,"")}</blockquote>`),a++):(l.push(t),a++)}let c=l.join("\n");return c=c.replace(/<\/blockquote>\n<blockquote>/g,"\n"),c}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],c=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,p=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let g=l,u="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!d){const[,e,n]=$,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(;c.length>p+1;){const e=c.pop();a.push(`</${e.type}>`)}if(c.length===p)c.push({type:f,level:p}),a.push(`<${f}${n(f)}>`);else if(c.length===p+1){const e=c[c.length-1];e.type!==f&&(a.push(`</${e.type}>`),c.pop(),c.push({type:f,level:p}),a.push(`<${f}${n(f)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${g}</li>`)}else{for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,d,f),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=f&&t?` data-qd-alt="${h(t)}"`:"",l=f?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=f?` 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,s.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","*"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{_=_.replace(e,`<${t}${$(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${$("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-${e.lang}"`:"",n=d?$("code"):t,o=f&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=f?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else f&&(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-${e.lang}"`:"",n=d?$("code"):t,o=f&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=f?` 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 s(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const r=e.slice(0,n),o=e.slice(n+1),l=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let a=`<table${t("table")}>\n`;return a+=`<thead${t("thead")}>\n`,r.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<th${t("th",r)}>${o}</th>\n`}),a+="</tr>\n"}),a+="</thead>\n",o.length>0&&(a+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<td${t("td",r)}>${o}</td>\n`}),a+="</tr>\n"}),a+="</tbody>\n"),a+="</table>",a}return c.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,c]of Object.entries(n)){let n=c;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},c.configure=function(e){return function(t){return c(t,e)}},c.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=c),"undefined"!=typeof window&&(window.quikdown=c),c});
|
|
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;for(let t=0;t<e.length;t++){const n=e[t];if("-"!==n){if(" "===n||"\t"===n){for(let n=t+1;n<e.length;n++)if(" "!==e[n]&&"\t"!==e[n])return!1;return t>=3}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;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 c(c,s={}){if(!c||"string"!=typeof c)return"";const{fence_plugin:p,inline_styles:d=!1,bidirectional:f=!1,lazy_linefeeds:g=!1,allow_unsafe_html:u=!1}=s,$=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=f?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 _=c;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(u)?Object.fromEntries(u.map(e=>[e,1])):u&&"object"==typeof u?u: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,c=[];let s;for(;null!==(s=a.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)c.push(e);else{let n=t;e.toLowerCase()in o&&(n=b(t)),c.push(`${e}="${n}"`)}}return n+(c.length?" "+c.join(" "):"")+l}(e),n=y.length;return y.push(t),`${r}${n}§`}return e})),!0!==u&&(_=h(_)),k&&y.forEach((e,t)=>{_=_.replace(`${r}${t}§`,e)}),_=function(e,t){const n=e.split("\n"),r=[];let o=!1,l=[];for(let e=0;e<n.length;e++){const a=n[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))o||(o=!0,l=[]),l.push(a);else{if(o){const e=i(l,t);e?r.push(e):r.push(...l),o=!1,l=[]}r.push(n[e])}}if(o&&l.length>0){const e=i(l,t);e?r.push(e):r.push(...l)}return r.join("\n")}(_,$),_=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 c=0;for(;c<t.length&&c<7&&"#"===t[c];)c++;if(c>=1&&c<=6&&" "===t[c]){const e=t.slice(c+1).replace(/\s*#+\s*$/,""),o="h"+c;l.push(`<${o}${n(o)}${r("#".repeat(c))}>${e}</${o}>`),a++;continue}e(t)?(l.push(`<hr${n("hr")}>`),a++):/^>\s+/.test(t)?(l.push(`<blockquote${n("blockquote")}>${t.replace(/^>\s+/,"")}</blockquote>`),a++):(l.push(t),a++)}let c=l.join("\n");return c=c.replace(/<\/blockquote>\n<blockquote>/g,"\n"),c}(_,$,m),_=function(e,n,r,o){const l=e.split("\n"),a=[],c=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,p=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let g=l,u="";const $=l.match(/^\[([x ])\]\s+(.*)$/i);if($&&!d){const[,e,n]=$,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(;c.length>p+1;){const e=c.pop();a.push(`</${e.type}>`)}if(c.length===p)c.push({type:f,level:p}),a.push(`<${f}${n(f)}>`);else if(c.length===p+1){const e=c[c.length-1];e.type!==f&&(a.push(`</${e.type}>`),c.pop(),c.push({type:f,level:p}),a.push(`<${f}${n(f)}>`))}const h=u||n("li");a.push(`<li${h}${i(o)}>${g}</li>`)}else{for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}a.push(o)}}for(;c.length>0;){const e=c.pop();a.push(`</${e.type}>`)}return a.join("\n")}(_,$,d,f),_=_.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=f&&t?` data-qd-alt="${h(t)}"`:"",l=f?` data-qd-src="${h(n)}"`:"";return`<img${$("img")} src="${r}" alt="${t}"${o}${l}${m("!")}>`}),_=_.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const r=b(n,s.allow_unsafe_urls),o=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=f?` 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,s.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","*"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{_=_.replace(e,`<${t}${$(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${$("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-${e.lang}"`:"",n=d?$("code"):t,o=f&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=f?` data-qd-fence="${h(e.fence)}"`:"";r=`<pre${$("pre")}${l}${o}><code${n}>${h(e.code)}</code></pre>`}else f&&(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-${e.lang}"`:"",n=d?$("code"):t,o=f&&e.lang?` data-qd-lang="${h(e.lang)}"`:"",l=f?` 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 s(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const r=e.slice(0,n),o=e.slice(n+1),l=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let a=`<table${t("table")}>\n`;return a+=`<thead${t("thead")}>\n`,r.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<th${t("th",r)}>${o}</th>\n`}),a+="</tr>\n"}),a+="</thead>\n",o.length>0&&(a+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{a+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const r=l[n]&&"left"!==l[n]?`text-align:${l[n]}`:"",o=s(e.trim(),t);a+=`<td${t("td",r)}>${o}</td>\n`}),a+="</tr>\n"}),a+="</tbody>\n"),a+="</table>",a}return c.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,c]of Object.entries(n)){let n=c;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},c.configure=function(e){return function(t){return c(t,e)}},c.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=c),"undefined"!=typeof window&&(window.quikdown=c),c});
|
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
// Version will be injected at build time
|
|
18
|
-
const quikdownVersion = '1.2.
|
|
18
|
+
const quikdownVersion = '1.2.12';
|
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// Version will be injected at build time
|
|
16
|
-
const quikdownVersion = '1.2.
|
|
16
|
+
const quikdownVersion = '1.2.12';
|
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const l=[],r=e.split("\n");let h=0;for(;h<r.length;){const e=r[h];if(""===e.trim()){h++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.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:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),h++;continue}const o=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(o){const[,e,t]=o;l.push({type:"heading",level:e.length,children:c(t)}),h++;continue}if(e.includes("|")){const e=n(r,h);if(e){l.push(e.node),h=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;h<r.length&&r[h].match(/^>\s*/);)e.push(r[h].replace(/^>\s*/,"")),h++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(r,h);l.push(e.node),h=e.nextIndex;continue}const u=[];for(;h<r.length;){const e=r[h];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("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;u.push(e),h++}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 h=s(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),o=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:o,rows:u,alignments:h},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 h=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),o=/^\d+\./.test(h[2]),u=h[1].length;for(;l<e.length&&r<1e3;){r++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,h,p]=t,a=n.length;if(a<u)break;const d=/^\d+\./.test(h);if(a===u&&d!==o)break;if(a>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const s=e[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),l++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const f={type:"list_item",checked:null,children:null},g=p.match(/^\[([x ])\]\s*(.*)$/i);g&&!o?(f.checked="x"===g[1].toLowerCase(),f.children=c(g[2])):f.children=c(p),s.push(f),l++}return{node:{type:"list",ordered:o,items:s},nextIndex:l}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const h=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(h){n.push({type:"em",children:l(h[2])}),s=s.slice(h[0].length);continue}const o=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(o){n.push({type:"link",url:o[1],children:[{type:"text",value:o[1]}]}),s=s.slice(o[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.
|
|
7
|
+
function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,s){const l=[],r=e.split("\n");let h=0;for(;h<r.length;){const e=r[h];if(""===e.trim()){h++;continue}const s=e.match(/^(```|~~~)(.*)$/);if(s){const[,e,t]=s,n=t.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:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),h++;continue}const o=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(o){const[,e,t]=o;l.push({type:"heading",level:e.length,children:c(t)}),h++;continue}if(e.includes("|")){const e=n(r,h);if(e){l.push(e.node),h=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;h<r.length&&r[h].match(/^>\s*/);)e.push(r[h].replace(/^>\s*/,"")),h++;l.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(r,h);l.push(e.node),h=e.nextIndex;continue}const u=[];for(;h<r.length;){const e=r[h];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("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;u.push(e),h++}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 h=s(l).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),o=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:o,rows:u,alignments:h},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 h=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),o=/^\d+\./.test(h[2]),u=h[1].length;for(;l<e.length&&r<1e3;){r++;const t=e[l].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,h,p]=t,a=n.length;if(a<u)break;const d=/^\d+\./.test(h);if(a===u&&d!==o)break;if(a>u){const t=[];let n=0;for(;l<e.length&&n<1e3;){n++;const s=e[l],i=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(s),l++}if(t.length>0&&s.length>0){const e=i(t,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const f={type:"list_item",checked:null,children:null},g=p.match(/^\[([x ])\]\s*(.*)$/i);g&&!o?(f.checked="x"===g[1].toLowerCase(),f.children=c(g[2])):f.children=c(p),s.push(f),l++}return{node:{type:"list",ordered:o,items:s},nextIndex:l}}function c(e,t){if(!e)return[];const n=[];let s=e;for(;s.length>0;){if(s.match(/^(.+?)(?: {2}|\\\n|\n)/)&&s.includes("\n")){const e=s.indexOf("\n"),t=s.slice(0,e),i=s.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&n.push(...l(e)),n.push({type:"br"}),s=i;continue}}const e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const h=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(h){n.push({type:"em",children:l(h[2])}),s=s.slice(h[0].length);continue}const o=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(o){n.push({type:"link",url:o[1],children:[{type:"text",value:o[1]}]}),s=s.slice(o[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);export{e 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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
// Version will be injected at build time
|
|
22
|
-
const quikdownVersion = '1.2.
|
|
22
|
+
const quikdownVersion = '1.2.12';
|
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown_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 e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:l(o[2])}),s=s.slice(o[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}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 e=s.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),s=s.slice(e[0].length);continue}const t=s.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:l(t[1])}),s=s.slice(t[0].length);continue}const i=s.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),s=s.slice(i[0].length);continue}const c=s.match(/^(\*\*|__)(.+?)\1/);if(c){n.push({type:"strong",children:l(c[2])}),s=s.slice(c[0].length);continue}const r=s.match(/^~~(.+?)~~/);if(r){n.push({type:"del",children:l(r[1])}),s=s.slice(r[0].length);continue}const o=s.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:l(o[2])}),s=s.slice(o[0].length);continue}const h=s.match(/^(https?:\/\/[^\s<>[\]]+)/);if(h){n.push({type:"link",url:h[1],children:[{type:"text",value:h[1]}]}),s=s.slice(h[0].length);continue}const u=s.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:s});break}0===u?(n.push({type:"text",value:s[0]}),s=s.slice(1)):(n.push({type:"text",value:s.slice(0,u)}),s=s.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function l(e,t){return c(e.replace(/\n/g," "))}return e.version="1.2.12","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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
// Version will be injected at build time
|
|
18
|
-
const quikdownVersion$1 = '1.2.
|
|
18
|
+
const quikdownVersion$1 = '1.2.12';
|
|
19
19
|
|
|
20
20
|
// Safety limit to prevent infinite loops in list parsing
|
|
21
21
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -508,7 +508,7 @@ if (typeof window !== 'undefined') {
|
|
|
508
508
|
|
|
509
509
|
|
|
510
510
|
// Version will be injected at build time
|
|
511
|
-
const quikdownVersion = '1.2.
|
|
511
|
+
const quikdownVersion = '1.2.12';
|
|
512
512
|
|
|
513
513
|
// Constants
|
|
514
514
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
// Version will be injected at build time
|
|
16
|
-
const quikdownVersion$1 = '1.2.
|
|
16
|
+
const quikdownVersion$1 = '1.2.12';
|
|
17
17
|
|
|
18
18
|
// Safety limit to prevent infinite loops in list parsing
|
|
19
19
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -506,7 +506,7 @@ if (typeof window !== 'undefined') {
|
|
|
506
506
|
|
|
507
507
|
|
|
508
508
|
// Version will be injected at build time
|
|
509
|
-
const quikdownVersion = '1.2.
|
|
509
|
+
const quikdownVersion = '1.2.12';
|
|
510
510
|
|
|
511
511
|
// Constants
|
|
512
512
|
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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
7
|
-
function e(e,n={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:t(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e,r){const c=[],l=e.split("\n");let o=0;for(;o<l.length;){const e=l[o];if(""===e.trim()){o++;continue}const r=e.match(/^(```|~~~)(.*)$/);if(r){const[,e,t]=r,n=t.trim(),i=[];for(o++;o<l.length;){if(l[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(l[o]),o++}c.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){c.push({type:"hr"}),o++;continue}const a=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(a){const[,e,t]=a;c.push({type:"heading",level:e.length,children:s(t)}),o++;continue}if(e.includes("|")){const e=n(l,o);if(e){c.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<l.length&&l[o].match(/^>\s*/);)e.push(l[o].replace(/^>\s*/,"")),o++;c.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(l,o);c.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<l.length;){const e=l[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[o+1]))break;u.push(e),o++}u.length>0&&c.push({type:"paragraph",children:s(u.join("\n"))})}return c}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],c=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(c)||!c.includes("-"))return null;const l=r(i);if(0===l.length)return null;const o=r(c).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=l.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 c=t,l=0;const o=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;c<e.length&&l<1e3;){l++;const t=e[c].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(;c<e.length&&n<1e3;){n++;const r=e[c],i=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(r),c++}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},m=h.match(/^\[([x ])\]\s*(.*)$/i);m&&!a?(p.checked="x"===m[1].toLowerCase(),p.children=s(m[2])):p.children=s(h),r.push(p),c++}return{node:{type:"list",ordered:a,items:r},nextIndex:c}}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(...c(e)),n.push({type:"br"}),r=i;continue}}const e=r.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),r=r.slice(e[0].length);continue}const t=r.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:c(t[1])}),r=r.slice(t[0].length);continue}const i=r.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),r=r.slice(i[0].length);continue}const s=r.match(/^(\*\*|__)(.+?)\1/);if(s){n.push({type:"strong",children:c(s[2])}),r=r.slice(s[0].length);continue}const l=r.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:c(l[1])}),r=r.slice(l[0].length);continue}const o=r.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:c(o[2])}),r=r.slice(o[0].length);continue}const a=r.match(/^(https?:\/\/[^\s<>[\]]+)/);if(a){n.push({type:"link",url:a[1],children:[{type:"text",value:a[1]}]}),r=r.slice(a[0].length);continue}const u=r.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:r});break}0===u?(n.push({type:"text",value:r[0]}),r=r.slice(1)):(n.push({type:"text",value:r.slice(0,u)}),r=r.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function c(e,t){return s(e.replace(/\n/g," "))}e.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const l="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){if(!e)return"";const t=e.trim(),n=t.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(n.startsWith(e))return"data:"===e&&n.startsWith("data:image/")?t:"#";return t}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 c=t.search(/\S/);if(c<n&&c>=0)break;if(c>n&&r.length>0){i++;continue}if(!s.startsWith("- "))break;const l=s.slice(2);if(l.includes(":")){const t={},s=l.indexOf(":"),o=l.slice(0,s).trim(),a=l.slice(s+1).trim();if(""===a||a.startsWith("\n")){const n=f(e,i+1,c+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 c=r.search(/\S/);if(c<=n)break;if(s.startsWith("- "))break;const l=s.indexOf(":");if(l>0){const n=s.slice(0,l).trim(),r=s.slice(l+1).trim();if(""===r||r.startsWith("\n")){const r=f(e,i+1,c+2);t[n]=r.value,i=r.nextLine}else t[n]=p(r),i++}else i++}r.push(t)}else r.push(p(l)),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 c=t.search(/\S/);if(c<n&&c>=0)break;const l=s.indexOf(":");if(l<=0){i++;continue}const o=s.slice(0,l).trim(),a=s.slice(l+1).trim();if(""===a||"|"===a||">"===a){const t=f(e,i+1,c+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 m(e,t={}){return g(d(e,t),t)}function g(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="${l}${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 y(e.children,t,n);case"paragraph":return`<p>${y(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${y(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${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")}>${y(e.children,t,n)}</blockquote>`;case"list":const c=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>$(e,t,n)).join("");return`<${c}${t(c)}>${o}</${c}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${l}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${l}task-item"`}><input type="checkbox"${r}${i} disabled> ${y(e.children,t,n)}</li>`}return`<li${t("li")}>${y(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 c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<th${t("th",c)}>${y(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 c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<td${t("td",c)}>${y(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")}>${y(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${y(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${y(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${u(e.value||"")}</code>`;case"link":const a=h(e.url),d=/^https?:\/\//i.test(a)?' rel="noopener noreferrer"':"";return`<a${t("a")} href="${a}"${d}>${y(e.children,t,n)}</a>`;case"image":const f=h(e.url);return`<img${t("img")} src="${f}" alt="${u(e.alt||"")}">`;case"br":return"<br>";default:return e.children?y(e.children,t,n):void 0!==e.value?u(String(e.value)):""}}function y(e,t,n){return e?Array.isArray(e)?e.map(e=>$(e,t,n)).join(""):$(e,t,n):""}m.toAst=d,m.renderAst=g,m.version="1.2.11","undefined"!=typeof module&&module.exports&&(module.exports=m),"undefined"!=typeof window&&(window.quikdown_ast_html=m);export{m 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 c=[],l=e.split("\n");let o=0;for(;o<l.length;){const e=l[o];if(""===e.trim()){o++;continue}const r=e.match(/^(```|~~~)(.*)$/);if(r){const[,e,t]=r,n=t.trim(),i=[];for(o++;o<l.length;){if(l[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(l[o]),o++}c.push({type:"code_block",lang:n||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){c.push({type:"hr"}),o++;continue}const a=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(a){const[,e,t]=a;c.push({type:"heading",level:e.length,children:s(t)}),o++;continue}if(e.includes("|")){const e=n(l,o);if(e){c.push(e.node),o=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];for(;o<l.length&&l[o].match(/^>\s*/);)e.push(l[o].replace(/^>\s*/,"")),o++;c.push({type:"blockquote",children:t(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=i(l,o);c.push(e.node),o=e.nextIndex;continue}const u=[];for(;o<l.length;){const e=l[o];if(""===e.trim())break;if(/^(```|~~~)/.test(e))break;if(/^#{1,6}\s/.test(e))break;if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))break;if(/^>\s*/.test(e))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(e))break;if(e.includes("|")&&o+1<l.length&&/^\|?[\s\-:|]+\|?$/.test(l[o+1]))break;u.push(e),o++}u.length>0&&c.push({type:"paragraph",children:s(u.join("\n"))})}return c}function n(e,t,n){if(t+1>=e.length)return null;const i=e[t],c=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(c)||!c.includes("-"))return null;const l=r(i);if(0===l.length)return null;const o=r(c).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=l.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 c=t,l=0;const o=e[c].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;c<e.length&&l<1e3;){l++;const t=e[c].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(;c<e.length&&n<1e3;){n++;const r=e[c],i=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!i)break;if(i[1].length<u)break;if(i[1].length===u)break;t.push(r),c++}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},m=h.match(/^\[([x ])\]\s*(.*)$/i);m&&!a?(p.checked="x"===m[1].toLowerCase(),p.children=s(m[2])):p.children=s(h),r.push(p),c++}return{node:{type:"list",ordered:a,items:r},nextIndex:c}}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(...c(e)),n.push({type:"br"}),r=i;continue}}const e=r.match(/^!\[([^\]]*)\]\(\s*([^)\s]+)\s*\)/);if(e){n.push({type:"image",alt:e[1],url:e[2].trim()}),r=r.slice(e[0].length);continue}const t=r.match(/^\[([^\]]+)\]\(\s*([^)\s]+)\s*\)/);if(t){n.push({type:"link",url:t[2].trim(),children:c(t[1])}),r=r.slice(t[0].length);continue}const i=r.match(/^`([^`]+)`/);if(i){n.push({type:"code",value:i[1]}),r=r.slice(i[0].length);continue}const s=r.match(/^(\*\*|__)(.+?)\1/);if(s){n.push({type:"strong",children:c(s[2])}),r=r.slice(s[0].length);continue}const l=r.match(/^~~(.+?)~~/);if(l){n.push({type:"del",children:c(l[1])}),r=r.slice(l[0].length);continue}const o=r.match(/^(\*|_)(?!\1)(.+?)(?<!\1)\1(?!\1)/);if(o){n.push({type:"em",children:c(o[2])}),r=r.slice(o[0].length);continue}const a=r.match(/^(https?:\/\/[^\s<>[\]]+)/);if(a){n.push({type:"link",url:a[1],children:[{type:"text",value:a[1]}]}),r=r.slice(a[0].length);continue}const u=r.search(/[`*_~![\\n]|https?:\/\//);if(-1===u){n.push({type:"text",value:r});break}0===u?(n.push({type:"text",value:r[0]}),r=r.slice(1)):(n.push({type:"text",value:r.slice(0,u)}),r=r.slice(u))}return function(e){const t=[];for(const n of e)"text"===n.type&&t.length>0&&"text"===t[t.length-1].type?t[t.length-1].value+=n.value:t.push(n);return t}(n)}function c(e,t){return s(e.replace(/\n/g," "))}e.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const l="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){if(!e)return"";const t=e.trim(),n=t.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(n.startsWith(e))return"data:"===e&&n.startsWith("data:image/")?t:"#";return t}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 c=t.search(/\S/);if(c<n&&c>=0)break;if(c>n&&r.length>0){i++;continue}if(!s.startsWith("- "))break;const l=s.slice(2);if(l.includes(":")){const t={},s=l.indexOf(":"),o=l.slice(0,s).trim(),a=l.slice(s+1).trim();if(""===a||a.startsWith("\n")){const n=f(e,i+1,c+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 c=r.search(/\S/);if(c<=n)break;if(s.startsWith("- "))break;const l=s.indexOf(":");if(l>0){const n=s.slice(0,l).trim(),r=s.slice(l+1).trim();if(""===r||r.startsWith("\n")){const r=f(e,i+1,c+2);t[n]=r.value,i=r.nextLine}else t[n]=p(r),i++}else i++}r.push(t)}else r.push(p(l)),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 c=t.search(/\S/);if(c<n&&c>=0)break;const l=s.indexOf(":");if(l<=0){i++;continue}const o=s.slice(0,l).trim(),a=s.slice(l+1).trim();if(""===a||"|"===a||">"===a){const t=f(e,i+1,c+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 m(e,t={}){return g(d(e,t),t)}function g(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="${l}${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 y(e.children,t,n);case"paragraph":return`<p>${y(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${y(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${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")}>${y(e.children,t,n)}</blockquote>`;case"list":const c=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>$(e,t,n)).join("");return`<${c}${t(c)}>${o}</${c}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${l}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${l}task-item"`}><input type="checkbox"${r}${i} disabled> ${y(e.children,t,n)}</li>`}return`<li${t("li")}>${y(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 c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<th${t("th",c)}>${y(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 c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";i+=`<td${t("td",c)}>${y(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")}>${y(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${y(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${y(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${u(e.value||"")}</code>`;case"link":const a=h(e.url),d=/^https?:\/\//i.test(a)?' rel="noopener noreferrer"':"";return`<a${t("a")} href="${a}"${d}>${y(e.children,t,n)}</a>`;case"image":const f=h(e.url);return`<img${t("img")} src="${f}" alt="${u(e.alt||"")}">`;case"br":return"<br>";default:return e.children?y(e.children,t,n):void 0!==e.value?u(String(e.value)):""}}function y(e,t,n){return e?Array.isArray(e)?e.map(e=>$(e,t,n)).join(""):$(e,t,n):""}m.toAst=d,m.renderAst=g,m.version="1.2.12","undefined"!=typeof module&&module.exports&&(module.exports=m),"undefined"!=typeof window&&(window.quikdown_ast_html=m);export{m 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.12
|
|
4
4
|
* @license BSD-2-Clause
|
|
5
5
|
* @copyright DeftIO 2025
|
|
6
6
|
*/
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
// Version will be injected at build time
|
|
22
|
-
const quikdownVersion$1 = '1.2.
|
|
22
|
+
const quikdownVersion$1 = '1.2.12';
|
|
23
23
|
|
|
24
24
|
// Safety limit to prevent infinite loops in list parsing
|
|
25
25
|
const MAX_LOOP_ITERATIONS = 1000;
|
|
@@ -512,7 +512,7 @@
|
|
|
512
512
|
|
|
513
513
|
|
|
514
514
|
// Version will be injected at build time
|
|
515
|
-
const quikdownVersion = '1.2.
|
|
515
|
+
const quikdownVersion = '1.2.12';
|
|
516
516
|
|
|
517
517
|
// Constants
|
|
518
518
|
const CLASS_PREFIX = 'quikdown-';
|