@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,741 +0,0 @@
|
|
|
1
|
-
import { a as z, s as P, e as _, f as j } from "./plugins-DQ-VUuCT.js";
|
|
2
|
-
import { visit as S } from "unist-util-visit";
|
|
3
|
-
function C(t, a, e) {
|
|
4
|
-
const i = t.find((s) => s.id === a.id);
|
|
5
|
-
if (!i) {
|
|
6
|
-
t.push(a);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (P(i) !== P(a))
|
|
10
|
-
throw new Error(`Markdown plugin ${e} id "${a.id}" is declared with conflicting definitions`);
|
|
11
|
-
}
|
|
12
|
-
function $(t, a) {
|
|
13
|
-
const e = [];
|
|
14
|
-
return t.forEach((i) => C(e, i, a)), e;
|
|
15
|
-
}
|
|
16
|
-
function de() {
|
|
17
|
-
const t = {
|
|
18
|
-
behaviors: [],
|
|
19
|
-
math: !1,
|
|
20
|
-
pluginClients: [],
|
|
21
|
-
pluginStyles: []
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
markBehavior(a) {
|
|
25
|
-
t.behaviors.includes(a) || t.behaviors.push(a);
|
|
26
|
-
},
|
|
27
|
-
markMath() {
|
|
28
|
-
t.math = !0;
|
|
29
|
-
},
|
|
30
|
-
markPluginAssets(a) {
|
|
31
|
-
a.assets?.math && (t.math = !0);
|
|
32
|
-
for (const e of a.assets?.clients ?? [])
|
|
33
|
-
C(t.pluginClients, e, "client");
|
|
34
|
-
for (const e of a.assets?.styles ?? [])
|
|
35
|
-
C(t.pluginStyles, e, "style");
|
|
36
|
-
},
|
|
37
|
-
snapshot() {
|
|
38
|
-
return {
|
|
39
|
-
behaviors: [...t.behaviors],
|
|
40
|
-
math: t.math,
|
|
41
|
-
pluginClients: [...t.pluginClients],
|
|
42
|
-
pluginStyles: [...t.pluginStyles]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function fe(t, a = [], e = "markdown") {
|
|
48
|
-
const i = z(a, { source: t, mode: e }), s = /<(?:Markdown)?Gallery\b/i.test(t), n = /:::\s*(?:tabs|code-group)\b|<(?:Markdown)?(?:Tabs|CodeGroup)\b/i.test(t), r = /<(?:Markdown)?FileTree\b/i.test(t), p = /<(?:Markdown)?Details\b/i.test(t), o = /^ {0,3}(?:\|[^\r\n]*\||[^\r\n|]+\|[^\r\n]*)\r?\n {0,3}\|? *:?-+:? *(?:\| *:?-+:? *)+\|? *$/m, c = [];
|
|
49
|
-
return s && c.push("gallery"), n && c.push("tabs"), p && c.push("details"), r && c.push("file-tree"), /<(?:Markdown)?(?:Terminal)\b|(?:`{3,}|~{3,})\s*terminal\b/i.test(t) && c.push("terminal-toolbar"), /<(?:Markdown)?Image\b|!\[[^\]]*\]\([^)]*\)/i.test(t) && c.push("image"), /(?:^|\n)\s*#{2,6}\s+\S/.test(t) && c.push("heading"), /<(?:Markdown)?CodeBlock\b|(?:^|\n)\s*(?:`{3,}|~{3,})(?!\s*terminal\b)/i.test(t) && c.push("code-toolbar"), /<(?:Markdown)?CopySnippet\b|data-df-component=["']copy-snippet["']/i.test(t) && c.push("copy-snippet"), (/<(?:Markdown)?Table\b/i.test(t) || o.test(t)) && c.push("table"), {
|
|
50
|
-
behaviors: [...new Set(c)],
|
|
51
|
-
math: i.some((d) => d.assets?.math),
|
|
52
|
-
pluginClients: $(
|
|
53
|
-
i.flatMap((d) => d.assets?.clients ?? []),
|
|
54
|
-
"client"
|
|
55
|
-
),
|
|
56
|
-
pluginStyles: $(
|
|
57
|
-
i.flatMap((d) => d.assets?.styles ?? []),
|
|
58
|
-
"style"
|
|
59
|
-
)
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const U = /* @__PURE__ */ new Set(["info", "tip", "warning", "danger"]), H = /* @__PURE__ */ new Set(["accent", "success", "warning", "danger"]);
|
|
63
|
-
function N(t) {
|
|
64
|
-
return "value" in t && typeof t.value == "string" ? t.value : "children" in t && Array.isArray(t.children) ? t.children.map((a) => N(a)).join("") : "";
|
|
65
|
-
}
|
|
66
|
-
function I(t) {
|
|
67
|
-
return "children" in t && Array.isArray(t.children);
|
|
68
|
-
}
|
|
69
|
-
function v(t) {
|
|
70
|
-
const a = t.children.find((e) => e.data?.directiveLabel);
|
|
71
|
-
return a ? N(a).trim() : "";
|
|
72
|
-
}
|
|
73
|
-
function x(t) {
|
|
74
|
-
return t.children.filter((a) => !a.data?.directiveLabel);
|
|
75
|
-
}
|
|
76
|
-
function K(t, a) {
|
|
77
|
-
return `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "tab"}-${a + 1}`;
|
|
78
|
-
}
|
|
79
|
-
function q(t, a) {
|
|
80
|
-
return t.replace("{index}", String(a + 1));
|
|
81
|
-
}
|
|
82
|
-
function J(t, a, e) {
|
|
83
|
-
const s = String(t.meta ?? "").match(/(?:title|filename)\s*=\s*["']([^"']+)["']|\[([^\]]+)\]/i), n = s?.[1] ?? s?.[2];
|
|
84
|
-
return n?.trim() ? n.trim() : String(t.lang ?? "").trim() || q(e, a);
|
|
85
|
-
}
|
|
86
|
-
function W(t) {
|
|
87
|
-
return t.replace(/[\\[\]]/g, (a) => `\\${a}`);
|
|
88
|
-
}
|
|
89
|
-
function A(t) {
|
|
90
|
-
return t.attributes ?? {};
|
|
91
|
-
}
|
|
92
|
-
function f(t, a) {
|
|
93
|
-
const e = A(t)[a];
|
|
94
|
-
return typeof e == "string" ? e.trim() : "";
|
|
95
|
-
}
|
|
96
|
-
function X(t) {
|
|
97
|
-
const a = t.children.find((e) => e.data?.directiveLabel);
|
|
98
|
-
if (!(!a || !I(a)))
|
|
99
|
-
return {
|
|
100
|
-
type: "paragraph",
|
|
101
|
-
children: [
|
|
102
|
-
{
|
|
103
|
-
type: "strong",
|
|
104
|
-
children: a.children
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function Z(t) {
|
|
110
|
-
const a = t.children.find((e) => e.data?.directiveLabel);
|
|
111
|
-
if (!(!a || !I(a)))
|
|
112
|
-
return {
|
|
113
|
-
type: "paragraph",
|
|
114
|
-
data: { hName: "summary", hProperties: { dataDfSlot: "summary" } },
|
|
115
|
-
children: a.children
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function y(t, a, e, i = {}) {
|
|
119
|
-
t.data = {
|
|
120
|
-
...t.data,
|
|
121
|
-
hName: a,
|
|
122
|
-
hProperties: {
|
|
123
|
-
...t.data?.hProperties,
|
|
124
|
-
dataDfComponent: e,
|
|
125
|
-
...i
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function M(t, a, e) {
|
|
130
|
-
t.data = {
|
|
131
|
-
...t.data,
|
|
132
|
-
hName: a,
|
|
133
|
-
hProperties: {
|
|
134
|
-
...t.data?.hProperties,
|
|
135
|
-
...e
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const me = () => (t) => {
|
|
140
|
-
S(t, (a) => {
|
|
141
|
-
if (a.type !== "containerDirective" && a.type !== "leafDirective" && a.type !== "textDirective")
|
|
142
|
-
return;
|
|
143
|
-
const e = a;
|
|
144
|
-
if (e.type === "textDirective" && e.name === "badge") {
|
|
145
|
-
const n = f(e, "tone").toLowerCase();
|
|
146
|
-
y(e, "span", "badge", {
|
|
147
|
-
className: n && H.has(n) ? [`df-badge-${n}`] : []
|
|
148
|
-
});
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (e.type === "textDirective" && e.name === "copy") {
|
|
152
|
-
y(e, "span", "copy-snippet", { dataDfValue: N(e).trim() });
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (e.type === "leafDirective" && (e.name === "audio" || e.name === "video")) {
|
|
156
|
-
const n = N(e).trim(), r = f(e, "preload");
|
|
157
|
-
M(e, e.name, {
|
|
158
|
-
src: f(e, "src"),
|
|
159
|
-
controls: !0,
|
|
160
|
-
preload: r || (e.name === "video" ? "metadata" : "none"),
|
|
161
|
-
title: n,
|
|
162
|
-
ariaLabel: n,
|
|
163
|
-
dataDfElement: e.name,
|
|
164
|
-
...e.name === "video" && f(e, "poster") ? { poster: f(e, "poster") } : {}
|
|
165
|
-
});
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (e.type === "leafDirective" && e.name === "embed") {
|
|
169
|
-
const n = N(e).trim(), r = A(e);
|
|
170
|
-
M(e, "iframe", {
|
|
171
|
-
src: f(e, "src"),
|
|
172
|
-
title: n,
|
|
173
|
-
loading: f(e, "loading") || "lazy",
|
|
174
|
-
sandbox: f(e, "sandbox").split(/\s+/).filter(Boolean),
|
|
175
|
-
referrerPolicy: f(e, "referrerpolicy") || "no-referrer",
|
|
176
|
-
dataDfElement: "embed",
|
|
177
|
-
...f(e, "allow") ? { allow: f(e, "allow") } : {},
|
|
178
|
-
...Object.hasOwn(r, "allowfullscreen") ? { allowFullScreen: !0 } : {}
|
|
179
|
-
});
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (e.type !== "containerDirective") return;
|
|
183
|
-
const i = X(e), s = x(e);
|
|
184
|
-
if (e.name === "details") {
|
|
185
|
-
const n = Z(e);
|
|
186
|
-
y(e, "details", "details", {
|
|
187
|
-
...Object.hasOwn(A(e), "open") ? { open: !0 } : {}
|
|
188
|
-
}), e.children = [...n ? [n] : [], ...s];
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
if (e.name === "aside") {
|
|
192
|
-
y(e, "aside", "aside"), e.children = [...i ? [i] : [], ...s];
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (e.name === "file-tree") {
|
|
196
|
-
y(e, "div", "file-tree"), e.children = s;
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (e.name === "gallery") {
|
|
200
|
-
y(e, "div", "gallery", {
|
|
201
|
-
...v(e) ? { dataDfGalleryLabel: v(e) } : {}
|
|
202
|
-
}), e.children = s;
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (e.name === "card-grid") {
|
|
206
|
-
y(e, "div", "card-grid"), e.children = s;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (e.name === "card") {
|
|
210
|
-
const n = f(e, "href");
|
|
211
|
-
if (!n) return;
|
|
212
|
-
e.data = {
|
|
213
|
-
...e.data,
|
|
214
|
-
hName: "a",
|
|
215
|
-
hProperties: {
|
|
216
|
-
...e.data?.hProperties,
|
|
217
|
-
className: ["df-link-card"],
|
|
218
|
-
href: n,
|
|
219
|
-
dataDfSlot: "card"
|
|
220
|
-
}
|
|
221
|
-
}, e.children = [...i ? [i] : [], ...s];
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (e.name === "api") {
|
|
225
|
-
y(e, "section", "api", {
|
|
226
|
-
dataDfApiMethod: f(e, "method").toUpperCase(),
|
|
227
|
-
dataDfApiPath: f(e, "path")
|
|
228
|
-
}), e.children = s;
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
e.name === "response" && (e.data = {
|
|
232
|
-
...e.data,
|
|
233
|
-
hName: "div",
|
|
234
|
-
hProperties: {
|
|
235
|
-
...e.data?.hProperties,
|
|
236
|
-
dataDfApiResponse: v(e)
|
|
237
|
-
}
|
|
238
|
-
}, e.children = s);
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
function g(t, a = {}, e = []) {
|
|
242
|
-
return { type: "element", tagName: t, properties: a, children: e };
|
|
243
|
-
}
|
|
244
|
-
function F(t) {
|
|
245
|
-
return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((a) => F(a)).join("") : "" : "";
|
|
246
|
-
}
|
|
247
|
-
function Q(t) {
|
|
248
|
-
const a = t.properties.className ?? t.properties.class;
|
|
249
|
-
return Array.isArray(a) ? a.map(String) : typeof a == "string" ? a.split(/\s+/) : [];
|
|
250
|
-
}
|
|
251
|
-
function Y(t, a) {
|
|
252
|
-
t.properties = {
|
|
253
|
-
...t.properties,
|
|
254
|
-
className: [.../* @__PURE__ */ new Set([...Q(t), a])]
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
function B(t) {
|
|
258
|
-
if (t.tagName === "ul")
|
|
259
|
-
for (const a of t.children) {
|
|
260
|
-
if (a.type !== "element" || a.tagName !== "li") continue;
|
|
261
|
-
const e = a.children.find(
|
|
262
|
-
(s) => s.type === "element" && s.tagName === "ul"
|
|
263
|
-
), i = F({
|
|
264
|
-
type: "root",
|
|
265
|
-
children: a.children.filter((s) => s !== e)
|
|
266
|
-
}).trim();
|
|
267
|
-
e ? (B(e), a.properties = { ...a.properties, dataDfFileTreeBranch: "" }, a.children = [
|
|
268
|
-
g("button", { type: "button", ariaExpanded: "true" }, [
|
|
269
|
-
{ type: "text", value: i.replace(/\/$/, "") }
|
|
270
|
-
]),
|
|
271
|
-
e
|
|
272
|
-
]) : (a.properties = { ...a.properties, dataDfFileTreeFile: "" }, a.children = [{ type: "text", value: i }]);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function ee(t) {
|
|
276
|
-
const a = t.children.find(
|
|
277
|
-
(e) => e.type === "element" && e.tagName === "ul"
|
|
278
|
-
);
|
|
279
|
-
a && B(a);
|
|
280
|
-
}
|
|
281
|
-
function te(t) {
|
|
282
|
-
t.children = t.children.flatMap((a) => {
|
|
283
|
-
if (a.type !== "element" || a.tagName !== "p") return [a];
|
|
284
|
-
if (!a.children.every(
|
|
285
|
-
(n) => n.type === "element" && n.tagName === "img" || n.type === "text" && n.value.trim() === ""
|
|
286
|
-
)) return [a];
|
|
287
|
-
const i = a.children.find(
|
|
288
|
-
(n) => n.type === "element" && n.tagName === "img"
|
|
289
|
-
);
|
|
290
|
-
if (!i) return [a];
|
|
291
|
-
const s = typeof i.properties.title == "string" ? i.properties.title.trim() : "";
|
|
292
|
-
return [
|
|
293
|
-
g("figure", {}, [
|
|
294
|
-
i,
|
|
295
|
-
...s ? [g("figcaption", {}, [{ type: "text", value: s }])] : []
|
|
296
|
-
])
|
|
297
|
-
];
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
function ae(t) {
|
|
301
|
-
return t.split(/(:[A-Za-z0-9_-]+)/g).filter(Boolean).map(
|
|
302
|
-
(e) => e.startsWith(":") ? g("span", { className: ["df-api-path-param"] }, [{ type: "text", value: e }]) : { type: "text", value: e }
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
function re(t) {
|
|
306
|
-
const a = Number.parseInt(t, 10);
|
|
307
|
-
return a >= 200 && a < 300 ? "df-badge-success" : a >= 400 ? "df-badge-danger" : "";
|
|
308
|
-
}
|
|
309
|
-
function ie(t) {
|
|
310
|
-
const a = String(t.properties.dataDfApiMethod ?? "").trim(), e = String(t.properties.dataDfApiPath ?? "").trim();
|
|
311
|
-
delete t.properties.dataDfApiMethod, delete t.properties.dataDfApiPath;
|
|
312
|
-
const i = [];
|
|
313
|
-
(a || e) && i.push(
|
|
314
|
-
g("div", { className: ["df-api-endpoint"] }, [
|
|
315
|
-
...a ? [g("span", { className: ["df-api-method"] }, [{ type: "text", value: a }])] : [],
|
|
316
|
-
...e ? [g("span", {}, ae(e))] : []
|
|
317
|
-
])
|
|
318
|
-
);
|
|
319
|
-
for (const s of t.children) {
|
|
320
|
-
if (s.type !== "element") {
|
|
321
|
-
i.push(s);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
const n = String(s.properties.dataDfApiResponse ?? "").trim();
|
|
325
|
-
if (n) {
|
|
326
|
-
delete s.properties.dataDfApiResponse, Y(s, "df-api-response");
|
|
327
|
-
const r = re(n);
|
|
328
|
-
s.children.unshift(
|
|
329
|
-
g("span", { className: ["df-badge", ...r ? [r] : []], dataDfComponent: "badge" }, [
|
|
330
|
-
{ type: "text", value: n }
|
|
331
|
-
])
|
|
332
|
-
), i.push(s);
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
if (s.tagName === "table") {
|
|
336
|
-
i.push(g("div", { className: ["df-api-params"] }, [s]));
|
|
337
|
-
continue;
|
|
338
|
-
}
|
|
339
|
-
i.push(s);
|
|
340
|
-
}
|
|
341
|
-
t.children = i;
|
|
342
|
-
}
|
|
343
|
-
const he = () => (t) => {
|
|
344
|
-
S(t, "element", (a) => {
|
|
345
|
-
const e = String(a.properties.dataDfComponent ?? "");
|
|
346
|
-
e === "file-tree" && ee(a), e === "gallery" && te(a), e === "api" && ie(a);
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
function be(t) {
|
|
350
|
-
let a;
|
|
351
|
-
return t.split(`
|
|
352
|
-
`).map((e) => {
|
|
353
|
-
const i = e.match(/^ {0,3}(`{3,}|~{3,})(.*)$/), s = i?.[1], n = s?.[0], r = i?.[2] ?? "";
|
|
354
|
-
return a ? (s && n === a.marker && s.length >= a.size && /^[ \t]*$/.test(r) && (a = void 0), e) : s && n && (n !== "`" || !r.includes("`")) ? (a = { marker: n, size: s.length }, e) : e.replace(
|
|
355
|
-
/^(:{3,}\s*)(info|tip|warning|danger)[ \t]+(.+?)[ \t]*$/,
|
|
356
|
-
(p, o, c, d) => `${o}${c}[${W(d)}]`
|
|
357
|
-
);
|
|
358
|
-
}).join(`
|
|
359
|
-
`);
|
|
360
|
-
}
|
|
361
|
-
const ge = (t) => (a) => {
|
|
362
|
-
S(a, "containerDirective", (e, i, s) => {
|
|
363
|
-
if (!s || i === void 0) return;
|
|
364
|
-
const n = e.name === "tabs" && t.features.tabs, r = e.name === "code-group" && t.features.codeGroups;
|
|
365
|
-
if (!n && !r) return;
|
|
366
|
-
const p = v(e) || (r ? t.labels.codeGroupTitle : t.labels.tabsTitle), o = x(e), c = n ? o.filter(
|
|
367
|
-
(u) => u.type === "containerDirective" && u.name === "tab"
|
|
368
|
-
).map((u, h) => ({
|
|
369
|
-
type: "tabItem",
|
|
370
|
-
data: {
|
|
371
|
-
tabLabel: v(u) || q(t.labels.tabItem, h),
|
|
372
|
-
tabValue: "",
|
|
373
|
-
tabIndex: h
|
|
374
|
-
},
|
|
375
|
-
children: x(u)
|
|
376
|
-
})) : o.filter((u) => u.type === "code").map((u, h) => ({
|
|
377
|
-
type: "tabItem",
|
|
378
|
-
data: {
|
|
379
|
-
tabLabel: J(u, h, t.labels.codeGroupItem),
|
|
380
|
-
tabLanguage: String(u.lang ?? "").trim().toLowerCase(),
|
|
381
|
-
tabValue: "",
|
|
382
|
-
tabIndex: h
|
|
383
|
-
},
|
|
384
|
-
children: [u]
|
|
385
|
-
}));
|
|
386
|
-
if (!c.length) return;
|
|
387
|
-
c.forEach((u, h) => {
|
|
388
|
-
const L = K(u.data.tabLabel, h);
|
|
389
|
-
u.data = {
|
|
390
|
-
...u.data,
|
|
391
|
-
tabValue: L,
|
|
392
|
-
tabIndex: h
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
const d = {
|
|
396
|
-
type: "tabGroup",
|
|
397
|
-
data: { tabGroupLabel: p, tabGroupKind: r ? "code-group" : "tabs" },
|
|
398
|
-
children: c,
|
|
399
|
-
position: e.position
|
|
400
|
-
};
|
|
401
|
-
s.children[i] = d;
|
|
402
|
-
});
|
|
403
|
-
}, ye = (t) => (a) => {
|
|
404
|
-
S(a, "containerDirective", (e, i, s) => {
|
|
405
|
-
if (!s || i === void 0 || e.name !== "steps" || !t.features.steps) return;
|
|
406
|
-
const n = x(e).filter(
|
|
407
|
-
(p) => p.type === "containerDirective" && p.name === "step"
|
|
408
|
-
).map((p, o) => ({
|
|
409
|
-
type: "stepItem",
|
|
410
|
-
data: { stepTitle: v(p), stepIndex: o + 1 },
|
|
411
|
-
children: x(p)
|
|
412
|
-
}));
|
|
413
|
-
if (!n.length) return;
|
|
414
|
-
const r = {
|
|
415
|
-
type: "stepGroup",
|
|
416
|
-
data: { stepLabel: v(e) },
|
|
417
|
-
children: n,
|
|
418
|
-
position: e.position
|
|
419
|
-
};
|
|
420
|
-
s.children[i] = r;
|
|
421
|
-
});
|
|
422
|
-
};
|
|
423
|
-
function ve(t, a) {
|
|
424
|
-
const e = a.data.stepTitle ? [
|
|
425
|
-
{
|
|
426
|
-
type: "element",
|
|
427
|
-
tagName: "strong",
|
|
428
|
-
properties: { className: ["df-step-title"] },
|
|
429
|
-
children: [{ type: "text", value: a.data.stepTitle }]
|
|
430
|
-
},
|
|
431
|
-
...t.all(a)
|
|
432
|
-
] : t.all(a);
|
|
433
|
-
return {
|
|
434
|
-
type: "element",
|
|
435
|
-
tagName: "li",
|
|
436
|
-
properties: { dataDfSlot: "item" },
|
|
437
|
-
children: e
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
function De(t, a) {
|
|
441
|
-
const e = a.data.stepLabel.trim();
|
|
442
|
-
return {
|
|
443
|
-
type: "element",
|
|
444
|
-
tagName: "ol",
|
|
445
|
-
properties: {
|
|
446
|
-
className: ["df-steps"],
|
|
447
|
-
dataDfComponent: "steps",
|
|
448
|
-
dataDfSlot: "root",
|
|
449
|
-
...e ? { ariaLabel: e } : {}
|
|
450
|
-
},
|
|
451
|
-
children: t.all(a)
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function Se(t, a) {
|
|
455
|
-
const e = a.data, i = t.all(a);
|
|
456
|
-
return {
|
|
457
|
-
type: "element",
|
|
458
|
-
tagName: "div",
|
|
459
|
-
properties: {
|
|
460
|
-
className: ["df-tabs-content"],
|
|
461
|
-
role: "tabpanel",
|
|
462
|
-
dataDfTabPanel: e.tabValue,
|
|
463
|
-
dataDfSlot: "panel",
|
|
464
|
-
tabIndex: 0,
|
|
465
|
-
hidden: e.tabIndex !== 0
|
|
466
|
-
},
|
|
467
|
-
children: i
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
function we(t, a) {
|
|
471
|
-
const e = a.data, i = e.tabGroupKind === "code-group", s = a.children.map((n) => {
|
|
472
|
-
const r = n.data, p = r.tabIndex === 0, o = String(r.tabLabel ?? ""), c = String(r.tabLanguage ?? "");
|
|
473
|
-
return {
|
|
474
|
-
type: "element",
|
|
475
|
-
tagName: "button",
|
|
476
|
-
properties: {
|
|
477
|
-
type: "button",
|
|
478
|
-
role: "tab",
|
|
479
|
-
className: ["df-tabs-trigger"],
|
|
480
|
-
ariaSelected: p ? "true" : "false",
|
|
481
|
-
tabIndex: p ? 0 : -1,
|
|
482
|
-
dataDfTab: r.tabValue,
|
|
483
|
-
...i && r.tabLanguage ? { dataDfLanguage: r.tabLanguage } : {},
|
|
484
|
-
dataDfSlot: "tab",
|
|
485
|
-
title: o
|
|
486
|
-
},
|
|
487
|
-
children: i ? [
|
|
488
|
-
{
|
|
489
|
-
type: "element",
|
|
490
|
-
tagName: "span",
|
|
491
|
-
properties: {
|
|
492
|
-
className: ["df-code-file-icon"],
|
|
493
|
-
dataDfFileIcon: j(o, c),
|
|
494
|
-
dataDfFileKind: _(o, c),
|
|
495
|
-
ariaHidden: "true"
|
|
496
|
-
},
|
|
497
|
-
children: []
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
type: "element",
|
|
501
|
-
tagName: "span",
|
|
502
|
-
properties: { className: ["df-code-tab-label"] },
|
|
503
|
-
children: [{ type: "text", value: o }]
|
|
504
|
-
}
|
|
505
|
-
] : [{ type: "text", value: o }]
|
|
506
|
-
};
|
|
507
|
-
});
|
|
508
|
-
return {
|
|
509
|
-
type: "element",
|
|
510
|
-
tagName: "div",
|
|
511
|
-
properties: {
|
|
512
|
-
className: ["df-tabs", ...i ? ["df-code-group"] : []],
|
|
513
|
-
dataDfComponent: i ? "code-group" : "tabs",
|
|
514
|
-
dataDfSlot: "root",
|
|
515
|
-
dataDfBehavior: "tabs"
|
|
516
|
-
},
|
|
517
|
-
children: [
|
|
518
|
-
{
|
|
519
|
-
type: "element",
|
|
520
|
-
tagName: "div",
|
|
521
|
-
properties: {
|
|
522
|
-
className: ["df-tabs-list"],
|
|
523
|
-
role: "tablist",
|
|
524
|
-
ariaLabel: String(e.tabGroupLabel ?? "Tabs"),
|
|
525
|
-
dataDfSlot: "tab-list"
|
|
526
|
-
},
|
|
527
|
-
children: s
|
|
528
|
-
},
|
|
529
|
-
...t.all(a)
|
|
530
|
-
]
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
const Te = () => (t) => {
|
|
534
|
-
S(t, (a) => {
|
|
535
|
-
if (a.type !== "containerDirective" || !U.has(a.name)) return;
|
|
536
|
-
const e = ["df-callout", `df-callout-${a.name}`], i = a.children.find(
|
|
537
|
-
(p) => !!p.data?.directiveLabel && I(p)
|
|
538
|
-
), s = a.children.filter((p) => p !== i), n = {
|
|
539
|
-
type: "calloutBody",
|
|
540
|
-
data: { hName: "div", hProperties: { className: ["df-callout-body"], dataDfSlot: "content" } },
|
|
541
|
-
children: s
|
|
542
|
-
}, r = i ? [
|
|
543
|
-
{
|
|
544
|
-
type: "calloutTitle",
|
|
545
|
-
data: { hName: "div", hProperties: { className: ["df-callout-title"], dataDfSlot: "title" } },
|
|
546
|
-
children: i.children
|
|
547
|
-
},
|
|
548
|
-
n
|
|
549
|
-
] : [n];
|
|
550
|
-
a.data = {
|
|
551
|
-
hName: "div",
|
|
552
|
-
hProperties: { className: e, dataCallout: a.name, dataDfComponent: "callout", dataDfSlot: "root" }
|
|
553
|
-
}, a.children = r;
|
|
554
|
-
});
|
|
555
|
-
}, ne = /* @__PURE__ */ new Set(["accent", "success", "warning", "danger"]), E = /* @__PURE__ */ new Set(["audio", "video", "embed"]), G = /* @__PURE__ */ new Set([
|
|
556
|
-
"aside",
|
|
557
|
-
"file-tree",
|
|
558
|
-
"gallery",
|
|
559
|
-
"card-grid",
|
|
560
|
-
"card",
|
|
561
|
-
"api",
|
|
562
|
-
"response",
|
|
563
|
-
"details",
|
|
564
|
-
"tabs",
|
|
565
|
-
"tab",
|
|
566
|
-
"code-group",
|
|
567
|
-
"steps",
|
|
568
|
-
"step",
|
|
569
|
-
"info",
|
|
570
|
-
"tip",
|
|
571
|
-
"warning",
|
|
572
|
-
"danger"
|
|
573
|
-
]), O = /* @__PURE__ */ new Set(["badge", "copy"]), se = /* @__PURE__ */ new Set(["http", "https", "irc", "ircs", "mailto", "tel", "xmpp"]), R = /* @__PURE__ */ new Set(["http", "https"]);
|
|
574
|
-
function oe(t) {
|
|
575
|
-
return "children" in t && Array.isArray(t.children);
|
|
576
|
-
}
|
|
577
|
-
function V(t) {
|
|
578
|
-
return "value" in t && typeof t.value == "string" ? t.value : oe(t) ? t.children.map(V).join("") : "";
|
|
579
|
-
}
|
|
580
|
-
function w(t) {
|
|
581
|
-
return t.children.map((a) => V(a)).join("").trim();
|
|
582
|
-
}
|
|
583
|
-
function b(t, a) {
|
|
584
|
-
const e = t.attributes?.[a];
|
|
585
|
-
return typeof e == "string" ? e.trim() : "";
|
|
586
|
-
}
|
|
587
|
-
function k(t, a) {
|
|
588
|
-
const e = t.indexOf(":"), i = t.indexOf("/"), s = t.indexOf("?"), n = t.indexOf("#");
|
|
589
|
-
if (e === -1 || i !== -1 && e > i || s !== -1 && e > s || n !== -1 && e > n)
|
|
590
|
-
return !0;
|
|
591
|
-
const r = t.slice(0, e).replace(/[\u0000-\u0020]/g, "").toLowerCase();
|
|
592
|
-
return a.has(r);
|
|
593
|
-
}
|
|
594
|
-
function D(t) {
|
|
595
|
-
return t.children.filter((a) => !a.data?.directiveLabel);
|
|
596
|
-
}
|
|
597
|
-
function T(t, a) {
|
|
598
|
-
return !!(t && (t.type === "containerDirective" || t.type === "leafDirective" || t.type === "textDirective") && t.name === a);
|
|
599
|
-
}
|
|
600
|
-
function le(t) {
|
|
601
|
-
if (t.type !== "paragraph") return !1;
|
|
602
|
-
const e = t.children.filter(
|
|
603
|
-
(i) => i.type !== "text" || String(i.value ?? "").trim() !== ""
|
|
604
|
-
);
|
|
605
|
-
return e.length === 1 && e.every(
|
|
606
|
-
(i) => i.type === "image" || i.type === "imageReference"
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
function l(t, a) {
|
|
610
|
-
return {
|
|
611
|
-
message: t,
|
|
612
|
-
line: a.position?.start.line,
|
|
613
|
-
column: a.position?.start.column,
|
|
614
|
-
node: a
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
function m(t, a, e) {
|
|
618
|
-
for (const i of Object.keys(t.attributes ?? {}))
|
|
619
|
-
a.has(i) || e.push(l(`The ${t.name} directive does not support the \`${i}\` attribute`, t));
|
|
620
|
-
}
|
|
621
|
-
function ce(t, a = /* @__PURE__ */ new Set()) {
|
|
622
|
-
const e = [];
|
|
623
|
-
return S(t, (i, s, n) => {
|
|
624
|
-
if (i.type !== "containerDirective" && i.type !== "leafDirective" && i.type !== "textDirective")
|
|
625
|
-
return;
|
|
626
|
-
const r = i;
|
|
627
|
-
if (!(G.has(r.name) || O.has(r.name) || E.has(r.name))) {
|
|
628
|
-
a.has(r.name) || e.push(l(`Unknown Markdown directive \`${r.name}\``, r));
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
if (G.has(r.name) && r.type !== "containerDirective") {
|
|
632
|
-
e.push(l(`The ${r.name} directive must use container syntax`, r));
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
if (O.has(r.name) && r.type !== "textDirective") {
|
|
636
|
-
e.push(l(`The ${r.name} directive must use inline syntax`, r));
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
if (E.has(r.name) && r.type !== "leafDirective") {
|
|
640
|
-
e.push(l(`The ${r.name} directive must use leaf syntax`, r));
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
if (r.type === "textDirective" && r.name === "badge") {
|
|
644
|
-
m(r, /* @__PURE__ */ new Set(["tone"]), e), w(r) || e.push(l("Badge directives require a label", r));
|
|
645
|
-
const o = b(r, "tone").toLowerCase();
|
|
646
|
-
o && !ne.has(o) && e.push(l("Badge `tone` must be one of `accent`, `success`, `warning`, or `danger`", r));
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
if (r.type === "textDirective" && r.name === "copy") {
|
|
650
|
-
m(r, /* @__PURE__ */ new Set(), e), w(r) || e.push(l("Copy directives require text to copy", r));
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
if (r.type === "leafDirective") {
|
|
654
|
-
const o = w(r), c = r.name === "embed" ? "Embed" : r.name === "video" ? "Video" : "Audio", d = r.name === "video" ? /* @__PURE__ */ new Set(["src", "poster", "preload"]) : r.name === "audio" ? /* @__PURE__ */ new Set(["src", "preload"]) : /* @__PURE__ */ new Set(["src", "loading", "sandbox", "allow", "referrerpolicy", "allowfullscreen"]);
|
|
655
|
-
m(r, d, e), b(r, "src") ? k(b(r, "src"), R) || e.push(l(`${c} \`src\` must use a relative, HTTP, or HTTPS URL`, r)) : e.push(l(`${c} directives require a \`src\` attribute`, r)), o || e.push(l(`${c} directives require an accessible label`, r));
|
|
656
|
-
const u = b(r, "preload");
|
|
657
|
-
u && !["none", "metadata", "auto"].includes(u) && e.push(l("Media `preload` must be `none`, `metadata`, or `auto`", r));
|
|
658
|
-
const h = b(r, "loading");
|
|
659
|
-
r.name === "embed" && h && !["lazy", "eager"].includes(h) && e.push(l("Embed `loading` must be `lazy` or `eager`", r));
|
|
660
|
-
const L = b(r, "poster");
|
|
661
|
-
L && !k(L, R) && e.push(l("Video `poster` must use a relative, HTTP, or HTTPS URL", r));
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
if (r.type === "containerDirective") {
|
|
665
|
-
if (r.name === "gallery") {
|
|
666
|
-
m(r, /* @__PURE__ */ new Set(), e);
|
|
667
|
-
for (const o of D(r))
|
|
668
|
-
le(o) || e.push(l("Each Gallery item must contain exactly one Markdown image", o));
|
|
669
|
-
D(r).length || e.push(l("Gallery directives require at least one image", r));
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
if (r.name === "card") {
|
|
673
|
-
m(r, /* @__PURE__ */ new Set(["href"]), e), b(r, "href") ? k(b(r, "href"), se) || e.push(l("Card `href` uses an unsupported URL protocol", r)) : e.push(l("Card directives require an `href` attribute", r)), T(n, "card-grid") || e.push(l("Card directives must be direct children of a card-grid directive", r));
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
if (r.name === "api") {
|
|
677
|
-
m(r, /* @__PURE__ */ new Set(["method", "path"]), e), b(r, "method") || e.push(l("API directives require a `method` attribute", r)), b(r, "path") || e.push(l("API directives require a `path` attribute", r));
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
if (r.name === "response") {
|
|
681
|
-
m(r, /* @__PURE__ */ new Set(), e), w(r) || e.push(l("Response directives require a status label", r)), T(n, "api") || e.push(l("Response directives must be direct children of an API directive", r));
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
if (r.name === "details") {
|
|
685
|
-
m(r, /* @__PURE__ */ new Set(["open"]), e), w(r) || e.push(l("Details directives require a summary label", r)), D(r).length || e.push(l("Details directives require body content", r));
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
if (r.name === "tabs" || r.name === "steps" || r.name === "card-grid") {
|
|
689
|
-
m(r, /* @__PURE__ */ new Set(), e);
|
|
690
|
-
const o = r.name === "tabs" ? "tab" : r.name === "steps" ? "step" : "card", c = D(r);
|
|
691
|
-
c.length || e.push(l(`${r.name} directives require at least one ${o} child`, r));
|
|
692
|
-
for (const d of c)
|
|
693
|
-
T(d, o) || e.push(l(`${r.name} directives can contain only ${o} directives`, d));
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
if (r.name === "code-group") {
|
|
697
|
-
m(r, /* @__PURE__ */ new Set(), e);
|
|
698
|
-
const o = D(r);
|
|
699
|
-
o.length || e.push(l("code-group directives require at least one code block", r));
|
|
700
|
-
for (const c of o)
|
|
701
|
-
c.type !== "code" && e.push(l("code-group directives can contain only fenced code blocks", c));
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
if (r.name === "tab") {
|
|
705
|
-
m(r, /* @__PURE__ */ new Set(), e), T(n, "tabs") || e.push(l("Tab directives must be direct children of a tabs directive", r));
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
if (r.name === "step") {
|
|
709
|
-
m(r, /* @__PURE__ */ new Set(), e), T(n, "steps") || e.push(l("Step directives must be direct children of a steps directive", r));
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
if (r.name === "file-tree") {
|
|
713
|
-
m(r, /* @__PURE__ */ new Set(), e);
|
|
714
|
-
const o = D(r);
|
|
715
|
-
(o.length !== 1 || o[0]?.type !== "list") && e.push(l("File-tree directives must contain exactly one Markdown list", r));
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
m(r, /* @__PURE__ */ new Set(), e);
|
|
719
|
-
}
|
|
720
|
-
}), e;
|
|
721
|
-
}
|
|
722
|
-
const Ne = (t = /* @__PURE__ */ new Set()) => (a, e) => {
|
|
723
|
-
const i = ce(a, t)[0];
|
|
724
|
-
i && e.fail(i.message, i.node);
|
|
725
|
-
};
|
|
726
|
-
export {
|
|
727
|
-
de as a,
|
|
728
|
-
ge as b,
|
|
729
|
-
ce as c,
|
|
730
|
-
fe as d,
|
|
731
|
-
ye as e,
|
|
732
|
-
Te as f,
|
|
733
|
-
me as g,
|
|
734
|
-
he as h,
|
|
735
|
-
ve as i,
|
|
736
|
-
De as j,
|
|
737
|
-
Se as k,
|
|
738
|
-
we as l,
|
|
739
|
-
be as n,
|
|
740
|
-
Ne as r
|
|
741
|
-
};
|