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