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