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
package/README.md CHANGED
@@ -6,21 +6,39 @@
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
7
  [![Bundle Size](https://img.shields.io/badge/minified-14.9KB-green.svg)](https://bundlephobia.com/package/quikdown)
8
8
 
9
- Quikdown is a small secure bidirectional markdown parser and editor for browsers and Node.js. Nine modules use only what you need.
9
+ Quikdown is a small, safe, bidirectional Markdown parser and editor for browser and Node.js appswith rich fences, streaming, undo/redo, MCP tools, and a standalone airgapped build.
10
10
 
11
- - **quikdown.js** (14.7 KB) Markdown to HTML parser. XSS-safe, fence plugin callbacks, inline styles or CSS classes.
12
- - **quikdown_bd.js** (19.5 KB) — Bidirectional: everything in core plus HTML to Markdown round-trip.
13
- - **quikdown_edit.js** (98 KB) — Drop-in split-view editor with live preview, undo/redo, bidirectional editing, and lazy-loaded fence plugins for code highlighting, Mermaid, MathJax, SVG, CSV, GeoJSON, STL, ABC music notation, and Vega/Vega-Lite charts.
14
- - **quikdown_edit_standalone.js** (7.7 MB) — Offline/air-gapped editor. Same as above but bundles highlight.js, Mermaid, DOMPurify, Leaflet, Three.js, ABCJS, Vega, Vega-Lite, Vega-Embed, and MathJax — no CDN required. See [Standalone Docs](docs/standalone-editor.md).
15
- - **quikdown_mcp.js** (26 KB) — MCP (Model Context Protocol) server. Exposes 24 tools for AI agents over JSON-RPC 2.0 on stdio. Works with Cursor, Claude Desktop, VS Code, and any MCP host.
11
+ **[Try the Editor](https://deftio.github.io/quikdown/pages/edit/)** | **[Live Site](https://deftio.github.io/quikdown/pages/)** | **[Examples](https://deftio.github.io/quikdown/pages/examples/)** | **[Downloads](https://deftio.github.io/quikdown/pages/downloads/)** | **[Docs](docs/)**
16
12
 
17
- ### Extras
18
- - **quikdown_ast.js** / **quikdown_json.js** / **quikdown_yaml.js** / **quikdown_ast_html.js**AST companion libraries for structured output.
13
+ ![quikdown editor demo — markdown, Mermaid diagram, MathJax equation, and syntax-highlighted code](pages/assets/editor-demo.gif)
14
+ *Split-mode editor: Markdown source on the left, live preview on the right with rendered Mermaid diagrams, MathJax equations, and syntax-highlighted code.*
19
15
 
20
- **[Live Site](https://deftio.github.io/quikdown/pages/)** | **[Try the Editor](https://deftio.github.io/quikdown/pages/edit/)** | **[Examples](https://deftio.github.io/quikdown/pages/examples/)** | **[Frameworks](https://deftio.github.io/quikdown/pages/frameworks/)** | **[Downloads](https://deftio.github.io/quikdown/pages/downloads/)** | **[Docs](docs/)**
16
+ ### Why Quikdown?
21
17
 
22
- ![quikdown editor in split mode with Mermaid diagram rendering](pages/assets/editor-screenshot.png)
23
- *quikdown_edit in split modemarkdown source on the left, live rendered preview with Mermaid diagram on the right. Toolbar shows mode switching, undo/redo, copy, and linefeed controls.*
18
+ - **Small** ~15 KB parser, ~98 KB editor. Zero runtime dependencies.
19
+ - **Safe by default**all HTML escaped, URL sanitization blocks `javascript:` / `vbscript:` / non-image `data:` URIs. No `eval`, no dynamic regex.
20
+ - **Bidirectional** — edit rendered HTML and get Markdown back. Round-trip preserves fences, tables, and formatting.
21
+ - **Rich fences** — Mermaid diagrams, Vega/Vega-Lite charts, MathJax equations, ABC music notation, GeoJSON maps, CSV/TSV/PSV tables, SVG, STL 3D models, syntax-highlighted code, and custom fences via the plugin API.
22
+ - **Undo/redo** — programmatic undo/redo lets LLMs and humans co-edit a shared document with full change reversibility.
23
+ - **Offline standalone** — a self-contained airgapped build (~7.7 MB / ~1 MB gzipped) bundles everything for air-gapped, regulated, or field environments. See companion app [Quikleaf](https://github.com/deftio/quikleaf) for an offline desktop app (with optional LLM support).
24
+ - **LLM-friendly** — stream Markdown tokens in, render incrementally, reverse agent mistakes with undo/redo. 24-tool MCP server for AI agents.
25
+
26
+ ### Why another Markdown parser?
27
+
28
+ Quikdown is a compact, embeddable parser/editor where Markdown remains the source of truth — for both humans and agents. It doesn't try to replace full CommonMark parsers or heavyweight editor stacks. It fills the gap for apps that need a fast, safe, self-contained Markdown render+edit surface with minimal footprint.
29
+
30
+ ### Modules
31
+
32
+ Nine modules — use only what you need:
33
+
34
+ | Module | Size | What it does |
35
+ |--------|------|--------------|
36
+ | **quikdown.js** | ~15 KB | Markdown → HTML parser. XSS-safe, fence plugin callbacks, inline styles or CSS classes. |
37
+ | **quikdown_bd.js** | ~20 KB | Bidirectional: core parser + HTML → Markdown round-trip. |
38
+ | **quikdown_edit.js** | ~98 KB | Drop-in split-view editor. Undo/redo, toolbar, lazy-loaded fence plugins. |
39
+ | **quikdown_edit_standalone.js** | ~7.7 MB | Offline editor. All fence libraries bundled — no CDN required. [Docs](docs/standalone-editor.md) |
40
+ | **quikdown_mcp.js** | ~26 KB | MCP server. 24 tools for AI agents over JSON-RPC 2.0. |
41
+ | **quikdown_ast/json/yaml/ast_html** | ~5–8 KB each | AST companion libraries for structured output. |
24
42
 
25
43
  ## Features
26
44
 
@@ -37,6 +55,24 @@ Quikdown is a small secure bidirectional markdown parser and editor for browsers
37
55
  - **Headless mode** — run the editor without a toolbar. Wire `undo()`, `setTheme()`, `setMode()` to your own UI. Rich API for controlling / selecting / manipulating markdown and rendered text with undo/redo support.
38
56
  - **Structured output** — parse markdown into AST, JSON, or YAML via companion libraries.
39
57
 
58
+ ## Security
59
+
60
+ All HTML is escaped by default. Only safe Markdown constructs become HTML:
61
+
62
+ ```javascript
63
+ const unsafe = '<script>alert("XSS")</script> **bold**';
64
+ const safe = quikdown(unsafe);
65
+ // &lt;script&gt;alert("XSS")&lt;/script&gt; <strong>bold</strong>
66
+ ```
67
+
68
+ - **HTML escaped by default** — no raw HTML passes through unless a fence plugin explicitly renders it.
69
+ - **URL sanitization** — blocks `javascript:`, `vbscript:`, and non-image `data:` URIs in links and images.
70
+ - **Trusted fence path** — fence plugin callbacks receive pre-extracted content and the declared language tag. The plugin decides what to render; untrusted content never reaches `innerHTML` without an explicit opt-in. The built-in editor uses DOMPurify for the `html` fence.
71
+ - **No `eval`, no dynamic `RegExp`** — all regex patterns are static literals, verified free of catastrophic backtracking (ReDoS).
72
+ - **Static analysis** — passes ESLint with [eslint-plugin-security](https://www.npmjs.com/package/eslint-plugin-security) at error level with zero findings. Enforced in CI on every build.
73
+
74
+ For the full security model, see [docs/security.md](docs/security.md).
75
+
40
76
  ## Installation
41
77
 
42
78
  Quikdown is available via [NPM](https://www.npmjs.com/package/quikdown) and related [unpkg](https://unpkg.com/quikdown) and [jsdelivr](https://cdn.jsdelivr.net/npm/quikdown)
@@ -338,39 +374,103 @@ console.log('syntax highlighting support via plugins');
338
374
 
339
375
  For complete API documentation, see [docs/api-reference.md](docs/api-reference.md)
340
376
 
341
- ## Security
377
+ ## Framework Integration
342
378
 
343
- All HTML is escaped by default. Only safe markdown constructs become HTML:
379
+ Works with React, Vue, Svelte, Angular. See [Framework Integration Guide](docs/framework-integration.md). For LLM/agent patterns (streaming, tool editor), see [LLM Integration](docs/llm-integration.md).
380
+
381
+ ## Streaming
382
+
383
+ Quikdown's parser is fast enough to re-parse the full buffer on every incoming chunk — no incremental parsing state to manage:
344
384
 
345
385
  ```javascript
346
- const unsafe = '<script>alert("XSS")</script> **bold**';
347
- const safe = quikdown(unsafe);
348
- // &lt;script&gt;alert("XSS")&lt;/script&gt; <strong>bold</strong>
386
+ // Render-only: stream tokens into a div
387
+ let buffer = '';
388
+ for await (const chunk of llmStream) {
389
+ buffer += chunk;
390
+ previewEl.innerHTML = quikdown(buffer, { lazy_linefeeds: true });
391
+ }
349
392
  ```
350
393
 
351
- **Static analysis** — quikdown passes ESLint with [eslint-plugin-security](https://www.npmjs.com/package/eslint-plugin-security) at error level with zero findings. All regex patterns are verified free of catastrophic backtracking (ReDoS), and no dynamic `RegExp` construction is used. Security lint is enforced in CI on every build.
394
+ ```javascript
395
+ // Editor: stream into QuikdownEditor
396
+ let buffer = '';
397
+ for await (const chunk of llmStream) {
398
+ buffer += chunk;
399
+ await editor.setMarkdown(buffer);
400
+ }
401
+ ```
352
402
 
353
- For the full security model, see [docs/security.md](docs/security.md).
403
+ Incomplete fences are handled gracefully — they render as plain text until the closing fence arrives. See [docs/llm-integration.md](docs/llm-integration.md) for production patterns (debouncing, undo grouping).
354
404
 
355
- ## Framework Integration
405
+ ## Undo / Redo
356
406
 
357
- Works with React, Vue, Svelte, Angular. See [Framework Integration Guide](docs/framework-integration.md). For LLM/agent patterns (streaming, tool editor), see [LLM Integration](docs/llm-integration.md).
407
+ The editor maintains a configurable undo stack (default 100 states). Keyboard shortcuts work out of the box:
408
+
409
+ | Action | Shortcut |
410
+ |--------|----------|
411
+ | Undo | Ctrl+Z (Cmd+Z on Mac) |
412
+ | Redo | Ctrl+Shift+Z / Ctrl+Y |
413
+
414
+ ```javascript
415
+ const editor = new QuikdownEditor('#container', {
416
+ undoStackSize: 200, // max undo states (default 100)
417
+ showUndoRedo: true // show toolbar buttons
418
+ });
419
+
420
+ editor.undo(); // undo last change
421
+ editor.redo(); // redo
422
+ editor.canUndo(); // → boolean
423
+ editor.canRedo(); // → boolean
424
+ editor.clearHistory(); // wipe all history
425
+ ```
358
426
 
359
- ## Limitations
427
+ This is especially useful for human + LLM collaborative editing: agents make mistakes, and users need reversible edits. Undo/redo is also available as an MCP tool in [Path B](docs/quikdown-mcp.md#path-a-vs-path-b). Full API: [docs/quikdown-editor.md](docs/quikdown-editor.md).
360
428
 
361
- For size and security, quikdown doesn't support:
362
- - Reference-style links
363
- - Footnotes
364
- - Definition lists
429
+ ## Standalone / Airgapped Build
365
430
 
366
- Optional **heading slugs**: pass `heading_ids: true` to add `id` attributes on headings for in-page anchor links.
431
+ The standalone editor bundles all fence libraries no CDN, no network required:
432
+
433
+ ```bash
434
+ # Download from GitHub Releases
435
+ # or build locally:
436
+ npm run build:standalone
437
+ ```
367
438
 
368
- Note that raw html, svg, etc can be rendered using appropriate fences
369
439
  ```html
370
- <h2>My HTML Content</h2>
371
- <p>Some HTML</p>
440
+ <!-- Single file, works offline -->
441
+ <div id="editor"></div>
442
+ <script src="quikdown_edit_standalone.umd.min.js"></script>
443
+ <script>
444
+ const editor = new QuikdownEditor('#editor', { mode: 'split' });
445
+ editor.setMarkdown('# Works offline');
446
+ </script>
372
447
  ```
373
- as long as an appropriate fence plugin is provided. See API docs for example or try out in quikdown_edit.js which has built-in support for HTML with XSS prevention.
448
+
449
+ Use cases: air-gapped networks, regulated environments, field deployments, offline demos, Electron apps, embedded systems. See [docs/standalone-editor.md](docs/standalone-editor.md) for the full list of bundled libraries and build details. Pre-built zip available on [GitHub Releases](https://github.com/deftio/quikdown/releases).
450
+
451
+ ## Comparison
452
+
453
+ | | Quikdown | marked | markdown-it | ProseMirror + markdown |
454
+ |---|---|---|---|---|
455
+ | **Parser size** | ~15 KB | ~40 KB | ~100 KB | ~200 KB+ |
456
+ | **Editor included** | Yes (~98 KB) | No | No | Yes (large stack) |
457
+ | **XSS-safe by default** | Yes | No (opt-in) | No (opt-in) | Depends on schema |
458
+ | **Bidirectional** | Yes | No | No | Yes |
459
+ | **Streaming-friendly** | Yes | Yes | Yes | Complex |
460
+ | **Offline standalone** | Yes (~7.7 MB all-in) | N/A | N/A | N/A |
461
+ | **Runtime deps** | 0 | 0 | 0 | Many |
462
+ | **MCP server** | 24 tools | No | No | No |
463
+ | **CommonMark coverage** | Subset | Full | Full | Full |
464
+
465
+ Quikdown intentionally trades full CommonMark coverage for a smaller, safer, more integrated package. If you need full spec compliance or a heavyweight collaborative editing framework, marked/markdown-it/ProseMirror are better choices.
466
+
467
+ ## What Quikdown Is Not
468
+
469
+ - **Not a full CommonMark parser** — reference-style links, footnotes, and definition lists are intentionally omitted for size and security.
470
+ - **Not a WYSIWYG framework** — the editor is a split-view Markdown-first surface, not a block-based rich text editor like Notion or ProseMirror.
471
+ - **Not a giant editor stack** — no virtual DOM, no plugin registries, no complex state management. One import, one `<div>`.
472
+
473
+ Optional **heading slugs**: pass `heading_ids: true` to add `id` attributes for in-page anchor links. Raw HTML/SVG can be rendered via fence plugins with XSS protection — see the API docs or try the built-in `html` fence in `quikdown_edit.js`.
374
474
 
375
475
  ## License
376
476
 
Binary file
package/dist/quikdown.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * quikdown - Lightweight 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-';
@@ -5,7 +5,7 @@
5
5
  * Theme with container-based scoping.
6
6
  * Usage: <div class="quikdown-dark">...content...</div>
7
7
  *
8
- * @version 1.2.17
8
+ * @version 1.2.19
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.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 - Lightweight 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",l="§BE",o={href:1,src:1,action:1,formaction:1},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s={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 c(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 f(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function p(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 u(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 d={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const l=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let o="";const a=[],c=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:f,content:p}=e[i];if(!(f<=0)){if(l&&0===i){const e=l[1].toUpperCase(),n=e.toLowerCase();if(c){const e=s.alert,t=s["alert-"+n];o+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else o+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=d[e];o+=c?`<p style="${s["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,a.push("alert");continue}for(;a.length>f;){o+="alert"===a.pop()?"</div>":"</blockquote>"}for(;a.length<f;)0===a.length&&l?a.push("alert"):(o+=`<blockquote${n("blockquote")}${r(">")}>`,a.push("blockquote"));o+=p,i<e.length-1&&(o+="\n")}}for(;a.length>0;){o+="alert"===a.pop()?"</div>":"</blockquote>"}return o.trimEnd()}function h(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 $(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(d,m={}){if(!d||"string"!=typeof d)return"";const{fence_plugin:b,inline_styles:_=!1,bidirectional:x=!1,lazy_linefeeds:q=!1,allow_unsafe_html:y=!1,heading_ids:w=!1}=m,A=function(e,n){return function(r,l=""){if(e){let e=n[r];return e||l?(l&&l.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${l?e?`${e}${l}`:l:e}"`):""}{const e=` class="${t}${r}"`;return l?`${e} style="${l}"`:e}}}(_,s),v=new Map;function z(e){return e.replace(/[&<>"']/g,e=>a[e])}const E=x?e=>` data-qd="${z(e)}"`:()=>"";function C(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let N=d;const W=[],T=[];N=N.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,l)=>{const o=`${n}${W.length}§`,a=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?W.push({lang:a,code:l.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):W.push({lang:a,code:z(l.trimEnd()),custom:!1,fence:t}),o});const j=[];N=N.replace(/\\`/g,()=>{const e=`${l}${j.length}§`;return j.push("`"),e}),N=N.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${T.length}§`;return T.push(z(t)),n}),N=N.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${l}${j.length}§`;return j.push(z(t)),n});const I=[],Z=Array.isArray(y)?Object.fromEntries(y.map(e=>[e,1])):y&&"object"==typeof y?y:null;Z&&(N=N.replace(/<!--[\s\S]*?-->/g,e=>{const t=I.length;return I.push(e),`${r}${t}§`}),N=N.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in Z){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=C(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=I.length;return I.push(t),`${r}${n}§`}return e})),!0!==y&&(N=z(N)),Z&&I.forEach((e,t)=>{N=N.replace(`${r}${t}§`,e)}),N=function(e,t,n){const r=e.split("\n"),l=[];let o=0;for(;o<r.length;){if(!h(r[o])){l.push(r[o]),o++;continue}const e=[];for(;o<r.length;){const t=r[o];if(""===t){if(o+1<r.length&&h(r[o+1])){e.push(""),o++;continue}break}if(!h(t))break;e.push($(t)),o++}const a=e.join("\n");l.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${a}</code></pre>`)}return l.join("\n")}(N,A,E),N=function(e,t,n){const r=e.split("\n"),l=[];let o=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))o||(o=!0,a=[]),a.push(s);else{if(o){const e=k(a,t,n);e?l.push(e):l.push(...a),o=!1,a=[]}l.push(r[e])}}if(o&&a.length>0){const e=k(a,t,n);e?l.push(e):l.push(...a)}return l.join("\n")}(N,A,x),N=function(t,n,r,l,o,a){const s=t.split("\n"),c=[];let d=0;for(;d<s.length;){const t=s[d];if(/^\[\/\/\]: #/.test(t)){d++;continue}let h=0;for(;h<t.length&&h<7&&"#"===t[h];)h++;if(h>=1&&h<=6&&" "===t[h]){const e=t.slice(h+1).replace(/\s*#+\s*$/,""),s="h"+h;let p="";if(l){p=` id="${a(f(i(e),o))}"`}c.push(`<${s}${n(s)}${p}${r("#".repeat(h))}>${e}</${s}>`),d++;continue}if(e(t))c.push(`<hr${n("hr")}${r(t.trim())}>`),d++;else{if(p(t).depth>0){const e=[];let t=0;for(;d<s.length;){const n=p(s[d]);if(n.depth>0)e.push(n),t=n.depth,d++;else{if(!(t>0)||u(s[d]))break;e.push({depth:t,content:s[d]}),d++}}c.push(g(e,n,r));continue}c.push(t),d++}}return c.join("\n")}(N,A,E,w,v,z),N=function(e,n,r,l){const o=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=l?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<o.length;e++){const l=o[e],c=l.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,l,o]=c,f=Math.floor(e.length/2),p=/^\d+\./.test(l),u=p?"ol":"ul";let d=o,g="";const h=o.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!p){const[,e,n]=h,l="x"===e.toLowerCase();d=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${l?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>f+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===f)s.push({type:u,level:f}),a.push(`<${u}${n(u)}>`);else if(s.length===f+1){const e=s[s.length-1];e.type!==u&&(a.push(`</${e.type}>`),s.pop(),s.push({type:u,level:f}),a.push(`<${u}${n(u)}>`))}const $=g||n("li");a.push(`<li${$}${i(l)}>${d}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(l)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(N,A,_,x),N=N.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=l?` title="${z(l)}"`:"",s=x&&t?` data-qd-alt="${z(t)}"`:"",i=x?` data-qd-src="${z(r)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<img${A("img")} src="${o}" alt="${t}"${a}${s}${i}${f}${E("!")}>`}),N=N.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"",s=l?` title="${z(l)}"`:"",i=x?` data-qd-text="${z(t)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<a${A("a")} href="${o}"${a}${s}${i}${f}${E("[")}>${t}</a>`}),N=N.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:l}=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),o=C(r,m.allow_unsafe_urls);return`${t}<a${A("a")} href="${o}" rel="noopener noreferrer">${r}</a>${l}`});const O=[];N=N.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])=>{N=N.replace(e,`<${t}${A(t)}${E(n)}>$1</${t}>`)}),N=N.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),N=N.replace(/\\\n/g,`<br${A("br")}>`),q){const e=[];let t=0;N=N.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),N=N.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${A("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>N=N.replace(`§B${t}§`,e)),N="<p>"+N+"</p>"}else N=N.replace(/ {2}$/gm,`<br${A("br")}>`),N=N.replace(/\n\n+/g,(e,t)=>N.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),N="<p>"+N+"</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])=>{N=N.replace(e,t)}),N=N.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),W.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${z(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${z(e.fence)}" data-qd-lang="${z(e.lang)}" data-qd-source="${z(e.code)}"`));else{const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${e.code}</code></pre>`}const l=`${n}${t}§`;N=N.replace(l,r)}),T.forEach((e,t)=>{const n=`§IC${t}§`;N=N.replace(n,`<code${A("code")}${E("`")}>${e}</code>`)}),j.forEach((e,t)=>{N=N.replace(`${l}${t}§`,e)}),N.trim()}function _(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 k(e,t,n){if(e.length<2)return null;let r,l,o,a=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){a=t;break}if(-1===a)r=[e[0]],l=e.slice(1),o=m(e[0]).map(()=>"left");else{r=e.slice(0,a),l=e.slice(a+1);const t=m(e[a]);o=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const s=o.length,c=n?` data-qd-align="${o.join(",")}"`:"";let i=`<table${t("table")}${c}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<th${t("th",l)}>${a}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<td${t("td",l)}>${a}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}b.emitStyles=function(e="quikdown-",t="light"){const n=s,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},l={_textColor:"#333"};let o="";for(const[a,s]of Object.entries(n)){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${l._textColor}`)}o+=`.${e}${a} { ${n} }\n`}return o},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);export{b 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",l="§BE",o={href:1,src:1,action:1,formaction:1},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s={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 c(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 f(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function p(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 u(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 d={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const l=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let o="";const a=[],c=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:f,content:p}=e[i];if(!(f<=0)){if(l&&0===i){const e=l[1].toUpperCase(),n=e.toLowerCase();if(c){const e=s.alert,t=s["alert-"+n];o+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else o+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=d[e];o+=c?`<p style="${s["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,a.push("alert");continue}for(;a.length>f;){o+="alert"===a.pop()?"</div>":"</blockquote>"}for(;a.length<f;)0===a.length&&l?a.push("alert"):(o+=`<blockquote${n("blockquote")}${r(">")}>`,a.push("blockquote"));o+=p,i<e.length-1&&(o+="\n")}}for(;a.length>0;){o+="alert"===a.pop()?"</div>":"</blockquote>"}return o.trimEnd()}function h(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 $(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(d,m={}){if(!d||"string"!=typeof d)return"";const{fence_plugin:b,inline_styles:_=!1,bidirectional:x=!1,lazy_linefeeds:q=!1,allow_unsafe_html:y=!1,heading_ids:w=!1}=m,A=function(e,n){return function(r,l=""){if(e){let e=n[r];return e||l?(l&&l.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${l?e?`${e}${l}`:l:e}"`):""}{const e=` class="${t}${r}"`;return l?`${e} style="${l}"`:e}}}(_,s),v=new Map;function z(e){return e.replace(/[&<>"']/g,e=>a[e])}const E=x?e=>` data-qd="${z(e)}"`:()=>"";function C(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let N=d;const W=[],T=[];N=N.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,l)=>{const o=`${n}${W.length}§`,a=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?W.push({lang:a,code:l.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):W.push({lang:a,code:z(l.trimEnd()),custom:!1,fence:t}),o});const j=[];N=N.replace(/\\`/g,()=>{const e=`${l}${j.length}§`;return j.push("`"),e}),N=N.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${T.length}§`;return T.push(z(t)),n}),N=N.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${l}${j.length}§`;return j.push(z(t)),n});const I=[],Z=Array.isArray(y)?Object.fromEntries(y.map(e=>[e,1])):y&&"object"==typeof y?y:null;Z&&(N=N.replace(/<!--[\s\S]*?-->/g,e=>{const t=I.length;return I.push(e),`${r}${t}§`}),N=N.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in Z){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=C(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=I.length;return I.push(t),`${r}${n}§`}return e})),!0!==y&&(N=z(N)),Z&&I.forEach((e,t)=>{N=N.replace(`${r}${t}§`,e)}),N=function(e,t,n){const r=e.split("\n"),l=[];let o=0;for(;o<r.length;){if(!h(r[o])){l.push(r[o]),o++;continue}const e=[];for(;o<r.length;){const t=r[o];if(""===t){if(o+1<r.length&&h(r[o+1])){e.push(""),o++;continue}break}if(!h(t))break;e.push($(t)),o++}const a=e.join("\n");l.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${a}</code></pre>`)}return l.join("\n")}(N,A,E),N=function(e,t,n){const r=e.split("\n"),l=[];let o=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))o||(o=!0,a=[]),a.push(s);else{if(o){const e=k(a,t,n);e?l.push(e):l.push(...a),o=!1,a=[]}l.push(r[e])}}if(o&&a.length>0){const e=k(a,t,n);e?l.push(e):l.push(...a)}return l.join("\n")}(N,A,x),N=function(t,n,r,l,o,a){const s=t.split("\n"),c=[];let d=0;for(;d<s.length;){const t=s[d];if(/^\[\/\/\]: #/.test(t)){d++;continue}let h=0;for(;h<t.length&&h<7&&"#"===t[h];)h++;if(h>=1&&h<=6&&" "===t[h]){const e=t.slice(h+1).replace(/\s*#+\s*$/,""),s="h"+h;let p="";if(l){p=` id="${a(f(i(e),o))}"`}c.push(`<${s}${n(s)}${p}${r("#".repeat(h))}>${e}</${s}>`),d++;continue}if(e(t))c.push(`<hr${n("hr")}${r(t.trim())}>`),d++;else{if(p(t).depth>0){const e=[];let t=0;for(;d<s.length;){const n=p(s[d]);if(n.depth>0)e.push(n),t=n.depth,d++;else{if(!(t>0)||u(s[d]))break;e.push({depth:t,content:s[d]}),d++}}c.push(g(e,n,r));continue}c.push(t),d++}}return c.join("\n")}(N,A,E,w,v,z),N=function(e,n,r,l){const o=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=l?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<o.length;e++){const l=o[e],c=l.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,l,o]=c,f=Math.floor(e.length/2),p=/^\d+\./.test(l),u=p?"ol":"ul";let d=o,g="";const h=o.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!p){const[,e,n]=h,l="x"===e.toLowerCase();d=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${l?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>f+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===f)s.push({type:u,level:f}),a.push(`<${u}${n(u)}>`);else if(s.length===f+1){const e=s[s.length-1];e.type!==u&&(a.push(`</${e.type}>`),s.pop(),s.push({type:u,level:f}),a.push(`<${u}${n(u)}>`))}const $=g||n("li");a.push(`<li${$}${i(l)}>${d}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(l)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(N,A,_,x),N=N.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=l?` title="${z(l)}"`:"",s=x&&t?` data-qd-alt="${z(t)}"`:"",i=x?` data-qd-src="${z(r)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<img${A("img")} src="${o}" alt="${t}"${a}${s}${i}${f}${E("!")}>`}),N=N.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"",s=l?` title="${z(l)}"`:"",i=x?` data-qd-text="${z(t)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<a${A("a")} href="${o}"${a}${s}${i}${f}${E("[")}>${t}</a>`}),N=N.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:l}=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),o=C(r,m.allow_unsafe_urls);return`${t}<a${A("a")} href="${o}" rel="noopener noreferrer">${r}</a>${l}`});const O=[];N=N.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])=>{N=N.replace(e,`<${t}${A(t)}${E(n)}>$1</${t}>`)}),N=N.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),N=N.replace(/\\\n/g,`<br${A("br")}>`),q){const e=[];let t=0;N=N.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),N=N.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${A("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>N=N.replace(`§B${t}§`,e)),N="<p>"+N+"</p>"}else N=N.replace(/ {2}$/gm,`<br${A("br")}>`),N=N.replace(/\n\n+/g,(e,t)=>N.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),N="<p>"+N+"</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])=>{N=N.replace(e,t)}),N=N.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),W.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${z(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${z(e.fence)}" data-qd-lang="${z(e.lang)}" data-qd-source="${z(e.code)}"`));else{const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${e.code}</code></pre>`}const l=`${n}${t}§`;N=N.replace(l,r)}),T.forEach((e,t)=>{const n=`§IC${t}§`;N=N.replace(n,`<code${A("code")}${E("`")}>${e}</code>`)}),j.forEach((e,t)=>{N=N.replace(`${l}${t}§`,e)}),N.trim()}function _(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 k(e,t,n){if(e.length<2)return null;let r,l,o,a=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){a=t;break}if(-1===a)r=[e[0]],l=e.slice(1),o=m(e[0]).map(()=>"left");else{r=e.slice(0,a),l=e.slice(a+1);const t=m(e[a]);o=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const s=o.length,c=n?` data-qd-align="${o.join(",")}"`:"";let i=`<table${t("table")}${c}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<th${t("th",l)}>${a}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<td${t("td",l)}>${a}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}b.emitStyles=function(e="quikdown-",t="light"){const n=s,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},l={_textColor:"#333"};let o="";for(const[a,s]of Object.entries(n)){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${l._textColor}`)}o+=`.${e}${a} { ${n} }\n`}return o},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);export{b as default};
8
8
  //# sourceMappingURL=quikdown.esm.min.js.map
Binary file
@@ -5,7 +5,7 @@
5
5
  * Theme with container-based scoping.
6
6
  * Usage: <div class="quikdown-light">...content...</div>
7
7
  *
8
- * @version 1.2.17
8
+ * @version 1.2.19
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.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-';
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown - Lightweight 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=t()}(this,function(){"use strict";function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",l="§BE",o={href:1,src:1,action:1,formaction:1},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s={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 c(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 f(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function u(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 d(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 p={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const l=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let o="";const a=[],c=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:f,content:u}=e[i];if(!(f<=0)){if(l&&0===i){const e=l[1].toUpperCase(),n=e.toLowerCase();if(c){const e=s.alert,t=s["alert-"+n];o+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else o+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=p[e];o+=c?`<p style="${s["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,a.push("alert");continue}for(;a.length>f;){o+="alert"===a.pop()?"</div>":"</blockquote>"}for(;a.length<f;)0===a.length&&l?a.push("alert"):(o+=`<blockquote${n("blockquote")}${r(">")}>`,a.push("blockquote"));o+=u,i<e.length-1&&(o+="\n")}}for(;a.length>0;){o+="alert"===a.pop()?"</div>":"</blockquote>"}return o.trimEnd()}function h(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 $(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(p,m={}){if(!p||"string"!=typeof p)return"";const{fence_plugin:b,inline_styles:_=!1,bidirectional:x=!1,lazy_linefeeds:q=!1,allow_unsafe_html:y=!1,heading_ids:w=!1}=m,A=function(e,n){return function(r,l=""){if(e){let e=n[r];return e||l?(l&&l.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${l?e?`${e}${l}`:l:e}"`):""}{const e=` class="${t}${r}"`;return l?`${e} style="${l}"`:e}}}(_,s),v=new Map;function z(e){return e.replace(/[&<>"']/g,e=>a[e])}const E=x?e=>` data-qd="${z(e)}"`:()=>"";function C(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let N=p;const W=[],T=[];N=N.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,l)=>{const o=`${n}${W.length}§`,a=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?W.push({lang:a,code:l.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):W.push({lang:a,code:z(l.trimEnd()),custom:!1,fence:t}),o});const j=[];N=N.replace(/\\`/g,()=>{const e=`${l}${j.length}§`;return j.push("`"),e}),N=N.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${T.length}§`;return T.push(z(t)),n}),N=N.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${l}${j.length}§`;return j.push(z(t)),n});const I=[],Z=Array.isArray(y)?Object.fromEntries(y.map(e=>[e,1])):y&&"object"==typeof y?y:null;Z&&(N=N.replace(/<!--[\s\S]*?-->/g,e=>{const t=I.length;return I.push(e),`${r}${t}§`}),N=N.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in Z){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=C(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=I.length;return I.push(t),`${r}${n}§`}return e})),!0!==y&&(N=z(N)),Z&&I.forEach((e,t)=>{N=N.replace(`${r}${t}§`,e)}),N=function(e,t,n){const r=e.split("\n"),l=[];let o=0;for(;o<r.length;){if(!h(r[o])){l.push(r[o]),o++;continue}const e=[];for(;o<r.length;){const t=r[o];if(""===t){if(o+1<r.length&&h(r[o+1])){e.push(""),o++;continue}break}if(!h(t))break;e.push($(t)),o++}const a=e.join("\n");l.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${a}</code></pre>`)}return l.join("\n")}(N,A,E),N=function(e,t,n){const r=e.split("\n"),l=[];let o=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))o||(o=!0,a=[]),a.push(s);else{if(o){const e=k(a,t,n);e?l.push(e):l.push(...a),o=!1,a=[]}l.push(r[e])}}if(o&&a.length>0){const e=k(a,t,n);e?l.push(e):l.push(...a)}return l.join("\n")}(N,A,x),N=function(t,n,r,l,o,a){const s=t.split("\n"),c=[];let p=0;for(;p<s.length;){const t=s[p];if(/^\[\/\/\]: #/.test(t)){p++;continue}let h=0;for(;h<t.length&&h<7&&"#"===t[h];)h++;if(h>=1&&h<=6&&" "===t[h]){const e=t.slice(h+1).replace(/\s*#+\s*$/,""),s="h"+h;let u="";if(l){u=` id="${a(f(i(e),o))}"`}c.push(`<${s}${n(s)}${u}${r("#".repeat(h))}>${e}</${s}>`),p++;continue}if(e(t))c.push(`<hr${n("hr")}${r(t.trim())}>`),p++;else{if(u(t).depth>0){const e=[];let t=0;for(;p<s.length;){const n=u(s[p]);if(n.depth>0)e.push(n),t=n.depth,p++;else{if(!(t>0)||d(s[p]))break;e.push({depth:t,content:s[p]}),p++}}c.push(g(e,n,r));continue}c.push(t),p++}}return c.join("\n")}(N,A,E,w,v,z),N=function(e,n,r,l){const o=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=l?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<o.length;e++){const l=o[e],c=l.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,l,o]=c,f=Math.floor(e.length/2),u=/^\d+\./.test(l),d=u?"ol":"ul";let p=o,g="";const h=o.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!u){const[,e,n]=h,l="x"===e.toLowerCase();p=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${l?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>f+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===f)s.push({type:d,level:f}),a.push(`<${d}${n(d)}>`);else if(s.length===f+1){const e=s[s.length-1];e.type!==d&&(a.push(`</${e.type}>`),s.pop(),s.push({type:d,level:f}),a.push(`<${d}${n(d)}>`))}const $=g||n("li");a.push(`<li${$}${i(l)}>${p}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(l)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(N,A,_,x),N=N.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=l?` title="${z(l)}"`:"",s=x&&t?` data-qd-alt="${z(t)}"`:"",i=x?` data-qd-src="${z(r)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<img${A("img")} src="${o}" alt="${t}"${a}${s}${i}${f}${E("!")}>`}),N=N.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"",s=l?` title="${z(l)}"`:"",i=x?` data-qd-text="${z(t)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<a${A("a")} href="${o}"${a}${s}${i}${f}${E("[")}>${t}</a>`}),N=N.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:l}=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),o=C(r,m.allow_unsafe_urls);return`${t}<a${A("a")} href="${o}" rel="noopener noreferrer">${r}</a>${l}`});const O=[];N=N.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])=>{N=N.replace(e,`<${t}${A(t)}${E(n)}>$1</${t}>`)}),N=N.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),N=N.replace(/\\\n/g,`<br${A("br")}>`),q){const e=[];let t=0;N=N.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),N=N.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${A("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>N=N.replace(`§B${t}§`,e)),N="<p>"+N+"</p>"}else N=N.replace(/ {2}$/gm,`<br${A("br")}>`),N=N.replace(/\n\n+/g,(e,t)=>N.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),N="<p>"+N+"</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])=>{N=N.replace(e,t)}),N=N.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),W.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${z(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${z(e.fence)}" data-qd-lang="${z(e.lang)}" data-qd-source="${z(e.code)}"`));else{const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${e.code}</code></pre>`}const l=`${n}${t}§`;N=N.replace(l,r)}),T.forEach((e,t)=>{const n=`§IC${t}§`;N=N.replace(n,`<code${A("code")}${E("`")}>${e}</code>`)}),j.forEach((e,t)=>{N=N.replace(`${l}${t}§`,e)}),N.trim()}function _(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 k(e,t,n){if(e.length<2)return null;let r,l,o,a=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){a=t;break}if(-1===a)r=[e[0]],l=e.slice(1),o=m(e[0]).map(()=>"left");else{r=e.slice(0,a),l=e.slice(a+1);const t=m(e[a]);o=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const s=o.length,c=n?` data-qd-align="${o.join(",")}"`:"";let i=`<table${t("table")}${c}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<th${t("th",l)}>${a}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<td${t("td",l)}>${a}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}return b.emitStyles=function(e="quikdown-",t="light"){const n=s,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},l={_textColor:"#333"};let o="";for(const[a,s]of Object.entries(n)){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${l._textColor}`)}o+=`.${e}${a} { ${n} }\n`}return o},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),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=t()}(this,function(){"use strict";function e(e){if(e.length<3)return!1;let t="";for(let n=0;n<e.length;n++){const r=e[n];" "!==r&&"\t"!==r&&(t+=r)}if(t.length<3)return!1;const n=t[0];if("-"!==n&&"*"!==n&&"_"!==n)return!1;for(let e=1;e<t.length;e++)if(t[e]!==n)return!1;return!0}const t="quikdown-",n="§CB",r="§HT",l="§BE",o={href:1,src:1,action:1,formaction:1},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s={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 c(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 f(e,t){const n=t.get(e)||0;return t.set(e,n+1),0===n?e:`${e}-${n}`}function u(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 d(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 p={NOTE:"Note",TIP:"Tip",IMPORTANT:"Important",WARNING:"Warning",CAUTION:"Caution"};function g(e,n,r){const l=e.length>0&&1===e[0].depth?e[0].content.trim().match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i):null;let o="";const a=[],c=n("blockquote").includes("style=");for(let i=0;i<e.length;i++){const{depth:f,content:u}=e[i];if(!(f<=0)){if(l&&0===i){const e=l[1].toUpperCase(),n=e.toLowerCase();if(c){const e=s.alert,t=s["alert-"+n];o+=`<div style="${t?`${e};${t}`:e}"${r(">")}>`}else o+=`<div class="${t}alert ${t}alert-${n}"${r(">")}>`;const i=p[e];o+=c?`<p style="${s["alert-title"]}">${i}</p>`:`<p class="${t}alert-title">${i}</p>`,a.push("alert");continue}for(;a.length>f;){o+="alert"===a.pop()?"</div>":"</blockquote>"}for(;a.length<f;)0===a.length&&l?a.push("alert"):(o+=`<blockquote${n("blockquote")}${r(">")}>`,a.push("blockquote"));o+=u,i<e.length-1&&(o+="\n")}}for(;a.length>0;){o+="alert"===a.pop()?"</div>":"</blockquote>"}return o.trimEnd()}function h(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 $(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(p,m={}){if(!p||"string"!=typeof p)return"";const{fence_plugin:b,inline_styles:_=!1,bidirectional:x=!1,lazy_linefeeds:q=!1,allow_unsafe_html:y=!1,heading_ids:w=!1}=m,A=function(e,n){return function(r,l=""){if(e){let e=n[r];return e||l?(l&&l.includes("text-align")&&e&&e.includes("text-align")&&(e=e.replace(/text-align:[^;]+;?/,"").trim(),e&&!e.endsWith(";")&&(e+=";")),` style="${l?e?`${e}${l}`:l:e}"`):""}{const e=` class="${t}${r}"`;return l?`${e} style="${l}"`:e}}}(_,s),v=new Map;function z(e){return e.replace(/[&<>"']/g,e=>a[e])}const E=x?e=>` data-qd="${z(e)}"`:()=>"";function C(e,t=!1){if(!e)return"";if(t)return e;const n=e.trim(),r=n.toLowerCase(),l=["javascript:","vbscript:","data:"];for(const e of l)if(r.startsWith(e))return"data:"===e&&r.startsWith("data:image/")?n:"#";return n}let N=p;const W=[],T=[];N=N.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm,(e,t,r,l)=>{const o=`${n}${W.length}§`,a=r?r.trim():"";return b&&b.render&&"function"==typeof b.render?W.push({lang:a,code:l.trimEnd(),custom:!0,fence:t,hasReverse:!!b.reverse}):W.push({lang:a,code:z(l.trimEnd()),custom:!1,fence:t}),o});const j=[];N=N.replace(/\\`/g,()=>{const e=`${l}${j.length}§`;return j.push("`"),e}),N=N.replace(/`([^`\n]+)`/g,(e,t)=>{const n=`§IC${T.length}§`;return T.push(z(t)),n}),N=N.replace(/\\([\\*_{}[\]()#+\-.!~|<>])/g,(e,t)=>{const n=`${l}${j.length}§`;return j.push(z(t)),n});const I=[],Z=Array.isArray(y)?Object.fromEntries(y.map(e=>[e,1])):y&&"object"==typeof y?y:null;Z&&(N=N.replace(/<!--[\s\S]*?-->/g,e=>{const t=I.length;return I.push(e),`${r}${t}§`}),N=N.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)\b[^>]*\/?>/g,(e,t)=>{if(t.toLowerCase()in Z){const t=function(e){if(!/\s/.test(e.replace(/<\/?[a-zA-Z][a-zA-Z0-9]*/,"").replace(/\/?>$/,"")))return e;const t=e.match(/^(<\/?[a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?>)$/);if(!t)return e;const[,n,r,l]=t,a=/([a-zA-Z_][\w\-.:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,s=[];let c;for(;null!==(c=a.exec(r));){const e=c[1],t=void 0!==c[2]?c[2]:void 0!==c[3]?c[3]:c[4];if(!/^on/i.test(e))if(void 0===t)s.push(e);else{let n=t;e.toLowerCase()in o&&(n=C(t)),s.push(`${e}="${n}"`)}}return n+(s.length?" "+s.join(" "):"")+l}(e),n=I.length;return I.push(t),`${r}${n}§`}return e})),!0!==y&&(N=z(N)),Z&&I.forEach((e,t)=>{N=N.replace(`${r}${t}§`,e)}),N=function(e,t,n){const r=e.split("\n"),l=[];let o=0;for(;o<r.length;){if(!h(r[o])){l.push(r[o]),o++;continue}const e=[];for(;o<r.length;){const t=r[o];if(""===t){if(o+1<r.length&&h(r[o+1])){e.push(""),o++;continue}break}if(!h(t))break;e.push($(t)),o++}const a=e.join("\n");l.push(`<pre${t("pre")}${n(" ")}><code${t("code")}>${a}</code></pre>`)}return l.join("\n")}(N,A,E),N=function(e,t,n){const r=e.split("\n"),l=[];let o=!1,a=[];for(let e=0;e<r.length;e++){const s=r[e].trim();if(s.includes("|")&&(s.startsWith("|")||/[^\\|]/.test(s)))o||(o=!0,a=[]),a.push(s);else{if(o){const e=k(a,t,n);e?l.push(e):l.push(...a),o=!1,a=[]}l.push(r[e])}}if(o&&a.length>0){const e=k(a,t,n);e?l.push(e):l.push(...a)}return l.join("\n")}(N,A,x),N=function(t,n,r,l,o,a){const s=t.split("\n"),c=[];let p=0;for(;p<s.length;){const t=s[p];if(/^\[\/\/\]: #/.test(t)){p++;continue}let h=0;for(;h<t.length&&h<7&&"#"===t[h];)h++;if(h>=1&&h<=6&&" "===t[h]){const e=t.slice(h+1).replace(/\s*#+\s*$/,""),s="h"+h;let u="";if(l){u=` id="${a(f(i(e),o))}"`}c.push(`<${s}${n(s)}${u}${r("#".repeat(h))}>${e}</${s}>`),p++;continue}if(e(t))c.push(`<hr${n("hr")}${r(t.trim())}>`),p++;else{if(u(t).depth>0){const e=[];let t=0;for(;p<s.length;){const n=u(s[p]);if(n.depth>0)e.push(n),t=n.depth,p++;else{if(!(t>0)||d(s[p]))break;e.push({depth:t,content:s[p]}),p++}}c.push(g(e,n,r));continue}c.push(t),p++}}return c.join("\n")}(N,A,E,w,v,z),N=function(e,n,r,l){const o=e.split("\n"),a=[],s=[],c=e=>e.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),i=l?e=>` data-qd="${c(e)}"`:()=>"";for(let e=0;e<o.length;e++){const l=o[e],c=l.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);if(c){const[,e,l,o]=c,f=Math.floor(e.length/2),u=/^\d+\./.test(l),d=u?"ol":"ul";let p=o,g="";const h=o.match(/^\[([x ])\]\s+(.*)$/i);if(h&&!u){const[,e,n]=h,l="x"===e.toLowerCase();p=`<input type="checkbox"${r?' style="margin-right:.5em"':` class="${t}task-checkbox"`}${l?" checked":""} disabled> ${n}`,g=r?' style="list-style:none"':` class="${t}task-item"`}for(;s.length>f+1;){const e=s.pop();a.push(`</${e.type}>`)}if(s.length===f)s.push({type:d,level:f}),a.push(`<${d}${n(d)}>`);else if(s.length===f+1){const e=s[s.length-1];e.type!==d&&(a.push(`</${e.type}>`),s.pop(),s.push({type:d,level:f}),a.push(`<${d}${n(d)}>`))}const $=g||n("li");a.push(`<li${$}${i(l)}>${p}</li>`)}else{for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}a.push(l)}}for(;s.length>0;){const e=s.pop();a.push(`</${e.type}>`)}return a.join("\n")}(N,A,_,x),N=N.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=l?` title="${z(l)}"`:"",s=x&&t?` data-qd-alt="${z(t)}"`:"",i=x?` data-qd-src="${z(r)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<img${A("img")} src="${o}" alt="${t}"${a}${s}${i}${f}${E("!")}>`}),N=N.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{const{url:r,title:l}=c(n),o=C(r,m.allow_unsafe_urls),a=/^https?:\/\//i.test(o)?' rel="noopener noreferrer"':"",s=l?` title="${z(l)}"`:"",i=x?` data-qd-text="${z(t)}"`:"",f=x&&l?` data-qd-title="${z(l)}"`:"";return`<a${A("a")} href="${o}"${a}${s}${i}${f}${E("[")}>${t}</a>`}),N=N.replace(/(^|\s)(https?:\/\/[^\s<]+)/g,(e,t,n)=>{const{url:r,trailing:l}=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),o=C(r,m.allow_unsafe_urls);return`${t}<a${A("a")} href="${o}" rel="noopener noreferrer">${r}</a>${l}`});const O=[];N=N.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])=>{N=N.replace(e,`<${t}${A(t)}${E(n)}>$1</${t}>`)}),N=N.replace(/%%T(\d+)%%/g,(e,t)=>O[t]),N=N.replace(/\\\n/g,`<br${A("br")}>`),q){const e=[];let t=0;N=N.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g,n=>(e[t]=n,`§B${t++}§`)),N=N.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${A("br")}>`).replace(/§N§/g,"\n").replace(/§P§/g,"</p><p>"),e.forEach((e,t)=>N=N.replace(`§B${t}§`,e)),N="<p>"+N+"</p>"}else N=N.replace(/ {2}$/gm,`<br${A("br")}>`),N=N.replace(/\n\n+/g,(e,t)=>N.substring(0,t).match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)?"<p>":"</p><p>"),N="<p>"+N+"</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])=>{N=N.replace(e,t)}),N=N.replace(/(<\/(?:h[1-6]|blockquote|div|ul|ol|table|pre|hr)>)\n([^<])/g,"$1\n<p>$2"),W.forEach((e,t)=>{let r;if(e.custom&&b&&b.render)if(r=b.render(e.code,e.lang),void 0===r){const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${z(e.code)}</code></pre>`}else x&&(r=r.replace(/^<(\w+)/,`<$1 data-qd-fence="${z(e.fence)}" data-qd-lang="${z(e.lang)}" data-qd-source="${z(e.code)}"`));else{const t=!_&&e.lang?` class="language-${z(e.lang)}"`:"",n=_?A("code"):t,l=x&&e.lang?` data-qd-lang="${z(e.lang)}"`:"",o=x?` data-qd-fence="${z(e.fence)}"`:"";r=`<pre${A("pre")}${o}${l}><code${n}>${e.code}</code></pre>`}const l=`${n}${t}§`;N=N.replace(l,r)}),T.forEach((e,t)=>{const n=`§IC${t}§`;N=N.replace(n,`<code${A("code")}${E("`")}>${e}</code>`)}),j.forEach((e,t)=>{N=N.replace(`${l}${t}§`,e)}),N.trim()}function _(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 k(e,t,n){if(e.length<2)return null;let r,l,o,a=-1;for(let t=1;t<e.length;t++)if(/^\|?[\s\-:|]+\|?$/.test(e[t])&&e[t].includes("-")){a=t;break}if(-1===a)r=[e[0]],l=e.slice(1),o=m(e[0]).map(()=>"left");else{r=e.slice(0,a),l=e.slice(a+1);const t=m(e[a]);o=t.map(e=>{const t=e.trim();return t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left"})}const s=o.length,c=n?` data-qd-align="${o.join(",")}"`:"";let i=`<table${t("table")}${c}>\n`;return i+=`<thead${t("thead")}>\n`,r.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<th${t("th",l)}>${a}</th>\n`}i+="</tr>\n"}),i+="</thead>\n",l.length>0&&(i+=`<tbody${t("tbody")}>\n`,l.forEach(e=>{i+=`<tr${t("tr")}>\n`;const n=m(e);for(let e=0;e<s;e++){const r=e<n.length?n[e]:"",l=o[e]&&"left"!==o[e]?`text-align:${o[e]}`:"",a=_(r.trim(),t);i+=`<td${t("td",l)}>${a}</td>\n`}i+="</tr>\n"}),i+="</tbody>\n"),i+="</table>",i}return b.emitStyles=function(e="quikdown-",t="light"){const n=s,r={"#f4f4f4":"#2a2a2a","#f0f0f0":"#2a2a2a","#f2f2f2":"#2a2a2a","#ddd":"#3a3a3a","#06c":"#6db3f2","#ddf4ff":"#162d50","#dafbe1":"#16351d","#fbefff":"#2d1a42","#fff8c5":"#342a10","#ffebe9":"#3d1418",_textColor:"#e0e0e0"},l={_textColor:"#333"};let o="";for(const[a,s]of Object.entries(n)){let n=s;if("dark"===t&&r){for(const[e,t]of Object.entries(r))e.startsWith("_")||(n=n.replaceAll(e,t));["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${r._textColor}`)}else if("light"===t&&l){["h1","h2","h3","h4","h5","h6","td","li","blockquote","alert","alert-title"].includes(a)&&(n+=`;color:${l._textColor}`)}o+=`.${e}${a} { ${n} }\n`}return o},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),b});
8
8
  //# sourceMappingURL=quikdown.umd.min.js.map
Binary file
@@ -1,6 +1,6 @@
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
  */
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  // Version will be injected at build time
18
- const quikdownVersion = '1.2.17';
18
+ const quikdownVersion = '1.2.19';
19
19
 
20
20
  // Safety limit to prevent infinite loops in list parsing
21
21
  const MAX_LOOP_ITERATIONS = 1000;
@@ -1,6 +1,6 @@
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
  */
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  // Version will be injected at build time
16
- const quikdownVersion = '1.2.17';
16
+ const quikdownVersion = '1.2.19';
17
17
 
18
18
  // Safety limit to prevent infinite loops in list parsing
19
19
  const MAX_LOOP_ITERATIONS = 1000;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * quikdown_ast - AST Markdown Parser
3
- * @version 1.2.17
3
+ * @version 1.2.19
4
4
  * @license BSD-2-Clause
5
5
  * @copyright DeftIO 2025
6
6
  */
7
- 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 o=0;for(;o<r.length;){const t=r[o];if(""===t.trim()){o++;continue}const n=t.match(/^(```|~~~)(.*)$/);if(n){const[,t,e]=n,s=e.trim(),i=[];for(o++;o<r.length;){if(r[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(r[o]),o++}l.push({type:"code_block",lang:s||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),o++;continue}const u=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,t,e]=u;l.push({type:"heading",level:t.length,children:h(e)}),o++;continue}if(t.includes("|")){const t=i(r,o);if(t){l.push(t.node),o=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];let n=!0;for(;o<r.length;)if(r[o].match(/^>\s*/))t.push(r[o].replace(/^>\s*/,"")),n=!0,o++;else{if(!n||e(r[o]))break;t.push(r[o]),o++}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,o);l.push(t.node),o=t.nextIndex;continue}const a=[];for(;o<r.length;){const t=r[o];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("|")&&o+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[o+1]))break;a.push(t),o++}a.length>0&&l.push({type:"paragraph",children:h(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"}),o=r.length,u=[];for(let t=0;t<o;t++){const e=t<c.length?c[t]:"";u.push(h(e.trim()))}const a=[];let p=e+2;for(;p<t.length;){const e=t[p];if(!e.includes("|")||""===e.trim())break;const n=l(e),s=[];for(let t=0;t<o;t++){const e=t<n.length?n[t]:"";s.push(h(e.trim()))}a.push(s),p++}return{node:{type:"table",headers:u,rows:a,alignments:r},nextIndex:p}}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+(.*)$/),o=/^\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,p=n.length;if(p<u)break;const f=/^\d+\./.test(r);if(p===u&&f!==o)break;if(p>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&&!o?(d.checked="x"===g[1].toLowerCase(),d.children=h(g[2])):d.children=h(a),s.push(d),i++}return{node:{type:"list",ordered:o,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 h(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(...o(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:o(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 h=i.match(/^(\*\*|__)(.+?)\1/);if(h){s.push({type:"strong",children:o(h[2])}),i=i.slice(h[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){s.push({type:"del",children:o(u[1])}),i=i.slice(u[0].length);continue}const a=t[t.length-i.length-1]||"",p=!/[A-Za-z0-9_]/.test(a),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||p&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){s.push({type:"em",children:o(f[1])}),i=i.slice(f[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 o(t,e){return h(t.replace(/\n/g," "))}t.version="1.2.17","undefined"!=typeof module&&module.exports&&(module.exports=t),"undefined"!=typeof window&&(window.quikdown_ast=t);export{t as default};
7
+ 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 o=0;for(;o<r.length;){const t=r[o];if(""===t.trim()){o++;continue}const n=t.match(/^(```|~~~)(.*)$/);if(n){const[,t,e]=n,s=e.trim(),i=[];for(o++;o<r.length;){if(r[o].match(/^(```|~~~)\s*$/)){o++;break}i.push(r[o]),o++}l.push({type:"code_block",lang:s||null,content:i.join("\n"),fence:t});continue}if(/^---+\s*$/.test(t)||/^\*\*\*+\s*$/.test(t)||/^___+\s*$/.test(t)){l.push({type:"hr"}),o++;continue}const u=t.match(/^(#{1,6})\s*(.+?)\s*#*$/);if(u){const[,t,e]=u;l.push({type:"heading",level:t.length,children:h(e)}),o++;continue}if(t.includes("|")){const t=i(r,o);if(t){l.push(t.node),o=t.nextIndex;continue}}if(t.match(/^>\s*/)){const t=[];let n=!0;for(;o<r.length;)if(r[o].match(/^>\s*/))t.push(r[o].replace(/^>\s*/,"")),n=!0,o++;else{if(!n||e(r[o]))break;t.push(r[o]),o++}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,o);l.push(t.node),o=t.nextIndex;continue}const a=[];for(;o<r.length;){const t=r[o];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("|")&&o+1<r.length&&/^\|?[\s\-:|]+\|?$/.test(r[o+1]))break;a.push(t),o++}a.length>0&&l.push({type:"paragraph",children:h(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"}),o=r.length,u=[];for(let t=0;t<o;t++){const e=t<c.length?c[t]:"";u.push(h(e.trim()))}const a=[];let p=e+2;for(;p<t.length;){const e=t[p];if(!e.includes("|")||""===e.trim())break;const n=l(e),s=[];for(let t=0;t<o;t++){const e=t<n.length?n[t]:"";s.push(h(e.trim()))}a.push(s),p++}return{node:{type:"table",headers:u,rows:a,alignments:r},nextIndex:p}}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+(.*)$/),o=/^\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,p=n.length;if(p<u)break;const f=/^\d+\./.test(r);if(p===u&&f!==o)break;if(p>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&&!o?(d.checked="x"===g[1].toLowerCase(),d.children=h(g[2])):d.children=h(a),s.push(d),i++}return{node:{type:"list",ordered:o,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 h(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(...o(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:o(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 h=i.match(/^(\*\*|__)(.+?)\1/);if(h){s.push({type:"strong",children:o(h[2])}),i=i.slice(h[0].length);continue}const u=i.match(/^~~(.+?)~~/);if(u){s.push({type:"del",children:o(u[1])}),i=i.slice(u[0].length);continue}const a=t[t.length-i.length-1]||"",p=!/[A-Za-z0-9_]/.test(a),f=i.match(/^\*(?!\*)(.+?)(?<!\*)\*(?!\*)/)||p&&i.match(/^_(?![_\s])(.+?)(?<![\s_])_(?![A-Za-z0-9_])/);if(f){s.push({type:"em",children:o(f[1])}),i=i.slice(f[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 o(t,e){return h(t.replace(/\n/g," "))}t.version="1.2.19","undefined"!=typeof module&&module.exports&&(module.exports=t),"undefined"!=typeof window&&(window.quikdown_ast=t);export{t as default};
8
8
  //# sourceMappingURL=quikdown_ast.esm.min.js.map
Binary file
@@ -1,6 +1,6 @@
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
  */
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  // Version will be injected at build time
22
- const quikdownVersion = '1.2.17';
22
+ const quikdownVersion = '1.2.19';
23
23
 
24
24
  // Safety limit to prevent infinite loops in list parsing
25
25
  const MAX_LOOP_ITERATIONS = 1000;