@canofold/markdown 0.3.0 → 0.3.2

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 (41) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dist/ImageGallery-Bcpjlfh9.js +569 -0
  4. package/dist/Markdown-607_slPB.js +117 -0
  5. package/dist/assets-CqlggKr8.js +77 -0
  6. package/dist/base.css +1 -1
  7. package/dist/client/bundler.js +308 -0
  8. package/dist/client/chunks/{client-kVNIqHQd.js → client-CHUUETWE.js} +3 -3
  9. package/dist/client/chunks/{gallery-BTg1qJjd.js → gallery-Cr0TgC1h.js} +2 -2
  10. package/dist/client/chunks/{image-BuMCsr5L.js → image-6_o7fPkU.js} +3 -3
  11. package/dist/client/chunks/provider-k1N-5njv.js +1037 -0
  12. package/dist/client/chunks/react-runtime-DRPMrVPX.js +12062 -0
  13. package/dist/client/chunks/{serialized-T1PzI4rG.js → serialized-Chn9ydGA.js} +270 -220
  14. package/dist/client/chunks/{table-JOSJsHgy.js → table-D99-Zhc8.js} +3 -3
  15. package/dist/client/index.js +1 -1
  16. package/dist/compiler/fenceMetadata.d.ts +7 -0
  17. package/dist/compiler/normalizeOptions.d.ts +2 -1
  18. package/dist/compiler/plugins/code.d.ts +1 -1
  19. package/dist/compiler/prepareMarkdown.d.ts +1 -1
  20. package/dist/compiler/types.d.ts +3 -0
  21. package/dist/componentMap-CKSUGzQH.js +1483 -0
  22. package/dist/components/blocks/MarkdownCodeBlock.d.ts +3 -1
  23. package/dist/copyText-C0ZgrMnH.js +18 -0
  24. package/dist/{directiveValidation-BdVbgcY_.js → directiveValidation-B7LY-R5p.js} +187 -248
  25. package/dist/fileKinds-BPzIxbaS.js +170 -0
  26. package/dist/gallery-BqQ-i0TC.js +42 -0
  27. package/dist/image-CiPni6Az.js +38 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/plugins-CXYBB-oH.js +130 -0
  31. package/dist/{prepareMarkdown-D-bFl1_V.js → prepareMarkdown-CS6sALIb.js} +344 -329
  32. package/dist/provider-BJDHf4Z_.js +8 -0
  33. package/dist/serialized-DFiNQYA5.js +39 -0
  34. package/dist/server/analyze.js +11 -11
  35. package/dist/server.js +30 -28
  36. package/dist/table-DQSeLjVL.js +32 -0
  37. package/package.json +14 -9
  38. package/dist/Markdown-C7O01MRv.js +0 -2116
  39. package/dist/client/chunks/provider-DNSHvvN7.js +0 -841
  40. package/dist/client/chunks/react-runtime-Dzgdzn6D.js +0 -10571
  41. package/dist/plugins-StkCS2su.js +0 -298
@@ -1,57 +1,60 @@
1
- import D from "remark-parse";
2
- import j from "remark-rehype";
3
- import { unified as H } from "unified";
4
- import z from "rehype-slug";
5
- import { remarkDefinitionList as G, defListHastHandlers as _ } from "remark-definition-list";
6
- import O from "remark-directive";
7
- import R from "remark-gfm";
1
+ import O from "remark-parse";
2
+ import H from "remark-rehype";
3
+ import { unified as z } from "unified";
4
+ import G from "rehype-slug";
5
+ import { remarkDefinitionList as _, defListHastHandlers as R } from "remark-definition-list";
6
+ import q from "remark-directive";
7
+ import U from "remark-gfm";
8
8
  import { visit as h, SKIP as b } from "unist-util-visit";
9
- import { r as q, b as U, e as W, f as J, g as K, h as X, i as Z, j as V, k as Y, l as Q, n as ee, a as te } from "./directiveValidation-BdVbgcY_.js";
10
- import { D as ae, s as re } from "./Markdown-C7O01MRv.js";
11
- import { n as ne, m as oe, s as S, a as ie, b as se, c as le } from "./plugins-StkCS2su.js";
12
- import ce from "@shikijs/rehype/core";
13
- import { transformerMetaHighlight as pe, transformerNotationHighlight as me, transformerNotationDiff as ue, transformerNotationFocus as fe, transformerNotationWordHighlight as ge, transformerNotationErrorLevel as de } from "@shikijs/transformers";
14
- import { createHighlighterCore as he } from "shiki/core";
15
- import { createJavaScriptRegexEngine as ye } from "shiki/engine/javascript";
16
- import { bundledThemes as ke } from "shiki/themes";
17
- const Ce = "vscode://schemas/color-theme", be = "canofold-dark", ve = "Canofold Dark", we = "dark", Le = !0, Ne = { "editor.background": "#020610", "editor.foreground": "#E6EBF2" }, Se = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#91A0B2", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#C6B5FF" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#9FD3A7" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#F3D18A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#9EC7F3" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#8ED1CC" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#E6EBF2" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#E3AFD2" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#F0A89E" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#F3D18A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#F0A89E" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#AAB5C3" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#9FD3A7" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#F0A89E" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#9EC7F3", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#E6EBF2", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#E6EBF2", fontStyle: "italic" } }], xe = {
18
- $schema: Ce,
19
- name: be,
20
- displayName: ve,
21
- type: we,
22
- semanticHighlighting: Le,
23
- colors: Ne,
24
- tokenColors: Se
25
- }, Fe = "vscode://schemas/color-theme", Be = "canofold-light", Ae = "Canofold Light", Pe = "light", Te = !0, Ee = { "editor.background": "#F0F2F5", "editor.foreground": "#344054" }, $e = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#98A2B3", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#7C6BC4" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#3D9A48" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#C47A2A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#4B8DF5" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#2E8B8B" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#344054" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#B05A9A" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#DC5647" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#C47A2A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#DC5647" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#667085" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#3D9A48" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#DC5647" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#4B8DF5", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#344054", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#344054", fontStyle: "italic" } }], Ie = {
26
- $schema: Fe,
27
- name: Be,
28
- displayName: Ae,
29
- type: Pe,
30
- semanticHighlighting: Te,
31
- colors: Ee,
32
- tokenColors: $e
33
- }, x = {
34
- light: Ie,
35
- dark: xe
9
+ import { r as W, a as J, b as K, d as X, e as Z, f as V, g as Y, h as Q, i as ee, j as te, n as re } from "./directiveValidation-B7LY-R5p.js";
10
+ import { s as ae } from "./componentMap-CKSUGzQH.js";
11
+ import { n as ne, m as oe, s as F, a as ie, b as se, c as le } from "./plugins-CXYBB-oH.js";
12
+ import { c as ce } from "./assets-CqlggKr8.js";
13
+ import { D as pe } from "./ImageGallery-Bcpjlfh9.js";
14
+ import me from "@shikijs/rehype/core";
15
+ import { transformerMetaHighlight as fe, transformerNotationHighlight as ue, transformerNotationDiff as de, transformerNotationFocus as ge, transformerNotationWordHighlight as he, transformerNotationErrorLevel as ye } from "@shikijs/transformers";
16
+ import { createHighlighterCore as Ce } from "shiki/core";
17
+ import { createJavaScriptRegexEngine as ke } from "shiki/engine/javascript";
18
+ import { bundledThemes as be } from "shiki/themes";
19
+ const ve = "vscode://schemas/color-theme", we = "canofold-dark", Le = "Canofold Dark", Ne = "dark", Se = !0, xe = { "editor.background": "#020610", "editor.foreground": "#E6EBF2" }, Fe = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#91A0B2", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#C6B5FF" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#9FD3A7" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#F3D18A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#9EC7F3" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#8ED1CC" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#E6EBF2" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#E3AFD2" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#F0A89E" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#F3D18A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#F0A89E" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#AAB5C3" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#9FD3A7" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#F0A89E" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#9EC7F3", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#E6EBF2", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#E6EBF2", fontStyle: "italic" } }], Be = {
20
+ $schema: ve,
21
+ name: we,
22
+ displayName: Le,
23
+ type: Ne,
24
+ semanticHighlighting: Se,
25
+ colors: xe,
26
+ tokenColors: Fe
27
+ }, Pe = "vscode://schemas/color-theme", Ae = "canofold-light", Te = "Canofold Light", Ee = "light", $e = !0, Ie = { "editor.background": "#F0F2F5", "editor.foreground": "#344054" }, Me = [{ scope: ["comment", "punctuation.definition.comment", "string.comment"], settings: { foreground: "#98A2B3", fontStyle: "italic" } }, { scope: ["keyword", "storage", "storage.type", "storage.modifier", "keyword.control", "keyword.other"], settings: { foreground: "#7C6BC4" } }, { scope: ["string", "string.quoted", "punctuation.definition.string"], settings: { foreground: "#3D9A48" } }, { scope: ["constant.numeric", "constant.language.boolean", "constant.language.null", "constant.language.undefined"], settings: { foreground: "#C47A2A" } }, { scope: ["entity.name.function", "support.function", "variable.function", "meta.function-call"], settings: { foreground: "#4B8DF5" } }, { scope: ["entity.name.type", "entity.name.class", "support.type", "support.class", "entity.other.inherited-class"], settings: { foreground: "#2E8B8B" } }, { scope: ["variable", "variable.other", "variable.parameter", "meta.definition.variable.name"], settings: { foreground: "#344054" } }, { scope: ["variable.other.property", "support.variable.property", "meta.property-name", "meta.object-literal.key"], settings: { foreground: "#B05A9A" } }, { scope: ["entity.name.tag", "meta.tag.sgml", "punctuation.definition.tag"], settings: { foreground: "#DC5647" } }, { scope: ["entity.other.attribute-name"], settings: { foreground: "#C47A2A" } }, { scope: ["string.regexp", "source.regexp", "constant.other.character-class.regexp"], settings: { foreground: "#DC5647" } }, { scope: ["keyword.operator", "punctuation", "meta.brace", "meta.delimiter"], settings: { foreground: "#667085" } }, { scope: ["markup.inserted", "punctuation.definition.inserted"], settings: { foreground: "#3D9A48" } }, { scope: ["markup.deleted", "punctuation.definition.deleted", "invalid", "message.error"], settings: { foreground: "#DC5647" } }, { scope: ["markup.heading", "markup.heading entity.name"], settings: { foreground: "#4B8DF5", fontStyle: "bold" } }, { scope: ["markup.bold"], settings: { foreground: "#344054", fontStyle: "bold" } }, { scope: ["markup.italic"], settings: { foreground: "#344054", fontStyle: "italic" } }], De = {
28
+ $schema: Pe,
29
+ name: Ae,
30
+ displayName: Te,
31
+ type: Ee,
32
+ semanticHighlighting: $e,
33
+ colors: Ie,
34
+ tokenColors: Me
35
+ }, B = {
36
+ light: De,
37
+ dark: Be
36
38
  };
37
- function Me(t) {
39
+ function je(t) {
38
40
  if (!t) return {};
39
41
  const e = Object.entries(t);
40
42
  return e.every(
41
- ([r]) => r.length > 0 && r === r.trim().toLowerCase()
43
+ ([a]) => a.length > 0 && a === a.trim().toLowerCase()
42
44
  ) ? t : Object.fromEntries(
43
- e.map(([r, n]) => [r.trim().toLowerCase(), n]).filter(([r]) => r.length > 0)
45
+ e.map(([a, n]) => [a.trim().toLowerCase(), n]).filter(([a]) => a.length > 0)
44
46
  );
45
47
  }
46
- function De(t = {}) {
48
+ function Oe(t = {}) {
47
49
  return {
48
50
  htmlPolicy: t.html ?? "strip",
49
51
  codeThemes: {
50
- light: t.code?.themes?.light ?? x.light,
51
- dark: t.code?.themes?.dark ?? x.dark
52
+ light: t.code?.themes?.light ?? B.light,
53
+ dark: t.code?.themes?.dark ?? B.dark
52
54
  },
53
55
  fallbackLanguage: t.code?.fallbackLanguage?.trim().toLowerCase() || "text",
54
- codeLanguages: Me(t.code?.languages),
56
+ codeOverflow: t.code?.overflow ?? "wrap",
57
+ codeLanguages: je(t.code?.languages),
55
58
  unknownLanguage: t.code?.unknownLanguage ?? "warn",
56
59
  features: {
57
60
  callouts: t.features?.callouts !== !1,
@@ -64,101 +67,110 @@ function De(t = {}) {
64
67
  codeBlocks: t.features?.codeBlocks !== !1
65
68
  },
66
69
  labels: {
67
- ...ae,
70
+ ...pe,
68
71
  ...t.labels
69
72
  },
70
73
  plugins: ne(t.plugins)
71
74
  };
72
75
  }
73
- function je(t) {
76
+ const He = /(?:title|filename|label)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i, ze = /(?:^|\s)(wrap|scroll)(?=\s|$)/i;
77
+ function E(t) {
78
+ const e = t.match(He), r = t.match(ze), a = e?.[1]?.trim() || e?.[2]?.trim(), n = r?.[1]?.toLowerCase();
79
+ return {
80
+ ...a ? { filename: a } : {},
81
+ ...n ? { overflow: n } : {}
82
+ };
83
+ }
84
+ function Ge(t) {
74
85
  return String(t ?? "").replace(/^Markdown/, "").toLowerCase();
75
86
  }
76
- function P(t, e) {
87
+ function $(t, e) {
77
88
  if (!t || typeof t != "object" || !("properties" in t)) return !1;
78
- const a = t.properties;
79
- return a?.dataCfComponent === e || a?.["data-cf-component"] === e;
89
+ const r = t.properties;
90
+ return r?.dataCfComponent === e || r?.["data-cf-component"] === e;
80
91
  }
81
- function He(t, e) {
92
+ function _e(t, e) {
82
93
  if (t.type !== "mdxJsxFlowElement" && t.type !== "mdxJsxTextElement") return !1;
83
- const a = je(t.name);
84
- if (a === "terminal")
94
+ const r = Ge(t.name);
95
+ if (r === "terminal")
85
96
  return e.markBehavior("terminal-toolbar"), !0;
86
- if (a === "gallery") e.markBehavior("gallery");
87
- else if (a === "filetree") e.markBehavior("file-tree");
88
- else if (a === "table") e.markBehavior("table");
89
- else if (a === "image") e.markBehavior("image");
90
- else if (a === "codeblock") e.markBehavior("code-toolbar");
91
- else if (a === "codegroup" || a === "tabs") e.markBehavior("tabs");
97
+ if (r === "gallery") e.markBehavior("gallery");
98
+ else if (r === "filetree") e.markBehavior("file-tree");
99
+ else if (r === "table") e.markBehavior("table");
100
+ else if (r === "image") e.markBehavior("image");
101
+ else if (r === "codeblock") e.markBehavior("code-toolbar");
102
+ else if (r === "codegroup" || r === "tabs") e.markBehavior("tabs");
92
103
  else return !1;
93
104
  return !0;
94
105
  }
95
- const ze = (t) => (e) => {
96
- h(e, (a) => {
97
- He(a, t);
106
+ const Re = (t) => (e) => {
107
+ h(e, (r) => {
108
+ _e(r, t);
98
109
  });
99
- }, Ge = (t) => (e) => {
100
- h(e, "code", (a) => {
101
- const r = String(a.lang ?? "").toLowerCase(), n = String(a.meta ?? ""), o = n.match(/(?:title|filename|label)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i), l = o?.[1]?.trim() || o?.[2]?.trim(), i = t.features.terminals && r === "terminal";
102
- !n && !l && !i || (a.data = {
103
- ...a.data,
110
+ }, qe = (t) => (e) => {
111
+ h(e, "code", (r) => {
112
+ const a = String(r.lang ?? "").toLowerCase(), n = String(r.meta ?? ""), { filename: o, overflow: l } = E(n), i = t.features.terminals && a === "terminal";
113
+ !n && !o && !l && !i || (r.data = {
114
+ ...r.data,
104
115
  hProperties: {
105
- ...a.data?.hProperties,
116
+ ...r.data?.hProperties,
106
117
  ...n ? { metastring: n } : {},
107
- ...l ? { title: l, dataCfFilename: l } : {},
108
- ...i ? { title: l || t.labels.terminalTitle } : {}
118
+ ...o ? { title: o, dataCfFilename: o } : {},
119
+ ...l ? { dataCfCodeOverflow: l } : {},
120
+ ...i ? { title: o || t.labels.terminalTitle } : {}
109
121
  }
110
122
  });
111
123
  });
112
- }, _e = () => (t) => {
124
+ }, Ue = () => (t) => {
113
125
  h(t, "element", (e) => {
114
126
  if (e.tagName !== "pre") return;
115
- const a = e.children.find(
127
+ const r = e.children.find(
116
128
  (n) => n.type === "element" && n.tagName === "code"
117
- ), r = String(
118
- a?.properties?.dataCfFilename ?? a?.properties?.["data-cf-filename"] ?? a?.properties?.title ?? a?.properties?.["data-title"] ?? ""
129
+ ), a = String(
130
+ r?.properties?.dataCfFilename ?? r?.properties?.["data-cf-filename"] ?? r?.properties?.title ?? r?.properties?.["data-title"] ?? ""
119
131
  ).trim();
120
- r && (e.properties = { ...e.properties, dataCfFilename: r });
132
+ a && (e.properties = { ...e.properties, dataCfFilename: a });
121
133
  });
122
134
  };
123
- function T(t, e = {}, a = []) {
124
- return { type: "element", tagName: t, properties: e, children: a };
135
+ function I(t, e = {}, r = []) {
136
+ return { type: "element", tagName: t, properties: e, children: r };
125
137
  }
126
- function L(t) {
127
- return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((e) => L(e)).join("") : "" : "";
138
+ function N(t) {
139
+ return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((e) => N(e)).join("") : "" : "";
128
140
  }
129
- function Oe(t) {
141
+ function We(t) {
130
142
  const e = t?.properties?.className ?? t?.properties?.class;
131
143
  return Array.isArray(e) ? e.map(String) : typeof e == "string" ? e.split(/\s+/) : [];
132
144
  }
133
- function E(t) {
145
+ function M(t) {
134
146
  return t ? t.children.filter(
135
- (e) => e.type === "element" && e.tagName === "span" && Oe(e).includes("line")
147
+ (e) => e.type === "element" && e.tagName === "span" && We(e).includes("line")
136
148
  ) : [];
137
149
  }
138
- function Re(t, e) {
139
- const a = E(t);
140
- return a.length > 0 ? a.map((r) => L(r)).join(`
141
- `) : L(t ?? e).replace(/\n$/, "");
150
+ function Je(t, e) {
151
+ const r = M(t);
152
+ return r.length > 0 ? r.map((a) => N(a)).join(`
153
+ `) : N(t ?? e).replace(/\n$/, "");
142
154
  }
143
- function qe(t, e) {
144
- !t || E(t).length > 0 || (t.children = e.split(`
145
- `).map((a) => T("span", { className: ["line"] }, a ? [{ type: "text", value: a }] : [])));
155
+ function Ke(t, e) {
156
+ !t || M(t).length > 0 || (t.children = e.split(`
157
+ `).map((r) => I("span", { className: ["line"] }, r ? [{ type: "text", value: r }] : [])));
146
158
  }
147
- function $(t) {
148
- const e = t?.properties.className ?? t?.properties.class, r = (Array.isArray(e) ? e : typeof e == "string" ? e.split(/\s+/) : []).find(
159
+ function D(t) {
160
+ const e = t?.properties.className ?? t?.properties.class, a = (Array.isArray(e) ? e : typeof e == "string" ? e.split(/\s+/) : []).find(
149
161
  (n) => typeof n == "string" && n.startsWith("language-")
150
162
  );
151
- return typeof r == "string" ? r.slice(9).toLowerCase() : "";
163
+ return typeof a == "string" ? a.slice(9).toLowerCase() : "";
152
164
  }
153
- const Ue = (t, e) => (a) => {
154
- h(a, "element", (r, n, o) => {
155
- if (r.tagName !== "pre" || !o || n === void 0 || P(o, "code-block"))
165
+ const Xe = (t, e) => (r) => {
166
+ h(r, "element", (a, n, o) => {
167
+ if (a.tagName !== "pre" || !o || n === void 0 || $(o, "code-block"))
156
168
  return;
157
- const l = r.children.find(
169
+ const l = a.children.find(
158
170
  (s) => s.type === "element" && s.tagName === "code"
159
- ), i = $(l), c = L(l).replace(/\n$/, "");
171
+ ), i = D(l), c = N(l).replace(/\n$/, "");
160
172
  if (e.features.terminals && i === "terminal")
161
- return t.markBehavior("terminal-toolbar"), o.children[n] = T("div", {
173
+ return t.markBehavior("terminal-toolbar"), o.children[n] = I("div", {
162
174
  className: ["cf-terminal"],
163
175
  dataCfComponent: "terminal",
164
176
  dataCfBehavior: "terminal-toolbar",
@@ -170,40 +182,42 @@ const Ue = (t, e) => (a) => {
170
182
  }), [b, n];
171
183
  });
172
184
  };
173
- function w(t, e) {
185
+ function L(t, e) {
174
186
  return { type: "mdxJsxAttribute", name: t, value: e };
175
187
  }
176
- const We = (t, e) => (a) => {
177
- h(a, "code", (r, n, o) => {
188
+ const Ze = (t, e) => (r) => {
189
+ h(r, "code", (a, n, o) => {
178
190
  if (!o || n === void 0) return;
179
- const l = String(r.lang ?? "").toLowerCase(), i = String(r.value ?? ""), s = String(r.meta ?? "").match(/(?:title|label)\s*=\s*["']([^"']+)["']/i);
191
+ const l = String(a.lang ?? "").toLowerCase(), i = String(a.value ?? ""), s = String(a.meta ?? "").match(/(?:title|label)\s*=\s*["']([^"']+)["']/i);
180
192
  if (l === "terminal")
181
193
  return e.features.terminals ? (t.markBehavior("terminal-toolbar"), o.children[n] = {
182
194
  type: "mdxJsxFlowElement",
183
195
  name: "Terminal",
184
196
  attributes: [
185
- w("title", s?.[1]?.trim() || e.labels.terminalTitle),
186
- w("source", i),
187
- w("copyLabel", e.labels.copyTerminal),
188
- w("copyFailureLabel", e.labels.copyFailed)
197
+ L("title", s?.[1]?.trim() || e.labels.terminalTitle),
198
+ L("source", i),
199
+ L("copyLabel", e.labels.copyTerminal),
200
+ L("copyFailureLabel", e.labels.copyFailed)
189
201
  ],
190
202
  children: []
191
203
  }, [b, n]) : void 0;
192
204
  });
193
- }, Je = (t, e, a = /* @__PURE__ */ new Set()) => (r) => {
194
- h(r, "element", (n, o, l) => {
195
- if (n.tagName !== "pre" || !l || o === void 0 || P(l, "code-block"))
205
+ }, Ve = (t, e, r = /* @__PURE__ */ new Set()) => (a) => {
206
+ h(a, "element", (n, o, l) => {
207
+ if (n.tagName !== "pre" || !l || o === void 0 || $(l, "code-block"))
196
208
  return;
197
209
  t.markBehavior("code-toolbar"), n.properties = { ...n.properties, dataCfSlot: "content" };
198
210
  const i = n.children.find(
199
- (C) => C.type === "element" && C.tagName === "code"
200
- ), c = $(i);
201
- if (c && a.has(c)) return;
202
- const s = i?.properties?.className ?? i?.properties?.class, u = (Array.isArray(s) ? s : typeof s == "string" ? s.split(/\s+/) : []).find((C) => typeof C == "string" && C.startsWith("language-")), m = u ? u.slice(9) : "text", g = l.type === "element" ? l.properties : void 0, d = String(
203
- n.properties?.dataCfFilename ?? n.properties?.["data-cf-filename"] ?? g?.dataCfFilename ?? g?.["data-cf-filename"] ?? i?.properties?.dataCfFilename ?? i?.properties?.["data-cf-filename"] ?? i?.properties?.title ?? i?.properties?.["data-title"] ?? ""
204
- ).trim(), k = Re(i, n);
205
- qe(i, k);
206
- const f = {
211
+ (k) => k.type === "element" && k.tagName === "code"
212
+ ), c = D(i);
213
+ if (c && r.has(c)) return;
214
+ const s = i?.properties?.className ?? i?.properties?.class, u = (Array.isArray(s) ? s : typeof s == "string" ? s.split(/\s+/) : []).find((k) => typeof k == "string" && k.startsWith("language-")), m = u ? u.slice(9) : "text", d = l.type === "element" ? l.properties : void 0, g = String(
215
+ n.properties?.dataCfFilename ?? n.properties?.["data-cf-filename"] ?? d?.dataCfFilename ?? d?.["data-cf-filename"] ?? i?.properties?.dataCfFilename ?? i?.properties?.["data-cf-filename"] ?? i?.properties?.title ?? i?.properties?.["data-title"] ?? ""
216
+ ).trim(), C = String(
217
+ n.properties?.dataCfCodeOverflow ?? n.properties?.["data-cf-code-overflow"] ?? i?.properties?.dataCfCodeOverflow ?? i?.properties?.["data-cf-code-overflow"] ?? ""
218
+ ).trim(), f = C === "wrap" || C === "scroll" ? C : e.codeOverflow, w = Je(i, n);
219
+ Ke(i, w);
220
+ const x = {
207
221
  type: "element",
208
222
  tagName: "figure",
209
223
  properties: {
@@ -212,22 +226,23 @@ const We = (t, e) => (a) => {
212
226
  dataCfBehavior: "code-toolbar",
213
227
  dataCfSlot: "root",
214
228
  dataCfLanguage: m,
215
- ...d ? { dataCfFilename: d } : {},
216
- dataCfSource: k,
217
- dataCfCopyLabel: e.copyCode,
218
- dataCfCopyFailureLabel: e.copyFailed
229
+ ...g ? { dataCfFilename: g } : {},
230
+ ...f === "scroll" || C === "wrap" ? { dataCfCodeOverflow: f } : {},
231
+ dataCfSource: w,
232
+ dataCfCopyLabel: e.labels.copyCode,
233
+ dataCfCopyFailureLabel: e.labels.copyFailed
219
234
  },
220
235
  children: [n]
221
236
  };
222
- return l.children[o] = f, [b];
237
+ return l.children[o] = x, [b];
223
238
  });
224
239
  };
225
- function N(t) {
240
+ function S(t) {
226
241
  if (!t) return "";
227
242
  const e = t.properties;
228
243
  return String(e.dataCfComponent ?? e["data-cf-component"] ?? "");
229
244
  }
230
- const Ke = /* @__PURE__ */ new Map([
245
+ const Ye = /* @__PURE__ */ new Map([
231
246
  ["pdf", { kind: "pdf", badge: "PDF", label: "PDF document" }],
232
247
  ["doc", { kind: "word", badge: "DOC", label: "Microsoft Word" }],
233
248
  ["docx", { kind: "word", badge: "DOCX", label: "Microsoft Word" }],
@@ -236,117 +251,117 @@ const Ke = /* @__PURE__ */ new Map([
236
251
  ["xls", { kind: "excel", badge: "XLS", label: "Microsoft Excel" }],
237
252
  ["xlsx", { kind: "excel", badge: "XLSX", label: "Microsoft Excel" }]
238
253
  ]);
239
- function Xe(t) {
254
+ function Qe(t) {
240
255
  if (typeof t != "string" || !t.trim()) return;
241
- const e = t.trim(), a = e.match(/^([a-z][a-z\d+.-]*):/i)?.[1]?.toLowerCase();
242
- if (a && a !== "http" && a !== "https") return;
243
- let r = (e.split("#")[0] ?? "").split("?")[0] ?? "";
256
+ const e = t.trim(), r = e.match(/^([a-z][a-z\d+.-]*):/i)?.[1]?.toLowerCase();
257
+ if (r && r !== "http" && r !== "https") return;
258
+ let a = (e.split("#")[0] ?? "").split("?")[0] ?? "";
244
259
  try {
245
- (a || e.startsWith("//")) && (r = new URL(e.startsWith("//") ? `https:${e}` : e).pathname);
260
+ (r || e.startsWith("//")) && (a = new URL(e.startsWith("//") ? `https:${e}` : e).pathname);
246
261
  } catch {
247
262
  return;
248
263
  }
249
- const n = r.split("/").filter(Boolean).at(-1);
264
+ const n = a.split("/").filter(Boolean).at(-1);
250
265
  if (!n) return;
251
266
  let o = n;
252
267
  try {
253
268
  o = decodeURIComponent(n);
254
269
  } catch {
255
270
  }
256
- const l = o.toLowerCase().match(/\.([a-z\d]+)$/)?.[1], i = l ? Ke.get(l) : void 0;
271
+ const l = o.toLowerCase().match(/\.([a-z\d]+)$/)?.[1], i = l ? Ye.get(l) : void 0;
257
272
  return i ? { ...i, filename: o } : void 0;
258
273
  }
259
- function F(t) {
274
+ function P(t) {
260
275
  const e = t.properties?.className;
261
276
  return Array.isArray(e) ? e.map(String) : typeof e == "string" ? e.split(/\s+/) : [];
262
277
  }
263
- function Ze(t, e, a) {
264
- const r = t.properties ?? {}, n = N(t);
278
+ function et(t, e, r) {
279
+ const a = t.properties ?? {}, n = S(t);
265
280
  if (n === "gallery") {
266
281
  e.markBehavior("gallery");
267
- const o = typeof r.dataCfGalleryLabel == "string" && r.dataCfGalleryLabel.trim() ? r.dataCfGalleryLabel : typeof r["data-cf-gallery-label"] == "string" && r["data-cf-gallery-label"].trim() ? r["data-cf-gallery-label"] : a.imageGallery;
282
+ const o = typeof a.dataCfGalleryLabel == "string" && a.dataCfGalleryLabel.trim() ? a.dataCfGalleryLabel : typeof a["data-cf-gallery-label"] == "string" && a["data-cf-gallery-label"].trim() ? a["data-cf-gallery-label"] : r.imageGallery;
268
283
  t.properties = {
269
- ...r,
284
+ ...a,
270
285
  dataCfGalleryLabel: o,
271
- dataCfCloseLabel: a.closeImageGallery,
272
- dataCfPreviousLabel: a.previousGalleryImage,
273
- dataCfNextLabel: a.nextGalleryImage,
274
- dataCfThumbnailsLabel: a.galleryThumbnails,
275
- dataCfImageLabel: a.galleryImage
286
+ dataCfCloseLabel: r.closeImageGallery,
287
+ dataCfPreviousLabel: r.previousGalleryImage,
288
+ dataCfNextLabel: r.nextGalleryImage,
289
+ dataCfThumbnailsLabel: r.galleryThumbnails,
290
+ dataCfImageLabel: r.galleryImage
276
291
  };
277
292
  }
278
293
  (n === "tabs" || n === "code-group") && e.markBehavior("tabs"), n === "details" && e.markBehavior("details"), n === "file-tree" && e.markBehavior("file-tree"), n === "code-block" && e.markBehavior("code-toolbar"), n === "copy-snippet" && (e.markBehavior("copy-snippet"), t.properties = {
279
- ...r,
280
- dataCfCopyLabel: a.copySnippet,
281
- dataCfCopyFailureLabel: a.copyFailed
294
+ ...a,
295
+ dataCfCopyLabel: r.copySnippet,
296
+ dataCfCopyFailureLabel: r.copyFailed
282
297
  }), n === "table" && e.markBehavior("table"), n === "image" && e.markBehavior("image"), n === "terminal" && e.markBehavior("terminal-toolbar");
283
298
  }
284
- const Ve = (t, e) => (a) => {
285
- h(a, "element", (r, n, o) => {
299
+ const tt = (t, e) => (r) => {
300
+ h(r, "element", (a, n, o) => {
286
301
  if (!o || n === void 0) return;
287
- if (Ze(r, t, e), r.tagName === "input" && r.properties?.type === "checkbox") {
288
- r.properties.ariaLabel = r.properties.checked ? e.taskCompleted : e.taskIncomplete;
302
+ if (et(a, t, e), a.tagName === "input" && a.properties?.type === "checkbox") {
303
+ a.properties.ariaLabel = a.properties.checked ? e.taskCompleted : e.taskIncomplete;
289
304
  return;
290
305
  }
291
- if (r.tagName === "section" && r.properties?.dataFootnotes !== void 0) {
292
- r.properties = { ...r.properties, dataCfElement: "footnotes" };
306
+ if (a.tagName === "section" && a.properties?.dataFootnotes !== void 0) {
307
+ a.properties = { ...a.properties, dataCfElement: "footnotes" };
293
308
  return;
294
309
  }
295
310
  const l = o.type === "element" ? o : void 0;
296
- if (r.tagName === "figure" && !N(r) && N(l) !== "gallery") {
297
- const m = r.children.filter((f) => f.type !== "text" || f.value.trim() !== ""), g = m.find(
311
+ if (a.tagName === "figure" && !S(a) && S(l) !== "gallery") {
312
+ const m = a.children.filter((f) => f.type !== "text" || f.value.trim() !== ""), d = m.find(
298
313
  (f) => f.type === "element" && f.tagName === "img"
299
- ), d = m.find(
314
+ ), g = m.find(
300
315
  (f) => f.type === "element" && f.tagName === "figcaption"
301
316
  );
302
- if (g && m.every(
317
+ if (d && m.every(
303
318
  (f) => f.type === "element" && (f.tagName === "img" || f.tagName === "figcaption")
304
319
  )) {
305
- const f = F(r);
306
- t.markBehavior("image"), r.properties = {
307
- ...r.properties,
320
+ const f = P(a);
321
+ t.markBehavior("image"), a.properties = {
322
+ ...a.properties,
308
323
  className: [.../* @__PURE__ */ new Set([...f, "cf-media-frame"])],
309
324
  dataCfComponent: "image",
310
325
  dataCfIsland: "image",
311
326
  dataCfSlot: "root",
312
327
  dataCfZoomLabel: e.zoomImage,
313
328
  dataCfCloseLabel: e.closeImagePreview
314
- }, d && (d.properties = { ...d.properties, dataCfSlot: "caption" });
329
+ }, g && (g.properties = { ...g.properties, dataCfSlot: "caption" });
315
330
  return;
316
331
  }
317
332
  }
318
- if (r.tagName === "details") {
319
- t.markBehavior("details"), r.properties = {
320
- ...r.properties,
333
+ if (a.tagName === "details") {
334
+ t.markBehavior("details"), a.properties = {
335
+ ...a.properties,
321
336
  dataCfComponent: "details",
322
337
  dataCfBehavior: "details",
323
338
  dataCfSlot: "root"
324
339
  };
325
- const m = r.children?.find(
326
- (g) => g.type === "element" && g.tagName === "summary"
340
+ const m = a.children?.find(
341
+ (d) => d.type === "element" && d.tagName === "summary"
327
342
  );
328
343
  m && (m.properties = { ...m.properties, dataCfSlot: "summary" });
329
344
  return;
330
345
  }
331
- if (/^h[2-6]$/.test(r.tagName) && r.properties?.id) {
332
- t.markBehavior("heading"), r.properties = {
333
- ...r.properties,
334
- dataCfAnchor: `#${r.properties.id}`,
346
+ if (/^h[2-6]$/.test(a.tagName) && a.properties?.id) {
347
+ t.markBehavior("heading"), a.properties = {
348
+ ...a.properties,
349
+ dataCfAnchor: `#${a.properties.id}`,
335
350
  dataCfAnchorLabel: e.copySectionLink,
336
351
  dataCfCopyFailureLabel: e.copyFailed
337
352
  };
338
353
  return;
339
354
  }
340
- if (r.tagName !== "p") return;
341
- const i = r.children.filter((m) => m.type !== "text" || m.value.trim() !== ""), c = i[0];
355
+ if (a.tagName !== "p") return;
356
+ const i = a.children.filter((m) => m.type !== "text" || m.value.trim() !== ""), c = i[0];
342
357
  if (i.length !== 1 || c?.type !== "element") return;
343
358
  if (c.tagName === "a") {
344
- const m = Xe(c.properties?.href);
359
+ const m = Qe(c.properties?.href);
345
360
  return m ? (o.children[n] = {
346
361
  ...c,
347
362
  properties: {
348
363
  ...c.properties,
349
- className: [.../* @__PURE__ */ new Set([...F(c), "cf-file-link"])],
364
+ className: [.../* @__PURE__ */ new Set([...P(c), "cf-file-link"])],
350
365
  dataCfFileKind: m.kind,
351
366
  dataCfElement: "file-link"
352
367
  },
@@ -413,16 +428,16 @@ const Ve = (t, e) => (a) => {
413
428
  }, [b];
414
429
  });
415
430
  };
416
- function Ye(t, e) {
431
+ function rt(t, e) {
417
432
  if (!t || typeof t != "object" || !("properties" in t)) return !1;
418
- const a = t.properties;
419
- return a?.dataCfComponent === e || a?.["data-cf-component"] === e;
433
+ const r = t.properties;
434
+ return r?.dataCfComponent === e || r?.["data-cf-component"] === e;
420
435
  }
421
- const Qe = (t, e) => (a) => {
422
- h(a, "element", (r, n, o) => {
423
- if (r.tagName !== "table" || !o || n === void 0 || Ye(o, "table")) return;
436
+ const at = (t, e) => (r) => {
437
+ h(r, "element", (a, n, o) => {
438
+ if (a.tagName !== "table" || !o || n === void 0 || rt(o, "table")) return;
424
439
  t.markBehavior("table");
425
- const l = { ...r, properties: { ...r.properties, dataCfSlot: "table" } }, i = {
440
+ const l = { ...a, properties: { ...a.properties, dataCfSlot: "table" } }, i = {
426
441
  type: "element",
427
442
  tagName: "figure",
428
443
  properties: {
@@ -439,44 +454,44 @@ const Qe = (t, e) => (a) => {
439
454
  dataCfSortLabel: e.sortTableColumn,
440
455
  // The raw HAST subtree lets the static React island hydrate the
441
456
  // same table without reparsing Markdown or reading rendered HTML.
442
- dataCfTable: re(l)
457
+ dataCfTable: ae(l)
443
458
  },
444
459
  children: [l]
445
460
  };
446
461
  return o.children[n] = i, [b];
447
462
  });
448
463
  };
449
- function et(t, e, a, r, n) {
450
- const { features: o } = a, l = new Set(
451
- a.plugins.flatMap((p) => p.fenceLanguages ?? []).map((p) => p.toLowerCase())
452
- ), i = [G, R];
453
- i.push(O), i.push([q, oe(a.plugins)]), (o.tabs || o.codeGroups) && i.push([U, a]), o.steps && i.push([W, a]), o.callouts && i.push(J), o.documentBlocks && i.push(K);
454
- for (const p of a.plugins)
464
+ function nt(t, e, r, a, n) {
465
+ const { features: o } = r, l = new Set(
466
+ r.plugins.flatMap((p) => p.fenceLanguages ?? []).map((p) => p.toLowerCase())
467
+ ), i = [_, U];
468
+ i.push(q), i.push([W, oe(r.plugins)]), (o.tabs || o.codeGroups) && i.push([J, r]), o.steps && i.push([K, r]), o.callouts && i.push(X), o.documentBlocks && i.push(Z);
469
+ for (const p of r.plugins)
455
470
  p.remarkPlugins && i.push(...p.remarkPlugins);
456
- t === "mdx" ? (i.push([ze, e]), o.terminals && i.push([We, e, a])) : (o.terminals || r.highlightedCode) && i.push([Ge, a]);
471
+ t === "mdx" ? (i.push([Re, e]), o.terminals && i.push([Ze, e, r])) : (o.terminals || a.highlightedCode) && i.push([qe, r]);
457
472
  const c = [];
458
- t === "markdown" && o.terminals && c.push([Ue, e, a]), o.documentBlocks && c.push(X), c.push(z), r.highlightedCode && c.push(_e), r.highlightedCode && n && c.push(n), o.documentBlocks && c.push([Ve, e, a.labels]), o.tables && c.push([Qe, e, a.labels]), o.codeBlocks && c.push([Je, e, a.labels, l]);
459
- for (const p of a.plugins)
473
+ t === "markdown" && o.terminals && c.push([Xe, e, r]), o.documentBlocks && c.push(V), c.push(G), a.highlightedCode && c.push(Ue), a.highlightedCode && n && c.push(n), o.documentBlocks && c.push([tt, e, r.labels]), o.tables && c.push([at, e, r.labels]), o.codeBlocks && c.push([Ve, e, r, l]);
474
+ for (const p of r.plugins)
460
475
  p.rehypePlugins && c.push(...p.rehypePlugins);
461
476
  const s = {
462
- ..._,
463
- tabGroup: Q,
464
- tabItem: Y,
465
- stepGroup: V,
466
- stepItem: Z
477
+ ...R,
478
+ tabGroup: te,
479
+ tabItem: ee,
480
+ stepGroup: Q,
481
+ stepItem: Y
467
482
  };
468
483
  return { remarkPlugins: i, rehypePlugins: c, handlers: s };
469
484
  }
470
- function tt() {
485
+ function ot() {
471
486
  return {
472
487
  name: "canofold:fence-metadata",
473
488
  pre(t) {
474
- const a = String(this.options.meta?.__raw ?? "").match(/(?:title|filename|label)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i), r = a?.[1]?.trim() || a?.[2]?.trim();
475
- return r && (t.properties.dataCfFilename = r), t;
489
+ const e = String(this.options.meta?.__raw ?? ""), { filename: r, overflow: a } = E(e);
490
+ return r && (t.properties.dataCfFilename = r), a && (t.properties.dataCfCodeOverflow = a), t;
476
491
  }
477
492
  };
478
493
  }
479
- function at() {
494
+ function it() {
480
495
  return {
481
496
  name: "canofold:collapse-code-newlines",
482
497
  code(t) {
@@ -484,7 +499,7 @@ function at() {
484
499
  }
485
500
  };
486
501
  }
487
- const rt = {
502
+ const st = {
488
503
  bash: () => import("@shikijs/langs/bash"),
489
504
  c: () => import("@shikijs/langs/c"),
490
505
  cpp: () => import("@shikijs/langs/cpp"),
@@ -514,7 +529,7 @@ const rt = {
514
529
  typescript: () => import("@shikijs/langs/typescript"),
515
530
  vue: () => import("@shikijs/langs/vue"),
516
531
  yaml: () => import("@shikijs/langs/yaml")
517
- }, nt = {
532
+ }, lt = {
518
533
  bash: "bash",
519
534
  c: "c",
520
535
  "c++": "cpp",
@@ -561,46 +576,46 @@ const rt = {
561
576
  yml: "yaml",
562
577
  yaml: "yaml",
563
578
  zsh: "bash"
564
- }, ot = /* @__PURE__ */ new Set(["ansi", "text", "plaintext", "txt", "plain"]), y = /* @__PURE__ */ new Map(), it = 8, B = /* @__PURE__ */ new WeakMap();
565
- let st = 1;
566
- function A(t) {
579
+ }, ct = /* @__PURE__ */ new Set(["ansi", "text", "plaintext", "txt", "plain"]), y = /* @__PURE__ */ new Map(), pt = 8, A = /* @__PURE__ */ new WeakMap();
580
+ let mt = 1;
581
+ function T(t) {
567
582
  if (typeof t != "string") return t;
568
- const e = ke[t];
583
+ const e = be[t];
569
584
  if (!e) throw new Error(`Unknown Shiki theme: ${t}`);
570
585
  return e;
571
586
  }
572
- function lt(t) {
573
- const e = S(t.codeThemes) ?? `${String(t.codeThemes.light)}\0${String(t.codeThemes.dark)}`;
587
+ function ft(t) {
588
+ const e = F(t.codeThemes) ?? `${String(t.codeThemes.light)}\0${String(t.codeThemes.dark)}`;
574
589
  if (Object.keys(t.codeLanguages).length === 0) return e;
575
- const a = S(t.codeLanguages);
576
- if (a !== void 0) return `${e}\0${a}`;
577
- const r = t.codeLanguages;
578
- let n = B.get(r);
579
- return n === void 0 && (n = st++, B.set(r, n)), `${e}\0custom:${n}`;
580
- }
581
- function ct(t, e) {
582
- for (y.delete(t), y.set(t, e); y.size > it; ) {
583
- const a = y.keys().next().value;
584
- if (a === void 0) break;
585
- y.delete(a);
590
+ const r = F(t.codeLanguages);
591
+ if (r !== void 0) return `${e}\0${r}`;
592
+ const a = t.codeLanguages;
593
+ let n = A.get(a);
594
+ return n === void 0 && (n = mt++, A.set(a, n)), `${e}\0custom:${n}`;
595
+ }
596
+ function ut(t, e) {
597
+ for (y.delete(t), y.set(t, e); y.size > pt; ) {
598
+ const r = y.keys().next().value;
599
+ if (r === void 0) break;
600
+ y.delete(r);
586
601
  }
587
602
  return e;
588
603
  }
589
- function pt(t) {
590
- const e = lt(t), a = y.get(e);
591
- if (a)
592
- return y.delete(e), y.set(e, a), a;
593
- const r = he({
594
- themes: [A(t.codeThemes.light), A(t.codeThemes.dark)],
604
+ function dt(t) {
605
+ const e = ft(t), r = y.get(e);
606
+ if (r)
607
+ return y.delete(e), y.set(e, r), r;
608
+ const a = Ce({
609
+ themes: [T(t.codeThemes.light), T(t.codeThemes.dark)],
595
610
  langs: [],
596
- engine: ye()
611
+ engine: ke()
597
612
  }).then((n) => ({ highlighter: n, loadedInputs: /* @__PURE__ */ new Set(), loadChain: Promise.resolve() })).catch((n) => {
598
- throw y.get(e) === r && y.delete(e), n;
613
+ throw y.get(e) === a && y.delete(e), n;
599
614
  });
600
- return ct(e, r);
615
+ return ut(e, a);
601
616
  }
602
- async function mt(t, e) {
603
- const r = await (typeof t == "function" ? t() : t), n = typeof r == "object" && r !== null && "default" in r ? r.default : r, o = (Array.isArray(n) ? n : [n]).map((i) => ({
617
+ async function gt(t, e) {
618
+ const a = await (typeof t == "function" ? t() : t), n = typeof a == "object" && a !== null && "default" in a ? a.default : a, o = (Array.isArray(n) ? n : [n]).map((i) => ({
604
619
  ...i,
605
620
  aliases: i.aliases ? [...i.aliases] : void 0
606
621
  })), l = o.find(
@@ -608,32 +623,32 @@ async function mt(t, e) {
608
623
  ) ?? o.at(-1);
609
624
  return l && l.name !== e && !l.aliases?.includes(e) && (l.aliases = [...l.aliases ?? [], e]), o;
610
625
  }
611
- function I(t, e) {
612
- const a = e.codeLanguages[t];
613
- if (a)
626
+ function j(t, e) {
627
+ const r = e.codeLanguages[t];
628
+ if (r)
614
629
  return {
615
630
  key: `custom:${t}`,
616
- input: () => mt(a, t)
631
+ input: () => gt(r, t)
617
632
  };
618
- const r = nt[t];
619
- if (r)
620
- return { key: `builtin:${r}`, input: rt[r] };
633
+ const a = lt[t];
634
+ if (a)
635
+ return { key: `builtin:${a}`, input: st[a] };
621
636
  }
622
- function ut(t, e, a) {
637
+ function ht(t, e, r) {
623
638
  if (!(t.length === 0 || e.unknownLanguage === "plain-text")) {
624
639
  if (e.unknownLanguage === "error")
625
640
  throw new Error(
626
641
  `Unsupported Markdown code language${t.length > 1 ? "s" : ""}: ${t.join(", ")}`
627
642
  );
628
- for (const r of t)
629
- a.has(r) || (a.add(r), console.warn(
630
- `[canofold/markdown] Unsupported code language "${r}"; rendering it as ${e.fallbackLanguage}.`
643
+ for (const a of t)
644
+ r.has(a) || (r.add(a), console.warn(
645
+ `[canofold/markdown] Unsupported code language "${a}"; rendering it as ${e.fallbackLanguage}.`
631
646
  ));
632
647
  }
633
648
  }
634
- async function ft(t, e, a, r) {
635
- const o = [.../* @__PURE__ */ new Set([...e, a.fallbackLanguage])].map((s) => s.trim().toLowerCase()).filter((s) => s && !ot.has(s)).map((s) => ({ language: s, resolved: I(s, a) })), l = o.filter((s) => !s.resolved).map((s) => s.language);
636
- ut(l, a, r);
649
+ async function yt(t, e, r, a) {
650
+ const o = [.../* @__PURE__ */ new Set([...e, r.fallbackLanguage])].map((s) => s.trim().toLowerCase()).filter((s) => s && !ct.has(s)).map((s) => ({ language: s, resolved: j(s, r) })), l = o.filter((s) => !s.resolved).map((s) => s.language);
651
+ ht(l, r, a);
637
652
  const i = o.flatMap((s) => !s.resolved || t.loadedInputs.has(s.resolved.key) ? [] : [s.resolved]);
638
653
  if (i.length === 0) return;
639
654
  const c = t.loadChain.then(async () => {
@@ -643,24 +658,24 @@ async function ft(t, e, a, r) {
643
658
  t.loadChain = c.catch(() => {
644
659
  }), await c;
645
660
  }
646
- async function gt(t, e, a = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
647
- const n = await pt(e);
648
- await ft(n, t, e, a);
649
- const o = I(e.fallbackLanguage, e) ? e.fallbackLanguage : "text";
661
+ async function Ct(t, e, r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set()) {
662
+ const n = await dt(e);
663
+ await yt(n, t, e, r);
664
+ const o = j(e.fallbackLanguage, e) ? e.fallbackLanguage : "text";
650
665
  return () => {
651
- const l = ce(n.highlighter, {
666
+ const l = me(n.highlighter, {
652
667
  themes: e.codeThemes,
653
668
  addLanguageClass: !0,
654
669
  fallbackLanguage: o,
655
670
  transformers: [
656
- tt(),
657
- at(),
658
- pe(),
659
- me(),
660
- ue(),
671
+ ot(),
672
+ it(),
661
673
  fe(),
674
+ ue(),
675
+ de(),
662
676
  ge(),
663
- de()
677
+ he(),
678
+ ye()
664
679
  ]
665
680
  });
666
681
  return async (c, s) => {
@@ -669,14 +684,14 @@ async function gt(t, e, a = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new S
669
684
  if (u.tagName !== "pre") return;
670
685
  const m = u.children.find(
671
686
  (f) => f.type === "element" && f.tagName === "code"
672
- ), g = m?.properties.className;
673
- if (!m || !Array.isArray(g)) return;
674
- const d = g.find(
687
+ ), d = m?.properties.className;
688
+ if (!m || !Array.isArray(d)) return;
689
+ const g = d.find(
675
690
  (f) => typeof f == "string" && f.startsWith("language-")
676
691
  );
677
- if (typeof d != "string") return;
678
- const k = d.slice(9).toLowerCase();
679
- r.has(k) && (p.push({ code: m, className: [...g] }), m.properties.className = g.filter((f) => f !== d));
692
+ if (typeof g != "string") return;
693
+ const C = g.slice(9).toLowerCase();
694
+ a.has(C) && (p.push({ code: m, className: [...d] }), m.properties.className = d.filter((f) => f !== g));
680
695
  });
681
696
  try {
682
697
  const u = await l(c, s, () => {
@@ -689,78 +704,78 @@ async function gt(t, e, a = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new S
689
704
  };
690
705
  };
691
706
  }
692
- const dt = /* @__PURE__ */ new Set(["text", "plaintext", "txt", "plain"]), ht = /* @__PURE__ */ new Set(["terminal"]);
693
- function yt(t, e) {
694
- let a = 0, r = 0;
695
- for (; a < t.length && r < e; ) {
696
- if (t[a] === " ") r += 1;
697
- else if (t[a] === " ") r += 4 - r % 4;
707
+ const kt = /* @__PURE__ */ new Set(["text", "plaintext", "txt", "plain"]), bt = /* @__PURE__ */ new Set(["terminal"]);
708
+ function vt(t, e) {
709
+ let r = 0, a = 0;
710
+ for (; r < t.length && a < e; ) {
711
+ if (t[r] === " ") a += 1;
712
+ else if (t[r] === " ") a += 4 - a % 4;
698
713
  else break;
699
- a += 1;
714
+ r += 1;
700
715
  }
701
- return r >= e ? t.slice(a) : void 0;
716
+ return a >= e ? t.slice(r) : void 0;
702
717
  }
703
- function kt(t, e) {
704
- let a = t;
718
+ function wt(t, e) {
719
+ let r = t;
705
720
  for (; ; ) {
706
- const l = a.match(/^ {0,3}>[ \t]?/);
721
+ const l = r.match(/^ {0,3}>[ \t]?/);
707
722
  if (!l) break;
708
- a = a.slice(l[0].length);
723
+ r = r.slice(l[0].length);
709
724
  }
710
- const r = e.listIndent > 0 ? yt(a, e.listIndent) : void 0, n = r ?? a, o = n.match(/^ {0,3}(?:[-+*]|\d{1,9}[.)])([ \t]+)(.*)$/);
725
+ const a = e.listIndent > 0 ? vt(r, e.listIndent) : void 0, n = a ?? r, o = n.match(/^ {0,3}(?:[-+*]|\d{1,9}[.)])([ \t]+)(.*)$/);
711
726
  if (o) {
712
727
  const l = o[2] ?? "";
713
- return e.listIndent = (r === void 0 ? 0 : e.listIndent) + n.length - l.length, l;
728
+ return e.listIndent = (a === void 0 ? 0 : e.listIndent) + n.length - l.length, l;
714
729
  }
715
- return r !== void 0 || a.trim() === "" ? n : (e.listIndent = 0, a);
730
+ return a !== void 0 || r.trim() === "" ? n : (e.listIndent = 0, r);
716
731
  }
717
- function Ct(t) {
732
+ function Lt(t) {
718
733
  const e = t.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
719
734
  if (!e?.[1]) return;
720
- const a = e[1][0], r = e[2]?.trim() ?? "";
721
- if (!(a === "`" && r.includes("`")))
735
+ const r = e[1][0], a = e[2]?.trim() ?? "";
736
+ if (!(r === "`" && a.includes("`")))
722
737
  return {
723
- marker: a,
738
+ marker: r,
724
739
  size: e[1].length,
725
- language: r.split(/\s+/, 1)[0]?.toLowerCase() || "text"
740
+ language: a.split(/\s+/, 1)[0]?.toLowerCase() || "text"
726
741
  };
727
742
  }
728
- function bt(t, e) {
729
- const a = t.match(/^ {0,3}(`+|~+)[ \t]*$/);
730
- return a?.[1]?.[0] === e.marker && a[1].length >= e.size;
743
+ function Nt(t, e) {
744
+ const r = t.match(/^ {0,3}(`+|~+)[ \t]*$/);
745
+ return r?.[1]?.[0] === e.marker && r[1].length >= e.size;
731
746
  }
732
- function vt(t, e = /* @__PURE__ */ new Set()) {
747
+ function St(t, e = /* @__PURE__ */ new Set()) {
733
748
  if (t === void 0) return { highlightedCode: !0, codeLanguages: [] };
734
- const a = /* @__PURE__ */ new Set();
735
- let r;
749
+ const r = /* @__PURE__ */ new Set();
750
+ let a;
736
751
  const n = { listIndent: 0 };
737
752
  for (const l of t.split(/\r?\n/)) {
738
- const i = kt(l, n);
739
- if (r) {
740
- bt(i, r) && (r = void 0);
753
+ const i = wt(l, n);
754
+ if (a) {
755
+ Nt(i, a) && (a = void 0);
741
756
  continue;
742
757
  }
743
- const c = Ct(i);
758
+ const c = Lt(i);
744
759
  if (!c) continue;
745
- r = c;
760
+ a = c;
746
761
  const { language: s } = c;
747
- !ht.has(s) && !dt.has(s) && !e.has(s) && a.add(s);
762
+ !bt.has(s) && !kt.has(s) && !e.has(s) && r.add(s);
748
763
  }
749
- const o = [...a];
764
+ const o = [...r];
750
765
  return { highlightedCode: o.length > 0, codeLanguages: o };
751
766
  }
752
767
  const v = "dataCfCompilerBoundary";
753
- function wt(t) {
768
+ function xt(t) {
754
769
  const e = t.className;
755
770
  return Array.isArray(e) ? e.map(String) : typeof e == "string" ? e.split(/\s+/) : [];
756
771
  }
757
- function Lt(t) {
772
+ function Ft(t) {
758
773
  const e = t.properties ?? {};
759
- return e.id !== void 0 || e.name !== void 0 || Object.keys(e).some((a) => a.startsWith("dataCf")) || wt(e).some((a) => a.startsWith("cf-"));
774
+ return e.id !== void 0 || e.name !== void 0 || Object.keys(e).some((r) => r.startsWith("dataCf")) || xt(e).some((r) => r.startsWith("cf-"));
760
775
  }
761
- function Nt(t) {
762
- const e = `cf-${globalThis.crypto.randomUUID()}-`, a = /* @__PURE__ */ new Map();
763
- let r = 0;
776
+ function Bt(t) {
777
+ const e = `cf-${globalThis.crypto.randomUUID()}-`, r = /* @__PURE__ */ new Map();
778
+ let a = 0;
764
779
  const n = new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\d+$`), o = {
765
780
  ...t,
766
781
  attributes: {
@@ -770,9 +785,9 @@ function Nt(t) {
770
785
  };
771
786
  return { mark: () => (s) => {
772
787
  h(s, "element", (p) => {
773
- if (!Lt(p)) return;
774
- const u = `${e}${r++}`;
775
- a.set(u, {
788
+ if (!Ft(p)) return;
789
+ const u = `${e}${a++}`;
790
+ r.set(u, {
776
791
  tagName: p.tagName,
777
792
  properties: { ...p.properties }
778
793
  }), p.properties = { ...p.properties, [v]: u };
@@ -780,78 +795,78 @@ function Nt(t) {
780
795
  }, protect: () => (s) => {
781
796
  h(s, "element", (p) => {
782
797
  const u = p.properties?.[v];
783
- typeof u != "string" || !a.has(u) || (p.tagName = "div", p.properties = { [v]: u });
798
+ typeof u != "string" || !r.has(u) || (p.tagName = "div", p.properties = { [v]: u });
784
799
  });
785
800
  }, restore: () => (s) => {
786
801
  h(s, "element", (p) => {
787
802
  const u = p.properties?.[v];
788
803
  if (typeof u != "string") return;
789
- const m = a.get(u);
790
- m && (p.tagName = m.tagName, p.properties = m.properties, a.delete(u));
804
+ const m = r.get(u);
805
+ m && (p.tagName = m.tagName, p.properties = m.properties, r.delete(u));
791
806
  });
792
807
  }, schema: o };
793
808
  }
794
- function St({
809
+ function Pt({
795
810
  assets: t,
796
811
  options: e,
797
- rehypeRaw: a,
798
- rehypeSanitize: r,
812
+ rehypeRaw: r,
813
+ rehypeSanitize: a,
799
814
  sanitizeSchema: n,
800
815
  syntax: o,
801
816
  syntaxHighlighter: l
802
817
  }) {
803
- const i = e.htmlPolicy !== "strip", c = et("markdown", t, e, o, l), s = H().use(D).use(c.remarkPlugins).use(j, {
818
+ const i = e.htmlPolicy !== "strip", c = nt("markdown", t, e, o, l), s = z().use(O).use(c.remarkPlugins).use(H, {
804
819
  allowDangerousHtml: i,
805
820
  handlers: c.handlers
806
821
  });
807
- if (e.htmlPolicy === "sanitize" && a && r && n) {
808
- const p = Nt(n);
809
- s.use(p.mark).use(a).use(p.protect).use(r, p.schema).use(p.restore);
810
- } else i && a && s.use(a);
822
+ if (e.htmlPolicy === "sanitize" && r && a && n) {
823
+ const p = Bt(n);
824
+ s.use(p.mark).use(r).use(p.protect).use(a, p.schema).use(p.restore);
825
+ } else i && r && s.use(r);
811
826
  return s.use(c.rehypePlugins);
812
827
  }
813
- async function xt(t, e, a = { warnedLanguages: /* @__PURE__ */ new Set() }) {
814
- const r = te(), n = De(e), o = ie(n.plugins, { source: t, mode: "markdown" }), l = se(o), i = { ...n, plugins: o }, c = vt(t, l), s = [
828
+ async function At(t, e, r = { warnedLanguages: /* @__PURE__ */ new Set() }) {
829
+ const a = ce(), n = Oe(e), o = ie(n.plugins, { source: t, mode: "markdown" }), l = se(o), i = { ...n, plugins: o }, c = St(t, l), s = [
815
830
  .../* @__PURE__ */ new Set([...c.codeLanguages, ...le(o)])
816
831
  ], p = {
817
832
  highlightedCode: s.length > 0,
818
833
  codeLanguages: s
819
834
  };
820
- o.forEach((M) => r.markPluginAssets(M));
821
- const [u, m, g] = await Promise.all([
835
+ o.forEach((k) => a.markPluginAssets(k));
836
+ const [u, m, d] = await Promise.all([
822
837
  i.htmlPolicy !== "strip" ? import("rehype-raw") : void 0,
823
838
  i.htmlPolicy === "sanitize" ? import("rehype-sanitize") : void 0,
824
- p.highlightedCode ? gt(
839
+ p.highlightedCode ? Ct(
825
840
  p.codeLanguages,
826
841
  i,
827
- a.warnedLanguages,
842
+ r.warnedLanguages,
828
843
  l
829
844
  ) : void 0
830
- ]), d = u?.default, k = m?.default, f = St({
831
- assets: r,
845
+ ]), g = u?.default, C = m?.default, f = Pt({
846
+ assets: a,
832
847
  options: i,
833
- rehypeRaw: d,
834
- rehypeSanitize: k,
848
+ rehypeRaw: g,
849
+ rehypeSanitize: C,
835
850
  sanitizeSchema: m?.defaultSchema,
836
851
  syntax: p,
837
- syntaxHighlighter: g
838
- }), C = f.parse(ee(t));
852
+ syntaxHighlighter: d
853
+ }), w = f.parse(re(t));
839
854
  return {
840
- document: await f.run(C, {
855
+ document: await f.run(w, {
841
856
  data: { canofoldLocale: e?.locale?.trim() || void 0 }
842
857
  }),
843
- assets: r.snapshot()
858
+ assets: a.snapshot()
844
859
  };
845
860
  }
846
- const qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
861
+ const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
847
862
  __proto__: null,
848
- prepareMarkdown: xt
863
+ prepareMarkdown: At
849
864
  }, Symbol.toStringTag, { value: "Module" }));
850
865
  export {
851
- et as a,
852
- qt as b,
853
- gt as c,
854
- vt as d,
855
- De as n,
856
- xt as p
866
+ nt as a,
867
+ Xt as b,
868
+ Ct as c,
869
+ St as d,
870
+ Oe as n,
871
+ At as p
857
872
  };