quikdown 1.2.17 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +130 -30
  2. package/dist/quikdown-airgap-v1.2.19.zip +0 -0
  3. package/dist/quikdown.cjs +2 -2
  4. package/dist/quikdown.dark.css +1 -1
  5. package/dist/quikdown.esm.js +2 -2
  6. package/dist/quikdown.esm.min.js +2 -2
  7. package/dist/quikdown.esm.min.js.gz +0 -0
  8. package/dist/quikdown.light.css +1 -1
  9. package/dist/quikdown.umd.js +2 -2
  10. package/dist/quikdown.umd.min.js +2 -2
  11. package/dist/quikdown.umd.min.js.gz +0 -0
  12. package/dist/quikdown_ast.cjs +2 -2
  13. package/dist/quikdown_ast.esm.js +2 -2
  14. package/dist/quikdown_ast.esm.min.js +2 -2
  15. package/dist/quikdown_ast.esm.min.js.gz +0 -0
  16. package/dist/quikdown_ast.umd.js +2 -2
  17. package/dist/quikdown_ast.umd.min.js +2 -2
  18. package/dist/quikdown_ast.umd.min.js.gz +0 -0
  19. package/dist/quikdown_ast_html.cjs +3 -3
  20. package/dist/quikdown_ast_html.esm.js +3 -3
  21. package/dist/quikdown_ast_html.esm.min.js +2 -2
  22. package/dist/quikdown_ast_html.esm.min.js.gz +0 -0
  23. package/dist/quikdown_ast_html.umd.js +3 -3
  24. package/dist/quikdown_ast_html.umd.min.js +2 -2
  25. package/dist/quikdown_ast_html.umd.min.js.gz +0 -0
  26. package/dist/quikdown_bd.cjs +2 -2
  27. package/dist/quikdown_bd.esm.js +2 -2
  28. package/dist/quikdown_bd.esm.min.js +2 -2
  29. package/dist/quikdown_bd.esm.min.js.gz +0 -0
  30. package/dist/quikdown_bd.umd.js +2 -2
  31. package/dist/quikdown_bd.umd.min.js +2 -2
  32. package/dist/quikdown_bd.umd.min.js.gz +0 -0
  33. package/dist/quikdown_edit.cjs +3 -3
  34. package/dist/quikdown_edit.esm.js +3 -3
  35. package/dist/quikdown_edit.esm.min.js +3 -3
  36. package/dist/quikdown_edit.esm.min.js.gz +0 -0
  37. package/dist/quikdown_edit.umd.js +3 -3
  38. package/dist/quikdown_edit.umd.min.js +3 -3
  39. package/dist/quikdown_edit.umd.min.js.gz +0 -0
  40. package/dist/quikdown_edit_standalone.esm.js +3 -3
  41. package/dist/quikdown_edit_standalone.esm.min.js +1 -1
  42. package/dist/quikdown_edit_standalone.esm.min.js.gz +0 -0
  43. package/dist/quikdown_edit_standalone.umd.js +3 -3
  44. package/dist/quikdown_edit_standalone.umd.min.js +1 -1
  45. package/dist/quikdown_edit_standalone.umd.min.js.gz +0 -0
  46. package/dist/quikdown_json.cjs +3 -3
  47. package/dist/quikdown_json.esm.js +3 -3
  48. package/dist/quikdown_json.esm.min.js +2 -2
  49. package/dist/quikdown_json.esm.min.js.gz +0 -0
  50. package/dist/quikdown_json.umd.js +3 -3
  51. package/dist/quikdown_json.umd.min.js +2 -2
  52. package/dist/quikdown_json.umd.min.js.gz +0 -0
  53. package/dist/quikdown_mcp.cjs +2 -2
  54. package/dist/quikdown_mcp.esm.js +2 -2
  55. package/dist/quikdown_yaml.cjs +3 -3
  56. package/dist/quikdown_yaml.esm.js +3 -3
  57. package/dist/quikdown_yaml.esm.min.js +2 -2
  58. package/dist/quikdown_yaml.esm.min.js.gz +0 -0
  59. package/dist/quikdown_yaml.umd.js +3 -3
  60. package/dist/quikdown_yaml.umd.min.js +2 -2
  61. package/dist/quikdown_yaml.umd.min.js.gz +0 -0
  62. package/package.json +14 -3
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_ast - AST Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).quikdown_ast=e()}(this,function(){"use strict";function t(t,e={}){if(!t||"string"!=typeof t)return{type:"document",children:[]};return{type:"document",children:s(t.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function e(t){const e=t.trim();return""===e||(!!/^#{1,6}\s/.test(e)||(!!(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))||(!!/^>\s*/.test(e)||(!!/^[-*+]\s/.test(e)||(!!/^\d+\.\s/.test(e)||(!!e.startsWith("|")||!!/^(```|~~~)/.test(e)))))))}function n(t){let e="";const n=/[.,;:!?)]/;for(;t.length>0&&n.test(t[t.length-1]);){const n=t[t.length-1];if(")"===n){if((t.match(/\(/g)||[]).length>=(t.match(/\)/g)||[]).length)break}e=n+e,t=t.slice(0,-1)}return{url:t,trailing:e}}function s(t,n){const l=[],r=t.split("\n");let h=0;for(;h<r.length;){const t=r[h];if(""===t.trim()){h++;continue}const n=t.match(/^(```|~~~)(.*)$/);if(n){const[,t,e]=n,s=e.trim(),i=[];for(h++;h<r.length;){if(r[h].match(/^(```|~~~)\s*$/)){h++;break}i.push(r[h]),h++}l.push({type:"code_block",lang:s||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),h++;continue}const u=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,t,e]=u;l.push({type:"heading",level:t.length,children:o(e)}),h++;continue}if(t.includes("|")){const t=i(r,h);if(t){l.push(t.node),h=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];let n=!0;for(;h<r.length;)if(r[h].match(/^>\s*/))t.push(r[h].replace(/^>\s*/,"")),n=!0,h++;else{if(!n||e(r[h]))break;t.push(r[h]),h++}const i=t.length>0?t[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const e=i[1].toLowerCase();l.push({type:"alert",alertType:e,children:s(t.slice(1).join("\n"))})}else l.push({type:"blockquote",children:s(t.join("\n"))});continue}if(t.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const t=c(r,h);l.push(t.node),h=t.nextIndex;continue}const a=[];for(;h<r.length;){const t=r[h];if(""===t.trim())break;if(/^(```|~~~)/.test(t))break;if(/^#{1,6}\s/.test(t))break;if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))break;if(/^>\s*/.test(t))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(t))break;if(t.includes("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;a.push(t),h++}a.length>0&&l.push({type:"paragraph",children:o(a.join("\n"))})}return l}function i(t,e,n){if(e+1>=t.length)return null;const s=t[e],i=t[e+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const c=l(s);if(0===c.length)return null;const r=l(i).map(t=>{const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":"left"}),h=r.length,u=[];for(let t=0;t<h;t++){const e=t<c.length?c[t]:"";u.push(o(e.trim()))}const a=[];let f=e+2;for(;f<t.length;){const e=t[f];if(!e.includes("|")||""===e.trim())break;const n=l(e),s=[];for(let t=0;t<h;t++){const e=t<n.length?n[t]:"";s.push(o(e.trim()))}a.push(s),f++}return{node:{type:"table",headers:u,rows:a,alignments:r},nextIndex:f}}function l(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|")}function c(t,e,n){const s=[];let i=e,l=0;const r=t[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(r[2]),u=r[1].length;for(;i<t.length&&l<1e3;){l++;const e=t[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!e)break;const[,n,r,a]=e,f=n.length;if(f<u)break;const p=/^\d+\./.test(r);if(f===u&&p!==h)break;if(f>u){const e=[];let n=0;for(;i<t.length&&n<1e3;){n++;const s=t[i],l=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;e.push(s),i++}if(e.length>0&&s.length>0){const t=c(e,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(t.node)}continue}const d={type:"list_item",checked:null,children:null},g=a.match(/^\[([x ])\]\s*(.*)$/i);g&&!h?(d.checked="x"===g[1].toLowerCase(),d.children=o(g[2])):d.children=o(a),s.push(d),i++}return{node:{type:"list",ordered:h,items:s},nextIndex:i}}function r(t){if(null==t||""===t)return{url:"",title:null};const e=t.match(/^(.*)\s+"([^"]*)"\s*$/);if(e)return{url:e[1].replace(/\s+$/,""),title:e[2]};const n=t.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:t.startsWith("<")&&t.endsWith(">")?{url:t.slice(1,-1),title:null}:{url:t,title:null}}function o(t,e){if(!t)return[];const s=[];let i=t;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const t=i.indexOf("\n"),e=i.slice(0,t),n=i.slice(t+1);if(e.endsWith(" ")||e.endsWith("\\")){const t=e.replace(/\\$/,"").replace(/ +$/,"");t&&s.push(...h(t)),s.push({type:"br"}),i=n;continue}}const e=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(e){const{url:t,title:n}=r(e[2]),l={type:"image",alt:e[1],url:t.trim()};n&&(l.title=n),s.push(l),i=i.slice(e[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:t,title:e}=r(l[2]),n={type:"link",url:t.trim(),children:h(l[1])};e&&(n.title=e),s.push(n),i=i.slice(l[0].length);continue}const c=i.match(/^`([^`\n]+)`/);if(c){s.push({type:"code",value:c[1]}),i=i.slice(c[0].length);continue}const o=i.match(/^(\*\*|__)(.+?)\1/);if(o){s.push({type:"strong",children:h(o[2])}),i=i.slice(o[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){s.push({type:"del",children:h(u[1])}),i=i.slice(u[0].length);continue}const a=t[t.length-i.length-1]||"",f=!/[A-Za-z0-9_]/.test(a),p=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||f&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(p){s.push({type:"em",children:h(p[1])}),i=i.slice(p[0].length);continue}const d=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){const{url:t,trailing:e}=n(d[1]);s.push({type:"link",url:t,children:[{type:"text",value:t}]}),e&&s.push({type:"text",value:e}),i=i.slice(d[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){s.push({type:"text",value:i});break}0===g?(s.push({type:"text",value:i[0]}),i=i.slice(1)):(s.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}return function(t){const e=[];for(const n of t)"text"===n.type&&e.length>0&&"text"===e[e.length-1].type?e[e.length-1].value+=n.value:e.push(n);return e}(s)}function h(t,e){return o(t.replace(/\n/g," "))}return t.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=t),"undefined"!=typeof window&&(window.quikdown_ast=t),t});
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).quikdown_ast=e()}(this,function(){"use strict";function t(t,e={}){if(!t||"string"!=typeof t)return{type:"document",children:[]};return{type:"document",children:s(t.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function e(t){const e=t.trim();return""===e||(!!/^#{1,6}\s/.test(e)||(!!(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e))||(!!/^>\s*/.test(e)||(!!/^[-*+]\s/.test(e)||(!!/^\d+\.\s/.test(e)||(!!e.startsWith("|")||!!/^(```|~~~)/.test(e)))))))}function n(t){let e="";const n=/[.,;:!?)]/;for(;t.length>0&&n.test(t[t.length-1]);){const n=t[t.length-1];if(")"===n){if((t.match(/\(/g)||[]).length>=(t.match(/\)/g)||[]).length)break}e=n+e,t=t.slice(0,-1)}return{url:t,trailing:e}}function s(t,n){const l=[],r=t.split("\n");let h=0;for(;h<r.length;){const t=r[h];if(""===t.trim()){h++;continue}const n=t.match(/^(```|~~~)(.*)$/);if(n){const[,t,e]=n,s=e.trim(),i=[];for(h++;h<r.length;){if(r[h].match(/^(```|~~~)\s*$/)){h++;break}i.push(r[h]),h++}l.push({type:"code_block",lang:s||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),h++;continue}const u=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,t,e]=u;l.push({type:"heading",level:t.length,children:o(e)}),h++;continue}if(t.includes("|")){const t=i(r,h);if(t){l.push(t.node),h=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];let n=!0;for(;h<r.length;)if(r[h].match(/^>\s*/))t.push(r[h].replace(/^>\s*/,"")),n=!0,h++;else{if(!n||e(r[h]))break;t.push(r[h]),h++}const i=t.length>0?t[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const e=i[1].toLowerCase();l.push({type:"alert",alertType:e,children:s(t.slice(1).join("\n"))})}else l.push({type:"blockquote",children:s(t.join("\n"))});continue}if(t.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const t=c(r,h);l.push(t.node),h=t.nextIndex;continue}const a=[];for(;h<r.length;){const t=r[h];if(""===t.trim())break;if(/^(```|~~~)/.test(t))break;if(/^#{1,6}\s/.test(t))break;if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))break;if(/^>\s*/.test(t))break;if(/^(\s*)([*\-+]|\d+\.)\s+/.test(t))break;if(t.includes("|")&&h+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[h+1]))break;a.push(t),h++}a.length>0&&l.push({type:"paragraph",children:o(a.join("\n"))})}return l}function i(t,e,n){if(e+1>=t.length)return null;const s=t[e],i=t[e+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const c=l(s);if(0===c.length)return null;const r=l(i).map(t=>{const e=t.trim();return e.startsWith(":")&&e.endsWith(":")?"center":e.endsWith(":")?"right":"left"}),h=r.length,u=[];for(let t=0;t<h;t++){const e=t<c.length?c[t]:"";u.push(o(e.trim()))}const a=[];let f=e+2;for(;f<t.length;){const e=t[f];if(!e.includes("|")||""===e.trim())break;const n=l(e),s=[];for(let t=0;t<h;t++){const e=t<n.length?n[t]:"";s.push(o(e.trim()))}a.push(s),f++}return{node:{type:"table",headers:u,rows:a,alignments:r},nextIndex:f}}function l(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|")}function c(t,e,n){const s=[];let i=e,l=0;const r=t[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),h=/^\d+\./.test(r[2]),u=r[1].length;for(;i<t.length&&l<1e3;){l++;const e=t[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!e)break;const[,n,r,a]=e,f=n.length;if(f<u)break;const p=/^\d+\./.test(r);if(f===u&&p!==h)break;if(f>u){const e=[];let n=0;for(;i<t.length&&n<1e3;){n++;const s=t[i],l=s.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;e.push(s),i++}if(e.length>0&&s.length>0){const t=c(e,0),n=s[s.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(t.node)}continue}const d={type:"list_item",checked:null,children:null},g=a.match(/^\[([x ])\]\s*(.*)$/i);g&&!h?(d.checked="x"===g[1].toLowerCase(),d.children=o(g[2])):d.children=o(a),s.push(d),i++}return{node:{type:"list",ordered:h,items:s},nextIndex:i}}function r(t){if(null==t||""===t)return{url:"",title:null};const e=t.match(/^(.*)\s+"([^"]*)"\s*$/);if(e)return{url:e[1].replace(/\s+$/,""),title:e[2]};const n=t.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:t.startsWith("<")&&t.endsWith(">")?{url:t.slice(1,-1),title:null}:{url:t,title:null}}function o(t,e){if(!t)return[];const s=[];let i=t;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const t=i.indexOf("\n"),e=i.slice(0,t),n=i.slice(t+1);if(e.endsWith(" ")||e.endsWith("\\")){const t=e.replace(/\\$/,"").replace(/ +$/,"");t&&s.push(...h(t)),s.push({type:"br"}),i=n;continue}}const e=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(e){const{url:t,title:n}=r(e[2]),l={type:"image",alt:e[1],url:t.trim()};n&&(l.title=n),s.push(l),i=i.slice(e[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:t,title:e}=r(l[2]),n={type:"link",url:t.trim(),children:h(l[1])};e&&(n.title=e),s.push(n),i=i.slice(l[0].length);continue}const c=i.match(/^`([^`\n]+)`/);if(c){s.push({type:"code",value:c[1]}),i=i.slice(c[0].length);continue}const o=i.match(/^(\*\*|__)(.+?)\1/);if(o){s.push({type:"strong",children:h(o[2])}),i=i.slice(o[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){s.push({type:"del",children:h(u[1])}),i=i.slice(u[0].length);continue}const a=t[t.length-i.length-1]||"",f=!/[A-Za-z0-9_]/.test(a),p=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||f&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(p){s.push({type:"em",children:h(p[1])}),i=i.slice(p[0].length);continue}const d=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(d){const{url:t,trailing:e}=n(d[1]);s.push({type:"link",url:t,children:[{type:"text",value:t}]}),e&&s.push({type:"text",value:e}),i=i.slice(d[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){s.push({type:"text",value:i});break}0===g?(s.push({type:"text",value:i[0]}),i=i.slice(1)):(s.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}return function(t){const e=[];for(const n of t)"text"===n.type&&e.length>0&&"text"===e[e.length-1].type?e[e.length-1].value+=n.value:e.push(n);return e}(s)}function h(t,e){return o(t.replace(/\n/g," "))}return t.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=t),"undefined"!=typeof window&&(window.quikdown_ast=t),t});
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.17
3
+ * @version 1.2.19
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.17';
18
+ const quikdownVersion$1 = '1.2.19';
19
19
 
20
20
  // Safety limit to prevent infinite loops in list parsing
21
21
  const MAX_LOOP_ITERATIONS = 1000;
@@ -611,7 +611,7 @@ if (typeof window !== 'undefined') {
611
611
 
612
612
 
613
613
  // Version will be injected at build time
614
- const quikdownVersion = '1.2.17';
614
+ const quikdownVersion = '1.2.19';
615
615
 
616
616
  // Constants
617
617
  const CLASS_PREFIX = 'quikdown-';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_ast_html - AST to HTML Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
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.17';
16
+ const quikdownVersion$1 = '1.2.19';
17
17
 
18
18
  // Safety limit to prevent infinite loops in list parsing
19
19
  const MAX_LOOP_ITERATIONS = 1000;
@@ -609,7 +609,7 @@ if (typeof window !== 'undefined') {
609
609
 
610
610
 
611
611
  // Version will be injected at build time
612
- const quikdownVersion = '1.2.17';
612
+ const quikdownVersion = '1.2.19';
613
613
 
614
614
  // Constants
615
615
  const CLASS_PREFIX = 'quikdown-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_ast_html - AST to HTML Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- function e(e,t={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:r(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e){const t=e.trim();return""===t||(!!/^#{1,6}\s/.test(t)||(!!(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))||(!!/^>\s*/.test(t)||(!!/^[-*+]\s/.test(t)||(!!/^\d+\.\s/.test(t)||(!!t.startsWith("|")||!!/^(```|~~~)/.test(t)))))))}function n(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n){if((e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break}t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}function r(e,n){const l=[],c=e.split("\n");let a=0;for(;a<c.length;){const e=c[a];if(""===e.trim()){a++;continue}const n=e.match(/^(```|~~~)(.*)$/);if(n){const[,e,t]=n,r=t.trim(),i=[];for(a++;a<c.length;){if(c[a].match(/^(```|~~~)\s*$/)){a++;break}i.push(c[a]),a++}l.push({type:"code_block",lang:r||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),a++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;l.push({type:"heading",level:e.length,children:o(t)}),a++;continue}if(e.includes("|")){const e=i(c,a);if(e){l.push(e.node),a=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];let n=!0;for(;a<c.length;)if(c[a].match(/^>\s*/))e.push(c[a].replace(/^>\s*/,"")),n=!0,a++;else{if(!n||t(c[a]))break;e.push(c[a]),a++}const i=e.length>0?e[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const t=i[1].toLowerCase();l.push({type:"alert",alertType:t,children:r(e.slice(1).join("\n"))})}else l.push({type:"blockquote",children:r(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=s(c,a);l.push(e.node),a=e.nextIndex;continue}const d=[];for(;a<c.length;){const e=c[a];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("|")&&a+1<c.length&&/^\|?[\s\-:|]+\|?$/.test(c[a+1]))break;d.push(e),a++}d.length>0&&l.push({type:"paragraph",children:o(d.join("\n"))})}return l}function i(e,t,n){if(t+1>=e.length)return null;const r=e[t],i=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const s=l(r);if(0===s.length)return null;const c=l(i).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=c.length,u=[];for(let e=0;e<a;e++){const t=e<s.length?s[e]:"";u.push(o(t.trim()))}const d=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=l(t),r=[];for(let e=0;e<a;e++){const t=e<n.length?n[e]:"";r.push(o(t.trim()))}d.push(r),h++}return{node:{type:"table",headers:u,rows:d,alignments:c},nextIndex:h}}function l(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function s(e,t,n){const r=[];let i=t,l=0;const c=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(c[2]),u=c[1].length;for(;i<e.length&&l<1e3;){l++;const t=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,c,d]=t,h=n.length;if(h<u)break;const f=/^\d+\./.test(c);if(h===u&&f!==a)break;if(h>u){const t=[];let n=0;for(;i<e.length&&n<1e3;){n++;const r=e[i],l=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;t.push(r),i++}if(t.length>0&&r.length>0){const e=s(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=d.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=o(g[2])):p.children=o(d),r.push(p),i++}return{node:{type:"list",ordered:a,items:r},nextIndex:i}}function c(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+"([^"]*)"\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]};const n=e.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(1,-1),title:null}:{url:e,title:null}}function o(e,t){if(!e)return[];const r=[];let i=e;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const e=i.indexOf("\n"),t=i.slice(0,e),n=i.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&r.push(...a(e)),r.push({type:"br"}),i=n;continue}}const t=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(t){const{url:e,title:n}=c(t[2]),l={type:"image",alt:t[1],url:e.trim()};n&&(l.title=n),r.push(l),i=i.slice(t[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:e,title:t}=c(l[2]),n={type:"link",url:e.trim(),children:a(l[1])};t&&(n.title=t),r.push(n),i=i.slice(l[0].length);continue}const s=i.match(/^`([^`\n]+)`/);if(s){r.push({type:"code",value:s[1]}),i=i.slice(s[0].length);continue}const o=i.match(/^(\*\*|__)(.+?)\1/);if(o){r.push({type:"strong",children:a(o[2])}),i=i.slice(o[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){r.push({type:"del",children:a(u[1])}),i=i.slice(u[0].length);continue}const d=e[e.length-i.length-1]||"",h=!/[A-Za-z0-9_]/.test(d),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||h&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){r.push({type:"em",children:a(f[1])}),i=i.slice(f[0].length);continue}const p=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){const{url:e,trailing:t}=n(p[1]);r.push({type:"link",url:e,children:[{type:"text",value:e}]}),t&&r.push({type:"text",value:t}),i=i.slice(p[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){r.push({type:"text",value:i});break}0===g?(r.push({type:"text",value:i[0]}),i=i.slice(1)):(r.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}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}(r)}function a(e,t){return o(e.replace(/\n/g," "))}e.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const u="quikdown-",d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},h={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",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function f(e){return e?String(e).replace(/[&<>"']/g,e=>d[e]):""}function p(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#039;|&apos;/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const l=i.toLowerCase(),s=["javascript:","vbscript:","data:"];for(const e of s)if(l.startsWith(e))return"data:"===e&&l.startsWith("data:image/")?n:"#";return n}function g(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=m(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function m(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return m(e,t+1,n);const l=r.search(/\S/);if(l<n&&l>=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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;if(s>n&&r.length>0){i++;continue}if(!l.startsWith("- "))break;const c=l.slice(2);if(c.includes(":")){const t={},l=c.indexOf(":"),o=c.slice(0,l).trim(),a=c.slice(l+1).trim();if(""===a||a.startsWith("\n")){const n=m(e,i+1,s+2);t[o]=n.value,i=n.nextLine}else t[o]=$(a),i++;for(;i<e.length;){const r=e[i],l=r.trim();if(""===l){i++;continue}const s=r.search(/\S/);if(s<=n)break;if(l.startsWith("- "))break;const c=l.indexOf(":");if(c>0){const n=l.slice(0,c).trim(),r=l.slice(c+1).trim();if(""===r||r.startsWith("\n")){const r=m(e,i+1,s+2);t[n]=r.value,i=r.nextLine}else t[n]=$(r),i++}else i++}r.push(t)}else r.push($(c)),i++}return{value:r,nextLine:i}}(e,t,l);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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;const c=l.indexOf(":");if(c<=0){i++;continue}const o=l.slice(0,c).trim(),a=l.slice(c+1).trim();if(""===a||"|"===a||">"===a){const t=m(e,i+1,s+2);r[o]=t.value,i=t.nextLine}else r[o]=$(a),i++}return{value:r,nextLine:i}}(e,t,l):{value:$(i),nextLine:t+1}}function $(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 b(e,t={}){return y(g(e,t),t)}function y(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=h[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="${u}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return x(e,r,t)}function x(e,t,n){if(!e)return"";switch(e.type){case"document":return k(e.children,t,n);case"paragraph":return`<p>${k(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${k(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${f(e.lang)}"`:"",l=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${l}>${f(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${k(e.children,t,n)}</blockquote>`;case"alert":{const r=(e.alertType||"note").toLowerCase(),i={note:"Note",tip:"Tip",important:"Important",warning:"Warning",caution:"Caution"}[r]||"Note";if(n.inline_styles){const l=h.alert,s=h["alert-"+r];return`<div style="${s?`${l};${s}`:l}"><p style="${h["alert-title"]}">${i}</p>${k(e.children,t,n)}</div>`}return`<div class="${u}alert ${u}alert-${r}"><p class="${u}alert-title">${i}</p>${k(e.children,t,n)}</div>`}case"list":const s=e.ordered?"ol":"ul",c=(e.items||[]).map(e=>x(e,t,n)).join("");return`<${s}${t(s)}>${c}</${s}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${u}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${u}task-item"`}><input type="checkbox"${r}${i} disabled> ${k(e.children,t,n)}</li>`}return`<li${t("li")}>${k(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[],i=r.length||(e.headers?e.headers.length:0);let l=`<table${t("table")}>\n`;if(e.headers&&e.headers.length>0){l+="<thead>\n<tr>\n";for(let s=0;s<i;s++){const i=s<e.headers.length?e.headers[s]:[],c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<th${t("th",c)}>${k(i,t,n)}</th>\n`}l+="</tr>\n</thead>\n"}e.rows&&e.rows.length>0&&(l+="<tbody>\n",e.rows.forEach(e=>{l+="<tr>\n";for(let s=0;s<i;s++){const i=s<e.length?e[s]:[],c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<td${t("td",c)}>${k(i,t,n)}</td>\n`}l+="</tr>\n"}),l+="</tbody>\n");return l+="</table>",l}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return f(e.value||"");case"strong":return`<strong${t("strong")}>${k(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${k(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${k(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${f(e.value||"")}</code>`;case"link":{const r=p(e.url,n.allow_unsafe_urls),i=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=e.title?` title="${f(e.title)}"`:"";return`<a${t("a")} href="${f(r)}"${i}${l}>${k(e.children,t,n)}</a>`}case"image":{const r=p(e.url,n.allow_unsafe_urls),i=e.title?` title="${f(e.title)}"`:"";return`<img${t("img")} src="${f(r)}" alt="${f(e.alt||"")}"${i}>`}case"br":return"<br>";default:return e.children?k(e.children,t,n):void 0!==e.value?f(String(e.value)):""}}function k(e,t,n){return e?Array.isArray(e)?e.map(e=>x(e,t,n)).join(""):x(e,t,n):""}b.toAst=g,b.renderAst=y,b.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown_ast_html=b);export{b as default};
7
+ function e(e,t={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:r(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e){const t=e.trim();return""===t||(!!/^#{1,6}\s/.test(t)||(!!(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))||(!!/^>\s*/.test(t)||(!!/^[-*+]\s/.test(t)||(!!/^\d+\.\s/.test(t)||(!!t.startsWith("|")||!!/^(```|~~~)/.test(t)))))))}function n(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n){if((e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break}t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}function r(e,n){const l=[],c=e.split("\n");let a=0;for(;a<c.length;){const e=c[a];if(""===e.trim()){a++;continue}const n=e.match(/^(```|~~~)(.*)$/);if(n){const[,e,t]=n,r=t.trim(),i=[];for(a++;a<c.length;){if(c[a].match(/^(```|~~~)\s*$/)){a++;break}i.push(c[a]),a++}l.push({type:"code_block",lang:r||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),a++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;l.push({type:"heading",level:e.length,children:o(t)}),a++;continue}if(e.includes("|")){const e=i(c,a);if(e){l.push(e.node),a=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];let n=!0;for(;a<c.length;)if(c[a].match(/^>\s*/))e.push(c[a].replace(/^>\s*/,"")),n=!0,a++;else{if(!n||t(c[a]))break;e.push(c[a]),a++}const i=e.length>0?e[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const t=i[1].toLowerCase();l.push({type:"alert",alertType:t,children:r(e.slice(1).join("\n"))})}else l.push({type:"blockquote",children:r(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=s(c,a);l.push(e.node),a=e.nextIndex;continue}const d=[];for(;a<c.length;){const e=c[a];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("|")&&a+1<c.length&&/^\|?[\s\-:|]+\|?$/.test(c[a+1]))break;d.push(e),a++}d.length>0&&l.push({type:"paragraph",children:o(d.join("\n"))})}return l}function i(e,t,n){if(t+1>=e.length)return null;const r=e[t],i=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const s=l(r);if(0===s.length)return null;const c=l(i).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=c.length,u=[];for(let e=0;e<a;e++){const t=e<s.length?s[e]:"";u.push(o(t.trim()))}const d=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=l(t),r=[];for(let e=0;e<a;e++){const t=e<n.length?n[e]:"";r.push(o(t.trim()))}d.push(r),h++}return{node:{type:"table",headers:u,rows:d,alignments:c},nextIndex:h}}function l(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function s(e,t,n){const r=[];let i=t,l=0;const c=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(c[2]),u=c[1].length;for(;i<e.length&&l<1e3;){l++;const t=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,c,d]=t,h=n.length;if(h<u)break;const f=/^\d+\./.test(c);if(h===u&&f!==a)break;if(h>u){const t=[];let n=0;for(;i<e.length&&n<1e3;){n++;const r=e[i],l=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;t.push(r),i++}if(t.length>0&&r.length>0){const e=s(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=d.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=o(g[2])):p.children=o(d),r.push(p),i++}return{node:{type:"list",ordered:a,items:r},nextIndex:i}}function c(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+"([^"]*)"\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]};const n=e.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(1,-1),title:null}:{url:e,title:null}}function o(e,t){if(!e)return[];const r=[];let i=e;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const e=i.indexOf("\n"),t=i.slice(0,e),n=i.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&r.push(...a(e)),r.push({type:"br"}),i=n;continue}}const t=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(t){const{url:e,title:n}=c(t[2]),l={type:"image",alt:t[1],url:e.trim()};n&&(l.title=n),r.push(l),i=i.slice(t[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:e,title:t}=c(l[2]),n={type:"link",url:e.trim(),children:a(l[1])};t&&(n.title=t),r.push(n),i=i.slice(l[0].length);continue}const s=i.match(/^`([^`\n]+)`/);if(s){r.push({type:"code",value:s[1]}),i=i.slice(s[0].length);continue}const o=i.match(/^(\*\*|__)(.+?)\1/);if(o){r.push({type:"strong",children:a(o[2])}),i=i.slice(o[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){r.push({type:"del",children:a(u[1])}),i=i.slice(u[0].length);continue}const d=e[e.length-i.length-1]||"",h=!/[A-Za-z0-9_]/.test(d),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||h&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){r.push({type:"em",children:a(f[1])}),i=i.slice(f[0].length);continue}const p=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){const{url:e,trailing:t}=n(p[1]);r.push({type:"link",url:e,children:[{type:"text",value:e}]}),t&&r.push({type:"text",value:t}),i=i.slice(p[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){r.push({type:"text",value:i});break}0===g?(r.push({type:"text",value:i[0]}),i=i.slice(1)):(r.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}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}(r)}function a(e,t){return o(e.replace(/\n/g," "))}e.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const u="quikdown-",d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},h={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",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function f(e){return e?String(e).replace(/[&<>"']/g,e=>d[e]):""}function p(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#039;|&apos;/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const l=i.toLowerCase(),s=["javascript:","vbscript:","data:"];for(const e of s)if(l.startsWith(e))return"data:"===e&&l.startsWith("data:image/")?n:"#";return n}function g(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=m(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function m(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return m(e,t+1,n);const l=r.search(/\S/);if(l<n&&l>=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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;if(s>n&&r.length>0){i++;continue}if(!l.startsWith("- "))break;const c=l.slice(2);if(c.includes(":")){const t={},l=c.indexOf(":"),o=c.slice(0,l).trim(),a=c.slice(l+1).trim();if(""===a||a.startsWith("\n")){const n=m(e,i+1,s+2);t[o]=n.value,i=n.nextLine}else t[o]=$(a),i++;for(;i<e.length;){const r=e[i],l=r.trim();if(""===l){i++;continue}const s=r.search(/\S/);if(s<=n)break;if(l.startsWith("- "))break;const c=l.indexOf(":");if(c>0){const n=l.slice(0,c).trim(),r=l.slice(c+1).trim();if(""===r||r.startsWith("\n")){const r=m(e,i+1,s+2);t[n]=r.value,i=r.nextLine}else t[n]=$(r),i++}else i++}r.push(t)}else r.push($(c)),i++}return{value:r,nextLine:i}}(e,t,l);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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;const c=l.indexOf(":");if(c<=0){i++;continue}const o=l.slice(0,c).trim(),a=l.slice(c+1).trim();if(""===a||"|"===a||">"===a){const t=m(e,i+1,s+2);r[o]=t.value,i=t.nextLine}else r[o]=$(a),i++}return{value:r,nextLine:i}}(e,t,l):{value:$(i),nextLine:t+1}}function $(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 b(e,t={}){return y(g(e,t),t)}function y(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=h[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="${u}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return x(e,r,t)}function x(e,t,n){if(!e)return"";switch(e.type){case"document":return k(e.children,t,n);case"paragraph":return`<p>${k(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${k(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${f(e.lang)}"`:"",l=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${l}>${f(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${k(e.children,t,n)}</blockquote>`;case"alert":{const r=(e.alertType||"note").toLowerCase(),i={note:"Note",tip:"Tip",important:"Important",warning:"Warning",caution:"Caution"}[r]||"Note";if(n.inline_styles){const l=h.alert,s=h["alert-"+r];return`<div style="${s?`${l};${s}`:l}"><p style="${h["alert-title"]}">${i}</p>${k(e.children,t,n)}</div>`}return`<div class="${u}alert ${u}alert-${r}"><p class="${u}alert-title">${i}</p>${k(e.children,t,n)}</div>`}case"list":const s=e.ordered?"ol":"ul",c=(e.items||[]).map(e=>x(e,t,n)).join("");return`<${s}${t(s)}>${c}</${s}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${u}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${u}task-item"`}><input type="checkbox"${r}${i} disabled> ${k(e.children,t,n)}</li>`}return`<li${t("li")}>${k(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[],i=r.length||(e.headers?e.headers.length:0);let l=`<table${t("table")}>\n`;if(e.headers&&e.headers.length>0){l+="<thead>\n<tr>\n";for(let s=0;s<i;s++){const i=s<e.headers.length?e.headers[s]:[],c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<th${t("th",c)}>${k(i,t,n)}</th>\n`}l+="</tr>\n</thead>\n"}e.rows&&e.rows.length>0&&(l+="<tbody>\n",e.rows.forEach(e=>{l+="<tr>\n";for(let s=0;s<i;s++){const i=s<e.length?e[s]:[],c=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<td${t("td",c)}>${k(i,t,n)}</td>\n`}l+="</tr>\n"}),l+="</tbody>\n");return l+="</table>",l}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return f(e.value||"");case"strong":return`<strong${t("strong")}>${k(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${k(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${k(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${f(e.value||"")}</code>`;case"link":{const r=p(e.url,n.allow_unsafe_urls),i=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=e.title?` title="${f(e.title)}"`:"";return`<a${t("a")} href="${f(r)}"${i}${l}>${k(e.children,t,n)}</a>`}case"image":{const r=p(e.url,n.allow_unsafe_urls),i=e.title?` title="${f(e.title)}"`:"";return`<img${t("img")} src="${f(r)}" alt="${f(e.alt||"")}"${i}>`}case"br":return"<br>";default:return e.children?k(e.children,t,n):void 0!==e.value?f(String(e.value)):""}}function k(e,t,n){return e?Array.isArray(e)?e.map(e=>x(e,t,n)).join(""):x(e,t,n):""}b.toAst=g,b.renderAst=y,b.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown_ast_html=b);export{b as default};
8
8
  //# sourceMappingURL=quikdown_ast_html.esm.min.js.map
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_ast_html - AST to HTML Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
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.17';
22
+ const quikdownVersion$1 = '1.2.19';
23
23
 
24
24
  // Safety limit to prevent infinite loops in list parsing
25
25
  const MAX_LOOP_ITERATIONS = 1000;
@@ -615,7 +615,7 @@
615
615
 
616
616
 
617
617
  // Version will be injected at build time
618
- const quikdownVersion = '1.2.17';
618
+ const quikdownVersion = '1.2.19';
619
619
 
620
620
  // Constants
621
621
  const CLASS_PREFIX = 'quikdown-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_ast_html - AST to HTML Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown_ast_html=t()}(this,function(){"use strict";function e(e,t={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:r(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e){const t=e.trim();return""===t||(!!/^#{1,6}\s/.test(t)||(!!(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))||(!!/^>\s*/.test(t)||(!!/^[-*+]\s/.test(t)||(!!/^\d+\.\s/.test(t)||(!!t.startsWith("|")||!!/^(```|~~~)/.test(t)))))))}function n(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n){if((e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break}t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}function r(e,n){const l=[],o=e.split("\n");let a=0;for(;a<o.length;){const e=o[a];if(""===e.trim()){a++;continue}const n=e.match(/^(```|~~~)(.*)$/);if(n){const[,e,t]=n,r=t.trim(),i=[];for(a++;a<o.length;){if(o[a].match(/^(```|~~~)\s*$/)){a++;break}i.push(o[a]),a++}l.push({type:"code_block",lang:r||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),a++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;l.push({type:"heading",level:e.length,children:c(t)}),a++;continue}if(e.includes("|")){const e=i(o,a);if(e){l.push(e.node),a=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];let n=!0;for(;a<o.length;)if(o[a].match(/^>\s*/))e.push(o[a].replace(/^>\s*/,"")),n=!0,a++;else{if(!n||t(o[a]))break;e.push(o[a]),a++}const i=e.length>0?e[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const t=i[1].toLowerCase();l.push({type:"alert",alertType:t,children:r(e.slice(1).join("\n"))})}else l.push({type:"blockquote",children:r(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=s(o,a);l.push(e.node),a=e.nextIndex;continue}const d=[];for(;a<o.length;){const e=o[a];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("|")&&a+1<o.length&&/^\|?[\s\-:|]+\|?$/.test(o[a+1]))break;d.push(e),a++}d.length>0&&l.push({type:"paragraph",children:c(d.join("\n"))})}return l}function i(e,t,n){if(t+1>=e.length)return null;const r=e[t],i=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const s=l(r);if(0===s.length)return null;const o=l(i).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=o.length,u=[];for(let e=0;e<a;e++){const t=e<s.length?s[e]:"";u.push(c(t.trim()))}const d=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=l(t),r=[];for(let e=0;e<a;e++){const t=e<n.length?n[e]:"";r.push(c(t.trim()))}d.push(r),h++}return{node:{type:"table",headers:u,rows:d,alignments:o},nextIndex:h}}function l(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function s(e,t,n){const r=[];let i=t,l=0;const o=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;i<e.length&&l<1e3;){l++;const t=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,d]=t,h=n.length;if(h<u)break;const f=/^\d+\./.test(o);if(h===u&&f!==a)break;if(h>u){const t=[];let n=0;for(;i<e.length&&n<1e3;){n++;const r=e[i],l=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;t.push(r),i++}if(t.length>0&&r.length>0){const e=s(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=d.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=c(g[2])):p.children=c(d),r.push(p),i++}return{node:{type:"list",ordered:a,items:r},nextIndex:i}}function o(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+"([^"]*)"\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]};const n=e.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(1,-1),title:null}:{url:e,title:null}}function c(e,t){if(!e)return[];const r=[];let i=e;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const e=i.indexOf("\n"),t=i.slice(0,e),n=i.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&r.push(...a(e)),r.push({type:"br"}),i=n;continue}}const t=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(t){const{url:e,title:n}=o(t[2]),l={type:"image",alt:t[1],url:e.trim()};n&&(l.title=n),r.push(l),i=i.slice(t[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:e,title:t}=o(l[2]),n={type:"link",url:e.trim(),children:a(l[1])};t&&(n.title=t),r.push(n),i=i.slice(l[0].length);continue}const s=i.match(/^`([^`\n]+)`/);if(s){r.push({type:"code",value:s[1]}),i=i.slice(s[0].length);continue}const c=i.match(/^(\*\*|__)(.+?)\1/);if(c){r.push({type:"strong",children:a(c[2])}),i=i.slice(c[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){r.push({type:"del",children:a(u[1])}),i=i.slice(u[0].length);continue}const d=e[e.length-i.length-1]||"",h=!/[A-Za-z0-9_]/.test(d),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||h&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){r.push({type:"em",children:a(f[1])}),i=i.slice(f[0].length);continue}const p=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){const{url:e,trailing:t}=n(p[1]);r.push({type:"link",url:e,children:[{type:"text",value:e}]}),t&&r.push({type:"text",value:t}),i=i.slice(p[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){r.push({type:"text",value:i});break}0===g?(r.push({type:"text",value:i[0]}),i=i.slice(1)):(r.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}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}(r)}function a(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const u="quikdown-",d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},h={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",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function f(e){return e?String(e).replace(/[&<>"']/g,e=>d[e]):""}function p(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#039;|&apos;/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const l=i.toLowerCase(),s=["javascript:","vbscript:","data:"];for(const e of s)if(l.startsWith(e))return"data:"===e&&l.startsWith("data:image/")?n:"#";return n}function g(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=m(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function m(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return m(e,t+1,n);const l=r.search(/\S/);if(l<n&&l>=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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;if(s>n&&r.length>0){i++;continue}if(!l.startsWith("- "))break;const o=l.slice(2);if(o.includes(":")){const t={},l=o.indexOf(":"),c=o.slice(0,l).trim(),a=o.slice(l+1).trim();if(""===a||a.startsWith("\n")){const n=m(e,i+1,s+2);t[c]=n.value,i=n.nextLine}else t[c]=$(a),i++;for(;i<e.length;){const r=e[i],l=r.trim();if(""===l){i++;continue}const s=r.search(/\S/);if(s<=n)break;if(l.startsWith("- "))break;const o=l.indexOf(":");if(o>0){const n=l.slice(0,o).trim(),r=l.slice(o+1).trim();if(""===r||r.startsWith("\n")){const r=m(e,i+1,s+2);t[n]=r.value,i=r.nextLine}else t[n]=$(r),i++}else i++}r.push(t)}else r.push($(o)),i++}return{value:r,nextLine:i}}(e,t,l);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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;const o=l.indexOf(":");if(o<=0){i++;continue}const c=l.slice(0,o).trim(),a=l.slice(o+1).trim();if(""===a||"|"===a||">"===a){const t=m(e,i+1,s+2);r[c]=t.value,i=t.nextLine}else r[c]=$(a),i++}return{value:r,nextLine:i}}(e,t,l):{value:$(i),nextLine:t+1}}function $(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 b(e,t={}){return y(g(e,t),t)}function y(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=h[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="${u}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return x(e,r,t)}function x(e,t,n){if(!e)return"";switch(e.type){case"document":return k(e.children,t,n);case"paragraph":return`<p>${k(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${k(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${f(e.lang)}"`:"",l=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${l}>${f(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${k(e.children,t,n)}</blockquote>`;case"alert":{const r=(e.alertType||"note").toLowerCase(),i={note:"Note",tip:"Tip",important:"Important",warning:"Warning",caution:"Caution"}[r]||"Note";if(n.inline_styles){const l=h.alert,s=h["alert-"+r];return`<div style="${s?`${l};${s}`:l}"><p style="${h["alert-title"]}">${i}</p>${k(e.children,t,n)}</div>`}return`<div class="${u}alert ${u}alert-${r}"><p class="${u}alert-title">${i}</p>${k(e.children,t,n)}</div>`}case"list":const s=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>x(e,t,n)).join("");return`<${s}${t(s)}>${o}</${s}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${u}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${u}task-item"`}><input type="checkbox"${r}${i} disabled> ${k(e.children,t,n)}</li>`}return`<li${t("li")}>${k(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[],i=r.length||(e.headers?e.headers.length:0);let l=`<table${t("table")}>\n`;if(e.headers&&e.headers.length>0){l+="<thead>\n<tr>\n";for(let s=0;s<i;s++){const i=s<e.headers.length?e.headers[s]:[],o=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<th${t("th",o)}>${k(i,t,n)}</th>\n`}l+="</tr>\n</thead>\n"}e.rows&&e.rows.length>0&&(l+="<tbody>\n",e.rows.forEach(e=>{l+="<tr>\n";for(let s=0;s<i;s++){const i=s<e.length?e[s]:[],o=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<td${t("td",o)}>${k(i,t,n)}</td>\n`}l+="</tr>\n"}),l+="</tbody>\n");return l+="</table>",l}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return f(e.value||"");case"strong":return`<strong${t("strong")}>${k(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${k(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${k(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${f(e.value||"")}</code>`;case"link":{const r=p(e.url,n.allow_unsafe_urls),i=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=e.title?` title="${f(e.title)}"`:"";return`<a${t("a")} href="${f(r)}"${i}${l}>${k(e.children,t,n)}</a>`}case"image":{const r=p(e.url,n.allow_unsafe_urls),i=e.title?` title="${f(e.title)}"`:"";return`<img${t("img")} src="${f(r)}" alt="${f(e.alt||"")}"${i}>`}case"br":return"<br>";default:return e.children?k(e.children,t,n):void 0!==e.value?f(String(e.value)):""}}function k(e,t,n){return e?Array.isArray(e)?e.map(e=>x(e,t,n)).join(""):x(e,t,n):""}return b.toAst=g,b.renderAst=y,b.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown_ast_html=b),b});
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_html=t()}(this,function(){"use strict";function e(e,t={}){if(!e||"string"!=typeof e)return{type:"document",children:[]};return{type:"document",children:r(e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"))}}function t(e){const t=e.trim();return""===t||(!!/^#{1,6}\s/.test(t)||(!!(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t))||(!!/^>\s*/.test(t)||(!!/^[-*+]\s/.test(t)||(!!/^\d+\.\s/.test(t)||(!!t.startsWith("|")||!!/^(```|~~~)/.test(t)))))))}function n(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n){if((e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break}t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}function r(e,n){const l=[],o=e.split("\n");let a=0;for(;a<o.length;){const e=o[a];if(""===e.trim()){a++;continue}const n=e.match(/^(```|~~~)(.*)$/);if(n){const[,e,t]=n,r=t.trim(),i=[];for(a++;a<o.length;){if(o[a].match(/^(```|~~~)\s*$/)){a++;break}i.push(o[a]),a++}l.push({type:"code_block",lang:r||null,content:i.join("\n"),fence:e});continue}if(/^---+\s*$/.test(e)||/^\*\*\*+\s*$/.test(e)||/^___+\s*$/.test(e)){l.push({type:"hr"}),a++;continue}const u=e.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,e,t]=u;l.push({type:"heading",level:e.length,children:c(t)}),a++;continue}if(e.includes("|")){const e=i(o,a);if(e){l.push(e.node),a=e.nextIndex;continue}}if(e.match(/^>\s*/)){const e=[];let n=!0;for(;a<o.length;)if(o[a].match(/^>\s*/))e.push(o[a].replace(/^>\s*/,"")),n=!0,a++;else{if(!n||t(o[a]))break;e.push(o[a]),a++}const i=e.length>0?e[0].trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;if(i){const t=i[1].toLowerCase();l.push({type:"alert",alertType:t,children:r(e.slice(1).join("\n"))})}else l.push({type:"blockquote",children:r(e.join("\n"))});continue}if(e.match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/)){const e=s(o,a);l.push(e.node),a=e.nextIndex;continue}const d=[];for(;a<o.length;){const e=o[a];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("|")&&a+1<o.length&&/^\|?[\s\-:|]+\|?$/.test(o[a+1]))break;d.push(e),a++}d.length>0&&l.push({type:"paragraph",children:c(d.join("\n"))})}return l}function i(e,t,n){if(t+1>=e.length)return null;const r=e[t],i=e[t+1];if(!/^\|?[\s\-:|]+\|?$/.test(i)||!i.includes("-"))return null;const s=l(r);if(0===s.length)return null;const o=l(i).map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"}),a=o.length,u=[];for(let e=0;e<a;e++){const t=e<s.length?s[e]:"";u.push(c(t.trim()))}const d=[];let h=t+2;for(;h<e.length;){const t=e[h];if(!t.includes("|")||""===t.trim())break;const n=l(t),r=[];for(let e=0;e<a;e++){const t=e<n.length?n[e]:"";r.push(c(t.trim()))}d.push(r),h++}return{node:{type:"table",headers:u,rows:d,alignments:o},nextIndex:h}}function l(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|")}function s(e,t,n){const r=[];let i=t,l=0;const o=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/),a=/^\d+\./.test(o[2]),u=o[1].length;for(;i<e.length&&l<1e3;){l++;const t=e[i].match(/^(\s*)([*\-+]|\d+\.)\s+(.*)$/);if(!t)break;const[,n,o,d]=t,h=n.length;if(h<u)break;const f=/^\d+\./.test(o);if(h===u&&f!==a)break;if(h>u){const t=[];let n=0;for(;i<e.length&&n<1e3;){n++;const r=e[i],l=r.match(/^(\s*)([*\-+]|\d+\.)\s+/);if(!l)break;if(l[1].length<u)break;if(l[1].length===u)break;t.push(r),i++}if(t.length>0&&r.length>0){const e=s(t,0),n=r[r.length-1];n.children?Array.isArray(n.children)||(n.children=[{type:"paragraph",children:n.children}]):n.children=[],n.children.push(e.node)}continue}const p={type:"list_item",checked:null,children:null},g=d.match(/^\[([x ])\]\s*(.*)$/i);g&&!a?(p.checked="x"===g[1].toLowerCase(),p.children=c(g[2])):p.children=c(d),r.push(p),i++}return{node:{type:"list",ordered:a,items:r},nextIndex:i}}function o(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+"([^"]*)"\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]};const n=e.match(/^(.*)\s+'([^']*)'\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]}:e.startsWith("<")&&e.endsWith(">")?{url:e.slice(1,-1),title:null}:{url:e,title:null}}function c(e,t){if(!e)return[];const r=[];let i=e;for(;i.length>0;){if(i.match(/^(.+?)(?: {2}|\\\n|\n)/)&&i.includes("\n")){const e=i.indexOf("\n"),t=i.slice(0,e),n=i.slice(e+1);if(t.endsWith(" ")||t.endsWith("\\")){const e=t.replace(/\\$/,"").replace(/ +$/,"");e&&r.push(...a(e)),r.push({type:"br"}),i=n;continue}}const t=i.match(/^!\[([^\]]*)\]\(([^)]+)\)/);if(t){const{url:e,title:n}=o(t[2]),l={type:"image",alt:t[1],url:e.trim()};n&&(l.title=n),r.push(l),i=i.slice(t[0].length);continue}const l=i.match(/^\[([^\]]+)\]\(([^)]+)\)/);if(l){const{url:e,title:t}=o(l[2]),n={type:"link",url:e.trim(),children:a(l[1])};t&&(n.title=t),r.push(n),i=i.slice(l[0].length);continue}const s=i.match(/^`([^`\n]+)`/);if(s){r.push({type:"code",value:s[1]}),i=i.slice(s[0].length);continue}const c=i.match(/^(\*\*|__)(.+?)\1/);if(c){r.push({type:"strong",children:a(c[2])}),i=i.slice(c[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){r.push({type:"del",children:a(u[1])}),i=i.slice(u[0].length);continue}const d=e[e.length-i.length-1]||"",h=!/[A-Za-z0-9_]/.test(d),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||h&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){r.push({type:"em",children:a(f[1])}),i=i.slice(f[0].length);continue}const p=i.match(/^(https?:\/\/[^\s<>[\]]+)/);if(p){const{url:e,trailing:t}=n(p[1]);r.push({type:"link",url:e,children:[{type:"text",value:e}]}),t&&r.push({type:"text",value:t}),i=i.slice(p[0].length);continue}const g=i.search(/[`*_~![\\n]|https?:\/\//);if(-1===g){r.push({type:"text",value:i});break}0===g?(r.push({type:"text",value:i[0]}),i=i.slice(1)):(r.push({type:"text",value:i.slice(0,g)}),i=i.slice(g))}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}(r)}function a(e,t){return c(e.replace(/\n/g," "))}e.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof window&&(window.quikdown_ast=e);const u="quikdown-",d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},h={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",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function f(e){return e?String(e).replace(/[&<>"']/g,e=>d[e]):""}function p(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);?/g,(e,t)=>String.fromCodePoint(parseInt(t,10))).replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#039;|&apos;/gi,"'");let i="";for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>32&&127!==t&&(i+=r[e])}const l=i.toLowerCase(),s=["javascript:","vbscript:","data:"];for(const e of s)if(l.startsWith(e))return"data:"===e&&l.startsWith("data:image/")?n:"#";return n}function g(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=m(r.split("\n"),0,0).value;if(e&&e.type)return e}catch(e){}return e(t,n)}return{type:"document",children:[]}}function m(e,t,n){if(t>=e.length)return{value:null,nextLine:t};const r=e[t],i=r.trim();if(""===i)return m(e,t+1,n);const l=r.search(/\S/);if(l<n&&l>=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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;if(s>n&&r.length>0){i++;continue}if(!l.startsWith("- "))break;const o=l.slice(2);if(o.includes(":")){const t={},l=o.indexOf(":"),c=o.slice(0,l).trim(),a=o.slice(l+1).trim();if(""===a||a.startsWith("\n")){const n=m(e,i+1,s+2);t[c]=n.value,i=n.nextLine}else t[c]=$(a),i++;for(;i<e.length;){const r=e[i],l=r.trim();if(""===l){i++;continue}const s=r.search(/\S/);if(s<=n)break;if(l.startsWith("- "))break;const o=l.indexOf(":");if(o>0){const n=l.slice(0,o).trim(),r=l.slice(o+1).trim();if(""===r||r.startsWith("\n")){const r=m(e,i+1,s+2);t[n]=r.value,i=r.nextLine}else t[n]=$(r),i++}else i++}r.push(t)}else r.push($(o)),i++}return{value:r,nextLine:i}}(e,t,l);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],l=t.trim();if(""===l){i++;continue}const s=t.search(/\S/);if(s<n&&s>=0)break;const o=l.indexOf(":");if(o<=0){i++;continue}const c=l.slice(0,o).trim(),a=l.slice(o+1).trim();if(""===a||"|"===a||">"===a){const t=m(e,i+1,s+2);r[c]=t.value,i=t.nextLine}else r[c]=$(a),i++}return{value:r,nextLine:i}}(e,t,l):{value:$(i),nextLine:t+1}}function $(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 b(e,t={}){return y(g(e,t),t)}function y(e,t={}){if(!e)return"";const{inline_styles:n=!1}=t,r=function(e){return function(t,n=""){if(e){let e=h[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="${u}${t}"`;return n?`${e} style="${n}"`:e}}}(n);return x(e,r,t)}function x(e,t,n){if(!e)return"";switch(e.type){case"document":return k(e.children,t,n);case"paragraph":return`<p>${k(e.children,t,n)}</p>`;case"heading":const r=e.level||1;return`<h${r}${t("h"+r)}>${k(e.children,t,n)}</h${r}>`;case"code_block":const i=!n.inline_styles&&e.lang?` class="language-${f(e.lang)}"`:"",l=n.inline_styles?t("code"):i;return`<pre${t("pre")}><code${l}>${f(e.content)}</code></pre>`;case"blockquote":return`<blockquote${t("blockquote")}>${k(e.children,t,n)}</blockquote>`;case"alert":{const r=(e.alertType||"note").toLowerCase(),i={note:"Note",tip:"Tip",important:"Important",warning:"Warning",caution:"Caution"}[r]||"Note";if(n.inline_styles){const l=h.alert,s=h["alert-"+r];return`<div style="${s?`${l};${s}`:l}"><p style="${h["alert-title"]}">${i}</p>${k(e.children,t,n)}</div>`}return`<div class="${u}alert ${u}alert-${r}"><p class="${u}alert-title">${i}</p>${k(e.children,t,n)}</div>`}case"list":const s=e.ordered?"ol":"ul",o=(e.items||[]).map(e=>x(e,t,n)).join("");return`<${s}${t(s)}>${o}</${s}>`;case"list_item":if(null!==e.checked&&void 0!==e.checked){const r=n.inline_styles?' style="margin-right:.5em"':` class="${u}task-checkbox"`,i=e.checked?" checked":"";return`<li${n.inline_styles?' style="list-style:none"':` class="${u}task-item"`}><input type="checkbox"${r}${i} disabled> ${k(e.children,t,n)}</li>`}return`<li${t("li")}>${k(e.children,t,n)}</li>`;case"table":return function(e,t,n){const r=e.alignments||[],i=r.length||(e.headers?e.headers.length:0);let l=`<table${t("table")}>\n`;if(e.headers&&e.headers.length>0){l+="<thead>\n<tr>\n";for(let s=0;s<i;s++){const i=s<e.headers.length?e.headers[s]:[],o=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<th${t("th",o)}>${k(i,t,n)}</th>\n`}l+="</tr>\n</thead>\n"}e.rows&&e.rows.length>0&&(l+="<tbody>\n",e.rows.forEach(e=>{l+="<tr>\n";for(let s=0;s<i;s++){const i=s<e.length?e[s]:[],o=r[s]&&"left"!==r[s]?`text-align:${r[s]}`:"";l+=`<td${t("td",o)}>${k(i,t,n)}</td>\n`}l+="</tr>\n"}),l+="</tbody>\n");return l+="</table>",l}(e,t,n);case"hr":return`<hr${t("hr")}>`;case"text":return f(e.value||"");case"strong":return`<strong${t("strong")}>${k(e.children,t,n)}</strong>`;case"em":return`<em${t("em")}>${k(e.children,t,n)}</em>`;case"del":return`<del${t("del")}>${k(e.children,t,n)}</del>`;case"code":return`<code${t("code")}>${f(e.value||"")}</code>`;case"link":{const r=p(e.url,n.allow_unsafe_urls),i=/^https?:\/\//i.test(r)?' rel="noopener noreferrer"':"",l=e.title?` title="${f(e.title)}"`:"";return`<a${t("a")} href="${f(r)}"${i}${l}>${k(e.children,t,n)}</a>`}case"image":{const r=p(e.url,n.allow_unsafe_urls),i=e.title?` title="${f(e.title)}"`:"";return`<img${t("img")} src="${f(r)}" alt="${f(e.alt||"")}"${i}>`}case"br":return"<br>";default:return e.children?k(e.children,t,n):void 0!==e.value?f(String(e.value)):""}}function k(e,t,n){return e?Array.isArray(e)?e.map(e=>x(e,t,n)).join(""):x(e,t,n):""}return b.toAst=g,b.renderAst=y,b.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown_ast_html=b),b});
8
8
  //# sourceMappingURL=quikdown_ast_html.umd.min.js.map
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_bd - Bidirectional Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -127,7 +127,7 @@ function isHRLine(trimmed) {
127
127
  // ────────────────────────────────────────────────────────────────────
128
128
 
129
129
  /** Build-time version stamp (injected by tools/updateVersion) */
130
- const quikdownVersion = '1.2.17';
130
+ const quikdownVersion = '1.2.19';
131
131
 
132
132
  /** CSS class prefix used for all generated elements */
133
133
  const CLASS_PREFIX = 'quikdown-';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_bd - Bidirectional Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -125,7 +125,7 @@ function isHRLine(trimmed) {
125
125
  // ────────────────────────────────────────────────────────────────────
126
126
 
127
127
  /** Build-time version stamp (injected by tools/updateVersion) */
128
- const quikdownVersion = '1.2.17';
128
+ const quikdownVersion = '1.2.19';
129
129
 
130
130
  /** CSS class prefix used for all generated elements */
131
131
  const CLASS_PREFIX = 'quikdown-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_bd - Bidirectional Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",o="§BE",l={href:1,src:1,action:1,formaction:1},c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a={h1:"font-size:2em;margin:.67em 0;text-align:left",h2:"font-size:1.5em;margin:.83em 0",h3:"font-size:1.25em;margin:1em 0",h4:"font-size:1em;margin:1.33em 0",h5:"font-size:.875em;margin:1.67em 0",h6:"font-size:.85em;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function s(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+(?:"([^"]*)"|&quot;([^&]*?)&quot;)\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]??t[3]};const n=e.match(/^(.*)\s+(?:'([^']*)'|&#39;([^&]*?)&#39;)\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]??n[3]}:e.startsWith("&lt;")&&e.endsWith("&gt;")?{url:e.slice(4,-4),title:null}:{url:e,title:null}}function i(e){return e.replace(/[*_`~]/g,"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}function u(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function d(e){let t=0,n=0;for(;n<e.length&&e.startsWith("&gt;",n);)n+=4,t++," "===e[n]&&n++;return{depth:t,content:e.slice(n)}}function f(t){const r=t.trim();return""===r||(!!/^#{1,6}\s/.test(r)||(!!e(r)||(!!/^&gt;/.test(r)||(!!/^[-*+]\s/.test(r)||(!!/^\d+\.\s/.test(r)||(!!r.startsWith("|")||!!r.startsWith(n)))))))}const $={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const o=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let l="";const c=[],s=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:u,content:d}=e[i];if(!(u<=0)){if(o&&0===i){const e=o[1].toUpperCase(),n=e.toLowerCase();if(s){const e=a.alert,t=a["alert-"+n];l+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else l+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=$[e];l+=s?`<p style="${a["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,c.push("alert");continue}for(;c.length>u;){l+="alert"===c.pop()?"</div>":"</blockquote>"}for(;c.length<u;)0===c.length&&o?c.push("alert"):(l+=`<blockquote${n("blockquote")}${r(">")}>`,c.push("blockquote"));l+=d,i<e.length-1&&(l+="\n")}}for(;c.length>0;){l+="alert"===c.pop()?"</div>":"</blockquote>"}return l.trimEnd()}function p(e){if(0===e.length)return!1;const t=e.match(/^([ \t]+)(.*)$/);if(!t)return!1;if(t[1].replace(/\t/g," ").length<4)return!1;const n=t[2];return!(/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/^>/.test(n)||/^#{1,6}\s/.test(n))}function h(e){if(e.startsWith(" "))return e.slice(4);if("\t"===e[0])return e.slice(1);const t=e.match(/^[ \t]+(.*)$/);return t?t[1]:e}function m(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function b($,m={}){if(!$||"string"!=typeof $)return"";const{fence_plugin:b,inline_styles:q=!1,bidirectional:y=!1,lazy_linefeeds:_=!1,allow_unsafe_html:k=!1,heading_ids:A=!1}=m,w=function(e,n){return function(r,o=""){if(e){let e=n[r];return e||o?(o&&o.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${o?e?`${e}${o}`:o:e}"`):""}{const e=` class="${t}${r}"`;return o?`${e} style="${o}"`:e}}}(q,a),N=new Map;function E(e){return e.replace(/[&<>"']/g,e=>c[e])}const v=y?e=>` data-qd="${E(e)}"`:()=>"";function T(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),o=["javascript:","vbscript:","data:"];for(const e of o)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let C=$;const L=[],z=[];C=C.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${L.length}§`,c=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?L.push({lang:c,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):L.push({lang:c,code:E(o.trimEnd()),custom:!1,fence:t}),l});const j=[];C=C.replace(/\\`/g,()=>{const e=`${o}${j.length}§`;return j.push("`"),e}),C=C.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${z.length}§`;return z.push(E(t)),n}),C=C.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${o}${j.length}§`;return j.push(E(t)),n});const S=[],W=Array.isArray(k)?Object.fromEntries(k.map(e=>[e,1])):k&&"object"==typeof k?k:null;W&&(C=C.replace(/<!--[\s\S]*?-->/g,e=>{const t=S.length;return S.push(e),`${r}${t}§`}),C=C.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in W){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,o]=t,c=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,a=[];let s;for(;null!==(s=c.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)a.push(e);else{let n=t;e.toLowerCase()in l&&(n=T(t)),a.push(`${e}="${n}"`)}}return n+(a.length?" "+a.join(" "):"")+o}(e),n=S.length;return S.push(t),`${r}${n}§`}return e})),!0!==k&&(C=E(C)),W&&S.forEach((e,t)=>{C=C.replace(`${r}${t}§`,e)}),C=function(e,t,n){const r=e.split("\n"),o=[];let l=0;for(;l<r.length;){if(!p(r[l])){o.push(r[l]),l++;continue}const e=[];for(;l<r.length;){const t=r[l];if(""===t){if(l+1<r.length&&p(r[l+1])){e.push(""),l++;continue}break}if(!p(t))break;e.push(h(t)),l++}const c=e.join("\n");o.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${c}</code></pre>`)}return o.join("\n")}(C,w,v),C=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,c=[];for(let e=0;e<r.length;e++){const a=r[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))l||(l=!0,c=[]),c.push(a);else{if(l){const e=x(c,t,n);e?o.push(e):o.push(...c),l=!1,c=[]}o.push(r[e])}}if(l&&c.length>0){const e=x(c,t,n);e?o.push(e):o.push(...c)}return o.join("\n")}(C,w,y),C=function(t,n,r,o,l,c){const a=t.split("\n"),s=[];let $=0;for(;$<a.length;){const t=a[$];if(/^\[\/\/\]: #/.test(t)){$++;continue}let p=0;for(;p<t.length&&p<7&&"#"===t[p];)p++;if(p>=1&&p<=6&&" "===t[p]){const e=t.slice(p+1).replace(/\s*#+\s*$/,""),a="h"+p;let d="";if(o){d=` id="${c(u(i(e),l))}"`}s.push(`<${a}${n(a)}${d}${r("#".repeat(p))}>${e}</${a}>`),$++;continue}if(e(t))s.push(`<hr${n("hr")}${r(t.trim())}>`),$++;else{if(d(t).depth>0){const e=[];let t=0;for(;$<a.length;){const n=d(a[$]);if(n.depth>0)e.push(n),t=n.depth,$++;else{if(!(t>0)||f(a[$]))break;e.push({depth:t,content:a[$]}),$++}}s.push(g(e,n,r));continue}s.push(t),$++}}return s.join("\n")}(C,w,v,A,N,E),C=function(e,n,r,o){const l=e.split("\n"),c=[],a=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,u=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let $=l,g="";const p=l.match(/^\[([x ])\]\s+(.*)$/i);if(p&&!d){const[,e,n]=p,o="x"===e.toLowerCase();$=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;a.length>u+1;){const e=a.pop();c.push(`</${e.type}>`)}if(a.length===u)a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`);else if(a.length===u+1){const e=a[a.length-1];e.type!==f&&(c.push(`</${e.type}>`),a.pop(),a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`))}const h=g||n("li");c.push(`<li${h}${i(o)}>${$}</li>`)}else{for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}c.push(o)}}for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}return c.join("\n")}(C,w,q,y),C=C.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=T(r,m.allow_unsafe_urls),c=o?` title="${E(o)}"`:"",a=y&&t?` data-qd-alt="${E(t)}"`:"",i=y?` data-qd-src="${E(r)}"`:"",u=y&&o?` data-qd-title="${E(o)}"`:"";return`<img${w("img")} src="${l}" alt="${t}"${c}${a}${i}${u}${v("!")}>`}),C=C.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=T(r,m.allow_unsafe_urls),c=/^https?:\/\//i.test(l)?' rel="noopener noreferrer"':"",a=o?` title="${E(o)}"`:"",i=y?` data-qd-text="${E(t)}"`:"",u=y&&o?` data-qd-title="${E(o)}"`:"";return`<a${w("a")} href="${l}"${c}${a}${i}${u}${v("[")}>${t}</a>`}),C=C.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:o}=function(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n&&(e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break;t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}(n),l=T(r,m.allow_unsafe_urls);return`${t}<a${w("a")} href="${l}" rel="noopener noreferrer">${r}</a>${o}`});const O=[];C=C.replace(/<[^>]+>/g,e=>(O.push(e),`%%T${O.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{C=C.replace(e,`<${t}${w(t)}${v(n)}>$1</${t}>`)}),C=C.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),C=C.replace(/\\\n/g,`<br${w("br")}>`),_){const e=[];let t=0;C=C.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),C=C.replace(/\n\n+/g,"§P§").replace(/(<\/(?:h[1-6]|blockquote|pre)>)\n/g,"$1§N§").replace(/(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)\n/g,"$1§N§").replace(/\n(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)/g,"§N§$1").replace(/\n(§B\d+§)/g,"§N§$1").replace(/(§B\d+§)\n/g,"$1§N§").replace(/\n/g,`<br${w("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>C=C.replace(`§B${t}§`,e)),C="<p>"+C+"</p>"}else C=C.replace(/ {2}$/gm,`<br${w("br")}>`),C=C.replace(/\n\n+/g,(e,t)=>C.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),C="<p>"+C+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[/<p>(<div[^>]*>)/g,"$1"],[/(<\/div>)<\/p>/g,"$1"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{C=C.replace(e,t)}),C=C.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),L.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=y&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=y?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${E(e.code)}</code></pre>`}else y&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${E(e.fence)}" data-qd-lang="${E(e.lang)}" data-qd-source="${E(e.code)}"`));else{const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=y&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=y?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;C=C.replace(o,r)}),z.forEach((e,t)=>{const n=`§IC${t}§`;C=C.replace(n,`<code${w("code")}${v("`")}>${e}</code>`)}),j.forEach((e,t)=>{C=C.replace(`${o}${t}§`,e)}),C.trim()}function q(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`\n]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function x(e,t,n){if(e.length<2)return null;let r,o,l,c=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){c=t;break}if(-1===c)r=[e[0]],o=e.slice(1),l=m(e[0]).map(()=>"left");else{r=e.slice(0,c),o=e.slice(c+1);const t=m(e[c]);l=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const a=l.length,s=n?` data-qd-align="${l.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<th${t("th",o)}>${c}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",o.length>0&&(i+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<td${t("td",o)}>${c}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}function y(e,t={}){return b(e,{...t,bidirectional:!0})}b.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[c,a]of Object.entries(n)){let n=a;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${c} { ${n} }\n`}return l},b.configure=function(e){return function(t){return b(t,e)}},b.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown=b),Object.keys(b).forEach(e=>{"configure"!==e&&(y[e]=b[e])}),y.toMarkdown=function(e,t={}){let n;if("string"==typeof e)n=document.createElement("div"),n.innerHTML=e;else{if(!(e instanceof Element))return"";n=e}function r(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const l=e.tagName.toLowerCase(),c=e.getAttribute("data-qd");let a="";for(const t of e.childNodes)a+=r(t,{parentTag:l,...n});switch(l){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(l[1]);return`${c||"#".repeat(n)} ${a.trim()}\n\n`;case"strong":case"b":if(!a)return"";const r=c||"**";return`${r}${a}${r}`;case"em":case"i":if(!a)return"";const s=c||"*";return`${s}${a}${s}`;case"del":case"s":case"strike":if(!a)return"";const i=c||"~~";return`${i}${a}${i}`;case"code":if(!a)return"";const u=c||"`";return`${u}${a}${u}`;case"pre":const d=e.getAttribute("data-qd-fence")||c||"```",f=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&f)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||d;return`${e}${n.lang||f}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const $=e.getAttribute("data-qd-source");if($)return`${d}${f}\n${$}\n${d}\n\n`;const g=e.querySelector("code");return`${d}${f}\n${(g?g.textContent:a).trimEnd()}\n${d}\n\n`;case"blockquote":const p=c||">";return a.trim().split("\n").map(e=>`${p} ${e}`).join("\n")+"\n\n";case"hr":return`${c||"---"}\n\n`;case"br":return`${c||" "}\n`;case"a":const h=e.getAttribute("data-qd-text")||a.trim(),m=e.getAttribute("href")||"";return h!==m||c?`[${h}](${m})`:`<${m}>`;case"img":return`${c||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return o(e,"ol"===l)+"\n";case"li":case"span":default:return a;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),r=n?n.split(","):[],o=e.querySelector("thead");if(o){const e=o.querySelector("tr");if(e){const n=[];for(const t of e.querySelectorAll("th"))n.push(t.textContent.trim());t+="| "+n.join(" | ")+" |\n";t+="| "+n.map((e,t)=>{const n=r[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const l=e.querySelector("tbody");if(l)for(const e of l.querySelectorAll("tr")){const n=[];for(const t of e.querySelectorAll("td"))n.push(t.textContent.trim());n.length>0&&(t+="| "+n.join(" | ")+" |\n")}return t.trim()}(e)+"\n\n";case"p":if(a.trim()){const e=a.split("\n");let t=a.trim();if(e.length>1){let n=0;for(let t=e.length-1;t>=0&&""===e[t].trim();t--)n++;if(n>0)return t+="\n ",t+"\n"}return t+"\n\n"}return"";case"div":const b=e.getAttribute("data-qd-lang"),q=e.getAttribute("data-qd-fence");if(b&&t.fence_plugin&&t.fence_plugin.reverse)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||q||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const x=e.getAttribute("data-qd-source");if(x&&q)return`${q}${b||""}\n${x}\n${q}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",r=e.getAttribute("data-qd-source");if(r){const e=document.createElement("textarea");e.innerHTML=r;return`${t}${n}\n${e.value}\n${t}\n\n`}const o=e.querySelector("pre.mermaid");if(o){const e=o.getAttribute("data-qd-source");if(e){const r=document.createElement("textarea");r.innerHTML=e;return`${t}${n}\n${r.value}\n${t}\n\n`}}const l=e.querySelector(".mermaid-source");if(l){const e=document.createElement("div");e.innerHTML=l.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const c=e.querySelector(".mermaid");if(c&&c.textContent.includes("graph"))return`${t}${n}\n${c.textContent.trim()}\n${t}\n\n`}if(e.classList&&e.classList.contains("mermaid")){const t=e.getAttribute("data-qd-fence")||"```";return`${t}${e.getAttribute("data-qd-lang")||"mermaid"}\n${e.textContent.trim()}\n${t}\n\n`}return a}}function o(e,t,n=0){let l="",c=1;const a=" ".repeat(n);for(const s of e.children){if("LI"!==s.tagName)continue;let e=s.getAttribute("data-qd")||(t?`${c}.`:"-");const i=s.querySelector('input[type="checkbox"]');if(i){const t=i.checked?"x":" ";e="-";let n="";for(const e of s.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=r(e));l+=`${a}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of s.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=o(e,"OL"===e.tagName,n+1):t+=r(e);l+=`${a}${e} ${t.trim()}\n`}c++}return l}let l=r(n);return l=l.replace(/\n{3,}/g,"\n\n"),l=l.trim(),l},y.configure=function(e){const t=b.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=y),"undefined"!=typeof window&&(window.quikdown_bd=y);export{y as default};
7
+ function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",o="§BE",l={href:1,src:1,action:1,formaction:1},c={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a={h1:"font-size:2em;margin:.67em 0;text-align:left",h2:"font-size:1.5em;margin:.83em 0",h3:"font-size:1.25em;margin:1em 0",h4:"font-size:1em;margin:1.33em 0",h5:"font-size:.875em;margin:1.67em 0",h6:"font-size:.85em;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em",alert:"padding:1em;margin:1em 0;border-left:4px solid #0969da;border-radius:4px;background:#ddf4ff","alert-title":"font-weight:600;margin:0 0 .4em","alert-note":"border-left-color:#0969da;background:#ddf4ff","alert-tip":"border-left-color:#1a7f37;background:#dafbe1","alert-important":"border-left-color:#8250df;background:#fbefff","alert-warning":"border-left-color:#9a6700;background:#fff8c5","alert-caution":"border-left-color:#cf222e;background:#ffebe9"};function s(e){if(null==e||""===e)return{url:"",title:null};const t=e.match(/^(.*)\s+(?:"([^"]*)"|&quot;([^&]*?)&quot;)\s*$/);if(t)return{url:t[1].replace(/\s+$/,""),title:t[2]??t[3]};const n=e.match(/^(.*)\s+(?:'([^']*)'|&#39;([^&]*?)&#39;)\s*$/);return n?{url:n[1].replace(/\s+$/,""),title:n[2]??n[3]}:e.startsWith("&lt;")&&e.endsWith("&gt;")?{url:e.slice(4,-4),title:null}:{url:e,title:null}}function i(e){return e.replace(/[*_`~]/g,"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"section"}function u(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function d(e){let t=0,n=0;for(;n<e.length&&e.startsWith("&gt;",n);)n+=4,t++," "===e[n]&&n++;return{depth:t,content:e.slice(n)}}function f(t){const r=t.trim();return""===r||(!!/^#{1,6}\s/.test(r)||(!!e(r)||(!!/^&gt;/.test(r)||(!!/^[-*+]\s/.test(r)||(!!/^\d+\.\s/.test(r)||(!!r.startsWith("|")||!!r.startsWith(n)))))))}const $={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const o=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let l="";const c=[],s=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:u,content:d}=e[i];if(!(u<=0)){if(o&&0===i){const e=o[1].toUpperCase(),n=e.toLowerCase();if(s){const e=a.alert,t=a["alert-"+n];l+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else l+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=$[e];l+=s?`<p style="${a["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,c.push("alert");continue}for(;c.length>u;){l+="alert"===c.pop()?"</div>":"</blockquote>"}for(;c.length<u;)0===c.length&&o?c.push("alert"):(l+=`<blockquote${n("blockquote")}${r(">")}>`,c.push("blockquote"));l+=d,i<e.length-1&&(l+="\n")}}for(;c.length>0;){l+="alert"===c.pop()?"</div>":"</blockquote>"}return l.trimEnd()}function p(e){if(0===e.length)return!1;const t=e.match(/^([ \t]+)(.*)$/);if(!t)return!1;if(t[1].replace(/\t/g," ").length<4)return!1;const n=t[2];return!(/^[-*+]\s/.test(n)||/^\d+\.\s/.test(n)||/^>/.test(n)||/^#{1,6}\s/.test(n))}function h(e){if(e.startsWith(" "))return e.slice(4);if("\t"===e[0])return e.slice(1);const t=e.match(/^[ \t]+(.*)$/);return t?t[1]:e}function m(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|")}function b($,m={}){if(!$||"string"!=typeof $)return"";const{fence_plugin:b,inline_styles:q=!1,bidirectional:y=!1,lazy_linefeeds:_=!1,allow_unsafe_html:k=!1,heading_ids:A=!1}=m,w=function(e,n){return function(r,o=""){if(e){let e=n[r];return e||o?(o&&o.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${o?e?`${e}${o}`:o:e}"`):""}{const e=` class="${t}${r}"`;return o?`${e} style="${o}"`:e}}}(q,a),N=new Map;function E(e){return e.replace(/[&<>"']/g,e=>c[e])}const v=y?e=>` data-qd="${E(e)}"`:()=>"";function T(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),o=["javascript:","vbscript:","data:"];for(const e of o)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let C=$;const L=[],z=[];C=C.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,o)=>{const l=`${n}${L.length}§`,c=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?L.push({lang:c,code:o.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):L.push({lang:c,code:E(o.trimEnd()),custom:!1,fence:t}),l});const j=[];C=C.replace(/\\`/g,()=>{const e=`${o}${j.length}§`;return j.push("`"),e}),C=C.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${z.length}§`;return z.push(E(t)),n}),C=C.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${o}${j.length}§`;return j.push(E(t)),n});const S=[],W=Array.isArray(k)?Object.fromEntries(k.map(e=>[e,1])):k&&"object"==typeof k?k:null;W&&(C=C.replace(/<!--[\s\S]*?-->/g,e=>{const t=S.length;return S.push(e),`${r}${t}§`}),C=C.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in W){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,o]=t,c=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,a=[];let s;for(;null!==(s=c.exec(r));){const e=s[1],t=void 0!==s[2]?s[2]:void 0!==s[3]?s[3]:s[4];if(!/^on/i.test(e))if(void 0===t)a.push(e);else{let n=t;e.toLowerCase()in l&&(n=T(t)),a.push(`${e}="${n}"`)}}return n+(a.length?" "+a.join(" "):"")+o}(e),n=S.length;return S.push(t),`${r}${n}§`}return e})),!0!==k&&(C=E(C)),W&&S.forEach((e,t)=>{C=C.replace(`${r}${t}§`,e)}),C=function(e,t,n){const r=e.split("\n"),o=[];let l=0;for(;l<r.length;){if(!p(r[l])){o.push(r[l]),l++;continue}const e=[];for(;l<r.length;){const t=r[l];if(""===t){if(l+1<r.length&&p(r[l+1])){e.push(""),l++;continue}break}if(!p(t))break;e.push(h(t)),l++}const c=e.join("\n");o.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${c}</code></pre>`)}return o.join("\n")}(C,w,v),C=function(e,t,n){const r=e.split("\n"),o=[];let l=!1,c=[];for(let e=0;e<r.length;e++){const a=r[e].trim();if(a.includes("|")&&(a.startsWith("|")||/[^\\|]/.test(a)))l||(l=!0,c=[]),c.push(a);else{if(l){const e=x(c,t,n);e?o.push(e):o.push(...c),l=!1,c=[]}o.push(r[e])}}if(l&&c.length>0){const e=x(c,t,n);e?o.push(e):o.push(...c)}return o.join("\n")}(C,w,y),C=function(t,n,r,o,l,c){const a=t.split("\n"),s=[];let $=0;for(;$<a.length;){const t=a[$];if(/^\[\/\/\]: #/.test(t)){$++;continue}let p=0;for(;p<t.length&&p<7&&"#"===t[p];)p++;if(p>=1&&p<=6&&" "===t[p]){const e=t.slice(p+1).replace(/\s*#+\s*$/,""),a="h"+p;let d="";if(o){d=` id="${c(u(i(e),l))}"`}s.push(`<${a}${n(a)}${d}${r("#".repeat(p))}>${e}</${a}>`),$++;continue}if(e(t))s.push(`<hr${n("hr")}${r(t.trim())}>`),$++;else{if(d(t).depth>0){const e=[];let t=0;for(;$<a.length;){const n=d(a[$]);if(n.depth>0)e.push(n),t=n.depth,$++;else{if(!(t>0)||f(a[$]))break;e.push({depth:t,content:a[$]}),$++}}s.push(g(e,n,r));continue}s.push(t),$++}}return s.join("\n")}(C,w,v,A,N,E),C=function(e,n,r,o){const l=e.split("\n"),c=[],a=[],s=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=o?e=>` data-qd="${s(e)}"`:()=>"";for(let e=0;e<l.length;e++){const o=l[e],s=o.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(s){const[,e,o,l]=s,u=Math.floor(e.length/2),d=/^\d+\./.test(o),f=d?"ol":"ul";let $=l,g="";const p=l.match(/^\[([x ])\]\s+(.*)$/i);if(p&&!d){const[,e,n]=p,o="x"===e.toLowerCase();$=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${o?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;a.length>u+1;){const e=a.pop();c.push(`</${e.type}>`)}if(a.length===u)a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`);else if(a.length===u+1){const e=a[a.length-1];e.type!==f&&(c.push(`</${e.type}>`),a.pop(),a.push({type:f,level:u}),c.push(`<${f}${n(f)}>`))}const h=g||n("li");c.push(`<li${h}${i(o)}>${$}</li>`)}else{for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}c.push(o)}}for(;a.length>0;){const e=a.pop();c.push(`</${e.type}>`)}return c.join("\n")}(C,w,q,y),C=C.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=T(r,m.allow_unsafe_urls),c=o?` title="${E(o)}"`:"",a=y&&t?` data-qd-alt="${E(t)}"`:"",i=y?` data-qd-src="${E(r)}"`:"",u=y&&o?` data-qd-title="${E(o)}"`:"";return`<img${w("img")} src="${l}" alt="${t}"${c}${a}${i}${u}${v("!")}>`}),C=C.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:o}=s(n),l=T(r,m.allow_unsafe_urls),c=/^https?:\/\//i.test(l)?' rel="noopener noreferrer"':"",a=o?` title="${E(o)}"`:"",i=y?` data-qd-text="${E(t)}"`:"",u=y&&o?` data-qd-title="${E(o)}"`:"";return`<a${w("a")} href="${l}"${c}${a}${i}${u}${v("[")}>${t}</a>`}),C=C.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:o}=function(e){let t="";const n=/[.,;:!?)]/;for(;e.length>0&&n.test(e[e.length-1]);){const n=e[e.length-1];if(")"===n&&(e.match(/\(/g)||[]).length>=(e.match(/\)/g)||[]).length)break;t=n+t,e=e.slice(0,-1)}return{url:e,trailing:t}}(n),l=T(r,m.allow_unsafe_urls);return`${t}<a${w("a")} href="${l}" rel="noopener noreferrer">${r}</a>${o}`});const O=[];C=C.replace(/<[^>]+>/g,e=>(O.push(e),`%%T${O.length-1}%%`));if([[/\*\*(.+?)\*\*/g,"strong","**"],[/__(.+?)__/g,"strong","__"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em","*"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em","_"],[/~~(.+?)~~/g,"del","~~"]].forEach(([e,t,n])=>{C=C.replace(e,`<${t}${w(t)}${v(n)}>$1</${t}>`)}),C=C.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),C=C.replace(/\\\n/g,`<br${w("br")}>`),_){const e=[];let t=0;C=C.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),C=C.replace(/\n\n+/g,"§P§").replace(/(<\/(?:h[1-6]|blockquote|pre)>)\n/g,"$1§N§").replace(/(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)\n/g,"$1§N§").replace(/\n(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)/g,"§N§$1").replace(/\n(§B\d+§)/g,"§N§$1").replace(/(§B\d+§)\n/g,"$1§N§").replace(/\n/g,`<br${w("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>C=C.replace(`§B${t}§`,e)),C="<p>"+C+"</p>"}else C=C.replace(/ {2}$/gm,`<br${w("br")}>`),C=C.replace(/\n\n+/g,(e,t)=>C.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),C="<p>"+C+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[/<p>(<div[^>]*>)/g,"$1"],[/(<\/div>)<\/p>/g,"$1"],[new RegExp(`<p>(${n}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{C=C.replace(e,t)}),C=C.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),L.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=y&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=y?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${E(e.code)}</code></pre>`}else y&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${E(e.fence)}" data-qd-lang="${E(e.lang)}" data-qd-source="${E(e.code)}"`));else{const t=!q&&e.lang?` class="language-${E(e.lang)}"`:"",n=q?w("code"):t,o=y&&e.lang?` data-qd-lang="${E(e.lang)}"`:"",l=y?` data-qd-fence="${E(e.fence)}"`:"";r=`<pre${w("pre")}${l}${o}><code${n}>${e.code}</code></pre>`}const o=`${n}${t}§`;C=C.replace(o,r)}),z.forEach((e,t)=>{const n=`§IC${t}§`;C=C.replace(n,`<code${w("code")}${v("`")}>${e}</code>`)}),j.forEach((e,t)=>{C=C.replace(`${o}${t}§`,e)}),C.trim()}function q(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<![A-Za-z0-9_])_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`\n]+)`/g,"code"]].forEach(([n,r])=>{e=e.replace(n,`<${r}${t(r)}>$1</${r}>`)}),e}function x(e,t,n){if(e.length<2)return null;let r,o,l,c=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){c=t;break}if(-1===c)r=[e[0]],o=e.slice(1),l=m(e[0]).map(()=>"left");else{r=e.slice(0,c),o=e.slice(c+1);const t=m(e[c]);l=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const a=l.length,s=n?` data-qd-align="${l.join(",")}"`:"";let i=`<table${t("table")}${s}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<th${t("th",o)}>${c}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",o.length>0&&(i+=`<tbody${t("tbody")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<a;e++){const r=e<n.length?n[e]:"",o=l[e]&&"left"!==l[e]?`text-align:${l[e]}`:"",c=q(r.trim(),t);i+=`<td${t("td",o)}>${c}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}function y(e,t={}){return b(e,{...t,bidirectional:!0})}b.emitStyles=function(e="quikdown-",t="light"){const n=a,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},o={_textColor:"#333"};let l="";for(const[c,a]of Object.entries(n)){let n=a;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&o){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(c)&&(n+=`;color:${o._textColor}`)}l+=`.${e}${c} { ${n} }\n`}return l},b.configure=function(e){return function(t){return b(t,e)}},b.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=b),"undefined"!=typeof window&&(window.quikdown=b),Object.keys(b).forEach(e=>{"configure"!==e&&(y[e]=b[e])}),y.toMarkdown=function(e,t={}){let n;if("string"==typeof e)n=document.createElement("div"),n.innerHTML=e;else{if(!(e instanceof Element))return"";n=e}function r(e,n={}){if(e.nodeType===Node.TEXT_NODE)return e.textContent;if(e.nodeType!==Node.ELEMENT_NODE)return"";const l=e.tagName.toLowerCase(),c=e.getAttribute("data-qd");let a="";for(const t of e.childNodes)a+=r(t,{parentTag:l,...n});switch(l){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":const n=parseInt(l[1]);return`${c||"#".repeat(n)} ${a.trim()}\n\n`;case"strong":case"b":if(!a)return"";const r=c||"**";return`${r}${a}${r}`;case"em":case"i":if(!a)return"";const s=c||"*";return`${s}${a}${s}`;case"del":case"s":case"strike":if(!a)return"";const i=c||"~~";return`${i}${a}${i}`;case"code":if(!a)return"";const u=c||"`";return`${u}${a}${u}`;case"pre":const d=e.getAttribute("data-qd-fence")||c||"```",f=e.getAttribute("data-qd-lang")||"";if(t.fence_plugin&&t.fence_plugin.reverse&&f)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||d;return`${e}${n.lang||f}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const $=e.getAttribute("data-qd-source");if($)return`${d}${f}\n${$}\n${d}\n\n`;const g=e.querySelector("code");return`${d}${f}\n${(g?g.textContent:a).trimEnd()}\n${d}\n\n`;case"blockquote":const p=c||">";return a.trim().split("\n").map(e=>`${p} ${e}`).join("\n")+"\n\n";case"hr":return`${c||"---"}\n\n`;case"br":return`${c||" "}\n`;case"a":const h=e.getAttribute("data-qd-text")||a.trim(),m=e.getAttribute("href")||"";return h!==m||c?`[${h}](${m})`:`<${m}>`;case"img":return`${c||"!"}[${e.getAttribute("data-qd-alt")||e.getAttribute("alt")||""}](${e.getAttribute("data-qd-src")||e.getAttribute("src")||""})`;case"ul":case"ol":return o(e,"ol"===l)+"\n";case"li":case"span":default:return a;case"table":return function(e){let t="";const n=e.getAttribute("data-qd-align"),r=n?n.split(","):[],o=e.querySelector("thead");if(o){const e=o.querySelector("tr");if(e){const n=[];for(const t of e.querySelectorAll("th"))n.push(t.textContent.trim());t+="| "+n.join(" | ")+" |\n";t+="| "+n.map((e,t)=>{const n=r[t]||"left";return"center"===n?":---:":"right"===n?"---:":"---"}).join(" | ")+" |\n"}}const l=e.querySelector("tbody");if(l)for(const e of l.querySelectorAll("tr")){const n=[];for(const t of e.querySelectorAll("td"))n.push(t.textContent.trim());n.length>0&&(t+="| "+n.join(" | ")+" |\n")}return t.trim()}(e)+"\n\n";case"p":if(a.trim()){const e=a.split("\n");let t=a.trim();if(e.length>1){let n=0;for(let t=e.length-1;t>=0&&""===e[t].trim();t--)n++;if(n>0)return t+="\n ",t+"\n"}return t+"\n\n"}return"";case"div":const b=e.getAttribute("data-qd-lang"),q=e.getAttribute("data-qd-fence");if(b&&t.fence_plugin&&t.fence_plugin.reverse)try{const n=t.fence_plugin.reverse(e);if(n&&n.content){const e=n.fence||q||"```";return`${e}${n.lang||b}\n${n.content}\n${e}\n\n`}}catch(e){console.warn("Fence reverse handler error:",e)}const x=e.getAttribute("data-qd-source");if(x&&q)return`${q}${b||""}\n${x}\n${q}\n\n`;if(e.classList&&e.classList.contains("mermaid-container")){const t=e.getAttribute("data-qd-fence")||"```",n=e.getAttribute("data-qd-lang")||"mermaid",r=e.getAttribute("data-qd-source");if(r){const e=document.createElement("textarea");e.innerHTML=r;return`${t}${n}\n${e.value}\n${t}\n\n`}const o=e.querySelector("pre.mermaid");if(o){const e=o.getAttribute("data-qd-source");if(e){const r=document.createElement("textarea");r.innerHTML=e;return`${t}${n}\n${r.value}\n${t}\n\n`}}const l=e.querySelector(".mermaid-source");if(l){const e=document.createElement("div");e.innerHTML=l.innerHTML;return`${t}${n}\n${e.textContent}\n${t}\n\n`}const c=e.querySelector(".mermaid");if(c&&c.textContent.includes("graph"))return`${t}${n}\n${c.textContent.trim()}\n${t}\n\n`}if(e.classList&&e.classList.contains("mermaid")){const t=e.getAttribute("data-qd-fence")||"```";return`${t}${e.getAttribute("data-qd-lang")||"mermaid"}\n${e.textContent.trim()}\n${t}\n\n`}return a}}function o(e,t,n=0){let l="",c=1;const a=" ".repeat(n);for(const s of e.children){if("LI"!==s.tagName)continue;let e=s.getAttribute("data-qd")||(t?`${c}.`:"-");const i=s.querySelector('input[type="checkbox"]');if(i){const t=i.checked?"x":" ";e="-";let n="";for(const e of s.childNodes)e.nodeType===Node.TEXT_NODE?n+=e.textContent:e.tagName&&"INPUT"!==e.tagName&&(n+=r(e));l+=`${a}${e} [${t}] ${n.trim()}\n`}else{let t="";for(const e of s.childNodes)"UL"===e.tagName||"OL"===e.tagName?t+=o(e,"OL"===e.tagName,n+1):t+=r(e);l+=`${a}${e} ${t.trim()}\n`}c++}return l}let l=r(n);return l=l.replace(/\n{3,}/g,"\n\n"),l=l.trim(),l},y.configure=function(e){const t=b.configure({...e,bidirectional:!0});return function(e){return t(e)}},"undefined"!=typeof module&&module.exports&&(module.exports=y),"undefined"!=typeof window&&(window.quikdown_bd=y);export{y as default};
8
8
  //# sourceMappingURL=quikdown_bd.esm.min.js.map
Binary file
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown_bd - Bidirectional Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -131,7 +131,7 @@
131
131
  // ────────────────────────────────────────────────────────────────────
132
132
 
133
133
  /** Build-time version stamp (injected by tools/updateVersion) */
134
- const quikdownVersion = '1.2.17';
134
+ const quikdownVersion = '1.2.19';
135
135
 
136
136
  /** CSS class prefix used for all generated elements */
137
137
  const CLASS_PREFIX = 'quikdown-';