@legionworks/facet 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +23 -0
- package/README.md +158 -0
- package/dist/gallery/chunk-4g8rem85.css +656 -0
- package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
- package/dist/gallery/frame/artifact.css +8424 -0
- package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
- package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
- package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
- package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
- package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
- package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
- package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
- package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
- package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
- package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
- package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
- package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
- package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
- package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
- package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
- package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
- package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
- package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
- package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
- package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
- package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
- package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
- package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
- package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
- package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
- package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
- package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
- package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
- package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
- package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
- package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
- package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
- package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
- package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
- package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
- package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
- package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
- package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
- package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
- package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
- package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
- package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
- package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
- package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
- package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
- package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
- package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
- package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
- package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
- package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
- package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
- package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
- package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
- package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
- package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
- package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
- package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
- package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
- package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
- package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
- package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
- package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
- package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
- package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
- package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
- package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
- package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
- package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
- package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
- package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
- package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
- package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
- package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
- package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
- package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
- package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
- package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
- package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
- package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
- package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
- package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
- package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
- package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
- package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
- package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
- package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
- package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
- package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
- package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
- package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
- package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
- package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
- package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
- package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
- package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
- package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
- package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
- package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
- package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
- package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
- package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
- package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
- package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
- package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
- package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
- package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
- package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
- package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
- package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
- package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
- package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
- package/dist/gallery/frame/frame.css +183 -0
- package/dist/gallery/frame/runtime/chart.js +42744 -0
- package/dist/gallery/frame/runtime/html.js +14 -0
- package/dist/gallery/frame/runtime/markdown.js +1403 -0
- package/dist/gallery/frame/runtime/mermaid.js +32 -0
- package/dist/gallery/frame/runtime/svg.js +14 -0
- package/dist/gallery/frame/runtime/tsx.js +52 -0
- package/dist/gallery/index.html +104 -0
- package/docs/reference/cli.md +163 -0
- package/docs/reference/export.md +106 -0
- package/docs/reference/html.md +215 -0
- package/docs/reference/http.md +85 -0
- package/docs/reference/mcp.md +78 -0
- package/docs/reference/security.md +119 -0
- package/docs/reference/storage.md +93 -0
- package/docs/reference/tsx.md +101 -0
- package/docs/reference/validation.md +212 -0
- package/package.json +89 -0
- package/scripts/build-gallery.ts +127 -0
- package/scripts/launch-netns.sh +67 -0
- package/skills/facet/SKILL.md +100 -0
- package/src/cli/client.ts +311 -0
- package/src/cli/commands/create.ts +49 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/export.ts +179 -0
- package/src/cli/commands/instantiate.ts +35 -0
- package/src/cli/commands/list.ts +49 -0
- package/src/cli/commands/open.ts +75 -0
- package/src/cli/commands/pin.ts +39 -0
- package/src/cli/commands/promote.ts +49 -0
- package/src/cli/commands/publish.ts +122 -0
- package/src/cli/commands/read-back.ts +56 -0
- package/src/cli/commands/status.ts +114 -0
- package/src/cli/commands/watch.ts +146 -0
- package/src/cli/main.ts +522 -0
- package/src/cli/output.ts +106 -0
- package/src/cli/parser.ts +376 -0
- package/src/cli/presenter.ts +212 -0
- package/src/cli/service-metadata.ts +134 -0
- package/src/cli/spawn-service.ts +326 -0
- package/src/css.d.ts +4 -0
- package/src/gallery-web/app.ts +1581 -0
- package/src/gallery-web/export-menu.ts +121 -0
- package/src/gallery-web/export.ts +112 -0
- package/src/gallery-web/favicon.ts +54 -0
- package/src/gallery-web/frame/entries/chart.ts +6 -0
- package/src/gallery-web/frame/entries/html.ts +6 -0
- package/src/gallery-web/frame/entries/markdown.ts +6 -0
- package/src/gallery-web/frame/entries/mermaid.ts +6 -0
- package/src/gallery-web/frame/entries/svg.ts +6 -0
- package/src/gallery-web/frame/entries/tsx.ts +6 -0
- package/src/gallery-web/frame/frame-payload.ts +91 -0
- package/src/gallery-web/frame/renderer-validation.ts +13 -0
- package/src/gallery-web/frame/renderers/chart.ts +182 -0
- package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
- package/src/gallery-web/frame/renderers/html.ts +48 -0
- package/src/gallery-web/frame/renderers/markdown.ts +81 -0
- package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
- package/src/gallery-web/frame/renderers/registry.ts +260 -0
- package/src/gallery-web/frame/renderers/svg.ts +393 -0
- package/src/gallery-web/frame/renderers/tsx.ts +61 -0
- package/src/gallery-web/frame/runtime.ts +501 -0
- package/src/gallery-web/frame/styles/artifact.css +8424 -0
- package/src/gallery-web/frame/styles/frame.css +183 -0
- package/src/gallery-web/frame/styles/html-source.css +23 -0
- package/src/gallery-web/frame/view-box.ts +33 -0
- package/src/gallery-web/frame-html.ts +72 -0
- package/src/gallery-web/index.html +104 -0
- package/src/gallery-web/session.ts +107 -0
- package/src/gallery-web/sse-client.ts +212 -0
- package/src/gallery-web/styles/app.css +420 -0
- package/src/gallery-web/styles/tokens.css +112 -0
- package/src/gallery-web/styles/verdict.css +186 -0
- package/src/gallery-web/swap.ts +64 -0
- package/src/gallery-web/theme.ts +40 -0
- package/src/gallery-web/view-state.ts +93 -0
- package/src/harness-adapters/claude-code/README.md +10 -0
- package/src/harness-adapters/claude-code/facet.sh +4 -0
- package/src/harness-adapters/codex/README.md +10 -0
- package/src/harness-adapters/codex/facet.sh +4 -0
- package/src/harness-adapters/mcp/README.md +13 -0
- package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
- package/src/harness-adapters/mcp/main.ts +15 -0
- package/src/harness-adapters/mcp/server.ts +164 -0
- package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
- package/src/harness-adapters/opencode/README.md +10 -0
- package/src/harness-adapters/opencode/facet.sh +4 -0
- package/src/runtime/compiled-entrypoints.ts +69 -0
- package/src/service/dispatcher.ts +717 -0
- package/src/service/export.ts +218 -0
- package/src/service/http-utils.ts +55 -0
- package/src/service/lexical/expectations.ts +210 -0
- package/src/service/lifecycle/idle-controller.ts +125 -0
- package/src/service/lifecycle/orphan-cleanup.ts +128 -0
- package/src/service/lifecycle/process-lock.ts +235 -0
- package/src/service/main.ts +136 -0
- package/src/service/process.ts +240 -0
- package/src/service/router-guards.ts +239 -0
- package/src/service/router.ts +627 -0
- package/src/service/security/auth.ts +168 -0
- package/src/service/security/host-origin.ts +138 -0
- package/src/service/security/http-guards.ts +13 -0
- package/src/service/security/leases.ts +182 -0
- package/src/service/security/token-store.ts +138 -0
- package/src/service/server.ts +356 -0
- package/src/service/store/database.ts +61 -0
- package/src/service/store/evidence-retention.ts +234 -0
- package/src/service/store/migrations.ts +167 -0
- package/src/service/store/repository-lifecycle.ts +121 -0
- package/src/service/store/repository.ts +732 -0
- package/src/service/store/schema.ts +218 -0
- package/src/service/stored-verdict.ts +97 -0
- package/src/service/stream.ts +301 -0
- package/src/service/verdict-enrichment.ts +45 -0
- package/src/shared/build/frame-bundle-plugins.ts +61 -0
- package/src/shared/build-mode.ts +28 -0
- package/src/shared/config/evidence-read.ts +98 -0
- package/src/shared/config/limits.ts +56 -0
- package/src/shared/config/paths.ts +96 -0
- package/src/shared/contracts/artifact-types.ts +2 -0
- package/src/shared/contracts/artifact.ts +98 -0
- package/src/shared/contracts/commands/_shared.ts +59 -0
- package/src/shared/contracts/commands/guards.ts +86 -0
- package/src/shared/contracts/commands/index.ts +204 -0
- package/src/shared/contracts/commands/names.ts +35 -0
- package/src/shared/contracts/commands/requests.ts +149 -0
- package/src/shared/contracts/commands/results.ts +200 -0
- package/src/shared/contracts/envelope.ts +140 -0
- package/src/shared/contracts/events.ts +41 -0
- package/src/shared/contracts/observed-counts.ts +19 -0
- package/src/shared/contracts/renderers.ts +6 -0
- package/src/shared/contracts/validation.ts +296 -0
- package/src/shared/errors/facet-error.ts +127 -0
- package/src/shared/errors/store-error.ts +68 -0
- package/src/shared/evidence-image.ts +37 -0
- package/src/shared/export.ts +31 -0
- package/src/shared/html/policy.ts +108 -0
- package/src/shared/html/style-vocabulary.ts +352 -0
- package/src/shared/logging/logger.ts +108 -0
- package/src/shared/logging/redact.ts +49 -0
- package/src/shared/security/frozen-csp.ts +13 -0
- package/src/shared/storage-version.ts +2 -0
- package/src/shared/tsx/execution.ts +29 -0
- package/src/shared/tsx/import-policy.ts +94 -0
- package/src/shared/util/dir-permissions.ts +94 -0
- package/src/shared/util/mermaid-nodes.ts +230 -0
- package/src/shared/util/process.ts +67 -0
- package/src/shared/util/time.ts +21 -0
- package/src/shared/version.ts +3 -0
- package/src/validation/sandbox/limits.ts +41 -0
- package/src/validation/sandbox/netns.ts +177 -0
- package/src/validation/tier0/chart.ts +177 -0
- package/src/validation/tier0/dom-shim.ts +54 -0
- package/src/validation/tier0/html.ts +408 -0
- package/src/validation/tier0/markdown.ts +285 -0
- package/src/validation/tier0/mermaid.ts +98 -0
- package/src/validation/tier0/runner.ts +504 -0
- package/src/validation/tier0/svg.ts +321 -0
- package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
- package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
- package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
- package/src/validation/tier0/tsx/ast-policy.ts +181 -0
- package/src/validation/tier0/tsx/compiler.ts +156 -0
- package/src/validation/tier0/worker-dispatch.ts +211 -0
- package/src/validation/tier0/worker-entry.ts +96 -0
- package/src/validation/tier0/worker-input.ts +75 -0
- package/src/validation/tier1/browser-process.ts +147 -0
- package/src/validation/tier1/cdp-pipe.ts +281 -0
- package/src/validation/tier1/entries/chart.ts +5 -0
- package/src/validation/tier1/entries/html.ts +6 -0
- package/src/validation/tier1/entries/markdown.ts +5 -0
- package/src/validation/tier1/entries/mermaid.ts +5 -0
- package/src/validation/tier1/entries/svg.ts +5 -0
- package/src/validation/tier1/entries/tsx.ts +5 -0
- package/src/validation/tier1/frame-target.ts +162 -0
- package/src/validation/tier1/harness-entry.ts +261 -0
- package/src/validation/tier1/harness.ts +215 -0
- package/src/validation/tier1/isolated-probe.ts +94 -0
- package/src/validation/tier1/launcher.ts +177 -0
- package/src/validation/tier1/limits.ts +80 -0
- package/src/validation/tier1/nonce.ts +17 -0
- package/src/validation/tier1/protocol-probe.ts +519 -0
- package/src/validation/tier1/runner.ts +1122 -0
- package/src/validation/tier1/verdict.ts +246 -0
- package/src/validation/tier1/webp.ts +69 -0
- package/templates/README.md +88 -0
- package/templates/bar-compare.vl.json +63 -0
- package/templates/capacity-report.tsx +102 -0
- package/templates/decision-record.md +24 -0
- package/templates/deployment-state.mmd +40 -0
- package/templates/exemplar.md +91 -0
- package/templates/facet-story.tsx +799 -0
- package/templates/fleet-dashboard.html +141 -0
- package/templates/html-release-ledger.html +91 -0
- package/templates/html-status-report.html +114 -0
- package/templates/incident-console.tsx +147 -0
- package/templates/legion-boundaries.mmd +23 -0
- package/templates/legion-flow.mmd +15 -0
- package/templates/legion-sequence.mmd +14 -0
- package/templates/legion-state.mmd +7 -0
- package/templates/metric-card.svg +29 -0
- package/templates/observability-map.svg +101 -0
- package/templates/pipeline-audit.md +108 -0
- package/templates/release-metrics.vl.json +98 -0
- package/templates/service-topology.mmd +47 -0
- package/templates/status-report.md +32 -0
- package/templates/system-map.svg +53 -0
- package/templates/timeseries.vl.json +71 -0
- package/templates/tsx-interactive-counter.tsx +19 -0
- package/templates/tsx-status-report.tsx +31 -0
|
@@ -0,0 +1,1403 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installGalleryFrameApi
|
|
3
|
+
} from "../chunks/markdown-fvfncadf.js";
|
|
4
|
+
import {
|
|
5
|
+
createRendererRegistry,
|
|
6
|
+
decodeArtifactBytes
|
|
7
|
+
} from "../chunks/markdown-d1wfbs70.js";
|
|
8
|
+
import {
|
|
9
|
+
__require
|
|
10
|
+
} from "../chunks/markdown-809k7q41.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/marked/lib/marked.esm.js
|
|
13
|
+
function C() {
|
|
14
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
15
|
+
}
|
|
16
|
+
var R = C();
|
|
17
|
+
function j(l) {
|
|
18
|
+
R = l;
|
|
19
|
+
}
|
|
20
|
+
var z = { exec: () => null };
|
|
21
|
+
function A(l) {
|
|
22
|
+
let e = [];
|
|
23
|
+
return (t) => {
|
|
24
|
+
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
25
|
+
return s || (s = l(n), e[n] = s), s;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function k(l, e = "") {
|
|
29
|
+
let t = typeof l == "string" ? l : l.source, n = { replace: (s, r) => {
|
|
30
|
+
let i = typeof r == "string" ? r : r.source;
|
|
31
|
+
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
32
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
var Te = ((l = "") => {
|
|
36
|
+
try {
|
|
37
|
+
return !!new RegExp("(?<=1)(?<!1)" + l);
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: A((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: A((l) => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: A((l) => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)), headingBeginRegex: A((l) => new RegExp(`^ {0,${l}}#`)), htmlBeginRegex: A((l) => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: A((l) => new RegExp(`^ {0,${l}}>`)) };
|
|
43
|
+
var Oe = /^(?:[ \t]*(?:\n|$))+/;
|
|
44
|
+
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
45
|
+
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
46
|
+
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
47
|
+
var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
48
|
+
var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
49
|
+
var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
50
|
+
var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
51
|
+
var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
52
|
+
var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
53
|
+
var _e = /^[^\n]+/;
|
|
54
|
+
var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
55
|
+
var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
56
|
+
var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
57
|
+
var Q = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
|
|
58
|
+
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
59
|
+
var Me = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
60
|
+
var le = (l) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", l).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
61
|
+
var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
62
|
+
var Ee = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
63
|
+
var Ce = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ee).getRegex();
|
|
64
|
+
var J = { blockquote: Ce, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Me, lheading: ae, list: Le, newline: Oe, paragraph: ze, table: z, text: _e };
|
|
65
|
+
var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
66
|
+
var Ae = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
|
|
67
|
+
var Ie = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
68
|
+
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
69
|
+
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
70
|
+
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
71
|
+
var pe = /^( {2,}|\\)\n(?!\s*$)/;
|
|
72
|
+
var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
73
|
+
var _ = /[\p{P}\p{S}]/u;
|
|
74
|
+
var I = /[\s\p{P}\p{S}]/u;
|
|
75
|
+
var v = /[^\s\p{P}\p{S}]/u;
|
|
76
|
+
var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, I).getRegex();
|
|
77
|
+
var He = /[\p{Pi}\p{Ps}"']/u;
|
|
78
|
+
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
79
|
+
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
80
|
+
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
81
|
+
var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
82
|
+
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
83
|
+
var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
|
|
84
|
+
var je = k(ce, "u").replace(/punct/g, ue).getRegex();
|
|
85
|
+
var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
86
|
+
var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
|
|
87
|
+
var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
88
|
+
var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
89
|
+
var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, ue).getRegex();
|
|
90
|
+
var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
91
|
+
var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
92
|
+
var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
93
|
+
var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
94
|
+
var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
95
|
+
var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
|
|
96
|
+
var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
97
|
+
var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
98
|
+
var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
99
|
+
var it = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
|
|
100
|
+
var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
|
|
101
|
+
var at = k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
102
|
+
var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
103
|
+
var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
104
|
+
var de = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
105
|
+
var ke = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
106
|
+
var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
|
|
107
|
+
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
108
|
+
var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: pe, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: ke, punctuation: ve, reflink: de, reflinkSearch: pt, tag: at, text: qe, url: z };
|
|
109
|
+
var ut = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
110
|
+
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
|
|
111
|
+
var ct = { ...F, br: k(pe).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
112
|
+
var H = { normal: J, gfm: Ae, pedantic: Ie };
|
|
113
|
+
var B = { normal: V, gfm: F, breaks: ct, pedantic: ut };
|
|
114
|
+
var ht = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
115
|
+
var ge = (l) => ht[l];
|
|
116
|
+
function O(l, e) {
|
|
117
|
+
if (e) {
|
|
118
|
+
if (m.escapeTest.test(l))
|
|
119
|
+
return l.replace(m.escapeReplace, ge);
|
|
120
|
+
} else if (m.escapeTestNoEncode.test(l))
|
|
121
|
+
return l.replace(m.escapeReplaceNoEncode, ge);
|
|
122
|
+
return l;
|
|
123
|
+
}
|
|
124
|
+
function Y(l) {
|
|
125
|
+
try {
|
|
126
|
+
l = encodeURI(l).replace(m.percentDecode, "%");
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return l;
|
|
131
|
+
}
|
|
132
|
+
function ee(l, e) {
|
|
133
|
+
let t = l.replace(m.findPipe, (r, i, o) => {
|
|
134
|
+
let p = false, a = i;
|
|
135
|
+
for (;--a >= 0 && o[a] === "\\"; )
|
|
136
|
+
p = !p;
|
|
137
|
+
return p ? "|" : " |";
|
|
138
|
+
}), n = t.split(m.splitPipe), s = 0;
|
|
139
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
|
|
140
|
+
if (n.length > e)
|
|
141
|
+
n.splice(e);
|
|
142
|
+
else
|
|
143
|
+
for (;n.length < e; )
|
|
144
|
+
n.push("");
|
|
145
|
+
for (;s < n.length; s++)
|
|
146
|
+
n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
147
|
+
return n;
|
|
148
|
+
}
|
|
149
|
+
function $(l, e, t) {
|
|
150
|
+
let n = l.length;
|
|
151
|
+
if (n === 0)
|
|
152
|
+
return "";
|
|
153
|
+
let s = 0;
|
|
154
|
+
for (;s < n; ) {
|
|
155
|
+
let r = l.charAt(n - s - 1);
|
|
156
|
+
if (r === e && !t)
|
|
157
|
+
s++;
|
|
158
|
+
else if (r !== e && t)
|
|
159
|
+
s++;
|
|
160
|
+
else
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return l.slice(0, n - s);
|
|
164
|
+
}
|
|
165
|
+
function te(l) {
|
|
166
|
+
let e = l.split(`
|
|
167
|
+
`), t = e.length - 1;
|
|
168
|
+
for (;t >= 0 && m.blankLine.test(e[t]); )
|
|
169
|
+
t--;
|
|
170
|
+
return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
|
|
171
|
+
`);
|
|
172
|
+
}
|
|
173
|
+
function fe(l, e) {
|
|
174
|
+
if (l.indexOf(e[1]) === -1)
|
|
175
|
+
return -1;
|
|
176
|
+
let t = 0;
|
|
177
|
+
for (let n = 0;n < l.length; n++)
|
|
178
|
+
if (l[n] === "\\")
|
|
179
|
+
n++;
|
|
180
|
+
else if (l[n] === e[0])
|
|
181
|
+
t++;
|
|
182
|
+
else if (l[n] === e[1] && (t--, t < 0))
|
|
183
|
+
return n;
|
|
184
|
+
return t > 0 ? -2 : -1;
|
|
185
|
+
}
|
|
186
|
+
function me(l, e = 0) {
|
|
187
|
+
let t = e, n = "";
|
|
188
|
+
for (let s of l)
|
|
189
|
+
if (s === "\t") {
|
|
190
|
+
let r = 4 - t % 4;
|
|
191
|
+
n += " ".repeat(r), t += r;
|
|
192
|
+
} else
|
|
193
|
+
n += s, t++;
|
|
194
|
+
return n;
|
|
195
|
+
}
|
|
196
|
+
function xe(l, e, t, n, s) {
|
|
197
|
+
let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
|
|
198
|
+
n.state.inLink = true;
|
|
199
|
+
let p = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
200
|
+
return n.state.inLink = false, p;
|
|
201
|
+
}
|
|
202
|
+
function dt(l, e, t) {
|
|
203
|
+
let n = l.match(t.other.indentCodeCompensation);
|
|
204
|
+
if (n === null)
|
|
205
|
+
return e;
|
|
206
|
+
let s = n[1];
|
|
207
|
+
return e.split(`
|
|
208
|
+
`).map((r) => {
|
|
209
|
+
let i = r.match(t.other.beginningSpace);
|
|
210
|
+
if (i === null)
|
|
211
|
+
return r;
|
|
212
|
+
let [o] = i;
|
|
213
|
+
return o.length >= s.length ? r.slice(s.length) : r;
|
|
214
|
+
}).join(`
|
|
215
|
+
`);
|
|
216
|
+
}
|
|
217
|
+
var y = class {
|
|
218
|
+
options;
|
|
219
|
+
rules;
|
|
220
|
+
lexer;
|
|
221
|
+
constructor(e) {
|
|
222
|
+
this.options = e || R;
|
|
223
|
+
}
|
|
224
|
+
space(e) {
|
|
225
|
+
let t = this.rules.block.newline.exec(e);
|
|
226
|
+
if (t && t[0].length > 0)
|
|
227
|
+
return { type: "space", raw: t[0] };
|
|
228
|
+
}
|
|
229
|
+
code(e) {
|
|
230
|
+
let t = this.rules.block.code.exec(e);
|
|
231
|
+
if (t) {
|
|
232
|
+
let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
233
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
fences(e) {
|
|
237
|
+
let t = this.rules.block.fences.exec(e);
|
|
238
|
+
if (t) {
|
|
239
|
+
let n = t[0], s = dt(n, t[3] || "", this.rules);
|
|
240
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
heading(e) {
|
|
244
|
+
let t = this.rules.block.heading.exec(e);
|
|
245
|
+
if (t) {
|
|
246
|
+
let n = t[2].trim();
|
|
247
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
248
|
+
let s = $(n, "#");
|
|
249
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
250
|
+
}
|
|
251
|
+
return { type: "heading", raw: $(t[0], `
|
|
252
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
hr(e) {
|
|
256
|
+
let t = this.rules.block.hr.exec(e);
|
|
257
|
+
if (t)
|
|
258
|
+
return { type: "hr", raw: $(t[0], `
|
|
259
|
+
`) };
|
|
260
|
+
}
|
|
261
|
+
blockquote(e) {
|
|
262
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
263
|
+
if (t) {
|
|
264
|
+
let n = $(t[0], `
|
|
265
|
+
`).split(`
|
|
266
|
+
`), s = "", r = "", i = [];
|
|
267
|
+
for (;n.length > 0; ) {
|
|
268
|
+
let o = false, p = [], a;
|
|
269
|
+
for (a = 0;a < n.length; a++)
|
|
270
|
+
if (this.rules.other.blockquoteStart.test(n[a]))
|
|
271
|
+
p.push(n[a]), o = true;
|
|
272
|
+
else if (!o)
|
|
273
|
+
p.push(n[a]);
|
|
274
|
+
else
|
|
275
|
+
break;
|
|
276
|
+
n = n.slice(a);
|
|
277
|
+
let u = p.join(`
|
|
278
|
+
`), c = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
279
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
280
|
+
s = s ? `${s}
|
|
281
|
+
${u}` : u, r = r ? `${r}
|
|
282
|
+
${c}` : c;
|
|
283
|
+
let h = this.lexer.state.top;
|
|
284
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0)
|
|
285
|
+
break;
|
|
286
|
+
let d = i.at(-1);
|
|
287
|
+
if (d?.type === "code")
|
|
288
|
+
break;
|
|
289
|
+
if (d?.type === "blockquote") {
|
|
290
|
+
let T = d, g = n.join(`
|
|
291
|
+
`), w = T.raw + `
|
|
292
|
+
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), M = this.blockquote(w);
|
|
293
|
+
i[i.length - 1] = M, s = `${s}
|
|
294
|
+
${g}`, r = r.substring(0, r.length - T.text.length) + M.text;
|
|
295
|
+
break;
|
|
296
|
+
} else if (d?.type === "list") {
|
|
297
|
+
let T = d, g = T.raw + `
|
|
298
|
+
` + n.join(`
|
|
299
|
+
`), w = this.list(g);
|
|
300
|
+
i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - T.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
|
|
301
|
+
`);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
list(e) {
|
|
309
|
+
let t = this.rules.block.list.exec(e);
|
|
310
|
+
if (t) {
|
|
311
|
+
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
312
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
313
|
+
let i = this.rules.other.listItemRegex(n), o = false;
|
|
314
|
+
for (;e; ) {
|
|
315
|
+
let a = false, u = "", c = "";
|
|
316
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
|
|
317
|
+
break;
|
|
318
|
+
u = t[0], e = e.substring(u.length);
|
|
319
|
+
let h = me(t[2].split(`
|
|
320
|
+
`, 1)[0], t[1].length), d = e.split(`
|
|
321
|
+
`, 1)[0], T = !h.trim(), g = 0;
|
|
322
|
+
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : T ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), T && this.rules.other.blankLine.test(d) && (u += d + `
|
|
323
|
+
`, e = e.substring(d.length + 1), a = true), !a) {
|
|
324
|
+
let w = this.rules.other.nextBulletRegex(g), M = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
|
|
325
|
+
for (;e; ) {
|
|
326
|
+
let N = e.split(`
|
|
327
|
+
`, 1)[0], D;
|
|
328
|
+
if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || M.test(d))
|
|
329
|
+
break;
|
|
330
|
+
if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim())
|
|
331
|
+
c += `
|
|
332
|
+
` + D.slice(g);
|
|
333
|
+
else {
|
|
334
|
+
if (T || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || M.test(h))
|
|
335
|
+
break;
|
|
336
|
+
c += `
|
|
337
|
+
` + d;
|
|
338
|
+
}
|
|
339
|
+
T = !d.trim(), u += N + `
|
|
340
|
+
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(u) && (o = true)), r.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += u;
|
|
344
|
+
}
|
|
345
|
+
let p = r.items.at(-1);
|
|
346
|
+
if (p)
|
|
347
|
+
p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
|
|
348
|
+
else
|
|
349
|
+
return;
|
|
350
|
+
r.raw = r.raw.trimEnd();
|
|
351
|
+
for (let a of r.items) {
|
|
352
|
+
this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
|
|
353
|
+
let u = a.tokens[0];
|
|
354
|
+
if (a.task && (u?.type === "text" || u?.type === "paragraph")) {
|
|
355
|
+
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), u.raw = u.raw.replace(this.rules.other.listReplaceTask, ""), u.text = u.text.replace(this.rules.other.listReplaceTask, "");
|
|
356
|
+
for (let h = this.lexer.inlineQueue.length - 1;h >= 0; h--)
|
|
357
|
+
if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
|
|
358
|
+
this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
let c = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
362
|
+
if (c) {
|
|
363
|
+
let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
|
|
364
|
+
a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
|
|
365
|
+
}
|
|
366
|
+
} else
|
|
367
|
+
a.task && (a.task = false);
|
|
368
|
+
if (!r.loose) {
|
|
369
|
+
let c = a.tokens.filter((d) => d.type === "space"), h = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw));
|
|
370
|
+
r.loose = h;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (r.loose)
|
|
374
|
+
for (let a of r.items) {
|
|
375
|
+
a.loose = true;
|
|
376
|
+
for (let u of a.tokens)
|
|
377
|
+
u.type === "text" && (u.type = "paragraph");
|
|
378
|
+
}
|
|
379
|
+
return r;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
html(e) {
|
|
383
|
+
let t = this.rules.block.html.exec(e);
|
|
384
|
+
if (t) {
|
|
385
|
+
let n = te(t[0]);
|
|
386
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
def(e) {
|
|
390
|
+
let t = this.rules.block.def.exec(e);
|
|
391
|
+
if (t) {
|
|
392
|
+
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
393
|
+
return { type: "def", tag: n, raw: $(t[0], `
|
|
394
|
+
`), href: s, title: r };
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
table(e) {
|
|
398
|
+
let t = this.rules.block.table.exec(e);
|
|
399
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
|
|
400
|
+
return;
|
|
401
|
+
let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
402
|
+
`) : [], i = { type: "table", raw: $(t[0], `
|
|
403
|
+
`), header: [], align: [], rows: [] };
|
|
404
|
+
if (n.length === s.length) {
|
|
405
|
+
for (let o of s)
|
|
406
|
+
this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
|
|
407
|
+
for (let o = 0;o < n.length; o++)
|
|
408
|
+
i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
409
|
+
for (let o of r)
|
|
410
|
+
i.rows.push(ee(o, i.header.length).map((p, a) => ({ text: p, tokens: this.lexer.inline(p), header: false, align: i.align[a] })));
|
|
411
|
+
return i;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
lheading(e) {
|
|
415
|
+
let t = this.rules.block.lheading.exec(e);
|
|
416
|
+
if (t) {
|
|
417
|
+
let n = t[1].trim();
|
|
418
|
+
return { type: "heading", raw: $(t[0], `
|
|
419
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
paragraph(e) {
|
|
423
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
424
|
+
if (t) {
|
|
425
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
426
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
427
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
text(e) {
|
|
431
|
+
let t = this.rules.block.text.exec(e);
|
|
432
|
+
if (t)
|
|
433
|
+
return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
434
|
+
}
|
|
435
|
+
escape(e) {
|
|
436
|
+
let t = this.rules.inline.escape.exec(e);
|
|
437
|
+
if (t)
|
|
438
|
+
return { type: "escape", raw: t[0], text: t[1] };
|
|
439
|
+
}
|
|
440
|
+
tag(e) {
|
|
441
|
+
let t = this.rules.inline.tag.exec(e);
|
|
442
|
+
if (t)
|
|
443
|
+
return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
444
|
+
}
|
|
445
|
+
link(e) {
|
|
446
|
+
let t = this.rules.inline.link.exec(e);
|
|
447
|
+
if (t) {
|
|
448
|
+
let n = t[2].trim();
|
|
449
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
450
|
+
if (!this.rules.other.endAngleBracket.test(n))
|
|
451
|
+
return;
|
|
452
|
+
let i = $(n.slice(0, -1), "\\");
|
|
453
|
+
if ((n.length - i.length) % 2 === 0)
|
|
454
|
+
return;
|
|
455
|
+
} else {
|
|
456
|
+
let i = fe(t[2], "()");
|
|
457
|
+
if (i === -2)
|
|
458
|
+
return;
|
|
459
|
+
if (i > -1) {
|
|
460
|
+
let p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
461
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, p).trim(), t[3] = "";
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
let s = t[2], r = "";
|
|
465
|
+
if (this.options.pedantic) {
|
|
466
|
+
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
467
|
+
i && (s = i[1], r = i[3]);
|
|
468
|
+
} else
|
|
469
|
+
r = t[3] ? t[3].slice(1, -1) : "";
|
|
470
|
+
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
reflink(e, t) {
|
|
474
|
+
let n;
|
|
475
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
476
|
+
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
477
|
+
if (!r) {
|
|
478
|
+
let i = n[0].charAt(0);
|
|
479
|
+
return { type: "text", raw: i, text: i };
|
|
480
|
+
}
|
|
481
|
+
return xe(n, r, n[0], this.lexer, this.rules);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
emStrong(e, t, n = "") {
|
|
485
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
486
|
+
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
487
|
+
return;
|
|
488
|
+
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
489
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
490
|
+
for (d.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = d.exec(t)) !== null; ) {
|
|
491
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o)
|
|
492
|
+
continue;
|
|
493
|
+
if (p = [...o].length, s[3] || s[4]) {
|
|
494
|
+
a += p;
|
|
495
|
+
continue;
|
|
496
|
+
} else if (s[5] || s[6]) {
|
|
497
|
+
if (i % 3 && !((i + p) % 3)) {
|
|
498
|
+
u += p;
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
if (h)
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
if (a -= p, a > 0)
|
|
505
|
+
continue;
|
|
506
|
+
p = Math.min(p, p + a + u);
|
|
507
|
+
let T = [...s[0]][0].length, g = e.slice(0, i + s.index + T + p);
|
|
508
|
+
if (Math.min(i, p) % 2) {
|
|
509
|
+
let M = g.slice(1, -1);
|
|
510
|
+
return { type: "em", raw: g, text: M, tokens: this.lexer.inlineTokens(M) };
|
|
511
|
+
}
|
|
512
|
+
let w = g.slice(2, -2);
|
|
513
|
+
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
codespan(e) {
|
|
518
|
+
let t = this.rules.inline.code.exec(e);
|
|
519
|
+
if (t) {
|
|
520
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
521
|
+
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
br(e) {
|
|
525
|
+
let t = this.rules.inline.br.exec(e);
|
|
526
|
+
if (t)
|
|
527
|
+
return { type: "br", raw: t[0] };
|
|
528
|
+
}
|
|
529
|
+
del(e, t, n = "") {
|
|
530
|
+
let s = this.rules.inline.delLDelim.exec(e);
|
|
531
|
+
if (!s)
|
|
532
|
+
return;
|
|
533
|
+
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
534
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = this.rules.inline.delRDelim;
|
|
535
|
+
for (u.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = u.exec(t)) !== null; ) {
|
|
536
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (p = [...o].length, p !== i))
|
|
537
|
+
continue;
|
|
538
|
+
if (s[3] || s[4]) {
|
|
539
|
+
a += p;
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (a -= p, a > 0)
|
|
543
|
+
continue;
|
|
544
|
+
p = Math.min(p, p + a);
|
|
545
|
+
let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + p), d = h.slice(i, -i);
|
|
546
|
+
return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
autolink(e) {
|
|
551
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
552
|
+
if (t) {
|
|
553
|
+
let n, s;
|
|
554
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
url(e) {
|
|
558
|
+
let t;
|
|
559
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
560
|
+
let n, s;
|
|
561
|
+
if (t[2] === "@")
|
|
562
|
+
n = t[0], s = "mailto:" + n;
|
|
563
|
+
else {
|
|
564
|
+
let r;
|
|
565
|
+
do
|
|
566
|
+
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
567
|
+
while (r !== t[0]);
|
|
568
|
+
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
569
|
+
}
|
|
570
|
+
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
inlineText(e) {
|
|
574
|
+
let t = this.rules.inline.text.exec(e);
|
|
575
|
+
if (t) {
|
|
576
|
+
let n = this.lexer.state.inRawBlock;
|
|
577
|
+
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
var x = class l {
|
|
582
|
+
tokens;
|
|
583
|
+
options;
|
|
584
|
+
state;
|
|
585
|
+
inlineQueue;
|
|
586
|
+
tokenizer;
|
|
587
|
+
constructor(e) {
|
|
588
|
+
this.tokens = [], this.tokens.links = Object.create(null), this.options = e || R, this.options.tokenizer = this.options.tokenizer || new y, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
|
|
589
|
+
let t = { other: m, block: H.normal, inline: B.normal };
|
|
590
|
+
this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
|
|
591
|
+
}
|
|
592
|
+
static get rules() {
|
|
593
|
+
return { block: H, inline: B };
|
|
594
|
+
}
|
|
595
|
+
static lex(e, t) {
|
|
596
|
+
return new l(t).lex(e);
|
|
597
|
+
}
|
|
598
|
+
static lexInline(e, t) {
|
|
599
|
+
return new l(t).inlineTokens(e);
|
|
600
|
+
}
|
|
601
|
+
lex(e) {
|
|
602
|
+
e = e.replace(m.carriageReturn, `
|
|
603
|
+
`), this.blockTokens(e, this.tokens);
|
|
604
|
+
for (let t = 0;t < this.inlineQueue.length; t++) {
|
|
605
|
+
let n = this.inlineQueue[t];
|
|
606
|
+
this.inlineTokens(n.src, n.tokens);
|
|
607
|
+
}
|
|
608
|
+
return this.inlineQueue = [], this.tokens;
|
|
609
|
+
}
|
|
610
|
+
blockTokens(e, t = [], n = false) {
|
|
611
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
612
|
+
let s = 1 / 0;
|
|
613
|
+
for (;e; ) {
|
|
614
|
+
if (e.length < s)
|
|
615
|
+
s = e.length;
|
|
616
|
+
else {
|
|
617
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
let r;
|
|
621
|
+
if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
|
|
622
|
+
continue;
|
|
623
|
+
if (r = this.tokenizer.space(e)) {
|
|
624
|
+
e = e.substring(r.raw.length);
|
|
625
|
+
let o = t.at(-1);
|
|
626
|
+
r.raw.length === 1 && o !== undefined ? o.raw += `
|
|
627
|
+
` : t.push(r);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (r = this.tokenizer.code(e)) {
|
|
631
|
+
e = e.substring(r.raw.length);
|
|
632
|
+
let o = t.at(-1);
|
|
633
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
634
|
+
`) ? "" : `
|
|
635
|
+
`) + r.raw, o.text += `
|
|
636
|
+
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
if (r = this.tokenizer.fences(e)) {
|
|
640
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
if (r = this.tokenizer.heading(e)) {
|
|
644
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
if (r = this.tokenizer.hr(e)) {
|
|
648
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
652
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (r = this.tokenizer.list(e)) {
|
|
656
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (r = this.tokenizer.html(e)) {
|
|
660
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (r = this.tokenizer.def(e)) {
|
|
664
|
+
e = e.substring(r.raw.length);
|
|
665
|
+
let o = t.at(-1);
|
|
666
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
667
|
+
`) ? "" : `
|
|
668
|
+
`) + r.raw, o.text += `
|
|
669
|
+
` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
if (r = this.tokenizer.table(e)) {
|
|
673
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
677
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
let i = e;
|
|
681
|
+
if (this.options.extensions?.startBlock) {
|
|
682
|
+
let o = 1 / 0, p = e.slice(1), a;
|
|
683
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
684
|
+
a = u.call({ lexer: this }, p), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
685
|
+
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
686
|
+
}
|
|
687
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
688
|
+
let o = t.at(-1);
|
|
689
|
+
n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
690
|
+
`) ? "" : `
|
|
691
|
+
`) + r.raw, o.text += `
|
|
692
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
if (r = this.tokenizer.text(e)) {
|
|
696
|
+
e = e.substring(r.raw.length);
|
|
697
|
+
let o = t.at(-1);
|
|
698
|
+
o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
699
|
+
`) ? "" : `
|
|
700
|
+
`) + r.raw, o.text += `
|
|
701
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (e) {
|
|
705
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return this.state.top = true, t;
|
|
710
|
+
}
|
|
711
|
+
inline(e, t = []) {
|
|
712
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
713
|
+
}
|
|
714
|
+
inlineTokens(e, t = []) {
|
|
715
|
+
this.tokenizer.lexer = this;
|
|
716
|
+
let n = e;
|
|
717
|
+
if (this.tokens.links) {
|
|
718
|
+
let o = Object.keys(this.tokens.links);
|
|
719
|
+
o.length > 0 && (n = n.replace(this.tokenizer.rules.inline.reflinkSearch, (p) => o.includes(p.slice(p.lastIndexOf("[") + 1, -1)) ? "[" + "a".repeat(p.length - 2) + "]" : p));
|
|
720
|
+
}
|
|
721
|
+
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, "++"), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, p, a) => {
|
|
722
|
+
let u = a ? a.length : 0;
|
|
723
|
+
return o.slice(0, u) + "[" + "a".repeat(o.length - u - 2) + "]";
|
|
724
|
+
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
725
|
+
let s = false, r = "", i = 1 / 0;
|
|
726
|
+
for (;e; ) {
|
|
727
|
+
if (e.length < i)
|
|
728
|
+
i = e.length;
|
|
729
|
+
else {
|
|
730
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
s || (r = ""), s = false;
|
|
734
|
+
let o;
|
|
735
|
+
if (this.options.extensions?.inline?.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false))
|
|
736
|
+
continue;
|
|
737
|
+
if (o = this.tokenizer.escape(e)) {
|
|
738
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (o = this.tokenizer.tag(e)) {
|
|
742
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
if (o = this.tokenizer.link(e)) {
|
|
746
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
750
|
+
e = e.substring(o.raw.length);
|
|
751
|
+
let a = t.at(-1);
|
|
752
|
+
o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
756
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
757
|
+
continue;
|
|
758
|
+
}
|
|
759
|
+
if (o = this.tokenizer.codespan(e)) {
|
|
760
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
if (o = this.tokenizer.br(e)) {
|
|
764
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
if (o = this.tokenizer.del(e, n, r)) {
|
|
768
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
if (o = this.tokenizer.autolink(e)) {
|
|
772
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
776
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
779
|
+
let p = e;
|
|
780
|
+
if (this.options.extensions?.startInline) {
|
|
781
|
+
let a = 1 / 0, u = e.slice(1), c;
|
|
782
|
+
this.options.extensions.startInline.forEach((h) => {
|
|
783
|
+
c = h.call({ lexer: this }, u), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
784
|
+
}), a < 1 / 0 && a >= 0 && (p = e.substring(0, a + 1));
|
|
785
|
+
}
|
|
786
|
+
if (o = this.tokenizer.inlineText(p)) {
|
|
787
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
|
|
788
|
+
let a = t.at(-1);
|
|
789
|
+
a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (e) {
|
|
793
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return t;
|
|
798
|
+
}
|
|
799
|
+
infiniteLoopError(e) {
|
|
800
|
+
let t = "Infinite loop on byte: " + e;
|
|
801
|
+
if (this.options.silent)
|
|
802
|
+
console.error(t);
|
|
803
|
+
else
|
|
804
|
+
throw new Error(t);
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
var P = class {
|
|
808
|
+
options;
|
|
809
|
+
parser;
|
|
810
|
+
constructor(e) {
|
|
811
|
+
this.options = e || R;
|
|
812
|
+
}
|
|
813
|
+
space(e) {
|
|
814
|
+
return "";
|
|
815
|
+
}
|
|
816
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
817
|
+
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
818
|
+
`;
|
|
819
|
+
return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
|
|
820
|
+
` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
|
|
821
|
+
`;
|
|
822
|
+
}
|
|
823
|
+
blockquote({ tokens: e }) {
|
|
824
|
+
return `<blockquote>
|
|
825
|
+
${this.parser.parse(e)}</blockquote>
|
|
826
|
+
`;
|
|
827
|
+
}
|
|
828
|
+
html({ text: e }) {
|
|
829
|
+
return e;
|
|
830
|
+
}
|
|
831
|
+
def(e) {
|
|
832
|
+
return "";
|
|
833
|
+
}
|
|
834
|
+
heading({ tokens: e, depth: t }) {
|
|
835
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
836
|
+
`;
|
|
837
|
+
}
|
|
838
|
+
hr(e) {
|
|
839
|
+
return `<hr>
|
|
840
|
+
`;
|
|
841
|
+
}
|
|
842
|
+
list(e) {
|
|
843
|
+
let { ordered: t, start: n } = e, s = "";
|
|
844
|
+
for (let o = 0;o < e.items.length; o++) {
|
|
845
|
+
let p = e.items[o];
|
|
846
|
+
s += this.listitem(p);
|
|
847
|
+
}
|
|
848
|
+
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
849
|
+
return "<" + r + i + `>
|
|
850
|
+
` + s + "</" + r + `>
|
|
851
|
+
`;
|
|
852
|
+
}
|
|
853
|
+
listitem(e) {
|
|
854
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
855
|
+
`;
|
|
856
|
+
}
|
|
857
|
+
checkbox({ checked: e }) {
|
|
858
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
859
|
+
}
|
|
860
|
+
paragraph({ tokens: e }) {
|
|
861
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
862
|
+
`;
|
|
863
|
+
}
|
|
864
|
+
table(e) {
|
|
865
|
+
let t = "", n = "";
|
|
866
|
+
for (let r = 0;r < e.header.length; r++)
|
|
867
|
+
n += this.tablecell(e.header[r]);
|
|
868
|
+
t += this.tablerow({ text: n });
|
|
869
|
+
let s = "";
|
|
870
|
+
for (let r = 0;r < e.rows.length; r++) {
|
|
871
|
+
let i = e.rows[r];
|
|
872
|
+
n = "";
|
|
873
|
+
for (let o = 0;o < i.length; o++)
|
|
874
|
+
n += this.tablecell(i[o]);
|
|
875
|
+
s += this.tablerow({ text: n });
|
|
876
|
+
}
|
|
877
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
878
|
+
<thead>
|
|
879
|
+
` + t + `</thead>
|
|
880
|
+
` + s + `</table>
|
|
881
|
+
`;
|
|
882
|
+
}
|
|
883
|
+
tablerow({ text: e }) {
|
|
884
|
+
return `<tr>
|
|
885
|
+
${e}</tr>
|
|
886
|
+
`;
|
|
887
|
+
}
|
|
888
|
+
tablecell(e) {
|
|
889
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
890
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
891
|
+
`;
|
|
892
|
+
}
|
|
893
|
+
strong({ tokens: e }) {
|
|
894
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
895
|
+
}
|
|
896
|
+
em({ tokens: e }) {
|
|
897
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
898
|
+
}
|
|
899
|
+
codespan({ text: e }) {
|
|
900
|
+
return `<code>${O(e, true)}</code>`;
|
|
901
|
+
}
|
|
902
|
+
br(e) {
|
|
903
|
+
return "<br>";
|
|
904
|
+
}
|
|
905
|
+
del({ tokens: e }) {
|
|
906
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
907
|
+
}
|
|
908
|
+
link({ href: e, title: t, tokens: n }) {
|
|
909
|
+
let s = this.parser.parseInline(n), r = Y(e);
|
|
910
|
+
if (r === null)
|
|
911
|
+
return s;
|
|
912
|
+
e = r;
|
|
913
|
+
let i = '<a href="' + e + '"';
|
|
914
|
+
return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
|
|
915
|
+
}
|
|
916
|
+
image({ href: e, title: t, text: n, tokens: s }) {
|
|
917
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
918
|
+
let r = Y(e);
|
|
919
|
+
if (r === null)
|
|
920
|
+
return O(n);
|
|
921
|
+
e = r;
|
|
922
|
+
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
923
|
+
return t && (i += ` title="${O(t)}"`), i += ">", i;
|
|
924
|
+
}
|
|
925
|
+
text(e) {
|
|
926
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : O(e.text);
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
var L = class {
|
|
930
|
+
strong({ text: e }) {
|
|
931
|
+
return e;
|
|
932
|
+
}
|
|
933
|
+
em({ text: e }) {
|
|
934
|
+
return e;
|
|
935
|
+
}
|
|
936
|
+
codespan({ text: e }) {
|
|
937
|
+
return e;
|
|
938
|
+
}
|
|
939
|
+
del({ text: e }) {
|
|
940
|
+
return e;
|
|
941
|
+
}
|
|
942
|
+
html({ text: e }) {
|
|
943
|
+
return e;
|
|
944
|
+
}
|
|
945
|
+
text({ text: e }) {
|
|
946
|
+
return e;
|
|
947
|
+
}
|
|
948
|
+
link({ text: e }) {
|
|
949
|
+
return "" + e;
|
|
950
|
+
}
|
|
951
|
+
image({ text: e }) {
|
|
952
|
+
return "" + e;
|
|
953
|
+
}
|
|
954
|
+
br() {
|
|
955
|
+
return "";
|
|
956
|
+
}
|
|
957
|
+
checkbox({ raw: e }) {
|
|
958
|
+
return e;
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
var b = class l2 {
|
|
962
|
+
options;
|
|
963
|
+
renderer;
|
|
964
|
+
textRenderer;
|
|
965
|
+
constructor(e) {
|
|
966
|
+
this.options = e || R, this.options.renderer = this.options.renderer || new P, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L;
|
|
967
|
+
}
|
|
968
|
+
static parse(e, t) {
|
|
969
|
+
return new l2(t).parse(e);
|
|
970
|
+
}
|
|
971
|
+
static parseInline(e, t) {
|
|
972
|
+
return new l2(t).parseInline(e);
|
|
973
|
+
}
|
|
974
|
+
parse(e) {
|
|
975
|
+
this.renderer.parser = this;
|
|
976
|
+
let t = "";
|
|
977
|
+
for (let n = 0;n < e.length; n++) {
|
|
978
|
+
let s = e[n];
|
|
979
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
980
|
+
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
981
|
+
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
982
|
+
t += o || "";
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
let r = s;
|
|
987
|
+
switch (r.type) {
|
|
988
|
+
case "space": {
|
|
989
|
+
t += this.renderer.space(r);
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
case "hr": {
|
|
993
|
+
t += this.renderer.hr(r);
|
|
994
|
+
break;
|
|
995
|
+
}
|
|
996
|
+
case "heading": {
|
|
997
|
+
t += this.renderer.heading(r);
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
case "code": {
|
|
1001
|
+
t += this.renderer.code(r);
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
case "table": {
|
|
1005
|
+
t += this.renderer.table(r);
|
|
1006
|
+
break;
|
|
1007
|
+
}
|
|
1008
|
+
case "blockquote": {
|
|
1009
|
+
t += this.renderer.blockquote(r);
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
case "list": {
|
|
1013
|
+
t += this.renderer.list(r);
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
case "checkbox": {
|
|
1017
|
+
t += this.renderer.checkbox(r);
|
|
1018
|
+
break;
|
|
1019
|
+
}
|
|
1020
|
+
case "html": {
|
|
1021
|
+
t += this.renderer.html(r);
|
|
1022
|
+
break;
|
|
1023
|
+
}
|
|
1024
|
+
case "def": {
|
|
1025
|
+
t += this.renderer.def(r);
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
case "paragraph": {
|
|
1029
|
+
t += this.renderer.paragraph(r);
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
case "text": {
|
|
1033
|
+
t += this.renderer.text(r);
|
|
1034
|
+
break;
|
|
1035
|
+
}
|
|
1036
|
+
default: {
|
|
1037
|
+
let i = 'Token with "' + r.type + '" type was not found.';
|
|
1038
|
+
if (this.options.silent)
|
|
1039
|
+
return console.error(i), "";
|
|
1040
|
+
throw new Error(i);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return t;
|
|
1045
|
+
}
|
|
1046
|
+
parseInline(e, t = this.renderer) {
|
|
1047
|
+
this.renderer.parser = this;
|
|
1048
|
+
let n = "";
|
|
1049
|
+
for (let s = 0;s < e.length; s++) {
|
|
1050
|
+
let r = e[s];
|
|
1051
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
1052
|
+
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
1053
|
+
if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
1054
|
+
n += o || "";
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
let i = r;
|
|
1059
|
+
switch (i.type) {
|
|
1060
|
+
case "escape": {
|
|
1061
|
+
n += t.text(i);
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
case "html": {
|
|
1065
|
+
n += t.html(i);
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
case "link": {
|
|
1069
|
+
n += t.link(i);
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
case "image": {
|
|
1073
|
+
n += t.image(i);
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
case "checkbox": {
|
|
1077
|
+
n += t.checkbox(i);
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
case "strong": {
|
|
1081
|
+
n += t.strong(i);
|
|
1082
|
+
break;
|
|
1083
|
+
}
|
|
1084
|
+
case "em": {
|
|
1085
|
+
n += t.em(i);
|
|
1086
|
+
break;
|
|
1087
|
+
}
|
|
1088
|
+
case "codespan": {
|
|
1089
|
+
n += t.codespan(i);
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
case "br": {
|
|
1093
|
+
n += t.br(i);
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
case "del": {
|
|
1097
|
+
n += t.del(i);
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1100
|
+
case "text": {
|
|
1101
|
+
n += t.text(i);
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
default: {
|
|
1105
|
+
let o = 'Token with "' + i.type + '" type was not found.';
|
|
1106
|
+
if (this.options.silent)
|
|
1107
|
+
return console.error(o), "";
|
|
1108
|
+
throw new Error(o);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return n;
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var S = class {
|
|
1116
|
+
options;
|
|
1117
|
+
block;
|
|
1118
|
+
constructor(e) {
|
|
1119
|
+
this.options = e || R;
|
|
1120
|
+
}
|
|
1121
|
+
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
1122
|
+
static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
1123
|
+
preprocess(e) {
|
|
1124
|
+
return e;
|
|
1125
|
+
}
|
|
1126
|
+
postprocess(e) {
|
|
1127
|
+
return e;
|
|
1128
|
+
}
|
|
1129
|
+
processAllTokens(e) {
|
|
1130
|
+
return e;
|
|
1131
|
+
}
|
|
1132
|
+
emStrongMask(e) {
|
|
1133
|
+
return e;
|
|
1134
|
+
}
|
|
1135
|
+
provideLexer(e = this.block) {
|
|
1136
|
+
return e ? x.lex : x.lexInline;
|
|
1137
|
+
}
|
|
1138
|
+
provideParser(e = this.block) {
|
|
1139
|
+
return e ? b.parse : b.parseInline;
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
var Z = class {
|
|
1143
|
+
defaults = C();
|
|
1144
|
+
options = this.setOptions;
|
|
1145
|
+
parse = this.parseMarkdown(true);
|
|
1146
|
+
parseInline = this.parseMarkdown(false);
|
|
1147
|
+
Parser = b;
|
|
1148
|
+
Renderer = P;
|
|
1149
|
+
TextRenderer = L;
|
|
1150
|
+
Lexer = x;
|
|
1151
|
+
Tokenizer = y;
|
|
1152
|
+
Hooks = S;
|
|
1153
|
+
constructor(...e) {
|
|
1154
|
+
this.use(...e);
|
|
1155
|
+
}
|
|
1156
|
+
walkTokens(e, t) {
|
|
1157
|
+
let n = [];
|
|
1158
|
+
for (let s of e)
|
|
1159
|
+
switch (n = n.concat(t.call(this, s)), s.type) {
|
|
1160
|
+
case "table": {
|
|
1161
|
+
let r = s;
|
|
1162
|
+
for (let i of r.header)
|
|
1163
|
+
n = n.concat(this.walkTokens(i.tokens, t));
|
|
1164
|
+
for (let i of r.rows)
|
|
1165
|
+
for (let o of i)
|
|
1166
|
+
n = n.concat(this.walkTokens(o.tokens, t));
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
case "list": {
|
|
1170
|
+
let r = s;
|
|
1171
|
+
n = n.concat(this.walkTokens(r.items, t));
|
|
1172
|
+
break;
|
|
1173
|
+
}
|
|
1174
|
+
default: {
|
|
1175
|
+
let r = s;
|
|
1176
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
1177
|
+
let o = r[i].flat(1 / 0);
|
|
1178
|
+
n = n.concat(this.walkTokens(o, t));
|
|
1179
|
+
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return n;
|
|
1183
|
+
}
|
|
1184
|
+
use(...e) {
|
|
1185
|
+
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1186
|
+
return e.forEach((n) => {
|
|
1187
|
+
let s = { ...n };
|
|
1188
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
1189
|
+
if (!r.name)
|
|
1190
|
+
throw new Error("extension name required");
|
|
1191
|
+
if ("renderer" in r) {
|
|
1192
|
+
let i = t.renderers[r.name];
|
|
1193
|
+
i ? t.renderers[r.name] = function(...o) {
|
|
1194
|
+
let p = r.renderer.apply(this, o);
|
|
1195
|
+
return p === false && (p = i.apply(this, o)), p;
|
|
1196
|
+
} : t.renderers[r.name] = r.renderer;
|
|
1197
|
+
}
|
|
1198
|
+
if ("tokenizer" in r) {
|
|
1199
|
+
if (!r.level || r.level !== "block" && r.level !== "inline")
|
|
1200
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
1201
|
+
let i = t[r.level];
|
|
1202
|
+
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
1203
|
+
}
|
|
1204
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
1205
|
+
}), s.extensions = t), n.renderer) {
|
|
1206
|
+
let r = this.defaults.renderer || new P(this.defaults);
|
|
1207
|
+
for (let i in n.renderer) {
|
|
1208
|
+
if (!(i in r))
|
|
1209
|
+
throw new Error(`renderer '${i}' does not exist`);
|
|
1210
|
+
if (["options", "parser"].includes(i))
|
|
1211
|
+
continue;
|
|
1212
|
+
let o = i, p = n.renderer[o], a = r[o];
|
|
1213
|
+
r[o] = (...u) => {
|
|
1214
|
+
let c = p.apply(r, u);
|
|
1215
|
+
return c === false && (c = a.apply(r, u)), c || "";
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
s.renderer = r;
|
|
1219
|
+
}
|
|
1220
|
+
if (n.tokenizer) {
|
|
1221
|
+
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
1222
|
+
for (let i in n.tokenizer) {
|
|
1223
|
+
if (!(i in r))
|
|
1224
|
+
throw new Error(`tokenizer '${i}' does not exist`);
|
|
1225
|
+
if (["options", "rules", "lexer"].includes(i))
|
|
1226
|
+
continue;
|
|
1227
|
+
let o = i, p = n.tokenizer[o], a = r[o];
|
|
1228
|
+
r[o] = (...u) => {
|
|
1229
|
+
let c = p.apply(r, u);
|
|
1230
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
s.tokenizer = r;
|
|
1234
|
+
}
|
|
1235
|
+
if (n.hooks) {
|
|
1236
|
+
let r = this.defaults.hooks || new S;
|
|
1237
|
+
for (let i in n.hooks) {
|
|
1238
|
+
if (!(i in r))
|
|
1239
|
+
throw new Error(`hook '${i}' does not exist`);
|
|
1240
|
+
if (["options", "block"].includes(i))
|
|
1241
|
+
continue;
|
|
1242
|
+
let o = i, p = n.hooks[o], a = r[o];
|
|
1243
|
+
S.passThroughHooks.has(i) ? r[o] = (u) => {
|
|
1244
|
+
if (this.defaults.async && S.passThroughHooksRespectAsync.has(i))
|
|
1245
|
+
return (async () => {
|
|
1246
|
+
let h = await p.call(r, u);
|
|
1247
|
+
return a.call(r, h);
|
|
1248
|
+
})();
|
|
1249
|
+
let c = p.call(r, u);
|
|
1250
|
+
return a.call(r, c);
|
|
1251
|
+
} : r[o] = (...u) => {
|
|
1252
|
+
if (this.defaults.async)
|
|
1253
|
+
return (async () => {
|
|
1254
|
+
let h = await p.apply(r, u);
|
|
1255
|
+
return h === false && (h = await a.apply(r, u)), h;
|
|
1256
|
+
})();
|
|
1257
|
+
let c = p.apply(r, u);
|
|
1258
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
s.hooks = r;
|
|
1262
|
+
}
|
|
1263
|
+
if (n.walkTokens) {
|
|
1264
|
+
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
1265
|
+
s.walkTokens = function(o) {
|
|
1266
|
+
let p = [];
|
|
1267
|
+
return p.push(i.call(this, o)), r && (p = p.concat(r.call(this, o))), p;
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
this.defaults = { ...this.defaults, ...s };
|
|
1271
|
+
}), this;
|
|
1272
|
+
}
|
|
1273
|
+
setOptions(e) {
|
|
1274
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
1275
|
+
}
|
|
1276
|
+
lexer(e, t) {
|
|
1277
|
+
return x.lex(e, t ?? this.defaults);
|
|
1278
|
+
}
|
|
1279
|
+
parser(e, t) {
|
|
1280
|
+
return b.parse(e, t ?? this.defaults);
|
|
1281
|
+
}
|
|
1282
|
+
parseMarkdown(e) {
|
|
1283
|
+
return (n, s) => {
|
|
1284
|
+
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
1285
|
+
if (this.defaults.async === true && r.async === false)
|
|
1286
|
+
return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
|
|
1287
|
+
if (typeof n > "u" || n === null)
|
|
1288
|
+
return o(new Error("marked(): input parameter is undefined or null"));
|
|
1289
|
+
if (typeof n != "string")
|
|
1290
|
+
return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
1291
|
+
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async)
|
|
1292
|
+
return (async () => {
|
|
1293
|
+
let p = i.hooks ? await i.hooks.preprocess(n) : n, u = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(p, i), c = i.hooks ? await i.hooks.processAllTokens(u) : u;
|
|
1294
|
+
i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
|
|
1295
|
+
let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
|
|
1296
|
+
return i.hooks ? await i.hooks.postprocess(d) : d;
|
|
1297
|
+
})().catch(o);
|
|
1298
|
+
try {
|
|
1299
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
1300
|
+
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
1301
|
+
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
1302
|
+
let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
1303
|
+
return i.hooks && (c = i.hooks.postprocess(c)), c;
|
|
1304
|
+
} catch (p) {
|
|
1305
|
+
return o(p);
|
|
1306
|
+
}
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
onError(e, t) {
|
|
1310
|
+
return (n) => {
|
|
1311
|
+
if (n.message += `
|
|
1312
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
1313
|
+
let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
1314
|
+
return t ? Promise.resolve(s) : s;
|
|
1315
|
+
}
|
|
1316
|
+
if (t)
|
|
1317
|
+
return Promise.reject(n);
|
|
1318
|
+
throw n;
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
var E = new Z;
|
|
1323
|
+
function f(l3, e) {
|
|
1324
|
+
return E.parse(l3, e);
|
|
1325
|
+
}
|
|
1326
|
+
f.options = f.setOptions = function(l3) {
|
|
1327
|
+
return E.setOptions(l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
1328
|
+
};
|
|
1329
|
+
f.getDefaults = C;
|
|
1330
|
+
f.defaults = R;
|
|
1331
|
+
function kt(...l3) {
|
|
1332
|
+
return E.use(...l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
1333
|
+
}
|
|
1334
|
+
f.use = kt;
|
|
1335
|
+
f.walkTokens = function(l3, e) {
|
|
1336
|
+
return E.walkTokens(l3, e);
|
|
1337
|
+
};
|
|
1338
|
+
f.parseInline = E.parseInline;
|
|
1339
|
+
f.Parser = b;
|
|
1340
|
+
f.parser = b.parse;
|
|
1341
|
+
f.Renderer = P;
|
|
1342
|
+
f.TextRenderer = L;
|
|
1343
|
+
f.Lexer = x;
|
|
1344
|
+
f.lexer = x.lex;
|
|
1345
|
+
f.Tokenizer = y;
|
|
1346
|
+
f.Hooks = S;
|
|
1347
|
+
f.parse = f;
|
|
1348
|
+
var nn = f.options;
|
|
1349
|
+
var rn = f.setOptions;
|
|
1350
|
+
var sn = f.walkTokens;
|
|
1351
|
+
var on = f.parseInline;
|
|
1352
|
+
var ln = b.parse;
|
|
1353
|
+
var pn = x.lex;
|
|
1354
|
+
|
|
1355
|
+
// src/gallery-web/frame/renderers/markdown.ts
|
|
1356
|
+
var ESCAPES = new Map([
|
|
1357
|
+
["&", "&"],
|
|
1358
|
+
["<", "<"],
|
|
1359
|
+
[">", ">"],
|
|
1360
|
+
['"', """],
|
|
1361
|
+
["'", "'"]
|
|
1362
|
+
]);
|
|
1363
|
+
function escapeHtml(text) {
|
|
1364
|
+
return text.replace(/[&<>"']/g, (char) => ESCAPES.get(char) ?? char);
|
|
1365
|
+
}
|
|
1366
|
+
var marked = new Z({
|
|
1367
|
+
gfm: true,
|
|
1368
|
+
renderer: {
|
|
1369
|
+
html(token) {
|
|
1370
|
+
return escapeHtml(token.text);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
async function markdownToSanitizedHtml(text) {
|
|
1375
|
+
return await Promise.resolve(marked.parse(text));
|
|
1376
|
+
}
|
|
1377
|
+
async function renderMarkdown(ctx, bytes) {
|
|
1378
|
+
const text = decodeArtifactBytes(bytes);
|
|
1379
|
+
const html = await markdownToSanitizedHtml(text);
|
|
1380
|
+
const template = document.createElement("template");
|
|
1381
|
+
template.innerHTML = html;
|
|
1382
|
+
const mermaidBlocks = Array.from(template.content.querySelectorAll("pre > code.language-mermaid"));
|
|
1383
|
+
const renderMermaidInto = mermaidBlocks.length === 0 ? null : (await import("../chunks/mermaid-de7p4v0x.js")).renderMermaidInto;
|
|
1384
|
+
for (const code of mermaidBlocks) {
|
|
1385
|
+
const source = code.textContent ?? "";
|
|
1386
|
+
const pre = code.parentElement;
|
|
1387
|
+
if (pre === null)
|
|
1388
|
+
continue;
|
|
1389
|
+
const region = document.createElement("div");
|
|
1390
|
+
region.setAttribute("data-facet-diagram-region", "true");
|
|
1391
|
+
region.tabIndex = 0;
|
|
1392
|
+
await renderMermaidInto(region, source, ctx.theme);
|
|
1393
|
+
if (region.firstElementChild !== null)
|
|
1394
|
+
pre.replaceWith(region);
|
|
1395
|
+
else
|
|
1396
|
+
pre.remove();
|
|
1397
|
+
}
|
|
1398
|
+
ctx.container.appendChild(template.content);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/gallery-web/frame/entries/markdown.ts
|
|
1402
|
+
var registry = createRendererRegistry([["markdown", renderMarkdown]]);
|
|
1403
|
+
installGalleryFrameApi(registry);
|