quikdown 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,26 +4,43 @@
4
4
  [![npm version](https://img.shields.io/npm/v/quikdown.svg)](https://www.npmjs.com/package/quikdown)
5
5
  [![Coverage Status](https://img.shields.io/badge/coverage-99%25-blue.svg)](https://github.com/deftio/quikdown)
6
6
  [![License: BSD-2-Clause](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](https://opensource.org/licenses/BSD-2-Clause)
7
- [![Bundle Size](https://img.shields.io/badge/minified-<10KB-blue.svg)](https://github.com/deftio/quikdown/tree/main/dist)
7
+ [![Bundle Size](https://img.shields.io/badge/core-7.4KB-blue.svg)](https://github.com/deftio/quikdown/tree/main/dist)
8
+ [![Bundle Size BD](https://img.shields.io/badge/bidirectional-10KB-blue.svg)](https://github.com/deftio/quikdown/tree/main/dist)
8
9
 
9
- A lightweight, fast markdown parser with built-in XSS protection. Quikdown works in both browser and Node.js environments. Via its fenced plug-in support it can support highlighted code blocks, diagrams, and other custom fenced content.
10
+ A lightweight, fast markdown parser with built-in XSS protection and optional bidirectional conversion support. Quikdown works in both browser and Node.js environments. Via its fenced plug-in support it can support highlighted code blocks, diagrams, and other custom fenced content.
10
11
 
11
- 🚀 **[Try Live Demo](https://deftio.github.io/quikdown/examples/quikdown-live.html)** - Interactive markdown editor with real-time preview
12
+ 🚀 **[Try Live Demo](https://deftio.github.io/quikdown/examples/quikdown-live.html)** - Interactive markdown ot HTML editor with real-time preview
13
+ 🚀 **[Try Bidirectional Demo](https://deftio.github.io/quikdown/examples/quikdown-bd-editor.html)** - Interactive markdown editor with bidirectional support (can edit either markdown or html and see other update)
12
14
  📚 **[View Examples](examples/)** - Additional demos and test pages
13
15
  📖 **[Read Documentation](docs/)** - Architecture, security, API reference, and plugin guide
14
16
 
17
+ ## Table of Contents
18
+
19
+ - [Features](#features)
20
+ - [Installation](#installation)
21
+ - [Quick Start](#quick-start)
22
+ - [Bidirectional Conversion](#bidirectional-conversion-new)
23
+ - [Supported Markdown](#supported-markdown)
24
+ - [Configuration Options](#configuration-options)
25
+ - [Plugin System](#plugin-system)
26
+ - [Framework Integration](#framework-integration)
27
+ - [API Reference](#api-reference)
28
+ - [Security](#security)
29
+ - [Contributing](#contributing)
30
+
15
31
  ## Features
16
32
 
17
- - 🚀 **Lightweight** - Under 10KB minified
33
+ - 📦 **Zero dependencies** - No external libraries required
34
+ - 🌐 **Universal** - Works in browsers and Node.js
35
+ - 🚀 **Lightweight** - 7.4KB minified (core), 10KB with bidirectional support
18
36
  - 🔒 **Secure by default** - Built-in XSS protection with URL sanitization
19
37
  - 🎨 **Flexible styling** - Inline styles or CSS classes including light and dark mode generation, custom themes
20
38
  - 🔌 **Plugin system** - Extensible fence block handlers
21
- - 📦 **Zero dependencies** - No external libraries required
22
- - 🌐 **Universal** - Works in browsers and Node.js
23
39
  - ⚡ **Fast** - Optimized regex-based parsing
24
40
  - 📝 **CommonMark subset** - Supports essential markdown features
25
41
  - ✅ **Task Lists** - GitHub-style checkboxes
26
42
  - 🔗 **Autolinks** - Automatic URL detection
43
+ - 🔄 **Bidirectional** - Convert HTML back to Markdown (requires `quikdown_bd` module)
27
44
 
28
45
  ## Installation
29
46
 
@@ -52,11 +69,11 @@ Or via CDN:
52
69
  </script>
53
70
  ```
54
71
 
55
- > **Production tip:** Pin to a specific version for stability (e.g., `https://unpkg.com/quikdown@1.0.3/dist/quikdown.esm.min.js`)
72
+ > **Production tip:** Pin to a specific version for stability (e.g., `https://unpkg.com/quikdown@1.0.4/dist/quikdown.esm.min.js`)
56
73
 
57
74
  ## Quick Start
58
75
 
59
- ### Basic Usage
76
+ ### Basic Usage (Standard - One-way conversion)
60
77
 
61
78
  ```javascript
62
79
  import quikdown from 'quikdown';
@@ -65,6 +82,25 @@ const markdown = '# Hello World\n\nThis is **bold** text.';
65
82
  const html = quikdown(markdown);
66
83
  console.log(html);
67
84
  // Output: <h1>Hello World</h1><p>This is <strong>bold</strong> text.</p>
85
+
86
+ // Note: Regular quikdown does NOT support HTML to Markdown conversion
87
+ ```
88
+
89
+ ### Bidirectional Usage (Two-way conversion)
90
+
91
+ ```javascript
92
+ // Use quikdown_bd for bidirectional support
93
+ import quikdown_bd from 'quikdown/bd';
94
+
95
+ const markdown = '# Hello World\n\nThis is **bold** text.';
96
+
97
+ // Markdown to HTML
98
+ const html = quikdown_bd(markdown);
99
+
100
+ // HTML back to Markdown (only available in quikdown_bd)
101
+ const recoveredMarkdown = quikdown_bd.toMarkdown(html);
102
+ console.log(recoveredMarkdown);
103
+ // Output: # Hello World\n\nThis is **bold** text.
68
104
  ```
69
105
 
70
106
  ### With Options
@@ -264,15 +300,102 @@ const safe = quikdown(unsafe);
264
300
  // Output: &lt;script&gt;alert("XSS")&lt;/script&gt; <strong>bold</strong>
265
301
  ```
266
302
 
303
+ ## Bidirectional Conversion (1.0.4+)
304
+
305
+ **⚠️ Important:** Bidirectional conversion requires the `quikdown_bd` module, not the regular `quikdown` module.
306
+
307
+ The `quikdown_bd` module is a separate build that includes both markdown-to-HTML and HTML-to-markdown conversion capabilities. It's perfect for WYSIWYG editors and round-trip conversion scenarios.
308
+
309
+ ### Installation
310
+
311
+ ```javascript
312
+ // ES Modules - Use quikdown_bd, NOT quikdown
313
+ import quikdown_bd from 'quikdown/bd';
314
+
315
+ // CommonJS - Use quikdown_bd, NOT quikdown
316
+ const quikdown_bd = require('quikdown/bd');
317
+
318
+ // Browser - Load the quikdown_bd script, NOT the regular quikdown
319
+ <script src="https://unpkg.com/quikdown/dist/quikdown_bd.umd.min.js"></script>
320
+ <script>
321
+ // Available as window.quikdown_bd
322
+ const html = quikdown_bd(markdown);
323
+ </script>
324
+ ```
325
+
326
+ ### Basic Usage
327
+
328
+ ```javascript
329
+ // IMPORTANT: Use quikdown_bd for bidirectional support
330
+ import quikdown_bd from 'quikdown/bd';
331
+
332
+ // Markdown to HTML with source tracking
333
+ const html = quikdown_bd('**Hello** world', { bidirectional: true });
334
+ console.log(html);
335
+ // <strong data-qd="**">Hello</strong> world
336
+
337
+ // HTML back to Markdown (only available in quikdown_bd)
338
+ const markdown = quikdown_bd.toMarkdown(html);
339
+ console.log(markdown);
340
+ // **Hello** world
341
+
342
+ // Note: Regular quikdown does NOT have toMarkdown method
343
+ // This will fail: quikdown.toMarkdown(html) // ❌ Error
344
+ ```
345
+
346
+ ### Use Cases
347
+
348
+ - **Live Editors**: Build WYSIWYG markdown editors where users can edit in either view
349
+ - **Content Migration**: Convert existing HTML content to Markdown
350
+ - **Round-trip Preservation**: Maintain markdown source formatting through HTML conversion
351
+ - **Collaborative Editing**: Enable rich-text editing while storing content as Markdown
352
+
353
+ ### Browser Example
354
+
355
+ ```html
356
+ <div id="editor" contenteditable="true"></div>
357
+ <script type="module">
358
+ import quikdown_bd from 'https://unpkg.com/quikdown/dist/quikdown_bd.esm.min.js';
359
+
360
+ const editor = document.getElementById('editor');
361
+ const markdown = '# Edit me\n\n**Bold** and *italic*';
362
+
363
+ // Convert to HTML and display
364
+ editor.innerHTML = quikdown_bd(markdown, { bidirectional: true });
365
+
366
+ // Convert back to Markdown when needed
367
+ editor.addEventListener('blur', () => {
368
+ const updatedMarkdown = quikdown_bd.toMarkdown(editor);
369
+ console.log('Updated markdown:', updatedMarkdown);
370
+ });
371
+ </script>
372
+ ```
373
+
374
+ For complete documentation, see [Bidirectional Documentation](docs/quikdown-bidirectional.md).
375
+
267
376
  ## Quikdown Lexer Version
377
+
268
378
  An experimental lexer-based implementation is available for testing. See [docs/lexer-implementation.md](docs/lexer-implementation.md) for details.
269
379
 
270
380
 
381
+ ## Framework Integration
382
+
383
+ quikdown integrates seamlessly with modern JavaScript frameworks:
384
+
385
+ - **React** - Hooks, components, and Next.js support
386
+ - **Vue** - Composition API, Options API, and Nuxt support
387
+ - **Svelte** - Reactive statements and stores
388
+ - **Angular** - Components, services, and pipes
389
+
390
+ See the [Framework Integration Guide](docs/framework-integration.md) for detailed examples and best practices.
391
+
271
392
  ## API Reference
272
393
 
273
394
  For complete API documentation, see [docs/api-reference.md](docs/api-reference.md)
274
395
 
275
- ### `quikdown(markdown, options?)`
396
+ ### Core API
397
+
398
+ #### `quikdown(markdown, options?)`
276
399
 
277
400
  Main function to convert markdown to HTML.
278
401
 
@@ -284,7 +407,7 @@ Main function to convert markdown to HTML.
284
407
 
285
408
  **Returns:** HTML string
286
409
 
287
- ### `quikdown.configure(options)`
410
+ #### `quikdown.configure(options)`
288
411
 
289
412
  Creates a configured instance of the parser.
290
413
 
@@ -298,24 +421,47 @@ const myParser = quikdown.configure({
298
421
  const html = myParser(markdown);
299
422
  ```
300
423
 
301
- ### `quikdown.emitStyles(prefix?, theme?)`
424
+ #### `quikdown.emitStyles(prefix?, theme?)`
302
425
 
303
426
  Returns CSS styles for quikdown HTML output when not using inline styles.
304
427
 
305
- **Parameters:**
306
- - `prefix` (string, optional): CSS class prefix (default: 'quikdown-')
307
- - `theme` (string, optional): Theme name - 'light' or 'dark' (default: 'light')
308
-
309
428
  ```javascript
310
429
  // Get light theme CSS
311
430
  const lightStyles = quikdown.emitStyles();
312
431
 
313
432
  // Get dark theme CSS
314
433
  const darkStyles = quikdown.emitStyles('quikdown-', 'dark');
434
+ ```
435
+
436
+ ### Bidirectional API
437
+
438
+ **⚠️ These methods are only available in `quikdown_bd`, not in regular `quikdown`:**
439
+
440
+ #### `quikdown_bd(markdown, options?)`
441
+
442
+ Converts markdown to HTML with source tracking for bidirectional conversion.
443
+
444
+ #### `quikdown_bd.toMarkdown(htmlOrElement)`
315
445
 
316
- // Add to your stylesheet or <style> tag
446
+ Converts HTML back to Markdown. **This method only exists in `quikdown_bd`.**
447
+
448
+ **Parameters:**
449
+ - `htmlOrElement` (string | HTMLElement): HTML string or DOM element
450
+
451
+ **Returns:** Markdown string
452
+
453
+ ```javascript
454
+ // ✅ Correct - using quikdown_bd
455
+ import quikdown_bd from 'quikdown/bd';
456
+ const markdown = quikdown_bd.toMarkdown(html);
457
+
458
+ // ❌ Wrong - regular quikdown doesn't have toMarkdown
459
+ import quikdown from 'quikdown';
460
+ const markdown = quikdown.toMarkdown(html); // Error: toMarkdown is not a function
317
461
  ```
318
462
 
463
+ See [API Reference](docs/api-reference.md) for complete documentation.
464
+
319
465
  ## Theming
320
466
 
321
467
  QuikDown supports flexible theming through container-based CSS scoping:
package/dist/quikdown.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown - Lightweight Markdown Parser
3
- * @version 1.0.3
3
+ * @version 1.0.4
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -18,7 +18,7 @@
18
18
  */
19
19
 
20
20
  // Version will be injected at build time
21
- const quikdownVersion = '1.0.3';
21
+ const quikdownVersion = '1.0.4';
22
22
 
23
23
  // Constants for reuse
24
24
  const CLASS_PREFIX = 'quikdown-';
@@ -5,7 +5,7 @@
5
5
  * Theme with container-based scoping.
6
6
  * Usage: <div class="quikdown-dark">...content...</div>
7
7
  *
8
- * @generated 2025-08-17T11:14:25.791Z
8
+ * @generated 2025-08-18T00:32:14.951Z
9
9
  * @source tools/generateThemeCSS.js
10
10
  */
11
11
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown - Lightweight Markdown Parser
3
- * @version 1.0.3
3
+ * @version 1.0.4
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -16,7 +16,7 @@
16
16
  */
17
17
 
18
18
  // Version will be injected at build time
19
- const quikdownVersion = '1.0.3';
19
+ const quikdownVersion = '1.0.4';
20
20
 
21
21
  // Constants for reuse
22
22
  const CLASS_PREFIX = 'quikdown-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown - Lightweight Markdown Parser
3
- * @version 1.0.3
3
+ * @version 1.0.4
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- const e="quikdown-",t="§CB",n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em"};function r(r,l={}){if(!r||"string"!=typeof r)return"";const{fence_plugin:i,inline_styles:a=!1}=l,c=function(t,n){return function(o,r=""){if(t){const e=n[o];return e||r?` style="${r?e?`${e};${r}`:r:e}"`:""}return` class="${e}${o}"`}}(a,o);function p(e){return e.replace(/[&<>"']/g,e=>n[e])}function g(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),o=n.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(o.startsWith(e))return"data:"===e&&o.startsWith("data:image/")?n:"#";return n}let f=r;const d=[],h=[];f=f.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,n,o,r)=>{const l=`${t}${d.length}§`,s=o?o.trim():"";return i&&"function"==typeof i?d.push({lang:s,code:r.trimEnd(),custom:!0}):d.push({lang:s,code:p(r.trimEnd()),custom:!1}),l}),f=f.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${h.length}§`;return h.push(p(t)),n}),f=p(f),f=function(e,t){const n=e.split("\n"),o=[];let r=!1,l=[];for(let e=0;e<n.length;e++){const i=n[e].trim();if(i.includes("|")&&(i.startsWith("|")||/[^\\|]/.test(i)))r||(r=!0,l=[]),l.push(i);else{if(r){const e=s(l,t);e?o.push(e):o.push(...l),r=!1,l=[]}o.push(n[e])}}if(r&&l.length>0){const e=s(l,t);e?o.push(e):o.push(...l)}return o.join("\n")}(f,c),f=f.replace(/^(#{1,6})\s+(.+?)\s*#*$/gm,(e,t,n)=>{const o=t.length;return`<h${o}${c("h"+o)}>${n}</h${o}>`}),f=f.replace(/^&gt;\s+(.+)$/gm,`<blockquote${c("blockquote")}>$1</blockquote>`),f=f.replace(/<\/blockquote>\n<blockquote>/g,"\n"),f=f.replace(/^---+$/gm,`<hr${c("hr")}>`),f=function(t,n,o){const r=t.split("\n"),l=[];let s=[];for(let t=0;t<r.length;t++){const i=r[t],a=i.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(a){const[,t,r,i]=a,c=Math.floor(t.length/2),p=/^\d+\./.test(r),g=p?"ol":"ul";let f=i,d="";const h=i.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!p){const[,t,n]=h,r="x"===t.toLowerCase();f=`<input type="checkbox"${o?' style="margin-right:.5em"':` class="${e}task-checkbox"`}${r?" checked":""} disabled> ${n}`,d=o?' style="list-style:none"':` class="${e}task-item"`}for(;s.length>c+1;){const e=s.pop();l.push(`</${e.type}>`)}if(s.length===c)s.push({type:g,level:c}),l.push(`<${g}${n(g)}>`);else if(s.length===c+1){const e=s[s.length-1];e.type!==g&&(l.push(`</${e.type}>`),s.pop(),s.push({type:g,level:c}),l.push(`<${g}${n(g)}>`))}const u=d||n("li");l.push(`<li${u}>${f}</li>`)}else{for(;s.length>0;){const e=s.pop();l.push(`</${e.type}>`)}l.push(i)}}for(;s.length>0;){const e=s.pop();l.push(`</${e.type}>`)}return l.join("\n")}(f,c,a),f=f.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls);return`<img${c("img")} src="${o}" alt="${t}">`}),f=f.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls),r=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"";return`<a${c("a")} href="${o}"${r}>${t}</a>`}),f=f.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls);return`${t}<a${c("a")} href="${o}" rel="noopener noreferrer">${n}</a>`});[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"]].forEach(([e,t])=>{f=f.replace(e,`<${t}${c(t)}>$1</${t}>`)}),f=f.replace(/ $/gm,`<br${c("br")}>`),f=f.replace(/\n\n+/g,"</p><p>"),f="<p>"+f+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[new RegExp(`<p>(${t}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{f=f.replace(e,t)}),d.forEach((e,n)=>{let o;if(e.custom&&i){if(o=i(e.code,e.lang),void 0===o){const t=!a&&e.lang?` class="language-${e.lang}"`:"",n=a?c("code"):t;o=`<pre${c("pre")}><code${n}>${p(e.code)}</code></pre>`}}else{const t=!a&&e.lang?` class="language-${e.lang}"`:"",n=a?c("code"):t;o=`<pre${c("pre")}><code${n}>${e.code}</code></pre>`}const r=`${t}${n}§`;f=f.replace(r,o)}),h.forEach((e,t)=>{const n=`§IC${t}§`;f=f.replace(n,`<code${c("code")}>${e}</code>`)}),f.trim()}function l(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,o])=>{e=e.replace(n,`<${o}${t(o)}>$1</${o}>`)}),e}function s(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const o=e.slice(0,n),r=e.slice(n+1),s=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let i=`<table${t("table")}>\n`;return o.length>0&&(i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=s[n]&&"left"!==s[n]?`text-align:${s[n]}`:"",r=l(e.trim(),t);i+=`<th${t("th",o)}>${r}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n"),r.length>0&&(i+=`<tbody${t("tbody")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=s[n]&&"left"!==s[n]?`text-align:${s[n]}`:"",r=l(e.trim(),t);i+=`<td${t("td",o)}>${r}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}r.emitStyles=function(e="quikdown-",t="light"){const n=o,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},l={_textColor:"#333"};let s="";for(const[o,i]of Object.entries(n))if(i){let n=i;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replace(new RegExp(e,"g"),t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${l._textColor}`)}s+=`.${e}${o} { ${n} }\n`}return s},r.configure=function(e){return function(t){return r(t,e)}},r.version="1.0.3","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown=r);export{r as default};
7
+ const e="quikdown-",t="§CB",n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em"};function r(r,l={}){if(!r||"string"!=typeof r)return"";const{fence_plugin:i,inline_styles:a=!1}=l,c=function(t,n){return function(o,r=""){if(t){const e=n[o];return e||r?` style="${r?e?`${e};${r}`:r:e}"`:""}return` class="${e}${o}"`}}(a,o);function p(e){return e.replace(/[&<>"']/g,e=>n[e])}function g(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),o=n.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(o.startsWith(e))return"data:"===e&&o.startsWith("data:image/")?n:"#";return n}let f=r;const d=[],h=[];f=f.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,n,o,r)=>{const l=`${t}${d.length}§`,s=o?o.trim():"";return i&&"function"==typeof i?d.push({lang:s,code:r.trimEnd(),custom:!0}):d.push({lang:s,code:p(r.trimEnd()),custom:!1}),l}),f=f.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${h.length}§`;return h.push(p(t)),n}),f=p(f),f=function(e,t){const n=e.split("\n"),o=[];let r=!1,l=[];for(let e=0;e<n.length;e++){const i=n[e].trim();if(i.includes("|")&&(i.startsWith("|")||/[^\\|]/.test(i)))r||(r=!0,l=[]),l.push(i);else{if(r){const e=s(l,t);e?o.push(e):o.push(...l),r=!1,l=[]}o.push(n[e])}}if(r&&l.length>0){const e=s(l,t);e?o.push(e):o.push(...l)}return o.join("\n")}(f,c),f=f.replace(/^(#{1,6})\s+(.+?)\s*#*$/gm,(e,t,n)=>{const o=t.length;return`<h${o}${c("h"+o)}>${n}</h${o}>`}),f=f.replace(/^&gt;\s+(.+)$/gm,`<blockquote${c("blockquote")}>$1</blockquote>`),f=f.replace(/<\/blockquote>\n<blockquote>/g,"\n"),f=f.replace(/^---+$/gm,`<hr${c("hr")}>`),f=function(t,n,o){const r=t.split("\n"),l=[];let s=[];for(let t=0;t<r.length;t++){const i=r[t],a=i.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(a){const[,t,r,i]=a,c=Math.floor(t.length/2),p=/^\d+\./.test(r),g=p?"ol":"ul";let f=i,d="";const h=i.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!p){const[,t,n]=h,r="x"===t.toLowerCase();f=`<input type="checkbox"${o?' style="margin-right:.5em"':` class="${e}task-checkbox"`}${r?" checked":""} disabled> ${n}`,d=o?' style="list-style:none"':` class="${e}task-item"`}for(;s.length>c+1;){const e=s.pop();l.push(`</${e.type}>`)}if(s.length===c)s.push({type:g,level:c}),l.push(`<${g}${n(g)}>`);else if(s.length===c+1){const e=s[s.length-1];e.type!==g&&(l.push(`</${e.type}>`),s.pop(),s.push({type:g,level:c}),l.push(`<${g}${n(g)}>`))}const u=d||n("li");l.push(`<li${u}>${f}</li>`)}else{for(;s.length>0;){const e=s.pop();l.push(`</${e.type}>`)}l.push(i)}}for(;s.length>0;){const e=s.pop();l.push(`</${e.type}>`)}return l.join("\n")}(f,c,a),f=f.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls);return`<img${c("img")} src="${o}" alt="${t}">`}),f=f.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls),r=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"";return`<a${c("a")} href="${o}"${r}>${t}</a>`}),f=f.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const o=g(n,l.allow_unsafe_urls);return`${t}<a${c("a")} href="${o}" rel="noopener noreferrer">${n}</a>`});[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"]].forEach(([e,t])=>{f=f.replace(e,`<${t}${c(t)}>$1</${t}>`)}),f=f.replace(/ $/gm,`<br${c("br")}>`),f=f.replace(/\n\n+/g,"</p><p>"),f="<p>"+f+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[new RegExp(`<p>(${t}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{f=f.replace(e,t)}),d.forEach((e,n)=>{let o;if(e.custom&&i){if(o=i(e.code,e.lang),void 0===o){const t=!a&&e.lang?` class="language-${e.lang}"`:"",n=a?c("code"):t;o=`<pre${c("pre")}><code${n}>${p(e.code)}</code></pre>`}}else{const t=!a&&e.lang?` class="language-${e.lang}"`:"",n=a?c("code"):t;o=`<pre${c("pre")}><code${n}>${e.code}</code></pre>`}const r=`${t}${n}§`;f=f.replace(r,o)}),h.forEach((e,t)=>{const n=`§IC${t}§`;f=f.replace(n,`<code${c("code")}>${e}</code>`)}),f.trim()}function l(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,o])=>{e=e.replace(n,`<${o}${t(o)}>$1</${o}>`)}),e}function s(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const o=e.slice(0,n),r=e.slice(n+1),s=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let i=`<table${t("table")}>\n`;return o.length>0&&(i+=`<thead${t("thead")}>\n`,o.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=s[n]&&"left"!==s[n]?`text-align:${s[n]}`:"",r=l(e.trim(),t);i+=`<th${t("th",o)}>${r}</th>\n`}),i+="</tr>\n"}),i+="</thead>\n"),r.length>0&&(i+=`<tbody${t("tbody")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=s[n]&&"left"!==s[n]?`text-align:${s[n]}`:"",r=l(e.trim(),t);i+=`<td${t("td",o)}>${r}</td>\n`}),i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}r.emitStyles=function(e="quikdown-",t="light"){const n=o,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},l={_textColor:"#333"};let s="";for(const[o,i]of Object.entries(n))if(i){let n=i;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replace(new RegExp(e,"g"),t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${l._textColor}`)}s+=`.${e}${o} { ${n} }\n`}return s},r.configure=function(e){return function(t){return r(t,e)}},r.version="1.0.4","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown=r);export{r as default};
8
8
  //# sourceMappingURL=quikdown.esm.min.js.map
@@ -5,7 +5,7 @@
5
5
  * Theme with container-based scoping.
6
6
  * Usage: <div class="quikdown-light">...content...</div>
7
7
  *
8
- * @generated 2025-08-17T11:14:25.790Z
8
+ * @generated 2025-08-18T00:32:14.950Z
9
9
  * @source tools/generateThemeCSS.js
10
10
  */
11
11
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown - Lightweight Markdown Parser
3
- * @version 1.0.3
3
+ * @version 1.0.4
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
@@ -22,7 +22,7 @@
22
22
  */
23
23
 
24
24
  // Version will be injected at build time
25
- const quikdownVersion = '1.0.3';
25
+ const quikdownVersion = '1.0.4';
26
26
 
27
27
  // Constants for reuse
28
28
  const CLASS_PREFIX = 'quikdown-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown - Lightweight Markdown Parser
3
- * @version 1.0.3
3
+ * @version 1.0.4
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown=t()}(this,function(){"use strict";const e="quikdown-",t="§CB",n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em"};function r(r,l={}){if(!r||"string"!=typeof r)return"";const{fence_plugin:s,inline_styles:c=!1}=l,a=function(t,n){return function(o,r=""){if(t){const e=n[o];return e||r?` style="${r?e?`${e};${r}`:r:e}"`:""}return` class="${e}${o}"`}}(c,o);function p(e){return e.replace(/[&<>"']/g,e=>n[e])}function f(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),o=n.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(o.startsWith(e))return"data:"===e&&o.startsWith("data:image/")?n:"#";return n}let g=r;const d=[],u=[];g=g.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,n,o,r)=>{const l=`${t}${d.length}§`,i=o?o.trim():"";return s&&"function"==typeof s?d.push({lang:i,code:r.trimEnd(),custom:!0}):d.push({lang:i,code:p(r.trimEnd()),custom:!1}),l}),g=g.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${u.length}§`;return u.push(p(t)),n}),g=p(g),g=function(e,t){const n=e.split("\n"),o=[];let r=!1,l=[];for(let e=0;e<n.length;e++){const s=n[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))r||(r=!0,l=[]),l.push(s);else{if(r){const e=i(l,t);e?o.push(e):o.push(...l),r=!1,l=[]}o.push(n[e])}}if(r&&l.length>0){const e=i(l,t);e?o.push(e):o.push(...l)}return o.join("\n")}(g,a),g=g.replace(/^(#{1,6})\s+(.+?)\s*#*$/gm,(e,t,n)=>{const o=t.length;return`<h${o}${a("h"+o)}>${n}</h${o}>`}),g=g.replace(/^&gt;\s+(.+)$/gm,`<blockquote${a("blockquote")}>$1</blockquote>`),g=g.replace(/<\/blockquote>\n<blockquote>/g,"\n"),g=g.replace(/^---+$/gm,`<hr${a("hr")}>`),g=function(t,n,o){const r=t.split("\n"),l=[];let i=[];for(let t=0;t<r.length;t++){const s=r[t],c=s.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,t,r,s]=c,a=Math.floor(t.length/2),p=/^\d+\./.test(r),f=p?"ol":"ul";let g=s,d="";const u=s.match(/^\[([x ])\]\s+(.*)$/i);if(u&&!p){const[,t,n]=u,r="x"===t.toLowerCase();g=`<input type="checkbox"${o?' style="margin-right:.5em"':` class="${e}task-checkbox"`}${r?" checked":""} disabled> ${n}`,d=o?' style="list-style:none"':` class="${e}task-item"`}for(;i.length>a+1;){const e=i.pop();l.push(`</${e.type}>`)}if(i.length===a)i.push({type:f,level:a}),l.push(`<${f}${n(f)}>`);else if(i.length===a+1){const e=i[i.length-1];e.type!==f&&(l.push(`</${e.type}>`),i.pop(),i.push({type:f,level:a}),l.push(`<${f}${n(f)}>`))}const h=d||n("li");l.push(`<li${h}>${g}</li>`)}else{for(;i.length>0;){const e=i.pop();l.push(`</${e.type}>`)}l.push(s)}}for(;i.length>0;){const e=i.pop();l.push(`</${e.type}>`)}return l.join("\n")}(g,a,c),g=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls);return`<img${a("img")} src="${o}" alt="${t}">`}),g=g.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls),r=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"";return`<a${a("a")} href="${o}"${r}>${t}</a>`}),g=g.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls);return`${t}<a${a("a")} href="${o}" rel="noopener noreferrer">${n}</a>`});[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"]].forEach(([e,t])=>{g=g.replace(e,`<${t}${a(t)}>$1</${t}>`)}),g=g.replace(/ $/gm,`<br${a("br")}>`),g=g.replace(/\n\n+/g,"</p><p>"),g="<p>"+g+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[new RegExp(`<p>(${t}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{g=g.replace(e,t)}),d.forEach((e,n)=>{let o;if(e.custom&&s){if(o=s(e.code,e.lang),void 0===o){const t=!c&&e.lang?` class="language-${e.lang}"`:"",n=c?a("code"):t;o=`<pre${a("pre")}><code${n}>${p(e.code)}</code></pre>`}}else{const t=!c&&e.lang?` class="language-${e.lang}"`:"",n=c?a("code"):t;o=`<pre${a("pre")}><code${n}>${e.code}</code></pre>`}const r=`${t}${n}§`;g=g.replace(r,o)}),u.forEach((e,t)=>{const n=`§IC${t}§`;g=g.replace(n,`<code${a("code")}>${e}</code>`)}),g.trim()}function l(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,o])=>{e=e.replace(n,`<${o}${t(o)}>$1</${o}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const o=e.slice(0,n),r=e.slice(n+1),i=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let s=`<table${t("table")}>\n`;return o.length>0&&(s+=`<thead${t("thead")}>\n`,o.forEach(e=>{s+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=i[n]&&"left"!==i[n]?`text-align:${i[n]}`:"",r=l(e.trim(),t);s+=`<th${t("th",o)}>${r}</th>\n`}),s+="</tr>\n"}),s+="</thead>\n"),r.length>0&&(s+=`<tbody${t("tbody")}>\n`,r.forEach(e=>{s+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=i[n]&&"left"!==i[n]?`text-align:${i[n]}`:"",r=l(e.trim(),t);s+=`<td${t("td",o)}>${r}</td>\n`}),s+="</tr>\n"}),s+="</tbody>\n"),s+="</table>",s}return r.emitStyles=function(e="quikdown-",t="light"){const n=o,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},l={_textColor:"#333"};let i="";for(const[o,s]of Object.entries(n))if(s){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replace(new RegExp(e,"g"),t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${l._textColor}`)}i+=`.${e}${o} { ${n} }\n`}return i},r.configure=function(e){return function(t){return r(t,e)}},r.version="1.0.3","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown=r),r});
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikdown=t()}(this,function(){"use strict";const e="quikdown-",t="§CB",n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},o={h1:"font-size:2em;font-weight:600;margin:.67em 0;text-align:left",h2:"font-size:1.5em;font-weight:600;margin:.83em 0",h3:"font-size:1.25em;font-weight:600;margin:1em 0",h4:"font-size:1em;font-weight:600;margin:1.33em 0",h5:"font-size:.875em;font-weight:600;margin:1.67em 0",h6:"font-size:.85em;font-weight:600;margin:2em 0",pre:"background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0",code:"background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace",blockquote:"border-left:4px solid #ddd;margin-left:0;padding-left:1em",table:"border-collapse:collapse;width:100%;margin:1em 0",th:"border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left",td:"border:1px solid #ddd;padding:8px;text-align:left",hr:"border:none;border-top:1px solid #ddd;margin:1em 0",img:"max-width:100%;height:auto",a:"color:#06c;text-decoration:underline",strong:"font-weight:bold",em:"font-style:italic",del:"text-decoration:line-through",ul:"margin:.5em 0;padding-left:2em",ol:"margin:.5em 0;padding-left:2em",li:"margin:.25em 0","task-item":"list-style:none","task-checkbox":"margin-right:.5em"};function r(r,l={}){if(!r||"string"!=typeof r)return"";const{fence_plugin:s,inline_styles:c=!1}=l,a=function(t,n){return function(o,r=""){if(t){const e=n[o];return e||r?` style="${r?e?`${e};${r}`:r:e}"`:""}return` class="${e}${o}"`}}(c,o);function p(e){return e.replace(/[&<>"']/g,e=>n[e])}function f(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),o=n.toLowerCase(),r=["javascript:","vbscript:","data:"];for(const e of r)if(o.startsWith(e))return"data:"===e&&o.startsWith("data:image/")?n:"#";return n}let g=r;const d=[],u=[];g=g.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,n,o,r)=>{const l=`${t}${d.length}§`,i=o?o.trim():"";return s&&"function"==typeof s?d.push({lang:i,code:r.trimEnd(),custom:!0}):d.push({lang:i,code:p(r.trimEnd()),custom:!1}),l}),g=g.replace(/`([^`]+)`/g,(e,t)=>{const n=`§IC${u.length}§`;return u.push(p(t)),n}),g=p(g),g=function(e,t){const n=e.split("\n"),o=[];let r=!1,l=[];for(let e=0;e<n.length;e++){const s=n[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))r||(r=!0,l=[]),l.push(s);else{if(r){const e=i(l,t);e?o.push(e):o.push(...l),r=!1,l=[]}o.push(n[e])}}if(r&&l.length>0){const e=i(l,t);e?o.push(e):o.push(...l)}return o.join("\n")}(g,a),g=g.replace(/^(#{1,6})\s+(.+?)\s*#*$/gm,(e,t,n)=>{const o=t.length;return`<h${o}${a("h"+o)}>${n}</h${o}>`}),g=g.replace(/^&gt;\s+(.+)$/gm,`<blockquote${a("blockquote")}>$1</blockquote>`),g=g.replace(/<\/blockquote>\n<blockquote>/g,"\n"),g=g.replace(/^---+$/gm,`<hr${a("hr")}>`),g=function(t,n,o){const r=t.split("\n"),l=[];let i=[];for(let t=0;t<r.length;t++){const s=r[t],c=s.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,t,r,s]=c,a=Math.floor(t.length/2),p=/^\d+\./.test(r),f=p?"ol":"ul";let g=s,d="";const u=s.match(/^\[([x ])\]\s+(.*)$/i);if(u&&!p){const[,t,n]=u,r="x"===t.toLowerCase();g=`<input type="checkbox"${o?' style="margin-right:.5em"':` class="${e}task-checkbox"`}${r?" checked":""} disabled> ${n}`,d=o?' style="list-style:none"':` class="${e}task-item"`}for(;i.length>a+1;){const e=i.pop();l.push(`</${e.type}>`)}if(i.length===a)i.push({type:f,level:a}),l.push(`<${f}${n(f)}>`);else if(i.length===a+1){const e=i[i.length-1];e.type!==f&&(l.push(`</${e.type}>`),i.pop(),i.push({type:f,level:a}),l.push(`<${f}${n(f)}>`))}const h=d||n("li");l.push(`<li${h}>${g}</li>`)}else{for(;i.length>0;){const e=i.pop();l.push(`</${e.type}>`)}l.push(s)}}for(;i.length>0;){const e=i.pop();l.push(`</${e.type}>`)}return l.join("\n")}(g,a,c),g=g.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls);return`<img${a("img")} src="${o}" alt="${t}">`}),g=g.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls),r=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"";return`<a${a("a")} href="${o}"${r}>${t}</a>`}),g=g.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const o=f(n,l.allow_unsafe_urls);return`${t}<a${a("a")} href="${o}" rel="noopener noreferrer">${n}</a>`});[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"]].forEach(([e,t])=>{g=g.replace(e,`<${t}${a(t)}>$1</${t}>`)}),g=g.replace(/ $/gm,`<br${a("br")}>`),g=g.replace(/\n\n+/g,"</p><p>"),g="<p>"+g+"</p>";return[[/<p><\/p>/g,""],[/<p>(<h[1-6][^>]*>)/g,"$1"],[/(<\/h[1-6]>)<\/p>/g,"$1"],[/<p>(<blockquote[^>]*>)/g,"$1"],[/(<\/blockquote>)<\/p>/g,"$1"],[/<p>(<ul[^>]*>|<ol[^>]*>)/g,"$1"],[/(<\/ul>|<\/ol>)<\/p>/g,"$1"],[/<p>(<hr[^>]*>)<\/p>/g,"$1"],[/<p>(<table[^>]*>)/g,"$1"],[/(<\/table>)<\/p>/g,"$1"],[/<p>(<pre[^>]*>)/g,"$1"],[/(<\/pre>)<\/p>/g,"$1"],[new RegExp(`<p>(${t}\\d+§)</p>`,"g"),"$1"]].forEach(([e,t])=>{g=g.replace(e,t)}),d.forEach((e,n)=>{let o;if(e.custom&&s){if(o=s(e.code,e.lang),void 0===o){const t=!c&&e.lang?` class="language-${e.lang}"`:"",n=c?a("code"):t;o=`<pre${a("pre")}><code${n}>${p(e.code)}</code></pre>`}}else{const t=!c&&e.lang?` class="language-${e.lang}"`:"",n=c?a("code"):t;o=`<pre${a("pre")}><code${n}>${e.code}</code></pre>`}const r=`${t}${n}§`;g=g.replace(r,o)}),u.forEach((e,t)=>{const n=`§IC${t}§`;g=g.replace(n,`<code${a("code")}>${e}</code>`)}),g.trim()}function l(e,t){return[[/\*\*(.+?)\*\*/g,"strong"],[/__(.+?)__/g,"strong"],[/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"em"],[/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g,"em"],[/~~(.+?)~~/g,"del"],[/`([^`]+)`/g,"code"]].forEach(([n,o])=>{e=e.replace(n,`<${o}${t(o)}>$1</${o}>`)}),e}function i(e,t){if(e.length<2)return null;let n=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){n=t;break}if(-1===n)return null;const o=e.slice(0,n),r=e.slice(n+1),i=e[n].trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"});let s=`<table${t("table")}>\n`;return o.length>0&&(s+=`<thead${t("thead")}>\n`,o.forEach(e=>{s+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=i[n]&&"left"!==i[n]?`text-align:${i[n]}`:"",r=l(e.trim(),t);s+=`<th${t("th",o)}>${r}</th>\n`}),s+="</tr>\n"}),s+="</thead>\n"),r.length>0&&(s+=`<tbody${t("tbody")}>\n`,r.forEach(e=>{s+=`<tr${t("tr")}>\n`;e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").forEach((e,n)=>{const o=i[n]&&"left"!==i[n]?`text-align:${i[n]}`:"",r=l(e.trim(),t);s+=`<td${t("td",o)}>${r}</td>\n`}),s+="</tr>\n"}),s+="</tbody>\n"),s+="</table>",s}return r.emitStyles=function(e="quikdown-",t="light"){const n=o,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2",_textColor:"#e0e0e0"},l={_textColor:"#333"};let i="";for(const[o,s]of Object.entries(n))if(s){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replace(new RegExp(e,"g"),t));["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote"].includes(o)&&(n+=`;color:${l._textColor}`)}i+=`.${e}${o} { ${n} }\n`}return i},r.configure=function(e){return function(t){return r(t,e)}},r.version="1.0.4","undefined"!=typeof module&&module.exports&&(module.exports=r),"undefined"!=typeof window&&(window.quikdown=r),r});
8
8
  //# sourceMappingURL=quikdown.umd.min.js.map