@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.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/ImageGallery-Bcpjlfh9.js +569 -0
- package/dist/Markdown-607_slPB.js +117 -0
- package/dist/assets-CqlggKr8.js +77 -0
- package/dist/base.css +1 -1
- package/dist/client/bundler.js +308 -0
- package/dist/client/chunks/{client-kVNIqHQd.js → client-CHUUETWE.js} +3 -3
- package/dist/client/chunks/{gallery-BTg1qJjd.js → gallery-Cr0TgC1h.js} +2 -2
- package/dist/client/chunks/{image-BuMCsr5L.js → image-6_o7fPkU.js} +3 -3
- package/dist/client/chunks/provider-k1N-5njv.js +1037 -0
- package/dist/client/chunks/react-runtime-DRPMrVPX.js +12062 -0
- package/dist/client/chunks/{serialized-T1PzI4rG.js → serialized-Chn9ydGA.js} +270 -220
- package/dist/client/chunks/{table-JOSJsHgy.js → table-D99-Zhc8.js} +3 -3
- package/dist/client/index.js +1 -1
- package/dist/compiler/fenceMetadata.d.ts +7 -0
- package/dist/compiler/normalizeOptions.d.ts +2 -1
- package/dist/compiler/plugins/code.d.ts +1 -1
- package/dist/compiler/prepareMarkdown.d.ts +1 -1
- package/dist/compiler/types.d.ts +3 -0
- package/dist/componentMap-CKSUGzQH.js +1483 -0
- package/dist/components/blocks/MarkdownCodeBlock.d.ts +3 -1
- package/dist/copyText-C0ZgrMnH.js +18 -0
- package/dist/{directiveValidation-BdVbgcY_.js → directiveValidation-B7LY-R5p.js} +187 -248
- package/dist/fileKinds-BPzIxbaS.js +170 -0
- package/dist/gallery-BqQ-i0TC.js +42 -0
- package/dist/image-CiPni6Az.js +38 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/plugins-CXYBB-oH.js +130 -0
- package/dist/{prepareMarkdown-D-bFl1_V.js → prepareMarkdown-CS6sALIb.js} +344 -329
- package/dist/provider-BJDHf4Z_.js +8 -0
- package/dist/serialized-DFiNQYA5.js +39 -0
- package/dist/server/analyze.js +11 -11
- package/dist/server.js +30 -28
- package/dist/table-DQSeLjVL.js +32 -0
- package/package.json +14 -9
- package/dist/Markdown-C7O01MRv.js +0 -2116
- package/dist/client/chunks/provider-DNSHvvN7.js +0 -841
- package/dist/client/chunks/react-runtime-Dzgdzn6D.js +0 -10571
- package/dist/plugins-StkCS2su.js +0 -298
|
@@ -1,57 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { unified as
|
|
4
|
-
import
|
|
5
|
-
import { remarkDefinitionList as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
|
10
|
-
import {
|
|
11
|
-
import { n as ne, m as oe, s as
|
|
12
|
-
import ce from "
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
39
|
+
function je(t) {
|
|
38
40
|
if (!t) return {};
|
|
39
41
|
const e = Object.entries(t);
|
|
40
42
|
return e.every(
|
|
41
|
-
([
|
|
43
|
+
([a]) => a.length > 0 && a === a.trim().toLowerCase()
|
|
42
44
|
) ? t : Object.fromEntries(
|
|
43
|
-
e.map(([
|
|
45
|
+
e.map(([a, n]) => [a.trim().toLowerCase(), n]).filter(([a]) => a.length > 0)
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
|
-
function
|
|
48
|
+
function Oe(t = {}) {
|
|
47
49
|
return {
|
|
48
50
|
htmlPolicy: t.html ?? "strip",
|
|
49
51
|
codeThemes: {
|
|
50
|
-
light: t.code?.themes?.light ??
|
|
51
|
-
dark: t.code?.themes?.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
|
-
|
|
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
|
-
...
|
|
70
|
+
...pe,
|
|
68
71
|
...t.labels
|
|
69
72
|
},
|
|
70
73
|
plugins: ne(t.plugins)
|
|
71
74
|
};
|
|
72
75
|
}
|
|
73
|
-
|
|
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
|
|
87
|
+
function $(t, e) {
|
|
77
88
|
if (!t || typeof t != "object" || !("properties" in t)) return !1;
|
|
78
|
-
const
|
|
79
|
-
return
|
|
89
|
+
const r = t.properties;
|
|
90
|
+
return r?.dataCfComponent === e || r?.["data-cf-component"] === e;
|
|
80
91
|
}
|
|
81
|
-
function
|
|
92
|
+
function _e(t, e) {
|
|
82
93
|
if (t.type !== "mdxJsxFlowElement" && t.type !== "mdxJsxTextElement") return !1;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
94
|
+
const r = Ge(t.name);
|
|
95
|
+
if (r === "terminal")
|
|
85
96
|
return e.markBehavior("terminal-toolbar"), !0;
|
|
86
|
-
if (
|
|
87
|
-
else if (
|
|
88
|
-
else if (
|
|
89
|
-
else if (
|
|
90
|
-
else if (
|
|
91
|
-
else if (
|
|
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
|
|
96
|
-
h(e, (
|
|
97
|
-
|
|
106
|
+
const Re = (t) => (e) => {
|
|
107
|
+
h(e, (r) => {
|
|
108
|
+
_e(r, t);
|
|
98
109
|
});
|
|
99
|
-
},
|
|
100
|
-
h(e, "code", (
|
|
101
|
-
const
|
|
102
|
-
!n && !l && !i || (
|
|
103
|
-
...
|
|
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
|
-
...
|
|
116
|
+
...r.data?.hProperties,
|
|
106
117
|
...n ? { metastring: n } : {},
|
|
107
|
-
...
|
|
108
|
-
...
|
|
118
|
+
...o ? { title: o, dataCfFilename: o } : {},
|
|
119
|
+
...l ? { dataCfCodeOverflow: l } : {},
|
|
120
|
+
...i ? { title: o || t.labels.terminalTitle } : {}
|
|
109
121
|
}
|
|
110
122
|
});
|
|
111
123
|
});
|
|
112
|
-
},
|
|
124
|
+
}, Ue = () => (t) => {
|
|
113
125
|
h(t, "element", (e) => {
|
|
114
126
|
if (e.tagName !== "pre") return;
|
|
115
|
-
const
|
|
127
|
+
const r = e.children.find(
|
|
116
128
|
(n) => n.type === "element" && n.tagName === "code"
|
|
117
|
-
),
|
|
118
|
-
|
|
129
|
+
), a = String(
|
|
130
|
+
r?.properties?.dataCfFilename ?? r?.properties?.["data-cf-filename"] ?? r?.properties?.title ?? r?.properties?.["data-title"] ?? ""
|
|
119
131
|
).trim();
|
|
120
|
-
|
|
132
|
+
a && (e.properties = { ...e.properties, dataCfFilename: a });
|
|
121
133
|
});
|
|
122
134
|
};
|
|
123
|
-
function
|
|
124
|
-
return { type: "element", tagName: t, properties: e, children:
|
|
135
|
+
function I(t, e = {}, r = []) {
|
|
136
|
+
return { type: "element", tagName: t, properties: e, children: r };
|
|
125
137
|
}
|
|
126
|
-
function
|
|
127
|
-
return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((e) =>
|
|
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
|
|
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
|
|
145
|
+
function M(t) {
|
|
134
146
|
return t ? t.children.filter(
|
|
135
|
-
(e) => e.type === "element" && e.tagName === "span" &&
|
|
147
|
+
(e) => e.type === "element" && e.tagName === "span" && We(e).includes("line")
|
|
136
148
|
) : [];
|
|
137
149
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
return
|
|
141
|
-
`) :
|
|
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
|
|
144
|
-
!t ||
|
|
145
|
-
`).map((
|
|
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
|
|
148
|
-
const e = t?.properties.className ?? t?.properties.class,
|
|
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
|
|
163
|
+
return typeof a == "string" ? a.slice(9).toLowerCase() : "";
|
|
152
164
|
}
|
|
153
|
-
const
|
|
154
|
-
h(
|
|
155
|
-
if (
|
|
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 =
|
|
169
|
+
const l = a.children.find(
|
|
158
170
|
(s) => s.type === "element" && s.tagName === "code"
|
|
159
|
-
), i =
|
|
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] =
|
|
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
|
|
185
|
+
function L(t, e) {
|
|
174
186
|
return { type: "mdxJsxAttribute", name: t, value: e };
|
|
175
187
|
}
|
|
176
|
-
const
|
|
177
|
-
h(
|
|
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(
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
},
|
|
194
|
-
h(
|
|
195
|
-
if (n.tagName !== "pre" || !l || o === void 0 ||
|
|
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
|
-
(
|
|
200
|
-
), c =
|
|
201
|
-
if (c &&
|
|
202
|
-
const s = i?.properties?.className ?? i?.properties?.class, u = (Array.isArray(s) ? s : typeof s == "string" ? s.split(/\s+/) : []).find((
|
|
203
|
-
n.properties?.dataCfFilename ?? n.properties?.["data-cf-filename"] ??
|
|
204
|
-
).trim(),
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
...
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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] =
|
|
237
|
+
return l.children[o] = x, [b];
|
|
223
238
|
});
|
|
224
239
|
};
|
|
225
|
-
function
|
|
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
|
|
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
|
|
254
|
+
function Qe(t) {
|
|
240
255
|
if (typeof t != "string" || !t.trim()) return;
|
|
241
|
-
const e = t.trim(),
|
|
242
|
-
if (
|
|
243
|
-
let
|
|
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
|
-
(
|
|
260
|
+
(r || e.startsWith("//")) && (a = new URL(e.startsWith("//") ? `https:${e}` : e).pathname);
|
|
246
261
|
} catch {
|
|
247
262
|
return;
|
|
248
263
|
}
|
|
249
|
-
const n =
|
|
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 ?
|
|
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
|
|
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
|
|
264
|
-
const
|
|
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
|
|
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
|
-
...
|
|
284
|
+
...a,
|
|
270
285
|
dataCfGalleryLabel: o,
|
|
271
|
-
dataCfCloseLabel:
|
|
272
|
-
dataCfPreviousLabel:
|
|
273
|
-
dataCfNextLabel:
|
|
274
|
-
dataCfThumbnailsLabel:
|
|
275
|
-
dataCfImageLabel:
|
|
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
|
-
...
|
|
280
|
-
dataCfCopyLabel:
|
|
281
|
-
dataCfCopyFailureLabel:
|
|
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
|
|
285
|
-
h(
|
|
299
|
+
const tt = (t, e) => (r) => {
|
|
300
|
+
h(r, "element", (a, n, o) => {
|
|
286
301
|
if (!o || n === void 0) return;
|
|
287
|
-
if (
|
|
288
|
-
|
|
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 (
|
|
292
|
-
|
|
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 (
|
|
297
|
-
const m =
|
|
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
|
-
),
|
|
314
|
+
), g = m.find(
|
|
300
315
|
(f) => f.type === "element" && f.tagName === "figcaption"
|
|
301
316
|
);
|
|
302
|
-
if (
|
|
317
|
+
if (d && m.every(
|
|
303
318
|
(f) => f.type === "element" && (f.tagName === "img" || f.tagName === "figcaption")
|
|
304
319
|
)) {
|
|
305
|
-
const f =
|
|
306
|
-
t.markBehavior("image"),
|
|
307
|
-
...
|
|
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
|
-
},
|
|
329
|
+
}, g && (g.properties = { ...g.properties, dataCfSlot: "caption" });
|
|
315
330
|
return;
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
|
-
if (
|
|
319
|
-
t.markBehavior("details"),
|
|
320
|
-
...
|
|
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 =
|
|
326
|
-
(
|
|
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(
|
|
332
|
-
t.markBehavior("heading"),
|
|
333
|
-
...
|
|
334
|
-
dataCfAnchor: `#${
|
|
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 (
|
|
341
|
-
const i =
|
|
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 =
|
|
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([...
|
|
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
|
|
431
|
+
function rt(t, e) {
|
|
417
432
|
if (!t || typeof t != "object" || !("properties" in t)) return !1;
|
|
418
|
-
const
|
|
419
|
-
return
|
|
433
|
+
const r = t.properties;
|
|
434
|
+
return r?.dataCfComponent === e || r?.["data-cf-component"] === e;
|
|
420
435
|
}
|
|
421
|
-
const
|
|
422
|
-
h(
|
|
423
|
-
if (
|
|
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 = { ...
|
|
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:
|
|
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
|
|
450
|
-
const { features: o } =
|
|
451
|
-
|
|
452
|
-
), i = [
|
|
453
|
-
i.push(
|
|
454
|
-
for (const p of
|
|
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([
|
|
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([
|
|
459
|
-
for (const p of
|
|
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:
|
|
464
|
-
tabItem:
|
|
465
|
-
stepGroup:
|
|
466
|
-
stepItem:
|
|
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
|
|
485
|
+
function ot() {
|
|
471
486
|
return {
|
|
472
487
|
name: "canofold:fence-metadata",
|
|
473
488
|
pre(t) {
|
|
474
|
-
const
|
|
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
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
565
|
-
let
|
|
566
|
-
function
|
|
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 =
|
|
583
|
+
const e = be[t];
|
|
569
584
|
if (!e) throw new Error(`Unknown Shiki theme: ${t}`);
|
|
570
585
|
return e;
|
|
571
586
|
}
|
|
572
|
-
function
|
|
573
|
-
const e =
|
|
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
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
let n =
|
|
579
|
-
return n === void 0 && (n =
|
|
580
|
-
}
|
|
581
|
-
function
|
|
582
|
-
for (y.delete(t), y.set(t, e); y.size >
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
y.delete(
|
|
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
|
|
590
|
-
const e =
|
|
591
|
-
if (
|
|
592
|
-
return y.delete(e), y.set(e,
|
|
593
|
-
const
|
|
594
|
-
themes: [
|
|
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:
|
|
611
|
+
engine: ke()
|
|
597
612
|
}).then((n) => ({ highlighter: n, loadedInputs: /* @__PURE__ */ new Set(), loadChain: Promise.resolve() })).catch((n) => {
|
|
598
|
-
throw y.get(e) ===
|
|
613
|
+
throw y.get(e) === a && y.delete(e), n;
|
|
599
614
|
});
|
|
600
|
-
return
|
|
615
|
+
return ut(e, a);
|
|
601
616
|
}
|
|
602
|
-
async function
|
|
603
|
-
const
|
|
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
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
626
|
+
function j(t, e) {
|
|
627
|
+
const r = e.codeLanguages[t];
|
|
628
|
+
if (r)
|
|
614
629
|
return {
|
|
615
630
|
key: `custom:${t}`,
|
|
616
|
-
input: () =>
|
|
631
|
+
input: () => gt(r, t)
|
|
617
632
|
};
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
return { key: `builtin:${
|
|
633
|
+
const a = lt[t];
|
|
634
|
+
if (a)
|
|
635
|
+
return { key: `builtin:${a}`, input: st[a] };
|
|
621
636
|
}
|
|
622
|
-
function
|
|
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
|
|
629
|
-
|
|
630
|
-
`[canofold/markdown] Unsupported code language "${
|
|
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
|
|
635
|
-
const o = [.../* @__PURE__ */ new Set([...e,
|
|
636
|
-
|
|
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
|
|
647
|
-
const n = await
|
|
648
|
-
await
|
|
649
|
-
const o =
|
|
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 =
|
|
666
|
+
const l = me(n.highlighter, {
|
|
652
667
|
themes: e.codeThemes,
|
|
653
668
|
addLanguageClass: !0,
|
|
654
669
|
fallbackLanguage: o,
|
|
655
670
|
transformers: [
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
pe(),
|
|
659
|
-
me(),
|
|
660
|
-
ue(),
|
|
671
|
+
ot(),
|
|
672
|
+
it(),
|
|
661
673
|
fe(),
|
|
674
|
+
ue(),
|
|
675
|
+
de(),
|
|
662
676
|
ge(),
|
|
663
|
-
|
|
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
|
-
),
|
|
673
|
-
if (!m || !Array.isArray(
|
|
674
|
-
const
|
|
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
|
|
678
|
-
const
|
|
679
|
-
|
|
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
|
|
693
|
-
function
|
|
694
|
-
let
|
|
695
|
-
for (;
|
|
696
|
-
if (t[
|
|
697
|
-
else if (t[
|
|
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
|
-
|
|
714
|
+
r += 1;
|
|
700
715
|
}
|
|
701
|
-
return
|
|
716
|
+
return a >= e ? t.slice(r) : void 0;
|
|
702
717
|
}
|
|
703
|
-
function
|
|
704
|
-
let
|
|
718
|
+
function wt(t, e) {
|
|
719
|
+
let r = t;
|
|
705
720
|
for (; ; ) {
|
|
706
|
-
const l =
|
|
721
|
+
const l = r.match(/^ {0,3}>[ \t]?/);
|
|
707
722
|
if (!l) break;
|
|
708
|
-
|
|
723
|
+
r = r.slice(l[0].length);
|
|
709
724
|
}
|
|
710
|
-
const
|
|
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 = (
|
|
728
|
+
return e.listIndent = (a === void 0 ? 0 : e.listIndent) + n.length - l.length, l;
|
|
714
729
|
}
|
|
715
|
-
return
|
|
730
|
+
return a !== void 0 || r.trim() === "" ? n : (e.listIndent = 0, r);
|
|
716
731
|
}
|
|
717
|
-
function
|
|
732
|
+
function Lt(t) {
|
|
718
733
|
const e = t.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
719
734
|
if (!e?.[1]) return;
|
|
720
|
-
const
|
|
721
|
-
if (!(
|
|
735
|
+
const r = e[1][0], a = e[2]?.trim() ?? "";
|
|
736
|
+
if (!(r === "`" && a.includes("`")))
|
|
722
737
|
return {
|
|
723
|
-
marker:
|
|
738
|
+
marker: r,
|
|
724
739
|
size: e[1].length,
|
|
725
|
-
language:
|
|
740
|
+
language: a.split(/\s+/, 1)[0]?.toLowerCase() || "text"
|
|
726
741
|
};
|
|
727
742
|
}
|
|
728
|
-
function
|
|
729
|
-
const
|
|
730
|
-
return
|
|
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
|
|
747
|
+
function St(t, e = /* @__PURE__ */ new Set()) {
|
|
733
748
|
if (t === void 0) return { highlightedCode: !0, codeLanguages: [] };
|
|
734
|
-
const
|
|
735
|
-
let
|
|
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 =
|
|
739
|
-
if (
|
|
740
|
-
|
|
753
|
+
const i = wt(l, n);
|
|
754
|
+
if (a) {
|
|
755
|
+
Nt(i, a) && (a = void 0);
|
|
741
756
|
continue;
|
|
742
757
|
}
|
|
743
|
-
const c =
|
|
758
|
+
const c = Lt(i);
|
|
744
759
|
if (!c) continue;
|
|
745
|
-
|
|
760
|
+
a = c;
|
|
746
761
|
const { language: s } = c;
|
|
747
|
-
!
|
|
762
|
+
!bt.has(s) && !kt.has(s) && !e.has(s) && r.add(s);
|
|
748
763
|
}
|
|
749
|
-
const o = [...
|
|
764
|
+
const o = [...r];
|
|
750
765
|
return { highlightedCode: o.length > 0, codeLanguages: o };
|
|
751
766
|
}
|
|
752
767
|
const v = "dataCfCompilerBoundary";
|
|
753
|
-
function
|
|
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
|
|
772
|
+
function Ft(t) {
|
|
758
773
|
const e = t.properties ?? {};
|
|
759
|
-
return e.id !== void 0 || e.name !== void 0 || Object.keys(e).some((
|
|
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
|
|
762
|
-
const e = `cf-${globalThis.crypto.randomUUID()}-`,
|
|
763
|
-
let
|
|
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 (!
|
|
774
|
-
const u = `${e}${
|
|
775
|
-
|
|
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" || !
|
|
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 =
|
|
790
|
-
m && (p.tagName = m.tagName, p.properties = m.properties,
|
|
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
|
|
809
|
+
function Pt({
|
|
795
810
|
assets: t,
|
|
796
811
|
options: e,
|
|
797
|
-
rehypeRaw:
|
|
798
|
-
rehypeSanitize:
|
|
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 =
|
|
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" &&
|
|
808
|
-
const p =
|
|
809
|
-
s.use(p.mark).use(
|
|
810
|
-
} else i &&
|
|
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
|
|
814
|
-
const
|
|
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((
|
|
821
|
-
const [u, m,
|
|
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 ?
|
|
839
|
+
p.highlightedCode ? Ct(
|
|
825
840
|
p.codeLanguages,
|
|
826
841
|
i,
|
|
827
|
-
|
|
842
|
+
r.warnedLanguages,
|
|
828
843
|
l
|
|
829
844
|
) : void 0
|
|
830
|
-
]),
|
|
831
|
-
assets:
|
|
845
|
+
]), g = u?.default, C = m?.default, f = Pt({
|
|
846
|
+
assets: a,
|
|
832
847
|
options: i,
|
|
833
|
-
rehypeRaw:
|
|
834
|
-
rehypeSanitize:
|
|
848
|
+
rehypeRaw: g,
|
|
849
|
+
rehypeSanitize: C,
|
|
835
850
|
sanitizeSchema: m?.defaultSchema,
|
|
836
851
|
syntax: p,
|
|
837
|
-
syntaxHighlighter:
|
|
838
|
-
}),
|
|
852
|
+
syntaxHighlighter: d
|
|
853
|
+
}), w = f.parse(re(t));
|
|
839
854
|
return {
|
|
840
|
-
document: await f.run(
|
|
855
|
+
document: await f.run(w, {
|
|
841
856
|
data: { canofoldLocale: e?.locale?.trim() || void 0 }
|
|
842
857
|
}),
|
|
843
|
-
assets:
|
|
858
|
+
assets: a.snapshot()
|
|
844
859
|
};
|
|
845
860
|
}
|
|
846
|
-
const
|
|
861
|
+
const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
847
862
|
__proto__: null,
|
|
848
|
-
prepareMarkdown:
|
|
863
|
+
prepareMarkdown: At
|
|
849
864
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
850
865
|
export {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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
|
};
|