ssqch 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/bundled/completions/bash +66 -8
  2. package/bundled/completions/elvish +23 -4
  3. package/bundled/completions/fish +36 -25
  4. package/bundled/completions/powershell +25 -4
  5. package/bundled/completions/zsh +44 -10
  6. package/bundled/docs/agents.md +2 -2
  7. package/bundled/docs/build-summary.md +1 -1
  8. package/bundled/docs/comparing-builds.md +2 -2
  9. package/bundled/docs/configuring.md +3 -6
  10. package/bundled/docs/deploying.md +1 -1
  11. package/bundled/docs/field-guide.md +4 -4
  12. package/bundled/docs/github-pages.md +1 -0
  13. package/bundled/docs/index.md +1 -1
  14. package/bundled/docs/install.md +1 -1
  15. package/bundled/docs/known-gaps.md +1 -1
  16. package/bundled/docs/markdown.md +8 -12
  17. package/bundled/docs/nav.yml +5 -1
  18. package/bundled/docs/netlify.md +4 -2
  19. package/bundled/docs/patrol.md +48 -0
  20. package/bundled/docs/plugins.md +6 -6
  21. package/bundled/docs/robots.md +85 -0
  22. package/bundled/docs/seo.md +2 -38
  23. package/bundled/docs/serving-markdown.md +142 -0
  24. package/bundled/docs/template-languages.md +1 -1
  25. package/bundled/docs/templates.md +1 -1
  26. package/bundled/docs/trailheads/from-hugo.md +5 -3
  27. package/bundled/docs/trailheads/from-jekyll.md +54 -13
  28. package/bundled/docs/trailheads/from-mkdocs.md +15 -12
  29. package/bundled/docs/trailheads/from-vitepress.md +13 -11
  30. package/bundled/docs/trailheads.md +3 -3
  31. package/bundled/docs/where-values-come-from.md +5 -5
  32. package/bundled/docs/writing-plugins.md +69 -0
  33. package/bundled/ssqch.d.ts +118 -44
  34. package/bundled/starter/engines/index.edge +1 -0
  35. package/bundled/starter/engines/index.ejs +1 -0
  36. package/bundled/starter/engines/index.hbs +1 -0
  37. package/bundled/starter/engines/index.liquid +1 -0
  38. package/bundled/starter/engines/layout.edge +7 -0
  39. package/bundled/starter/engines/layout.ejs +4 -0
  40. package/bundled/starter/engines/layout.hbs +4 -0
  41. package/bundled/starter/engines/layout.liquid +4 -0
  42. package/bundled/starter/src/_data/site.json +1 -0
  43. package/bundled/starter/src/_includes/layout.jinja +4 -0
  44. package/bundled/starter/src/index.jinja +1 -0
  45. package/bundled/starter/ssqch.config.js +14 -1
  46. package/bundled/starter-docs/engines/edge/base.edge +7 -0
  47. package/bundled/starter-docs/engines/edge/doc.edge +4 -0
  48. package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
  49. package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
  50. package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
  51. package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
  52. package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
  54. package/bundled/starter-docs/src/_data/site.json +1 -0
  55. package/bundled/starter-docs/src/_includes/base.jinja +4 -0
  56. package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
  57. package/bundled/starter-docs/src/assets/docs.css +4 -0
  58. package/bundled/starter-docs/src/assets/docs.js +17 -0
  59. package/bundled/starter-docs/ssqch.config.js +14 -1
  60. package/lib/assets.js +9 -9
  61. package/lib/chunk-25WERNDD.js +112 -0
  62. package/lib/{chunk-4ZMNLWE4.js → chunk-2BJFGKOE.js} +2 -2
  63. package/lib/{chunk-M2BBE2C3.js → chunk-3ZTRIO6O.js} +18 -17
  64. package/lib/{chunk-57HLSKZS.js → chunk-4AZFCSGJ.js} +2 -2
  65. package/lib/{chunk-ULQHJ4TS.js → chunk-55WXDGO4.js} +3 -3
  66. package/lib/{chunk-JX43SJHU.js → chunk-6FY77I4M.js} +24 -22
  67. package/lib/{chunk-RY3KLUQ3.js → chunk-6OUCRDYI.js} +267 -202
  68. package/lib/{chunk-EVFNYUTR.js → chunk-6U5VIQVY.js} +5 -5
  69. package/lib/{chunk-N3IZ44XY.js → chunk-7U5GWTEH.js} +88 -54
  70. package/lib/{chunk-VTYQ3JKL.js → chunk-AIJNG6MJ.js} +2 -2
  71. package/lib/{chunk-IIBZPHAW.js → chunk-C2Q7JKFI.js} +8 -8
  72. package/lib/{chunk-6CSH757V.js → chunk-DFJFHULZ.js} +33 -8
  73. package/lib/{chunk-XVV7JJK7.js → chunk-ENWDM2RW.js} +40 -39
  74. package/lib/{chunk-JUALMFW3.js → chunk-ER72RPD6.js} +1 -1
  75. package/lib/{chunk-RFREB3SI.js → chunk-F3JPNFCZ.js} +7 -7
  76. package/lib/{chunk-LLOA3QXV.js → chunk-FENJHLNM.js} +3 -2
  77. package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
  78. package/lib/{chunk-IZCF4UH3.js → chunk-FQZDUDFK.js} +1 -1
  79. package/lib/chunk-GM5SHCTU.js +272 -0
  80. package/lib/{chunk-GVHQ37JE.js → chunk-GSNRAGKQ.js} +10 -5
  81. package/lib/{chunk-L2IY4P6O.js → chunk-GU7BBYWB.js} +3 -3
  82. package/lib/{chunk-RGYJQYW3.js → chunk-HDKU6LRI.js} +32 -5
  83. package/lib/{chunk-IQUGLVZY.js → chunk-K5WZ2VYK.js} +4 -4
  84. package/lib/{chunk-JVT5ZRRH.js → chunk-OOKBXQAY.js} +5 -5
  85. package/lib/{chunk-MOLTDO5A.js → chunk-SNQOHNXE.js} +1 -1
  86. package/lib/{chunk-Z3XH4KWX.js → chunk-SPIFZBIW.js} +1 -1
  87. package/lib/{chunk-FNNXRVSU.js → chunk-T5IUI7W7.js} +10 -10
  88. package/lib/{chunk-5HEZ3WUQ.js → chunk-TGSVSG2G.js} +2 -2
  89. package/lib/{chunk-3GROJ3TY.js → chunk-U2KEMVXO.js} +24 -17
  90. package/lib/{chunk-4B3N44SN.js → chunk-UHRBPZ4A.js} +3 -3
  91. package/lib/{chunk-GWWA5Y3X.js → chunk-ULCT3PAV.js} +1 -1
  92. package/lib/{chunk-7RGEWDLF.js → chunk-UZNUS7RP.js} +10 -8
  93. package/lib/{chunk-DZ5F5XSI.js → chunk-V3G2QGL3.js} +10 -105
  94. package/lib/{chunk-DOHOKUGB.js → chunk-VILOEVK7.js} +50 -26
  95. package/lib/{chunk-DXMDXHV7.js → chunk-WGAIE3DD.js} +15 -14
  96. package/lib/{chunk-G3RFQDKO.js → chunk-WUCRAV36.js} +8 -6
  97. package/lib/{chunk-52ROOMBZ.js → chunk-XYAWJTHM.js} +9 -9
  98. package/lib/{chunk-L3K7MMFC.js → chunk-YA23NDMW.js} +2 -2
  99. package/lib/{chunk-R7PBREXL.js → chunk-YNJNMQWU.js} +8 -5
  100. package/lib/{chunk-AK7ZKSZP.js → chunk-ZMG25MXF.js} +17 -16
  101. package/lib/cli.js +56 -34
  102. package/lib/elements.js +9 -9
  103. package/lib/from-hugo.js +36 -0
  104. package/lib/from-jekyll.js +41 -0
  105. package/lib/from-mkdocs.js +49 -0
  106. package/lib/from-vitepress.js +49 -0
  107. package/lib/image.js +10 -10
  108. package/lib/links.js +9 -9
  109. package/lib/llms.js +619 -54
  110. package/lib/minify.js +10 -10
  111. package/lib/redirects.js +9 -9
  112. package/lib/robots.js +87 -0
  113. package/lib/rss.js +22 -12
  114. package/lib/sass.js +10 -10
  115. package/lib/sitemap.js +22 -33
  116. package/lib/ssqch.js +5 -5
  117. package/lib/vue.js +14 -13
  118. package/package.json +21 -1
  119. package/types/from-hugo.d.ts +5 -0
  120. package/types/from-jekyll.d.ts +11 -0
  121. package/types/from-mkdocs.d.ts +11 -0
  122. package/types/from-vitepress.d.ts +5 -0
  123. package/types/index.d.ts +45 -29
  124. package/types/llms.d.ts +18 -8
  125. package/types/robots.d.ts +13 -0
  126. package/types/sass.d.ts +1 -1
  127. package/types/sitemap.d.ts +3 -5
  128. package/wasm/markdown.wasm +0 -0
  129. /package/lib/{chunk-JX43SJHU.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
  130. /package/lib/{chunk-R7PBREXL.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
@@ -1,22 +1,22 @@
1
1
  import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
- import {
4
- closest
5
- } from "./chunk-FVZ5JBRI.js";
6
3
  import {
7
4
  globBase,
8
5
  globProblem,
9
6
  globToRegExp,
10
7
  isGlob
11
- } from "./chunk-Z3XH4KWX.js";
8
+ } from "./chunk-SPIFZBIW.js";
9
+ import {
10
+ closest
11
+ } from "./chunk-FVZ5JBRI.js";
12
12
  import {
13
13
  ISSUES_URL,
14
14
  SOMETHING_LARGE
15
- } from "./chunk-UU43WIZG.js";
15
+ } from "./chunk-FJML7INB.js";
16
16
  import {
17
17
  describeThrown,
18
18
  settle
19
- } from "./chunk-57HLSKZS.js";
19
+ } from "./chunk-4AZFCSGJ.js";
20
20
  import {
21
21
  BuildError,
22
22
  Diagnostics,
@@ -29,7 +29,7 @@ import {
29
29
  readText,
30
30
  warn,
31
31
  warning
32
- } from "./chunk-R7PBREXL.js";
32
+ } from "./chunk-YNJNMQWU.js";
33
33
  import {
34
34
  comparePaths
35
35
  } from "./chunk-VJWQSYEG.js";
@@ -6034,177 +6034,19 @@ function withKramdownIds(html, text, seen) {
6034
6034
  });
6035
6035
  }
6036
6036
 
6037
- // src/engines/vitepress-dialect.ts
6038
- import crypto from "node:crypto";
6039
- var escapeHtml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6040
- var str = (v) => v === void 0 || v === null ? "" : String(v);
6041
- function vitepressSlug(text) {
6042
- return text.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[\u0000-\u001f]/g, "").replace(/[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
6043
- }
6044
- var FENCE = /^(\s*)(`{3,}|~{3,})/;
6045
- function vitepressBefore(source) {
6046
- if (!source.includes("<") && !source.includes("-vue")) return source;
6047
- const lines = source.split("\n");
6048
- const out = [];
6049
- let fence;
6050
- let vueFence = false;
6051
- for (let i = 0; i < lines.length; i++) {
6052
- const line = lines[i];
6053
- if (fence !== void 0) {
6054
- const m = FENCE.exec(line);
6055
- if (m && m[2][0] === fence[0] && m[2].length >= fence.length && line.trim() === m[2]) {
6056
- fence = void 0;
6057
- vueFence = false;
6058
- out.push(line);
6059
- continue;
6060
- }
6061
- out.push(vueFence ? line.replace(/\{\{\s*(['"])((?:(?!\1).)*)\1\s*\}\}/g, "$2") : line);
6062
- continue;
6063
- }
6064
- const open = FENCE.exec(line);
6065
- if (open) {
6066
- fence = open[2];
6067
- vueFence = /^\s*(?:`{3,}|~{3,})\s*[\w-]+-vue\b/.test(line);
6068
- out.push(vueFence ? line.replace(/-vue\b/, "") : line);
6069
- continue;
6070
- }
6071
- const block = /^<(script|style)\b/i.exec(line)?.[1].toLowerCase() ?? (/^\s*<ClientOnly>/.test(line) ? "ClientOnly" : void 0);
6072
- if (block !== void 0) {
6073
- const end = new RegExp(`</${block}>`, block === "ClientOnly" ? "" : "i");
6074
- let j = i;
6075
- while (j < lines.length && !end.test(lines[j])) j++;
6076
- i = j;
6077
- continue;
6078
- }
6079
- out.push(line);
6080
- }
6081
- return out.join("\n");
6082
- }
6083
- var EXTERNAL = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
6084
- function vitepressHref(href, htmlUrls) {
6085
- if (!href || href.startsWith("#") || EXTERNAL.test(href)) return href;
6086
- const m = /^([^?#]*)(.*)$/.exec(href);
6087
- let path4 = m[1];
6088
- const rest = m[2];
6089
- const index = /(^|.*\/)index\.md$/i.exec(path4);
6090
- if (index) path4 = index[1];
6091
- else if (/\.md$/i.test(path4)) path4 = path4.slice(0, -3) + (htmlUrls ? ".html" : "");
6092
- else if (htmlUrls && path4 && !path4.endsWith("/") && !/\.\w+$/.test(path4)) path4 += ".html";
6093
- if (path4 && !path4.startsWith("/") && !path4.startsWith("./")) path4 = `./${path4}`;
6094
- return path4 + rest;
6095
- }
6096
- var encodeUrl = (url) => url.replace(/[^\x21-\x7e]+/g, (s) => encodeURIComponent(s));
6097
- function lineSpans(html) {
6098
- if (html.startsWith('<span class="line')) return html.replace(/\n$/, "");
6099
- const open = [];
6100
- return html.replace(/\n$/, "").split("\n").map((line) => {
6101
- const start = open.join("");
6102
- for (const m of line.matchAll(/<span\b[^>]*>|<\/span>/g)) {
6103
- if (m[0] === "</span>") open.pop();
6104
- else open.push(m[0]);
6105
- }
6106
- return `<span class="line">${start}${line}${"</span>".repeat(open.length)}</span>`;
6107
- }).join("\n");
6108
- }
6109
- var fenceLabel = (lang) => lang === "vue-html" ? "template" : lang.replace(/-vue$/, "");
6110
- var fenceTitle = (info) => /\[([^\]]+)\]/.exec(info)?.[1] ?? "";
6111
- function fenceHtml(fence) {
6112
- const lang = fenceLabel(str(fence.lang));
6113
- const highlighted = typeof fence.highlighted === "string" && fence.highlighted !== "" ? fence.highlighted : escapeHtml(str(fence.code));
6114
- const block = `<div class="language-${escapeHtml(lang)} vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">${escapeHtml(lang)}</span><pre class="shiki vp-code" tabindex="0"><code>${lineSpans(highlighted)}</code></pre></div>`;
6115
- const title = fenceTitle(str(fence.info));
6116
- return title ? `<div class="vp-code-block-title"><div class="vp-code-block-title-bar"><span class="vp-code-block-title-text" data-title="${escapeHtml(title)}">${escapeHtml(title)}</span></div>${block}</div>` : block;
6117
- }
6118
- var custom = (kind, title) => (c) => {
6119
- const args = str(c.args).trim();
6120
- const head = args ? `<p class="custom-block-title">${args}</p>` : `<p class="custom-block-title custom-block-title-default">${title}</p>`;
6121
- return `<div class="${kind} custom-block">${head}
6122
- ${str(c.content)}</div>`;
6123
- };
6124
- function codeGroup(c) {
6125
- const source = str(c.source);
6126
- const labels = [...source.matchAll(/^\s*(?:`{3,}|~{3,})\S*[^\n]*?\[([^\]]+)\]/gm)].map((m) => m[1]);
6127
- const id = crypto.createHash("sha1").update(source).digest("hex").slice(0, 5);
6128
- const tabs = labels.map((label, i) => `<input type="radio" name="group-${id}" id="tab-${id}-${i}"${i === 0 ? " checked" : ""}><label data-title="${escapeHtml(label)}" for="tab-${id}-${i}">${escapeHtml(label)}</label>`).join("");
6129
- const blocks = str(c.content).replace(/<div class="vp-code-block-title"><div class="vp-code-block-title-bar">[\s\S]*?<\/div>(<div class="language-[\s\S]*?<\/pre><\/div>)<\/div>/g, "$1").replace(/<div class="(language-[^"]*)"/, '<div class="$1 active"');
6130
- return `<div class="vp-code-group"><div class="tabs">${tabs}</div><div class="blocks">${blocks}</div></div>`;
6131
- }
6132
- var VITEPRESS_HOOKS = {
6133
- "hooks/heading": (h) => {
6134
- const level = str(h.level), id = escapeHtml(str(h.id));
6135
- return `<h${level} id="${id}" tabindex="-1">${str(h.content)} <a class="header-anchor" href="#${id}" aria-label="Permalink to \u201C${escapeHtml(str(h.text).trim())}\u201D">\u200B</a></h${level}>`;
6136
- },
6137
- "hooks/link": (l, o) => {
6138
- const href = str(l.href);
6139
- const title = l.title ? ` title="${escapeHtml(str(l.title))}"` : "";
6140
- if (EXTERNAL.test(href)) return `<a href="${escapeHtml(encodeUrl(href))}"${title} target="_blank" rel="noreferrer">${str(l.content)}</a>`;
6141
- return `<a href="${escapeHtml(encodeUrl(vitepressHref(href, o.htmlUrls)))}"${title}>${str(l.content)}</a>`;
6142
- },
6143
- "hooks/fence": (f) => fenceHtml(f),
6144
- "hooks/table": (t) => `<table tabindex="0">${str(t.content)}</table>`,
6145
- "containers/tip": custom("tip", "TIP"),
6146
- "containers/info": custom("info", "INFO"),
6147
- "containers/warning": custom("warning", "WARNING"),
6148
- "containers/danger": custom("danger", "DANGER"),
6149
- "containers/details": (c) => `<details class="details custom-block"><summary>${str(c.args).trim() || "Details"}</summary>
6150
- ${str(c.content)}</details>`,
6151
- "containers/raw": (c) => `<div class="vp-raw">
6152
- ${str(c.content)}</div>`,
6153
- "containers/code-group": codeGroup
6154
- };
6155
- function vitepressAfter(html) {
6156
- let out = html.includes("<!--") ? withoutComments(html) : html;
6157
- out = asVueWritesIt(out);
6158
- const marker = /<p>\[\[toc\]\]<\/p>/i.exec(out);
6159
- if (!marker) return out;
6160
- const heads = [...out.matchAll(/<h([23]) id="([^"]*)"[^>]*>([\s\S]*?)<\/h\1>/g)].map(([, level2, id, inner]) => ({ level: Number(level2), id, text: inner.replace(/<a class="header-anchor"[\s\S]*?<\/a>/, "").replace(/<[^>]+>/g, "").trim() }));
6161
- let toc = '<nav class="table-of-contents"><ul>';
6162
- let level = 2;
6163
- let open = false;
6164
- for (const h of heads) {
6165
- if (h.level > level) {
6166
- toc += "<ul>";
6167
- level = h.level;
6168
- } else if (h.level < level) {
6169
- toc += "</li></ul></li>";
6170
- level = h.level;
6171
- } else if (open) toc += "</li>";
6172
- toc += `<li><a href="#${h.id}">${h.text}</a>`;
6173
- open = true;
6174
- }
6175
- if (open) toc += "</li>";
6176
- while (level-- > 2) toc += "</ul></li>";
6177
- toc += "</ul></nav>";
6178
- out = out.replace(marker[0], toc);
6179
- return out;
6180
- }
6181
- var VOID2 = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
6182
- function asVueWritesIt(html) {
6183
- if (!/\/>|\sv-pre\b|\s@[\w.-]+=|\sv-on:/.test(html)) return html;
6184
- return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<([a-z][\w-]*)((?:\s+[^\s"'>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?)*)\s*(\/?)>/g, (whole, raw, name, attrs, selfClosing) => {
6185
- if (raw !== void 0) return whole;
6186
- const kept = attrs.replace(/\s+(?:v-pre|@[\w.:-]+|v-on:[\w.:-]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?/g, "");
6187
- if (selfClosing && !VOID2.has(name)) return `<${name}${kept}></${name}>`;
6188
- return kept === attrs ? whole : `<${name}${kept}${selfClosing ? " /" : ""}>`;
6189
- });
6190
- }
6191
- function withoutComments(html) {
6192
- return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi, (m, raw) => raw ? m : "");
6193
- }
6194
-
6195
6037
  // src/engines/markdown-dialects.ts
6196
6038
  import path from "node:path";
6197
- var FENCE2 = /^([ \t]*)(`{3,}|~{3,})/;
6039
+ var FENCE = /^([ \t]*)(`{3,}|~{3,})/;
6198
6040
  function outsideFences(lines, each) {
6199
6041
  let fence;
6200
6042
  for (let i = 0; i < lines.length; i++) {
6201
6043
  const line = lines[i];
6202
6044
  if (fence) {
6203
- const m2 = FENCE2.exec(line);
6045
+ const m2 = FENCE.exec(line);
6204
6046
  if (m2 && m2[2][0] === fence[0] && m2[2].length >= fence.length && line.slice(m2[0].length).trim() === "") fence = void 0;
6205
6047
  continue;
6206
6048
  }
6207
- const m = FENCE2.exec(line);
6049
+ const m = FENCE.exec(line);
6208
6050
  if (m) {
6209
6051
  fence = m[2];
6210
6052
  continue;
@@ -6213,7 +6055,7 @@ function outsideFences(lines, each) {
6213
6055
  if (typeof next === "number") i = next - 1;
6214
6056
  }
6215
6057
  }
6216
- var escapeHtml2 = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6058
+ var escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
6217
6059
  function blockBody(lines, start, indent) {
6218
6060
  let end = start;
6219
6061
  let last = start;
@@ -6253,7 +6095,7 @@ function pythonMarkdownBlocks(source, options) {
6253
6095
  const lines = source.split("\n");
6254
6096
  let refs;
6255
6097
  const title = (text) => {
6256
- if (!options.title) return escapeHtml2(text);
6098
+ if (!options.title) return escapeHtml(text);
6257
6099
  if (refs === void 0) {
6258
6100
  const found = [];
6259
6101
  outsideFences(lines, (line) => {
@@ -6284,8 +6126,8 @@ function convertBlocks(lines, options, counter, title) {
6284
6126
  const first = classes.split(" ")[0];
6285
6127
  const heading = a[4] ?? first[0].toUpperCase() + first.slice(1);
6286
6128
  const details = a[2] !== "!!!";
6287
- const open = details ? `<details class="${escapeHtml2(classes)}"${a[2] === "???+" ? ' open="open"' : ""}>${heading === "" ? "" : `
6288
- ${pad}<summary>${title(heading)}</summary>`}` : `<div class="admonition ${escapeHtml2(classes)}">${heading === "" ? "" : `
6129
+ const open = details ? `<details class="${escapeHtml(classes)}"${a[2] === "???+" ? ' open="open"' : ""}>${heading === "" ? "" : `
6130
+ ${pad}<summary>${title(heading)}</summary>`}` : `<div class="admonition ${escapeHtml(classes)}">${heading === "" ? "" : `
6289
6131
  ${pad}<p class="admonition-title">${title(heading)}</p>`}`;
6290
6132
  out.push(`${pad}${open}`, "", ...body.map((l) => l === "" ? l : pad + l), "", `${pad}${details ? "</details>" : "</div>"}`);
6291
6133
  copied = end;
@@ -6550,7 +6392,7 @@ function pythonMarkdownIds(html) {
6550
6392
 
6551
6393
  // src/engines/markdown.ts
6552
6394
  import { Buffer as Buffer2 } from "node:buffer";
6553
- import crypto2 from "node:crypto";
6395
+ import crypto from "node:crypto";
6554
6396
  import fs from "node:fs";
6555
6397
  import path2 from "node:path";
6556
6398
  import { fileURLToPath } from "node:url";
@@ -6696,8 +6538,9 @@ var WasmMarkdown = class {
6696
6538
  this.#ready();
6697
6539
  const python = this.#options.dialect === "python-markdown" ? pythonMarkdownBefore(source) : void 0;
6698
6540
  if (python) source = python.source;
6699
- const vitepress = this.#options.dialect === "vitepress";
6700
- if (vitepress) source = vitepressBefore(source);
6541
+ const steps = this.#options.steps;
6542
+ const stepContext = steps.before.length || steps.after.length ? this.#context(data, file) : void 0;
6543
+ for (const [where, step] of steps.before) source = this.#step(step, source, stepContext, where, "before");
6701
6544
  const shortcodes = [];
6702
6545
  source = this.#dialects(source, shortcodes, data, file);
6703
6546
  const links = this.#options.sourceLinks;
@@ -6706,10 +6549,10 @@ var WasmMarkdown = class {
6706
6549
  if (shortcodes.length) html = this.#inlineShortcodes(html, shortcodes, data, file);
6707
6550
  if (links) html = sourceLinks(html, data, links, this.#inputRoot);
6708
6551
  if (ids) html = pythonMarkdownIds(html);
6709
- if (vitepress) html = vitepressAfter(html);
6552
+ for (const [where, step] of steps.after) html = this.#step(step, html, stepContext, where, "after");
6710
6553
  return python ? pythonMarkdownAfter(html, python.raw) : html;
6711
6554
  };
6712
- const changes = Boolean(links || ids || python || vitepress || shortcodes.length);
6555
+ const changes = Boolean(links || ids || python || steps.after.length || shortcodes.length);
6713
6556
  if (!this.#options.htmlMarkdown) {
6714
6557
  const out2 = this.#page(source, data, file);
6715
6558
  if (!changes) return out2;
@@ -6928,7 +6771,7 @@ ${refs}` : text, HOOKS | INLINE2, data, file, void 0, "an admonition's or a tab'
6928
6771
  }
6929
6772
  const text = readGrammar(this.#root, name, language.grammar);
6930
6773
  files2.set(wasmPath(language.grammar), text);
6931
- key.push([name, language.grammar, crypto2.createHash("sha256").update(text).digest("hex")]);
6774
+ key.push([name, language.grammar, crypto.createHash("sha256").update(text).digest("hex")]);
6932
6775
  return [name, { grammar: language.grammar }];
6933
6776
  });
6934
6777
  const json = JSON.stringify({
@@ -6941,11 +6784,11 @@ ${refs}` : text, HOOKS | INLINE2, data, file, void 0, "an admonition's or a tab'
6941
6784
  breaks: o.breaks,
6942
6785
  figures: o.figures,
6943
6786
  alerts: o.alerts,
6944
- containers: o.containers,
6787
+ // The wasm's markdown-it reading of a closing `:::`, which is ssqch's own now.
6788
+ containers: o.containers ? "markdown-it" : false,
6945
6789
  definitionLists: o.definitionLists,
6946
6790
  smartPunctuation: o.smartPunctuation,
6947
6791
  indentedCode: o.indentedCode,
6948
- encodeUrls: o.encodeUrls,
6949
6792
  highlight: o.highlight,
6950
6793
  highlightCss: o.highlightCss,
6951
6794
  highlightClasses: o.highlightClasses,
@@ -6964,21 +6807,58 @@ ${refs}` : text, HOOKS | INLINE2, data, file, void 0, "an admonition's or a tab'
6964
6807
  const template = `components/${name}`;
6965
6808
  return this.#hooks.has(template) ? this.renderHook(template, "component", value, data) : void 0;
6966
6809
  }
6967
- /** The dialect's built-in render hooks and containers (`dialect: "vitepress"`), which a site's own templates replace. */
6810
+ /** Plugins' render hooks and containers (`markdown: { hooks }`), which a site's own templates replace. */
6968
6811
  #builtinHooks() {
6969
- return this.#options.dialect === "vitepress" ? Object.keys(VITEPRESS_HOOKS) : [];
6812
+ return [...this.#options.steps.hooks.keys()];
6813
+ }
6814
+ /** What a plugin's step or hook gets besides its text. */
6815
+ #context(data, file) {
6816
+ return {
6817
+ data,
6818
+ page: isPlainObject(data.page) ? data.page : void 0,
6819
+ urls: this.#options.htmlUrls ? "html" : "folders",
6820
+ markdown: (text, options) => this.#markdown(String(text ?? ""), HOOKS | (options?.inline ? INLINE2 : 0), data, file, void 0, "a plugin's Markdown step"),
6821
+ hasHook: (name) => this.#hooks.has(name) || this.#options.steps.hooks.has(name),
6822
+ renderHook: (name, key, value) => this.renderHook(name, key, value, data)
6823
+ };
6824
+ }
6825
+ /** One plugin step, which answers at once with text. */
6826
+ #step(step, text, stepContext, where, which) {
6827
+ let out;
6828
+ try {
6829
+ out = step(text, stepContext);
6830
+ } catch (e) {
6831
+ throw context(e, `${where}: markdown.${which}`);
6832
+ }
6833
+ if (typeof out === "string") return out;
6834
+ if (out instanceof Promise) {
6835
+ out.catch(() => {
6836
+ });
6837
+ throw new BuildError(`${where}: markdown.${which} answered with a promise; a plugin's Markdown step answers at once (work out what it needs in beforeBuild or a data file first)`);
6838
+ }
6839
+ throw new BuildError(`${where}: markdown.${which} must return text, not ${out === null ? "null" : typeof out}`);
6970
6840
  }
6971
6841
  /** A render hook for the wasm: the template `name` with the page's data and `value` as `key`. */
6972
6842
  renderHook(name, key, value, data) {
6973
6843
  if (key === "container" && isPlainObject(value)) {
6974
6844
  if (name === "containers/slot") return keepSlot(value);
6975
- const own = { ...value, props: containerProps(value.args) };
6976
- own.slots = takeSlots(own);
6977
- value = own;
6845
+ const own2 = { ...value, props: containerProps(value.args) };
6846
+ own2.slots = takeSlots(own2);
6847
+ value = own2;
6978
6848
  }
6979
6849
  const template = this.#hooks.get(name);
6980
6850
  const engines = this.#engines;
6981
- if (!template && this.#builtinHooks().includes(name) && isPlainObject(value)) return VITEPRESS_HOOKS[name](value, { htmlUrls: this.#options.htmlUrls });
6851
+ const own = template ? void 0 : this.#options.steps.hooks.get(name);
6852
+ if (own && isPlainObject(value)) {
6853
+ let out;
6854
+ try {
6855
+ out = own[1](value, this.#context(data, pageOf(data)));
6856
+ } catch (e) {
6857
+ throw context(e, `${own[0]}: markdown.hooks["${name.replace(/^hooks\//, "")}"]`);
6858
+ }
6859
+ if (typeof out !== "string") throw new BuildError(`${own[0]}: markdown.hooks["${name.replace(/^hooks\//, "")}"] must return HTML as text, not ${out === null ? "null" : typeof out}`);
6860
+ return out;
6861
+ }
6982
6862
  if (!template || !engines) throw new BuildError(`no template for \`${name}\``);
6983
6863
  const hookData = { ...isPlainObject(data) ? data : {}, [key]: value };
6984
6864
  let text = template.body;
@@ -7136,7 +7016,7 @@ var disk;
7136
7016
  function highlighterOf(module, bytes) {
7137
7017
  const sections = WebAssembly.Module.customSections(module, "ssqch_markdown_inputs");
7138
7018
  const hash = sections.length ? Buffer2.from(sections[sections.length - 1]).toString("utf8") : "";
7139
- return /^[0-9a-f]{64}$/.test(hash) ? hash : `bytes ${crypto2.createHash("sha256").update(bytes).digest("hex")}`;
7019
+ return /^[0-9a-f]{64}$/.test(hash) ? hash : `bytes ${crypto.createHash("sha256").update(bytes).digest("hex")}`;
7140
7020
  }
7141
7021
  function beginFenceCache(root) {
7142
7022
  const file = path2.join(root, FENCE_CACHE);
@@ -7471,6 +7351,164 @@ function safe(html) {
7471
7351
  }
7472
7352
  var isSafe = (value) => value instanceof SafeString;
7473
7353
 
7354
+ // src/engines/vitepress-dialect.ts
7355
+ import crypto2 from "node:crypto";
7356
+ var escapeHtml2 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
7357
+ var str = (v) => v === void 0 || v === null ? "" : String(v);
7358
+ function vitepressSlug(text) {
7359
+ return text.normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[\u0000-\u001f]/g, "").replace(/[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
7360
+ }
7361
+ var FENCE2 = /^(\s*)(`{3,}|~{3,})/;
7362
+ function vitepressBefore(source) {
7363
+ if (!source.includes("<") && !source.includes("-vue")) return source;
7364
+ const lines = source.split("\n");
7365
+ const out = [];
7366
+ let fence;
7367
+ let vueFence = false;
7368
+ for (let i = 0; i < lines.length; i++) {
7369
+ const line = lines[i];
7370
+ if (fence !== void 0) {
7371
+ const m = FENCE2.exec(line);
7372
+ if (m && m[2][0] === fence[0] && m[2].length >= fence.length && line.trim() === m[2]) {
7373
+ fence = void 0;
7374
+ vueFence = false;
7375
+ out.push(line);
7376
+ continue;
7377
+ }
7378
+ out.push(vueFence ? line.replace(/\{\{\s*(['"])((?:(?!\1).)*)\1\s*\}\}/g, "$2") : line);
7379
+ continue;
7380
+ }
7381
+ const open = FENCE2.exec(line);
7382
+ if (open) {
7383
+ fence = open[2];
7384
+ vueFence = /^\s*(?:`{3,}|~{3,})\s*[\w-]+-vue\b/.test(line);
7385
+ out.push(vueFence ? line.replace(/-vue\b/, "") : line);
7386
+ continue;
7387
+ }
7388
+ const block = /^<(script|style)\b/i.exec(line)?.[1].toLowerCase() ?? (/^\s*<ClientOnly>/.test(line) ? "ClientOnly" : void 0);
7389
+ if (block !== void 0) {
7390
+ const end = new RegExp(`</${block}>`, block === "ClientOnly" ? "" : "i");
7391
+ let j = i;
7392
+ while (j < lines.length && !end.test(lines[j])) j++;
7393
+ i = j;
7394
+ continue;
7395
+ }
7396
+ out.push(line);
7397
+ }
7398
+ return out.join("\n");
7399
+ }
7400
+ var EXTERNAL = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
7401
+ function vitepressHref(href, htmlUrls) {
7402
+ if (!href || href.startsWith("#") || EXTERNAL.test(href)) return href;
7403
+ const m = /^([^?#]*)(.*)$/.exec(href);
7404
+ let path4 = m[1];
7405
+ const rest = m[2];
7406
+ const index = /(^|.*\/)index\.md$/i.exec(path4);
7407
+ if (index) path4 = index[1];
7408
+ else if (/\.md$/i.test(path4)) path4 = path4.slice(0, -3) + (htmlUrls ? ".html" : "");
7409
+ else if (htmlUrls && path4 && !path4.endsWith("/") && !/\.\w+$/.test(path4)) path4 += ".html";
7410
+ if (path4 && !path4.startsWith("/") && !path4.startsWith("./")) path4 = `./${path4}`;
7411
+ return path4 + rest;
7412
+ }
7413
+ var encodeUrl = (url) => url.replace(/[^\x21-\x7e]+/g, (s) => encodeURIComponent(s));
7414
+ function lineSpans(html) {
7415
+ if (html.startsWith('<span class="line')) return html.replace(/\n$/, "");
7416
+ const open = [];
7417
+ return html.replace(/\n$/, "").split("\n").map((line) => {
7418
+ const start = open.join("");
7419
+ for (const m of line.matchAll(/<span\b[^>]*>|<\/span>/g)) {
7420
+ if (m[0] === "</span>") open.pop();
7421
+ else open.push(m[0]);
7422
+ }
7423
+ return `<span class="line">${start}${line}${"</span>".repeat(open.length)}</span>`;
7424
+ }).join("\n");
7425
+ }
7426
+ var fenceLabel = (lang) => lang === "vue-html" ? "template" : lang.replace(/-vue$/, "");
7427
+ var fenceTitle = (info) => /\[([^\]]+)\]/.exec(info)?.[1] ?? "";
7428
+ function fenceHtml(fence) {
7429
+ const lang = fenceLabel(str(fence.lang));
7430
+ const highlighted = typeof fence.highlighted === "string" && fence.highlighted !== "" ? fence.highlighted : escapeHtml2(str(fence.code));
7431
+ const block = `<div class="language-${escapeHtml2(lang)} vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">${escapeHtml2(lang)}</span><pre class="shiki vp-code" tabindex="0"><code>${lineSpans(highlighted)}</code></pre></div>`;
7432
+ const title = fenceTitle(str(fence.info));
7433
+ return title ? `<div class="vp-code-block-title"><div class="vp-code-block-title-bar"><span class="vp-code-block-title-text" data-title="${escapeHtml2(title)}">${escapeHtml2(title)}</span></div>${block}</div>` : block;
7434
+ }
7435
+ var custom = (kind, title) => (c) => {
7436
+ const args = str(c.args).trim();
7437
+ const head = args ? `<p class="custom-block-title">${args}</p>` : `<p class="custom-block-title custom-block-title-default">${title}</p>`;
7438
+ return `<div class="${kind} custom-block">${head}
7439
+ ${str(c.content)}</div>`;
7440
+ };
7441
+ function codeGroup(c) {
7442
+ const source = str(c.source);
7443
+ const labels = [...source.matchAll(/^\s*(?:`{3,}|~{3,})\S*[^\n]*?\[([^\]]+)\]/gm)].map((m) => m[1]);
7444
+ const id = crypto2.createHash("sha1").update(source).digest("hex").slice(0, 5);
7445
+ const tabs = labels.map((label, i) => `<input type="radio" name="group-${id}" id="tab-${id}-${i}"${i === 0 ? " checked" : ""}><label data-title="${escapeHtml2(label)}" for="tab-${id}-${i}">${escapeHtml2(label)}</label>`).join("");
7446
+ const blocks = str(c.content).replace(/<div class="vp-code-block-title"><div class="vp-code-block-title-bar">[\s\S]*?<\/div>(<div class="language-[\s\S]*?<\/pre><\/div>)<\/div>/g, "$1").replace(/<div class="(language-[^"]*)"/, '<div class="$1 active"');
7447
+ return `<div class="vp-code-group"><div class="tabs">${tabs}</div><div class="blocks">${blocks}</div></div>`;
7448
+ }
7449
+ var VITEPRESS_HOOKS = {
7450
+ "hooks/heading": (h) => {
7451
+ const level = str(h.level), id = escapeHtml2(str(h.id));
7452
+ return `<h${level} id="${id}" tabindex="-1">${str(h.content)} <a class="header-anchor" href="#${id}" aria-label="Permalink to \u201C${escapeHtml2(str(h.text).trim())}\u201D">\u200B</a></h${level}>`;
7453
+ },
7454
+ "hooks/link": (l, o) => {
7455
+ const href = str(l.href);
7456
+ const title = l.title ? ` title="${escapeHtml2(str(l.title))}"` : "";
7457
+ if (EXTERNAL.test(href)) return `<a href="${escapeHtml2(encodeUrl(href))}"${title} target="_blank" rel="noreferrer">${str(l.content)}</a>`;
7458
+ return `<a href="${escapeHtml2(encodeUrl(vitepressHref(href, o.htmlUrls)))}"${title}>${str(l.content)}</a>`;
7459
+ },
7460
+ "hooks/fence": (f) => fenceHtml(f),
7461
+ "hooks/table": (t) => `<table tabindex="0">${str(t.content)}</table>`,
7462
+ "containers/tip": custom("tip", "TIP"),
7463
+ "containers/info": custom("info", "INFO"),
7464
+ "containers/warning": custom("warning", "WARNING"),
7465
+ "containers/danger": custom("danger", "DANGER"),
7466
+ "containers/details": (c) => `<details class="details custom-block"><summary>${str(c.args).trim() || "Details"}</summary>
7467
+ ${str(c.content)}</details>`,
7468
+ "containers/raw": (c) => `<div class="vp-raw">
7469
+ ${str(c.content)}</div>`,
7470
+ "containers/code-group": codeGroup
7471
+ };
7472
+ function vitepressAfter(html) {
7473
+ let out = html.includes("<!--") ? withoutComments(html) : html;
7474
+ out = asVueWritesIt(out);
7475
+ const marker = /<p>\[\[toc\]\]<\/p>/i.exec(out);
7476
+ if (!marker) return out;
7477
+ const heads = [...out.matchAll(/<h([23]) id="([^"]*)"[^>]*>([\s\S]*?)<\/h\1>/g)].map(([, level2, id, inner]) => ({ level: Number(level2), id, text: inner.replace(/<a class="header-anchor"[\s\S]*?<\/a>/, "").replace(/<[^>]+>/g, "").trim() }));
7478
+ let toc = '<nav class="table-of-contents"><ul>';
7479
+ let level = 2;
7480
+ let open = false;
7481
+ for (const h of heads) {
7482
+ if (h.level > level) {
7483
+ toc += "<ul>";
7484
+ level = h.level;
7485
+ } else if (h.level < level) {
7486
+ toc += "</li></ul></li>";
7487
+ level = h.level;
7488
+ } else if (open) toc += "</li>";
7489
+ toc += `<li><a href="#${h.id}">${h.text}</a>`;
7490
+ open = true;
7491
+ }
7492
+ if (open) toc += "</li>";
7493
+ while (level-- > 2) toc += "</ul></li>";
7494
+ toc += "</ul></nav>";
7495
+ out = out.replace(marker[0], toc);
7496
+ return out;
7497
+ }
7498
+ var VOID2 = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
7499
+ function asVueWritesIt(html) {
7500
+ if (!/\/>|\sv-pre\b|\s@[\w.-]+=|\sv-on:/.test(html)) return html;
7501
+ return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<([a-z][\w-]*)((?:\s+[^\s"'>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?)*)\s*(\/?)>/g, (whole, raw, name, attrs, selfClosing) => {
7502
+ if (raw !== void 0) return whole;
7503
+ const kept = attrs.replace(/\s+(?:v-pre|@[\w.:-]+|v-on:[\w.:-]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?/g, "");
7504
+ if (selfClosing && !VOID2.has(name)) return `<${name}${kept}></${name}>`;
7505
+ return kept === attrs ? whole : `<${name}${kept}${selfClosing ? " /" : ""}>`;
7506
+ });
7507
+ }
7508
+ function withoutComments(html) {
7509
+ return html.replace(/<(pre|code|script|style|textarea)\b[\s\S]*?<\/\1>|<!--[\s\S]*?-->/gi, (m, raw) => raw ? m : "");
7510
+ }
7511
+
7474
7512
  // src/markdown-options.ts
7475
7513
  function defaultMarkdownOptions() {
7476
7514
  return {
@@ -7486,7 +7524,6 @@ function defaultMarkdownOptions() {
7486
7524
  definitionLists: false,
7487
7525
  smartPunctuation: false,
7488
7526
  indentedCode: true,
7489
- encodeUrls: true,
7490
7527
  highlight: false,
7491
7528
  highlightCss: "/highlight.css",
7492
7529
  highlightClasses: null,
@@ -7499,11 +7536,12 @@ function defaultMarkdownOptions() {
7499
7536
  sourceLinks: false,
7500
7537
  preprocess: null,
7501
7538
  dialect: null,
7502
- htmlUrls: false
7539
+ htmlUrls: false,
7540
+ steps: { before: [], after: [], hooks: /* @__PURE__ */ new Map() }
7503
7541
  };
7504
7542
  }
7505
- var MARKDOWN_KEYS = ["headingIds", "headingAttributes", "footnotes", "taskLists", "autolinks", "alerts", "containers", "definitionLists", "smartPunctuation", "indentedCode", "highlight", "breaks", "figures", "htmlMarkdown", "encodeUrls", "admonitions", "tabs", "shortcodes", "sourceLinks", "preprocess", "dialect"];
7506
- var FLAGS = ["headingAttributes", "footnotes", "taskLists", "alerts", "definitionLists", "smartPunctuation", "indentedCode", "breaks", "figures", "encodeUrls"];
7543
+ var MARKDOWN_KEYS = ["headingIds", "headingAttributes", "footnotes", "taskLists", "autolinks", "alerts", "containers", "definitionLists", "smartPunctuation", "indentedCode", "highlight", "breaks", "figures", "sourceLinks", "preprocess"];
7544
+ var FLAGS = ["headingAttributes", "footnotes", "taskLists", "alerts", "definitionLists", "smartPunctuation", "indentedCode", "breaks", "figures"];
7507
7545
  var HIGHLIGHT_KINDS = ["comment", "keyword", "operator", "string", "regexp", "escape", "number", "constant", "builtin", "property", "attribute", "function", "type", "parameter", "tag", "heading", "strong", "emphasis", "link", "inserted", "deleted"];
7508
7546
  var PYGMENTS_CLASSES = { comment: "c", keyword: "k", operator: "o", string: "s", regexp: "sr", escape: "se", number: "m", constant: "kc", builtin: "nb", property: "py", attribute: "na", function: "nf", type: "nc", parameter: "nv", tag: "nt", heading: "gh", strong: "gs", emphasis: "ge", link: "nl", inserted: "gi", deleted: "gd" };
7509
7547
  var PRISM_CLASSES = { comment: "token comment", keyword: "token keyword", operator: "token operator", string: "token string", regexp: "token regex", escape: "token escape", number: "token number", constant: "token constant", builtin: "token builtin", property: "token property", attribute: "token attr-name", function: "token function", type: "token class-name", parameter: "token parameter", tag: "token tag", heading: "token title", strong: "token bold", emphasis: "token italic", link: "token url", inserted: "token inserted", deleted: "token deleted" };
@@ -7523,8 +7561,20 @@ function highlightClasses(value) {
7523
7561
  return { names, prism: false };
7524
7562
  }
7525
7563
  var typeOf = (v) => typeof v;
7526
- function applyMarkdownOptions(options, value) {
7564
+ var RETIRED_MARKDOWN = {
7565
+ dialect: (v) => v === "vitepress" ? 'fromVitepress() from "ssqch/from-vitepress"' : 'fromMkdocs() from "ssqch/from-mkdocs"',
7566
+ admonitions: () => 'fromMkdocs() from "ssqch/from-mkdocs"',
7567
+ tabs: () => 'fromMkdocs() from "ssqch/from-mkdocs"',
7568
+ shortcodes: () => 'fromHugo() from "ssqch/from-hugo"',
7569
+ htmlMarkdown: () => 'fromJekyll() from "ssqch/from-jekyll"'
7570
+ };
7571
+ function applyMarkdownOptions(options, value, from = "site") {
7527
7572
  if (!isPlainObject(value)) bail(`markdown must be an object, not ${typeOf(value)}`);
7573
+ if (from === "site") {
7574
+ for (const [key, v] of Object.entries(value)) {
7575
+ if (Object.hasOwn(RETIRED_MARKDOWN, key) && v !== false && v !== null && v !== void 0) bail(`markdown.${key} is ${RETIRED_MARKDOWN[key](v)} now: add it to plugins, and leave markdown.${key} out (\`ssqch docs ${RETIRED_MARKDOWN[key](v).split("(")[0]}\`)`);
7576
+ }
7577
+ }
7528
7578
  for (const [key, v] of Object.entries(value)) {
7529
7579
  if (key === "headingIds") {
7530
7580
  if (typeof v === "function") {
@@ -7585,24 +7635,36 @@ function applyMarkdownOptions(options, value) {
7585
7635
  if (typeof v !== "boolean" && v !== "fuzzy" && v !== "email") bail(`markdown.autolinks must be true, false, "email" or "fuzzy", not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
7586
7636
  options.autolinks = v;
7587
7637
  } else if (key === "containers") {
7588
- if (typeof v !== "boolean" && v !== "markdown-it") bail(`markdown.containers must be true, false or "markdown-it", not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
7638
+ if (v === "markdown-it") bail('markdown.containers: "markdown-it" is what `containers: true` does now (a closing `:::` indented under a list closes its container): write true, or leave it out');
7639
+ if (typeof v !== "boolean") bail(`markdown.containers must be true or false, not ${typeof v === "string" ? `"${v}"` : typeOf(v)}`);
7589
7640
  options.containers = v;
7590
7641
  } else if (FLAGS.includes(key)) {
7591
7642
  if (typeof v !== "boolean") bail(`markdown.${key} must be true or false, not ${typeOf(v)}`);
7592
7643
  options[key] = v;
7644
+ } else if (key === "encodeUrls") {
7645
+ bail("markdown.encodeUrls is gone: link and image URLs are percent-encoded, as CommonMark writes them, and browsers go to the same place either way (so does `ssqch diff`). Leave it out");
7593
7646
  } else {
7594
7647
  const near = closest(key, MARKDOWN_KEYS);
7595
7648
  bail(`markdown.${key} isn't an option${near ? ` (did you mean \`${near}\`?)` : ""} (options: ${MARKDOWN_KEYS.join(", ")})`);
7596
7649
  }
7597
7650
  }
7598
- if (options.dialect === "vitepress") {
7599
- const given = value;
7600
- if (!("headingIds" in given)) {
7601
- options.sluggerFn = vitepressSlug;
7602
- options.headingIds = "github";
7603
- }
7604
- if (!("autolinks" in given)) options.autolinks = "email";
7605
- if (!("containers" in given)) options.containers = "markdown-it";
7651
+ }
7652
+ var STEP_KEYS = ["before", "after", "hooks"];
7653
+ function addMarkdownSteps(steps, where, value) {
7654
+ if (!isPlainObject(value)) bail(`${where}: markdown must be an object of { before, after, hooks }`);
7655
+ for (const key of Object.keys(value)) if (!STEP_KEYS.includes(key)) bail(`${where}: markdown.${key} isn't a plugin's Markdown step${closest(key, STEP_KEYS) ? ` (did you mean \`${closest(key, STEP_KEYS)}\`?)` : ""} (a plugin's markdown has before, after and hooks; the site's own options go in the config's markdown, or in the plugin's defaults)`);
7656
+ for (const key of ["before", "after"]) {
7657
+ const fn = value[key];
7658
+ if (fn === void 0) continue;
7659
+ if (typeof fn !== "function") bail(`${where}: markdown.${key} must be a function, (${key === "before" ? "source" : "html"}, context) => text`);
7660
+ steps[key].push([where, fn]);
7661
+ }
7662
+ if (value.hooks !== void 0) {
7663
+ if (!isPlainObject(value.hooks)) bail(`${where}: markdown.hooks must be an object of { name: (value, context) => html }, like { heading: ..., "containers/tip": ... }`);
7664
+ for (const [name, hook] of Object.entries(value.hooks)) {
7665
+ if (typeof hook !== "function") bail(`${where}: markdown.hooks["${name}"] must be a function, (value, context) => html`);
7666
+ steps.hooks.set(/^(?:hooks|containers)\//.test(name) ? name : `hooks/${name}`, [where, hook]);
7667
+ }
7606
7668
  }
7607
7669
  }
7608
7670
  function setLanguage(options, name, value) {
@@ -8270,7 +8332,6 @@ export {
8270
8332
  probeFile,
8271
8333
  oriented,
8272
8334
  undecodable,
8273
- vitepressBefore,
8274
8335
  WebAssembly,
8275
8336
  loadHookTemplates,
8276
8337
  writeHighlightCss,
@@ -8284,8 +8345,12 @@ export {
8284
8345
  withPage,
8285
8346
  safe,
8286
8347
  isSafe,
8348
+ vitepressBefore,
8349
+ VITEPRESS_HOOKS,
8350
+ vitepressAfter,
8287
8351
  defaultMarkdownOptions,
8288
8352
  applyMarkdownOptions,
8353
+ addMarkdownSteps,
8289
8354
  slugWith,
8290
8355
  slugOptions,
8291
8356
  slugText,