@canofold/markdown 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dist/ImageGallery-Bcpjlfh9.js +569 -0
  4. package/dist/Markdown-607_slPB.js +117 -0
  5. package/dist/assets-CqlggKr8.js +77 -0
  6. package/dist/base.css +1 -1
  7. package/dist/client/bundler.js +308 -0
  8. package/dist/client/chunks/{client-kVNIqHQd.js → client-CHUUETWE.js} +3 -3
  9. package/dist/client/chunks/{gallery-BTg1qJjd.js → gallery-Cr0TgC1h.js} +2 -2
  10. package/dist/client/chunks/{image-BuMCsr5L.js → image-6_o7fPkU.js} +3 -3
  11. package/dist/client/chunks/provider-k1N-5njv.js +1037 -0
  12. package/dist/client/chunks/react-runtime-DRPMrVPX.js +12062 -0
  13. package/dist/client/chunks/{serialized-T1PzI4rG.js → serialized-Chn9ydGA.js} +270 -220
  14. package/dist/client/chunks/{table-JOSJsHgy.js → table-D99-Zhc8.js} +3 -3
  15. package/dist/client/index.js +1 -1
  16. package/dist/compiler/fenceMetadata.d.ts +7 -0
  17. package/dist/compiler/normalizeOptions.d.ts +2 -1
  18. package/dist/compiler/plugins/code.d.ts +1 -1
  19. package/dist/compiler/prepareMarkdown.d.ts +1 -1
  20. package/dist/compiler/types.d.ts +3 -0
  21. package/dist/componentMap-CKSUGzQH.js +1483 -0
  22. package/dist/components/blocks/MarkdownCodeBlock.d.ts +3 -1
  23. package/dist/copyText-C0ZgrMnH.js +18 -0
  24. package/dist/{directiveValidation-BdVbgcY_.js → directiveValidation-B7LY-R5p.js} +187 -248
  25. package/dist/fileKinds-BPzIxbaS.js +170 -0
  26. package/dist/gallery-BqQ-i0TC.js +42 -0
  27. package/dist/image-CiPni6Az.js +38 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/plugins-CXYBB-oH.js +130 -0
  31. package/dist/{prepareMarkdown-D-bFl1_V.js → prepareMarkdown-CS6sALIb.js} +344 -329
  32. package/dist/provider-BJDHf4Z_.js +8 -0
  33. package/dist/serialized-DFiNQYA5.js +39 -0
  34. package/dist/server/analyze.js +11 -11
  35. package/dist/server.js +30 -28
  36. package/dist/table-DQSeLjVL.js +32 -0
  37. package/package.json +14 -9
  38. package/dist/Markdown-C7O01MRv.js +0 -2116
  39. package/dist/client/chunks/provider-DNSHvvN7.js +0 -841
  40. package/dist/client/chunks/react-runtime-Dzgdzn6D.js +0 -10571
  41. package/dist/plugins-StkCS2su.js +0 -298
@@ -1,99 +1,40 @@
1
- import { a as z, s as P, f as _, g as j } from "./plugins-StkCS2su.js";
2
- import { visit as S } from "unist-util-visit";
3
- function k(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) => k(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
- k(t.pluginClients, e, "client");
34
- for (const e of a.assets?.styles ?? [])
35
- k(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-cf-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("") : "";
1
+ import { visit as C } from "unist-util-visit";
2
+ import { m as V, a as z } from "./fileKinds-BPzIxbaS.js";
3
+ const _ = /* @__PURE__ */ new Set(["info", "tip", "warning", "danger"]), B = /* @__PURE__ */ new Set(["accent", "success", "warning", "danger"]);
4
+ function x(t) {
5
+ return "value" in t && typeof t.value == "string" ? t.value : "children" in t && Array.isArray(t.children) ? t.children.map((a) => x(a)).join("") : "";
65
6
  }
66
7
  function I(t) {
67
8
  return "children" in t && Array.isArray(t.children);
68
9
  }
69
10
  function v(t) {
70
11
  const a = t.children.find((e) => e.data?.directiveLabel);
71
- return a ? N(a).trim() : "";
12
+ return a ? x(a).trim() : "";
72
13
  }
73
- function x(t) {
14
+ function L(t) {
74
15
  return t.children.filter((a) => !a.data?.directiveLabel);
75
16
  }
76
- function K(t, a) {
17
+ function M(t, a) {
77
18
  return `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "tab"}-${a + 1}`;
78
19
  }
79
- function q(t, a) {
20
+ function O(t, a) {
80
21
  return t.replace("{index}", String(a + 1));
81
22
  }
82
- function J(t, a, e) {
23
+ function j(t, a, e) {
83
24
  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);
25
+ return n?.trim() ? n.trim() : String(t.lang ?? "").trim() || O(e, a);
85
26
  }
86
- function W(t) {
27
+ function U(t) {
87
28
  return t.replace(/[\\[\]]/g, (a) => `\\${a}`);
88
29
  }
89
30
  function A(t) {
90
31
  return t.attributes ?? {};
91
32
  }
92
- function f(t, a) {
33
+ function d(t, a) {
93
34
  const e = A(t)[a];
94
35
  return typeof e == "string" ? e.trim() : "";
95
36
  }
96
- function X(t) {
37
+ function H(t) {
97
38
  const a = t.children.find((e) => e.data?.directiveLabel);
98
39
  if (!(!a || !I(a)))
99
40
  return {
@@ -106,7 +47,7 @@ function X(t) {
106
47
  ]
107
48
  };
108
49
  }
109
- function Z(t) {
50
+ function K(t) {
110
51
  const a = t.children.find((e) => e.data?.directiveLabel);
111
52
  if (!(!a || !I(a)))
112
53
  return {
@@ -126,7 +67,7 @@ function y(t, a, e, i = {}) {
126
67
  }
127
68
  };
128
69
  }
129
- function M(t, a, e) {
70
+ function P(t, a, e) {
130
71
  t.data = {
131
72
  ...t.data,
132
73
  hName: a,
@@ -136,53 +77,53 @@ function M(t, a, e) {
136
77
  }
137
78
  };
138
79
  }
139
- const me = () => (t) => {
140
- S(t, (a) => {
80
+ const oe = () => (t) => {
81
+ C(t, (a) => {
141
82
  if (a.type !== "containerDirective" && a.type !== "leafDirective" && a.type !== "textDirective")
142
83
  return;
143
84
  const e = a;
144
85
  if (e.type === "textDirective" && e.name === "badge") {
145
- const n = f(e, "tone").toLowerCase();
86
+ const n = d(e, "tone").toLowerCase();
146
87
  y(e, "span", "badge", {
147
- className: n && H.has(n) ? [`cf-badge-${n}`] : []
88
+ className: n && B.has(n) ? [`cf-badge-${n}`] : []
148
89
  });
149
90
  return;
150
91
  }
151
92
  if (e.type === "textDirective" && e.name === "copy") {
152
- y(e, "span", "copy-snippet", { dataCfValue: N(e).trim() });
93
+ y(e, "span", "copy-snippet", { dataCfValue: x(e).trim() });
153
94
  return;
154
95
  }
155
96
  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"),
97
+ const n = x(e).trim(), r = d(e, "preload");
98
+ P(e, e.name, {
99
+ src: d(e, "src"),
159
100
  controls: !0,
160
101
  preload: r || (e.name === "video" ? "metadata" : "none"),
161
102
  title: n,
162
103
  ariaLabel: n,
163
104
  dataCfElement: e.name,
164
- ...e.name === "video" && f(e, "poster") ? { poster: f(e, "poster") } : {}
105
+ ...e.name === "video" && d(e, "poster") ? { poster: d(e, "poster") } : {}
165
106
  });
166
107
  return;
167
108
  }
168
109
  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"),
110
+ const n = x(e).trim(), r = A(e);
111
+ P(e, "iframe", {
112
+ src: d(e, "src"),
172
113
  title: n,
173
- loading: f(e, "loading") || "lazy",
174
- sandbox: f(e, "sandbox").split(/\s+/).filter(Boolean),
175
- referrerPolicy: f(e, "referrerpolicy") || "no-referrer",
114
+ loading: d(e, "loading") || "lazy",
115
+ sandbox: d(e, "sandbox").split(/\s+/).filter(Boolean),
116
+ referrerPolicy: d(e, "referrerpolicy") || "no-referrer",
176
117
  dataCfElement: "embed",
177
- ...f(e, "allow") ? { allow: f(e, "allow") } : {},
118
+ ...d(e, "allow") ? { allow: d(e, "allow") } : {},
178
119
  ...Object.hasOwn(r, "allowfullscreen") ? { allowFullScreen: !0 } : {}
179
120
  });
180
121
  return;
181
122
  }
182
123
  if (e.type !== "containerDirective") return;
183
- const i = X(e), s = x(e);
124
+ const i = H(e), s = L(e);
184
125
  if (e.name === "details") {
185
- const n = Z(e);
126
+ const n = K(e);
186
127
  y(e, "details", "details", {
187
128
  ...Object.hasOwn(A(e), "open") ? { open: !0 } : {}
188
129
  }), e.children = [...n ? [n] : [], ...s];
@@ -207,7 +148,7 @@ const me = () => (t) => {
207
148
  return;
208
149
  }
209
150
  if (e.name === "card") {
210
- const n = f(e, "href");
151
+ const n = d(e, "href");
211
152
  if (!n) return;
212
153
  e.data = {
213
154
  ...e.data,
@@ -223,8 +164,8 @@ const me = () => (t) => {
223
164
  }
224
165
  if (e.name === "api") {
225
166
  y(e, "section", "api", {
226
- dataCfApiMethod: f(e, "method").toUpperCase(),
227
- dataCfApiPath: f(e, "path")
167
+ dataCfApiMethod: d(e, "method").toUpperCase(),
168
+ dataCfApiPath: d(e, "path")
228
169
  }), e.children = s;
229
170
  return;
230
171
  }
@@ -238,47 +179,47 @@ const me = () => (t) => {
238
179
  }, e.children = s);
239
180
  });
240
181
  };
241
- function g(t, a = {}, e = []) {
182
+ function b(t, a = {}, e = []) {
242
183
  return { type: "element", tagName: t, properties: a, children: e };
243
184
  }
244
- function F(t) {
245
- return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((a) => F(a)).join("") : "" : "";
185
+ function R(t) {
186
+ return t ? t.type === "text" ? t.value : "children" in t ? t.children.map((a) => R(a)).join("") : "" : "";
246
187
  }
247
- function Q(t) {
188
+ function W(t) {
248
189
  const a = t.properties.className ?? t.properties.class;
249
190
  return Array.isArray(a) ? a.map(String) : typeof a == "string" ? a.split(/\s+/) : [];
250
191
  }
251
- function Y(t, a) {
192
+ function X(t, a) {
252
193
  t.properties = {
253
194
  ...t.properties,
254
- className: [.../* @__PURE__ */ new Set([...Q(t), a])]
195
+ className: [.../* @__PURE__ */ new Set([...W(t), a])]
255
196
  };
256
197
  }
257
- function B(t) {
198
+ function q(t) {
258
199
  if (t.tagName === "ul")
259
200
  for (const a of t.children) {
260
201
  if (a.type !== "element" || a.tagName !== "li") continue;
261
202
  const e = a.children.find(
262
203
  (s) => s.type === "element" && s.tagName === "ul"
263
- ), i = F({
204
+ ), i = R({
264
205
  type: "root",
265
206
  children: a.children.filter((s) => s !== e)
266
207
  }).trim();
267
- e ? (B(e), a.properties = { ...a.properties, dataCfFileTreeBranch: "" }, a.children = [
268
- g("button", { type: "button", ariaExpanded: "true" }, [
208
+ e ? (q(e), a.properties = { ...a.properties, dataCfFileTreeBranch: "" }, a.children = [
209
+ b("button", { type: "button", ariaExpanded: "true" }, [
269
210
  { type: "text", value: i.replace(/\/$/, "") }
270
211
  ]),
271
212
  e
272
213
  ]) : (a.properties = { ...a.properties, dataCfFileTreeFile: "" }, a.children = [{ type: "text", value: i }]);
273
214
  }
274
215
  }
275
- function ee(t) {
216
+ function Z(t) {
276
217
  const a = t.children.find(
277
218
  (e) => e.type === "element" && e.tagName === "ul"
278
219
  );
279
- a && B(a);
220
+ a && q(a);
280
221
  }
281
- function te(t) {
222
+ function J(t) {
282
223
  t.children = t.children.flatMap((a) => {
283
224
  if (a.type !== "element" || a.tagName !== "p") return [a];
284
225
  if (!a.children.every(
@@ -290,30 +231,30 @@ function te(t) {
290
231
  if (!i) return [a];
291
232
  const s = typeof i.properties.title == "string" ? i.properties.title.trim() : "";
292
233
  return [
293
- g("figure", {}, [
234
+ b("figure", {}, [
294
235
  i,
295
- ...s ? [g("figcaption", {}, [{ type: "text", value: s }])] : []
236
+ ...s ? [b("figcaption", {}, [{ type: "text", value: s }])] : []
296
237
  ])
297
238
  ];
298
239
  });
299
240
  }
300
- function ae(t) {
241
+ function Q(t) {
301
242
  return t.split(/(:[A-Za-z0-9_-]+)/g).filter(Boolean).map(
302
- (e) => e.startsWith(":") ? g("span", { className: ["cf-api-path-param"] }, [{ type: "text", value: e }]) : { type: "text", value: e }
243
+ (e) => e.startsWith(":") ? b("span", { className: ["cf-api-path-param"] }, [{ type: "text", value: e }]) : { type: "text", value: e }
303
244
  );
304
245
  }
305
- function re(t) {
246
+ function Y(t) {
306
247
  const a = Number.parseInt(t, 10);
307
248
  return a >= 200 && a < 300 ? "cf-badge-success" : a >= 400 ? "cf-badge-danger" : "";
308
249
  }
309
- function ie(t) {
250
+ function ee(t) {
310
251
  const a = String(t.properties.dataCfApiMethod ?? "").trim(), e = String(t.properties.dataCfApiPath ?? "").trim();
311
252
  delete t.properties.dataCfApiMethod, delete t.properties.dataCfApiPath;
312
253
  const i = [];
313
254
  (a || e) && i.push(
314
- g("div", { className: ["cf-api-endpoint"] }, [
315
- ...a ? [g("span", { className: ["cf-api-method"] }, [{ type: "text", value: a }])] : [],
316
- ...e ? [g("span", {}, ae(e))] : []
255
+ b("div", { className: ["cf-api-endpoint"] }, [
256
+ ...a ? [b("span", { className: ["cf-api-method"] }, [{ type: "text", value: a }])] : [],
257
+ ...e ? [b("span", {}, Q(e))] : []
317
258
  ])
318
259
  );
319
260
  for (const s of t.children) {
@@ -323,92 +264,92 @@ function ie(t) {
323
264
  }
324
265
  const n = String(s.properties.dataCfApiResponse ?? "").trim();
325
266
  if (n) {
326
- delete s.properties.dataCfApiResponse, Y(s, "cf-api-response");
327
- const r = re(n);
267
+ delete s.properties.dataCfApiResponse, X(s, "cf-api-response");
268
+ const r = Y(n);
328
269
  s.children.unshift(
329
- g("span", { className: ["cf-badge", ...r ? [r] : []], dataCfComponent: "badge" }, [
270
+ b("span", { className: ["cf-badge", ...r ? [r] : []], dataCfComponent: "badge" }, [
330
271
  { type: "text", value: n }
331
272
  ])
332
273
  ), i.push(s);
333
274
  continue;
334
275
  }
335
276
  if (s.tagName === "table") {
336
- i.push(g("div", { className: ["cf-api-params"] }, [s]));
277
+ i.push(b("div", { className: ["cf-api-params"] }, [s]));
337
278
  continue;
338
279
  }
339
280
  i.push(s);
340
281
  }
341
282
  t.children = i;
342
283
  }
343
- const he = () => (t) => {
344
- S(t, "element", (a) => {
284
+ const le = () => (t) => {
285
+ C(t, "element", (a) => {
345
286
  const e = String(a.properties.dataCfComponent ?? "");
346
- e === "file-tree" && ee(a), e === "gallery" && te(a), e === "api" && ie(a);
287
+ e === "file-tree" && Z(a), e === "gallery" && J(a), e === "api" && ee(a);
347
288
  });
348
289
  };
349
- function be(t) {
290
+ function pe(t) {
350
291
  let a;
351
292
  return t.split(`
352
293
  `).map((e) => {
353
294
  const i = e.match(/^ {0,3}(`{3,}|~{3,})(.*)$/), s = i?.[1], n = s?.[0], r = i?.[2] ?? "";
354
295
  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
296
  /^(:{3,}\s*)(info|tip|warning|danger)[ \t]+(.+?)[ \t]*$/,
356
- (p, o, c, d) => `${o}${c}[${W(d)}]`
297
+ (u, o, l, g) => `${o}${l}[${U(g)}]`
357
298
  );
358
299
  }).join(`
359
300
  `);
360
301
  }
361
- const ge = (t) => (a) => {
362
- S(a, "containerDirective", (e, i, s) => {
302
+ const ue = (t) => (a) => {
303
+ C(a, "containerDirective", (e, i, s) => {
363
304
  if (!s || i === void 0) return;
364
305
  const n = e.name === "tabs" && t.features.tabs, r = e.name === "code-group" && t.features.codeGroups;
365
306
  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) => ({
307
+ const u = v(e) || (r ? t.labels.codeGroupTitle : t.labels.tabsTitle), o = L(e), l = n ? o.filter(
308
+ (p) => p.type === "containerDirective" && p.name === "tab"
309
+ ).map((p, m) => ({
369
310
  type: "tabItem",
370
311
  data: {
371
- tabLabel: v(u) || q(t.labels.tabItem, h),
312
+ tabLabel: v(p) || O(t.labels.tabItem, m),
372
313
  tabValue: "",
373
- tabIndex: h
314
+ tabIndex: m
374
315
  },
375
- children: x(u)
376
- })) : o.filter((u) => u.type === "code").map((u, h) => ({
316
+ children: L(p)
317
+ })) : o.filter((p) => p.type === "code").map((p, m) => ({
377
318
  type: "tabItem",
378
319
  data: {
379
- tabLabel: J(u, h, t.labels.codeGroupItem),
380
- tabLanguage: String(u.lang ?? "").trim().toLowerCase(),
320
+ tabLabel: j(p, m, t.labels.codeGroupItem),
321
+ tabLanguage: String(p.lang ?? "").trim().toLowerCase(),
381
322
  tabValue: "",
382
- tabIndex: h
323
+ tabIndex: m
383
324
  },
384
- children: [u]
325
+ children: [p]
385
326
  }));
386
- if (!c.length) return;
387
- c.forEach((u, h) => {
388
- const D = K(u.data.tabLabel, h);
389
- u.data = {
390
- ...u.data,
391
- tabValue: D,
392
- tabIndex: h
327
+ if (!l.length) return;
328
+ l.forEach((p, m) => {
329
+ const T = M(p.data.tabLabel, m);
330
+ p.data = {
331
+ ...p.data,
332
+ tabValue: T,
333
+ tabIndex: m
393
334
  };
394
335
  });
395
- const d = {
336
+ const g = {
396
337
  type: "tabGroup",
397
- data: { tabGroupLabel: p, tabGroupKind: r ? "code-group" : "tabs" },
398
- children: c,
338
+ data: { tabGroupLabel: u, tabGroupKind: r ? "code-group" : "tabs" },
339
+ children: l,
399
340
  position: e.position
400
341
  };
401
- s.children[i] = d;
342
+ s.children[i] = g;
402
343
  });
403
- }, ye = (t) => (a) => {
404
- S(a, "containerDirective", (e, i, s) => {
344
+ }, de = (t) => (a) => {
345
+ C(a, "containerDirective", (e, i, s) => {
405
346
  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) => ({
347
+ const n = L(e).filter(
348
+ (u) => u.type === "containerDirective" && u.name === "step"
349
+ ).map((u, o) => ({
409
350
  type: "stepItem",
410
- data: { stepTitle: v(p), stepIndex: o + 1 },
411
- children: x(p)
351
+ data: { stepTitle: v(u), stepIndex: o + 1 },
352
+ children: L(u)
412
353
  }));
413
354
  if (!n.length) return;
414
355
  const r = {
@@ -420,7 +361,7 @@ const ge = (t) => (a) => {
420
361
  s.children[i] = r;
421
362
  });
422
363
  };
423
- function ve(t, a) {
364
+ function fe(t, a) {
424
365
  const e = a.data.stepTitle ? [
425
366
  {
426
367
  type: "element",
@@ -437,7 +378,7 @@ function ve(t, a) {
437
378
  children: e
438
379
  };
439
380
  }
440
- function Ce(t, a) {
381
+ function me(t, a) {
441
382
  const e = a.data.stepLabel.trim();
442
383
  return {
443
384
  type: "element",
@@ -451,7 +392,7 @@ function Ce(t, a) {
451
392
  children: t.all(a)
452
393
  };
453
394
  }
454
- function Se(t, a) {
395
+ function he(t, a) {
455
396
  const e = a.data, i = t.all(a);
456
397
  return {
457
398
  type: "element",
@@ -467,9 +408,9 @@ function Se(t, a) {
467
408
  children: i
468
409
  };
469
410
  }
470
- function we(t, a) {
411
+ function be(t, a) {
471
412
  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 ?? "");
413
+ const r = n.data, u = r.tabIndex === 0, o = String(r.tabLabel ?? ""), l = String(r.tabLanguage ?? "");
473
414
  return {
474
415
  type: "element",
475
416
  tagName: "button",
@@ -477,8 +418,8 @@ function we(t, a) {
477
418
  type: "button",
478
419
  role: "tab",
479
420
  className: ["cf-tabs-trigger"],
480
- ariaSelected: p ? "true" : "false",
481
- tabIndex: p ? 0 : -1,
421
+ ariaSelected: u ? "true" : "false",
422
+ tabIndex: u ? 0 : -1,
482
423
  dataCfTab: r.tabValue,
483
424
  ...i && r.tabLanguage ? { dataCfLanguage: r.tabLanguage } : {},
484
425
  dataCfSlot: "tab",
@@ -490,8 +431,8 @@ function we(t, a) {
490
431
  tagName: "span",
491
432
  properties: {
492
433
  className: ["cf-code-file-icon"],
493
- dataCfFileIcon: j(o, c),
494
- dataCfFileKind: _(o, c),
434
+ dataCfFileIcon: z(o, l),
435
+ dataCfFileKind: V(o, l),
495
436
  ariaHidden: "true"
496
437
  },
497
438
  children: []
@@ -530,12 +471,12 @@ function we(t, a) {
530
471
  ]
531
472
  };
532
473
  }
533
- const Te = () => (t) => {
534
- S(t, (a) => {
535
- if (a.type !== "containerDirective" || !U.has(a.name)) return;
474
+ const ge = () => (t) => {
475
+ C(t, (a) => {
476
+ if (a.type !== "containerDirective" || !_.has(a.name)) return;
536
477
  const e = ["cf-callout", `cf-callout-${a.name}`], i = a.children.find(
537
- (p) => !!p.data?.directiveLabel && I(p)
538
- ), s = a.children.filter((p) => p !== i), n = {
478
+ (u) => !!u.data?.directiveLabel && I(u)
479
+ ), s = a.children.filter((u) => u !== i), n = {
539
480
  type: "calloutBody",
540
481
  data: { hName: "div", hProperties: { className: ["cf-callout-body"], dataCfSlot: "content" } },
541
482
  children: s
@@ -552,7 +493,7 @@ const Te = () => (t) => {
552
493
  hProperties: { className: e, dataCallout: a.name, dataCfComponent: "callout", dataCfSlot: "root" }
553
494
  }, a.children = r;
554
495
  });
555
- }, ne = /* @__PURE__ */ new Set(["accent", "success", "warning", "danger"]), E = /* @__PURE__ */ new Set(["audio", "video", "embed"]), G = /* @__PURE__ */ new Set([
496
+ }, te = /* @__PURE__ */ new Set(["accent", "success", "warning", "danger"]), $ = /* @__PURE__ */ new Set(["audio", "video", "embed"]), E = /* @__PURE__ */ new Set([
556
497
  "aside",
557
498
  "file-tree",
558
499
  "gallery",
@@ -570,34 +511,34 @@ const Te = () => (t) => {
570
511
  "tip",
571
512
  "warning",
572
513
  "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) {
514
+ ]), k = /* @__PURE__ */ new Set(["badge", "copy"]), ae = /* @__PURE__ */ new Set(["http", "https", "irc", "ircs", "mailto", "tel", "xmpp"]), G = /* @__PURE__ */ new Set(["http", "https"]);
515
+ function re(t) {
575
516
  return "children" in t && Array.isArray(t.children);
576
517
  }
577
- function V(t) {
578
- return "value" in t && typeof t.value == "string" ? t.value : oe(t) ? t.children.map(V).join("") : "";
518
+ function F(t) {
519
+ return "value" in t && typeof t.value == "string" ? t.value : re(t) ? t.children.map(F).join("") : "";
579
520
  }
580
521
  function w(t) {
581
- return t.children.map((a) => V(a)).join("").trim();
522
+ return t.children.map((a) => F(a)).join("").trim();
582
523
  }
583
- function b(t, a) {
524
+ function h(t, a) {
584
525
  const e = t.attributes?.[a];
585
526
  return typeof e == "string" ? e.trim() : "";
586
527
  }
587
- function L(t, a) {
528
+ function D(t, a) {
588
529
  const e = t.indexOf(":"), i = t.indexOf("/"), s = t.indexOf("?"), n = t.indexOf("#");
589
530
  if (e === -1 || i !== -1 && e > i || s !== -1 && e > s || n !== -1 && e > n)
590
531
  return !0;
591
532
  const r = t.slice(0, e).replace(/[\u0000-\u0020]/g, "").toLowerCase();
592
533
  return a.has(r);
593
534
  }
594
- function C(t) {
535
+ function S(t) {
595
536
  return t.children.filter((a) => !a.data?.directiveLabel);
596
537
  }
597
- function T(t, a) {
538
+ function N(t, a) {
598
539
  return !!(t && (t.type === "containerDirective" || t.type === "leafDirective" || t.type === "textDirective") && t.name === a);
599
540
  }
600
- function le(t) {
541
+ function ie(t) {
601
542
  if (t.type !== "paragraph") return !1;
602
543
  const e = t.children.filter(
603
544
  (i) => i.type !== "text" || String(i.value ?? "").trim() !== ""
@@ -606,7 +547,7 @@ function le(t) {
606
547
  (i) => i.type === "image" || i.type === "imageReference"
607
548
  );
608
549
  }
609
- function l(t, a) {
550
+ function c(t, a) {
610
551
  return {
611
552
  message: t,
612
553
  line: a.position?.start.line,
@@ -614,128 +555,126 @@ function l(t, a) {
614
555
  node: a
615
556
  };
616
557
  }
617
- function m(t, a, e) {
558
+ function f(t, a, e) {
618
559
  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));
560
+ a.has(i) || e.push(c(`The ${t.name} directive does not support the \`${i}\` attribute`, t));
620
561
  }
621
- function ce(t, a = /* @__PURE__ */ new Set()) {
562
+ function ne(t, a = /* @__PURE__ */ new Set()) {
622
563
  const e = [];
623
- return S(t, (i, s, n) => {
564
+ return C(t, (i, s, n) => {
624
565
  if (i.type !== "containerDirective" && i.type !== "leafDirective" && i.type !== "textDirective")
625
566
  return;
626
567
  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));
568
+ if (!(E.has(r.name) || k.has(r.name) || $.has(r.name))) {
569
+ a.has(r.name) || e.push(c(`Unknown Markdown directive \`${r.name}\``, r));
629
570
  return;
630
571
  }
631
- if (G.has(r.name) && r.type !== "containerDirective") {
632
- e.push(l(`The ${r.name} directive must use container syntax`, r));
572
+ if (E.has(r.name) && r.type !== "containerDirective") {
573
+ e.push(c(`The ${r.name} directive must use container syntax`, r));
633
574
  return;
634
575
  }
635
- if (O.has(r.name) && r.type !== "textDirective") {
636
- e.push(l(`The ${r.name} directive must use inline syntax`, r));
576
+ if (k.has(r.name) && r.type !== "textDirective") {
577
+ e.push(c(`The ${r.name} directive must use inline syntax`, r));
637
578
  return;
638
579
  }
639
- if (E.has(r.name) && r.type !== "leafDirective") {
640
- e.push(l(`The ${r.name} directive must use leaf syntax`, r));
580
+ if ($.has(r.name) && r.type !== "leafDirective") {
581
+ e.push(c(`The ${r.name} directive must use leaf syntax`, r));
641
582
  return;
642
583
  }
643
584
  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));
585
+ f(r, /* @__PURE__ */ new Set(["tone"]), e), w(r) || e.push(c("Badge directives require a label", r));
586
+ const o = h(r, "tone").toLowerCase();
587
+ o && !te.has(o) && e.push(c("Badge `tone` must be one of `accent`, `success`, `warning`, or `danger`", r));
647
588
  return;
648
589
  }
649
590
  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));
591
+ f(r, /* @__PURE__ */ new Set(), e), w(r) || e.push(c("Copy directives require text to copy", r));
651
592
  return;
652
593
  }
653
594
  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") ? L(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 D = b(r, "poster");
661
- D && !L(D, R) && e.push(l("Video `poster` must use a relative, HTTP, or HTTPS URL", r));
595
+ const o = w(r), l = r.name === "embed" ? "Embed" : r.name === "video" ? "Video" : "Audio", g = 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"]);
596
+ f(r, g, e), h(r, "src") ? D(h(r, "src"), G) || e.push(c(`${l} \`src\` must use a relative, HTTP, or HTTPS URL`, r)) : e.push(c(`${l} directives require a \`src\` attribute`, r)), o || e.push(c(`${l} directives require an accessible label`, r));
597
+ const p = h(r, "preload");
598
+ p && !["none", "metadata", "auto"].includes(p) && e.push(c("Media `preload` must be `none`, `metadata`, or `auto`", r));
599
+ const m = h(r, "loading");
600
+ r.name === "embed" && m && !["lazy", "eager"].includes(m) && e.push(c("Embed `loading` must be `lazy` or `eager`", r));
601
+ const T = h(r, "poster");
602
+ T && !D(T, G) && e.push(c("Video `poster` must use a relative, HTTP, or HTTPS URL", r));
662
603
  return;
663
604
  }
664
605
  if (r.type === "containerDirective") {
665
606
  if (r.name === "gallery") {
666
- m(r, /* @__PURE__ */ new Set(), e);
667
- for (const o of C(r))
668
- le(o) || e.push(l("Each Gallery item must contain exactly one Markdown image", o));
669
- C(r).length || e.push(l("Gallery directives require at least one image", r));
607
+ f(r, /* @__PURE__ */ new Set(), e);
608
+ for (const o of S(r))
609
+ ie(o) || e.push(c("Each Gallery item must contain exactly one Markdown image", o));
610
+ S(r).length || e.push(c("Gallery directives require at least one image", r));
670
611
  return;
671
612
  }
672
613
  if (r.name === "card") {
673
- m(r, /* @__PURE__ */ new Set(["href"]), e), b(r, "href") ? L(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));
614
+ f(r, /* @__PURE__ */ new Set(["href"]), e), h(r, "href") ? D(h(r, "href"), ae) || e.push(c("Card `href` uses an unsupported URL protocol", r)) : e.push(c("Card directives require an `href` attribute", r)), N(n, "card-grid") || e.push(c("Card directives must be direct children of a card-grid directive", r));
674
615
  return;
675
616
  }
676
617
  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));
618
+ f(r, /* @__PURE__ */ new Set(["method", "path"]), e), h(r, "method") || e.push(c("API directives require a `method` attribute", r)), h(r, "path") || e.push(c("API directives require a `path` attribute", r));
678
619
  return;
679
620
  }
680
621
  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));
622
+ f(r, /* @__PURE__ */ new Set(), e), w(r) || e.push(c("Response directives require a status label", r)), N(n, "api") || e.push(c("Response directives must be direct children of an API directive", r));
682
623
  return;
683
624
  }
684
625
  if (r.name === "details") {
685
- m(r, /* @__PURE__ */ new Set(["open"]), e), w(r) || e.push(l("Details directives require a summary label", r)), C(r).length || e.push(l("Details directives require body content", r));
626
+ f(r, /* @__PURE__ */ new Set(["open"]), e), w(r) || e.push(c("Details directives require a summary label", r)), S(r).length || e.push(c("Details directives require body content", r));
686
627
  return;
687
628
  }
688
629
  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 = C(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));
630
+ f(r, /* @__PURE__ */ new Set(), e);
631
+ const o = r.name === "tabs" ? "tab" : r.name === "steps" ? "step" : "card", l = S(r);
632
+ l.length || e.push(c(`${r.name} directives require at least one ${o} child`, r));
633
+ for (const g of l)
634
+ N(g, o) || e.push(c(`${r.name} directives can contain only ${o} directives`, g));
694
635
  return;
695
636
  }
696
637
  if (r.name === "code-group") {
697
- m(r, /* @__PURE__ */ new Set(), e);
698
- const o = C(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));
638
+ f(r, /* @__PURE__ */ new Set(), e);
639
+ const o = S(r);
640
+ o.length || e.push(c("code-group directives require at least one code block", r));
641
+ for (const l of o)
642
+ l.type !== "code" && e.push(c("code-group directives can contain only fenced code blocks", l));
702
643
  return;
703
644
  }
704
645
  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));
646
+ f(r, /* @__PURE__ */ new Set(), e), N(n, "tabs") || e.push(c("Tab directives must be direct children of a tabs directive", r));
706
647
  return;
707
648
  }
708
649
  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));
650
+ f(r, /* @__PURE__ */ new Set(), e), N(n, "steps") || e.push(c("Step directives must be direct children of a steps directive", r));
710
651
  return;
711
652
  }
712
653
  if (r.name === "file-tree") {
713
- m(r, /* @__PURE__ */ new Set(), e);
714
- const o = C(r);
715
- (o.length !== 1 || o[0]?.type !== "list") && e.push(l("File-tree directives must contain exactly one Markdown list", r));
654
+ f(r, /* @__PURE__ */ new Set(), e);
655
+ const o = S(r);
656
+ (o.length !== 1 || o[0]?.type !== "list") && e.push(c("File-tree directives must contain exactly one Markdown list", r));
716
657
  return;
717
658
  }
718
- m(r, /* @__PURE__ */ new Set(), e);
659
+ f(r, /* @__PURE__ */ new Set(), e);
719
660
  }
720
661
  }), e;
721
662
  }
722
- const Ne = (t = /* @__PURE__ */ new Set()) => (a, e) => {
723
- const i = ce(a, t)[0];
663
+ const ye = (t = /* @__PURE__ */ new Set()) => (a, e) => {
664
+ const i = ne(a, t)[0];
724
665
  i && e.fail(i.message, i.node);
725
666
  };
726
667
  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
- Ce as j,
737
- Se as k,
738
- we as l,
739
- be as n,
740
- Ne as r
668
+ ue as a,
669
+ de as b,
670
+ ne as c,
671
+ ge as d,
672
+ oe as e,
673
+ le as f,
674
+ fe as g,
675
+ me as h,
676
+ he as i,
677
+ be as j,
678
+ pe as n,
679
+ ye as r
741
680
  };