ssqch 0.11.0 → 0.13.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.
Files changed (138) hide show
  1. package/bundled/completions/bash +67 -9
  2. package/bundled/completions/elvish +24 -4
  3. package/bundled/completions/fish +37 -25
  4. package/bundled/completions/powershell +26 -4
  5. package/bundled/completions/zsh +45 -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 +7 -4
  9. package/bundled/docs/configuring.md +7 -12
  10. package/bundled/docs/deploying.md +1 -1
  11. package/bundled/docs/field-guide.md +4 -4
  12. package/bundled/docs/github-pages.md +2 -1
  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 +11 -13
  17. package/bundled/docs/nav.yml +6 -1
  18. package/bundled/docs/netlify.md +4 -2
  19. package/bundled/docs/patrol.md +48 -0
  20. package/bundled/docs/plugins.md +6 -4
  21. package/bundled/docs/robots.md +72 -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 +2 -1
  25. package/bundled/docs/templates.md +2 -1
  26. package/bundled/docs/trailheads/from-component-frameworks.md +9 -10
  27. package/bundled/docs/trailheads/from-hugo.md +5 -3
  28. package/bundled/docs/trailheads/from-jekyll.md +54 -13
  29. package/bundled/docs/trailheads/from-mkdocs.md +15 -12
  30. package/bundled/docs/trailheads/from-vitepress.md +142 -0
  31. package/bundled/docs/trailheads.md +5 -5
  32. package/bundled/docs/where-values-come-from.md +5 -5
  33. package/bundled/docs/writing-plugins.md +69 -0
  34. package/bundled/ssqch.d.ts +150 -34
  35. package/bundled/starter/engines/index.edge +1 -0
  36. package/bundled/starter/engines/index.ejs +1 -0
  37. package/bundled/starter/engines/index.hbs +1 -0
  38. package/bundled/starter/engines/index.liquid +1 -0
  39. package/bundled/starter/engines/layout.edge +7 -0
  40. package/bundled/starter/engines/layout.ejs +4 -0
  41. package/bundled/starter/engines/layout.hbs +4 -0
  42. package/bundled/starter/engines/layout.liquid +4 -0
  43. package/bundled/starter/src/_data/site.json +1 -0
  44. package/bundled/starter/src/_includes/layout.jinja +4 -0
  45. package/bundled/starter/src/index.jinja +1 -0
  46. package/bundled/starter/ssqch.config.js +14 -1
  47. package/bundled/starter-docs/engines/edge/base.edge +7 -0
  48. package/bundled/starter-docs/engines/edge/doc.edge +4 -0
  49. package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
  50. package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
  51. package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
  52. package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
  53. package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
  55. package/bundled/starter-docs/src/_data/site.json +1 -0
  56. package/bundled/starter-docs/src/_includes/base.jinja +4 -0
  57. package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
  58. package/bundled/starter-docs/src/assets/docs.css +4 -0
  59. package/bundled/starter-docs/src/assets/docs.js +17 -0
  60. package/bundled/starter-docs/ssqch.config.js +14 -1
  61. package/lib/assets.js +13 -11
  62. package/lib/chunk-25WERNDD.js +112 -0
  63. package/lib/{chunk-H5K2ZE7B.js → chunk-2BJFGKOE.js} +13 -5
  64. package/lib/chunk-2FKYWYAB.js +268 -0
  65. package/lib/{chunk-LJOURBYT.js → chunk-3ZTRIO6O.js} +21 -19
  66. package/lib/{chunk-IOBC665M.js → chunk-4AZFCSGJ.js} +5 -3
  67. package/lib/{chunk-HWW5NCVJ.js → chunk-4Q6WMTER.js} +1 -1
  68. package/lib/{chunk-V2FSMOFX.js → chunk-55WXDGO4.js} +3 -3
  69. package/lib/{chunk-ZR3JYLFB.js → chunk-6FY77I4M.js} +331 -58
  70. package/lib/{chunk-JC54PHIT.js → chunk-6OUCRDYI.js} +514 -141
  71. package/lib/{chunk-ERAIEV3O.js → chunk-6U5VIQVY.js} +9 -7
  72. package/lib/{chunk-Z5OP43HU.js → chunk-7U5GWTEH.js} +455 -94
  73. package/lib/{chunk-CMJ7X5WW.js → chunk-AIJNG6MJ.js} +3 -2
  74. package/lib/{chunk-3K237XAX.js → chunk-C2Q7JKFI.js} +12 -10
  75. package/lib/{chunk-GS5B3CBW.js → chunk-DDV6JEC2.js} +1 -1
  76. package/lib/{chunk-A75EVUJX.js → chunk-DFJFHULZ.js} +47 -20
  77. package/lib/{chunk-KZZS4W2V.js → chunk-ENWDM2RW.js} +45 -42
  78. package/lib/{chunk-I3HYKEEW.js → chunk-ER72RPD6.js} +3 -3
  79. package/lib/chunk-F3JPNFCZ.js +23 -0
  80. package/lib/{chunk-B5E27PLU.js → chunk-FENJHLNM.js} +6 -3
  81. package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
  82. package/lib/{chunk-KCF2Z6N7.js → chunk-FQZDUDFK.js} +5 -3
  83. package/lib/{chunk-GJNIQAIH.js → chunk-GSNRAGKQ.js} +13 -6
  84. package/lib/{chunk-443ZQLVX.js → chunk-GU7BBYWB.js} +5 -4
  85. package/lib/{chunk-X2GAVYV2.js → chunk-HDKU6LRI.js} +110 -748
  86. package/lib/chunk-J3C2LEW7.js +121 -0
  87. package/lib/{chunk-XS4EJSEK.js → chunk-K5WZ2VYK.js} +7 -5
  88. package/lib/{chunk-3HZZY3Y7.js → chunk-OOKBXQAY.js} +7 -6
  89. package/lib/chunk-P2WS4RM4.js +707 -0
  90. package/lib/{chunk-RBNPBTDP.js → chunk-SNQOHNXE.js} +1 -1
  91. package/lib/{chunk-HFSWUTXX.js → chunk-SPIFZBIW.js} +1 -1
  92. package/lib/{chunk-QLUTNR37.js → chunk-T5IUI7W7.js} +12 -11
  93. package/lib/{chunk-ZINLHOX4.js → chunk-TGSVSG2G.js} +3 -2
  94. package/lib/{chunk-2L3HR67O.js → chunk-U2KEMVXO.js} +24 -16
  95. package/lib/{chunk-RYIWYWRQ.js → chunk-UHRBPZ4A.js} +7 -5
  96. package/lib/{chunk-2QTJTEBV.js → chunk-ULCT3PAV.js} +1 -1
  97. package/lib/{chunk-FCM3NYFR.js → chunk-UZNUS7RP.js} +12 -9
  98. package/lib/{chunk-GLJQ4C76.js → chunk-V3G2QGL3.js} +13 -106
  99. package/lib/{chunk-Z44IAMNG.js → chunk-VILOEVK7.js} +60 -28
  100. package/lib/chunk-VJWQSYEG.js +119 -0
  101. package/lib/{chunk-5ELAUHRL.js → chunk-WGAIE3DD.js} +23 -19
  102. package/lib/{chunk-OQGXZYZS.js → chunk-WUCRAV36.js} +13 -7
  103. package/lib/{chunk-RZYAIX2R.js → chunk-XYAWJTHM.js} +11 -10
  104. package/lib/{chunk-OSBEH67S.js → chunk-YA23NDMW.js} +5 -3
  105. package/lib/{chunk-AIMEXBTK.js → chunk-YNJNMQWU.js} +37 -142
  106. package/lib/{chunk-QJ5ZFTML.js → chunk-ZMG25MXF.js} +20 -18
  107. package/lib/cli.js +72 -35
  108. package/lib/elements.js +13 -11
  109. package/lib/from-hugo.js +36 -0
  110. package/lib/from-jekyll.js +41 -0
  111. package/lib/from-mkdocs.js +49 -0
  112. package/lib/from-vitepress.js +49 -0
  113. package/lib/image.js +12 -11
  114. package/lib/links.js +13 -11
  115. package/lib/llms.js +613 -0
  116. package/lib/minify.js +14 -12
  117. package/lib/redirects.js +13 -11
  118. package/lib/robots.js +87 -0
  119. package/lib/rss.js +24 -13
  120. package/lib/sass.js +12 -11
  121. package/lib/sitemap.js +23 -18
  122. package/lib/ssqch.js +6 -5
  123. package/lib/vue.js +400 -0
  124. package/package.json +29 -1
  125. package/types/from-hugo.d.ts +5 -0
  126. package/types/from-jekyll.d.ts +11 -0
  127. package/types/from-mkdocs.d.ts +11 -0
  128. package/types/from-vitepress.d.ts +5 -0
  129. package/types/index.d.ts +51 -31
  130. package/types/llms.d.ts +27 -0
  131. package/types/robots.d.ts +13 -0
  132. package/types/sass.d.ts +1 -1
  133. package/types/sitemap.d.ts +2 -2
  134. package/types/vue.d.ts +17 -0
  135. package/wasm/markdown.wasm +0 -0
  136. package/lib/chunk-RVXGUMFI.js +0 -21
  137. /package/lib/{chunk-ZR3JYLFB.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
  138. /package/lib/{chunk-AIMEXBTK.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
package/lib/llms.js ADDED
@@ -0,0 +1,613 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ decodeEntities
5
+ } from "./chunk-25WERNDD.js";
6
+ import {
7
+ Options
8
+ } from "./chunk-SNQOHNXE.js";
9
+ import {
10
+ BUILTINS,
11
+ debugString
12
+ } from "./chunk-VILOEVK7.js";
13
+ import "./chunk-ULCT3PAV.js";
14
+ import "./chunk-6U5VIQVY.js";
15
+ import "./chunk-AD3HAW3W.js";
16
+ import "./chunk-YCOTX2VM.js";
17
+ import "./chunk-DDV6JEC2.js";
18
+ import {
19
+ currentRendering
20
+ } from "./chunk-6OUCRDYI.js";
21
+ import {
22
+ globSet
23
+ } from "./chunk-SPIFZBIW.js";
24
+ import "./chunk-FVZ5JBRI.js";
25
+ import "./chunk-FJML7INB.js";
26
+ import "./chunk-4AZFCSGJ.js";
27
+ import "./chunk-CMUWRPSQ.js";
28
+ import {
29
+ bail
30
+ } from "./chunk-YNJNMQWU.js";
31
+ import {
32
+ compareText
33
+ } from "./chunk-VJWQSYEG.js";
34
+ import "./chunk-I3PS26CI.js";
35
+
36
+ // src/modules/llms.ts
37
+ import fs from "node:fs";
38
+ import path from "node:path";
39
+
40
+ // src/html-markdown.ts
41
+ var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
42
+ var RAW = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "noscript", "template", "iframe", "noembed", "noframes"]);
43
+ var SKIP = /* @__PURE__ */ new Set(["script", "style", "noscript", "template", "head", "nav", "form", "button", "select", "input", "textarea", "iframe", "canvas", "svg", "math", "video", "audio", "object", "embed", "dialog", "meta", "link", "title"]);
44
+ var BLOCK = /* @__PURE__ */ new Set(["address", "article", "aside", "blockquote", "body", "details", "dialog", "dd", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "li", "main", "nav", "ol", "p", "pre", "section", "summary", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul", "html", "caption"]);
45
+ var CLOSES_P = /* @__PURE__ */ new Set(["address", "article", "aside", "blockquote", "details", "div", "dl", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "main", "nav", "ol", "p", "pre", "section", "table", "ul"]);
46
+ var TAG = /<(\/?)([A-Za-z][A-Za-z0-9-]*)((?:\s+[^\s"'>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*(\/?)>/y;
47
+ var ATTR = /([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
48
+ function parse(html) {
49
+ const root = { name: "#root", attrs: /* @__PURE__ */ new Map(), children: [] };
50
+ const stack = [root];
51
+ const top = () => stack[stack.length - 1];
52
+ const close = (name, stopAt = /* @__PURE__ */ new Set()) => {
53
+ for (let i = stack.length - 1; i > 0; i--) {
54
+ if (stopAt.has(stack[i].name)) return;
55
+ if (stack[i].name === name) {
56
+ stack.length = i;
57
+ return;
58
+ }
59
+ }
60
+ };
61
+ let at = 0;
62
+ let text = "";
63
+ const flush = () => {
64
+ if (text) top().children.push(decodeEntities(text));
65
+ text = "";
66
+ };
67
+ while (at < html.length) {
68
+ const lt = html.indexOf("<", at);
69
+ if (lt === -1) {
70
+ text += html.slice(at);
71
+ break;
72
+ }
73
+ text += html.slice(at, lt);
74
+ at = lt;
75
+ if (html.startsWith("<!--", at)) {
76
+ const end = html.indexOf("-->", at + 4);
77
+ at = end === -1 ? html.length : end + 3;
78
+ continue;
79
+ }
80
+ if (html[at + 1] === "!" || html[at + 1] === "?") {
81
+ const end = html.indexOf(">", at);
82
+ at = end === -1 ? html.length : end + 1;
83
+ continue;
84
+ }
85
+ TAG.lastIndex = at;
86
+ const m = TAG.exec(html);
87
+ if (!m) {
88
+ text += "<";
89
+ at++;
90
+ continue;
91
+ }
92
+ flush();
93
+ at = TAG.lastIndex;
94
+ const name = m[2].toLowerCase();
95
+ if (m[1]) {
96
+ if (name === "p" && !stack.some((e) => e.name === "p")) continue;
97
+ close(name);
98
+ continue;
99
+ }
100
+ const attrs = /* @__PURE__ */ new Map();
101
+ for (const a of m[3].matchAll(ATTR)) attrs.set(a[1].toLowerCase(), decodeEntities(a[2] ?? a[3] ?? a[4] ?? ""));
102
+ if (CLOSES_P.has(name)) close("p", /* @__PURE__ */ new Set(["button", "td", "th", "li", "blockquote", "div", "section", "article", "main"]));
103
+ if (name === "li") close("li", /* @__PURE__ */ new Set(["ul", "ol"]));
104
+ if (name === "dt" || name === "dd") {
105
+ close("dt", /* @__PURE__ */ new Set(["dl"]));
106
+ close("dd", /* @__PURE__ */ new Set(["dl"]));
107
+ }
108
+ if (name === "tr") close("tr", /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot"]));
109
+ if (name === "td" || name === "th") {
110
+ close("td", /* @__PURE__ */ new Set(["tr", "table"]));
111
+ close("th", /* @__PURE__ */ new Set(["tr", "table"]));
112
+ }
113
+ if (name === "thead" || name === "tbody" || name === "tfoot") {
114
+ close("thead", /* @__PURE__ */ new Set(["table"]));
115
+ close("tbody", /* @__PURE__ */ new Set(["table"]));
116
+ }
117
+ const el = { name, attrs, children: [] };
118
+ top().children.push(el);
119
+ if (VOID.has(name) || m[4]) continue;
120
+ if (RAW.has(name)) {
121
+ const end = html.toLowerCase().indexOf(`</${name}`, at);
122
+ const inner = html.slice(at, end === -1 ? html.length : end);
123
+ if (name === "textarea" || name === "title") el.children.push(decodeEntities(inner));
124
+ at = end === -1 ? html.length : html.indexOf(">", end) + 1 || html.length;
125
+ continue;
126
+ }
127
+ stack.push(el);
128
+ }
129
+ flush();
130
+ return root;
131
+ }
132
+ function find(el, name) {
133
+ for (const c of el.children) {
134
+ if (typeof c === "string") continue;
135
+ if (c.name === name) return c;
136
+ const inner = find(c, name);
137
+ if (inner) return inner;
138
+ }
139
+ return void 0;
140
+ }
141
+ var hidden = (el) => el.attrs.has("hidden") || el.attrs.get("aria-hidden") === "true";
142
+ var skipped = (el) => SKIP.has(el.name) || hidden(el);
143
+ var isBlock = (n) => typeof n !== "string" && BLOCK.has(n.name);
144
+ function textOf(n) {
145
+ if (typeof n === "string") return n;
146
+ if (n.name === "br") return "\n";
147
+ return n.children.map(textOf).join("");
148
+ }
149
+ function escape(text) {
150
+ return text.replace(/\\/g, "\\\\").replace(/[*`[\]]/g, "\\$&").replace(/(^|[^\p{L}\p{N}])_|_(?=[^\p{L}\p{N}]|$)/gu, (m) => m.replace("_", "\\_")).replace(/<(?=[A-Za-z/!?])/g, "\\<").replace(/&(?=#?[A-Za-z0-9]+;)/g, "\\&");
151
+ }
152
+ function escapeLineStart(line) {
153
+ return line.replace(/^(\s*)(#{1,6}(?=\s|$)|>|[-+](?=\s)|(\d+)([.)])(?=\s)|=+\s*$|~~~)/, (_, space, mark, digits, dot) => digits ? `${space}${digits}\\${dot}` : `${space}\\${mark}`);
154
+ }
155
+ var selfLink = (el) => el.name === "a" && (el.attrs.get("href") ?? "").startsWith("#") && !/[\p{L}\p{N}]/u.test(textOf(el));
156
+ function inline(nodes, inHeading = false) {
157
+ let out = "";
158
+ for (const n of nodes) {
159
+ if (typeof n === "string") {
160
+ out += escape(n.replace(/\s+/g, " "));
161
+ continue;
162
+ }
163
+ if (skipped(n)) continue;
164
+ switch (n.name) {
165
+ case "br":
166
+ out += "\\\n";
167
+ break;
168
+ case "img": {
169
+ const alt = n.attrs.get("alt");
170
+ if (alt === "" || !n.attrs.get("src")) break;
171
+ out += `![${escape(alt ?? "")}](${destination(n.attrs.get("src"))})`;
172
+ break;
173
+ }
174
+ case "a": {
175
+ if (inHeading && selfLink(n)) break;
176
+ const text = inline(n.children, inHeading).trim();
177
+ const href = n.attrs.get("href");
178
+ if (!href || !text) {
179
+ out += text;
180
+ break;
181
+ }
182
+ const title = n.attrs.get("title");
183
+ out += `[${text}](${destination(href)}${title ? ` "${title.replace(/"/g, '\\"')}"` : ""})`;
184
+ break;
185
+ }
186
+ case "strong":
187
+ case "b": {
188
+ const t = inline(n.children, inHeading).trim();
189
+ if (t) out += `**${t}**`;
190
+ break;
191
+ }
192
+ case "em":
193
+ case "i":
194
+ case "cite":
195
+ case "dfn": {
196
+ const t = inline(n.children, inHeading).trim();
197
+ if (t) out += `*${t}*`;
198
+ break;
199
+ }
200
+ case "del":
201
+ case "s":
202
+ case "strike": {
203
+ const t = inline(n.children, inHeading).trim();
204
+ if (t) out += `~~${t}~~`;
205
+ break;
206
+ }
207
+ case "code":
208
+ case "kbd":
209
+ case "samp":
210
+ case "tt":
211
+ out += codeSpan(textOf(n));
212
+ break;
213
+ default:
214
+ out += inline(n.children, inHeading);
215
+ }
216
+ }
217
+ return out;
218
+ }
219
+ var destination = (href) => /[\s()<>]/.test(href) ? `<${href.replace(/[<>]/g, (c) => encodeURIComponent(c))}>` : href;
220
+ function codeSpan(text) {
221
+ const code = text.replace(/\n/g, " ");
222
+ if (!code) return "";
223
+ const longest = Math.max(0, ...[...code.matchAll(/`+/g)].map((m) => m[0].length));
224
+ const ticks = "`".repeat(longest + 1);
225
+ const pad = code.startsWith("`") || code.endsWith("`") || code.startsWith(" ") && code.endsWith(" ") && code.trim() ? " " : "";
226
+ return `${ticks}${pad}${code}${pad}${ticks}`;
227
+ }
228
+ function paragraph(text) {
229
+ return text.replace(/[ \t]+/g, " ").split("\n").map((l) => escapeLineStart(l.trim())).join("\n").trim();
230
+ }
231
+ function languageOf(pre) {
232
+ const code = pre.children.find((c) => typeof c !== "string" && c.name === "code");
233
+ for (const el of [code, pre]) {
234
+ const m = /(?:^|\s)(?:language|lang)-([\w+#.-]+)/.exec(el?.attrs.get("class") ?? "") ?? (el?.attrs.get("data-lang") ? [, el.attrs.get("data-lang")] : null);
235
+ if (m?.[1]) return m[1];
236
+ }
237
+ return "";
238
+ }
239
+ function fence(text, lang) {
240
+ const body = text.replace(/\n$/, "");
241
+ const longest = Math.max(2, ...[...body.matchAll(/^\s*(`{3,})/gm)].map((m) => m[1].length));
242
+ const marks = "`".repeat(longest + 1);
243
+ return `${marks}${lang}
244
+ ${body}
245
+ ${marks}`;
246
+ }
247
+ var indent = (text, by) => text.split("\n").map((l, i) => i === 0 || l === "" ? l : by + l).join("\n");
248
+ function blocks(nodes) {
249
+ const out = [];
250
+ let run = [];
251
+ const endRun = () => {
252
+ const text = paragraph(inline(run));
253
+ if (text) out.push(text);
254
+ run = [];
255
+ };
256
+ for (const n of nodes) {
257
+ if (typeof n === "string" || !isBlock(n)) {
258
+ if (typeof n !== "string" && skipped(n)) continue;
259
+ run.push(n);
260
+ continue;
261
+ }
262
+ endRun();
263
+ if (skipped(n)) continue;
264
+ out.push(...block(n));
265
+ }
266
+ endRun();
267
+ return out;
268
+ }
269
+ function block(el) {
270
+ const name = el.name;
271
+ const heading = /^h([1-6])$/.exec(name);
272
+ if (heading) {
273
+ const text = inline(el.children, true).replace(/\s+/g, " ").trim();
274
+ return text ? [`${"#".repeat(Number(heading[1]))} ${text}`] : [];
275
+ }
276
+ switch (name) {
277
+ case "p": {
278
+ const t = paragraph(inline(el.children));
279
+ return t ? [t] : [];
280
+ }
281
+ case "hr":
282
+ return ["---"];
283
+ case "pre":
284
+ return [fence(textOf(el), languageOf(el))];
285
+ case "blockquote": {
286
+ const inner = blocks(el.children).join("\n\n");
287
+ return inner ? [inner.split("\n").map((l) => l ? `> ${l}` : ">").join("\n")] : [];
288
+ }
289
+ case "ul":
290
+ case "ol":
291
+ return list(el);
292
+ case "table":
293
+ return table(el);
294
+ case "dl": {
295
+ const out = [];
296
+ for (const c of el.children) {
297
+ if (typeof c === "string" || skipped(c)) continue;
298
+ if (c.name === "dt") {
299
+ const t = inline(c.children).trim();
300
+ if (t) out.push(`**${t}**`);
301
+ } else if (c.name === "dd") out.push(...blocks(c.children));
302
+ else out.push(...blocks([c]));
303
+ }
304
+ return out;
305
+ }
306
+ case "summary": {
307
+ const t = inline(el.children).trim();
308
+ return t ? [`**${t}**`] : [];
309
+ }
310
+ default:
311
+ return blocks(el.children);
312
+ }
313
+ }
314
+ function list(el) {
315
+ const ordered = el.name === "ol";
316
+ let n = ordered ? Number(el.attrs.get("start") ?? 1) || 1 : 0;
317
+ const items = [];
318
+ for (const c of el.children) {
319
+ if (typeof c === "string" || c.name !== "li" || skipped(c)) continue;
320
+ const marker = ordered ? `${n++}. ` : "- ";
321
+ const inner = blocks(c.children);
322
+ const loose = c.children.some((x) => typeof x !== "string" && x.name === "p");
323
+ const body = inner.join(loose ? "\n\n" : "\n");
324
+ items.push(marker + indent(body, " ".repeat(marker.length)));
325
+ }
326
+ return items.length ? [items.join("\n")] : [];
327
+ }
328
+ function table(el) {
329
+ const rows = [];
330
+ const walk = (e, head) => {
331
+ for (const c of e.children) {
332
+ if (typeof c === "string" || skipped(c)) continue;
333
+ if (c.name === "tr") {
334
+ const cells = c.children.filter((x) => typeof x !== "string" && (x.name === "td" || x.name === "th"));
335
+ rows.push({ cells: cells.map((x) => inline(x.children).replace(/\s+/g, " ").trim().replace(/\|/g, "\\|")), head: head || cells.length > 0 && cells.every((x) => x.name === "th") });
336
+ } else if (c.name === "thead") walk(c, true);
337
+ else if (c.name === "tbody" || c.name === "tfoot") walk(c, false);
338
+ }
339
+ };
340
+ walk(el, false);
341
+ if (!rows.length) return [];
342
+ const width = Math.max(...rows.map((r) => r.cells.length));
343
+ const line = (cells) => `| ${Array.from({ length: width }, (_, i) => cells[i] ?? "").join(" | ")} |`;
344
+ const [first, ...rest] = rows[0].head ? rows : [{ cells: [], head: true }, ...rows];
345
+ const caption = find(el, "caption");
346
+ const out = caption ? [paragraph(inline(caption.children))].filter(Boolean) : [];
347
+ out.push([line(first.cells), `|${" --- |".repeat(width)}`, ...rest.map((r) => line(r.cells))].join("\n"));
348
+ return out;
349
+ }
350
+ function htmlToMarkdown(html) {
351
+ const root = parse(html);
352
+ const part = find(root, "article") ?? find(root, "main") ?? find(root, "body") ?? root;
353
+ const text = blocks(part.children).join("\n\n").trim();
354
+ return text ? `${text}
355
+ ` : "";
356
+ }
357
+ var INLINE_LINK = /(\]\()(\s*)(<[^>\n]*>|(?:[^\s()\\]|\\.|\((?:[^\s()\\]|\\.)*\))+)/g;
358
+ var REFERENCE = /^( {0,3}\[[^\]\n]+\]:[ \t]*)(<[^>\n]*>|\S+)/;
359
+ var HTML_URL = /(<(?:a|img|source|link)\b[^>]*?\s(?:href|src)\s*=\s*)("([^"]*)"|'([^']*)')/gi;
360
+ function rewriteLinks(markdown, to) {
361
+ let fenced;
362
+ return markdown.split("\n").map((line) => {
363
+ const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
364
+ if (fenced !== void 0) {
365
+ if (marker && marker[0] === fenced[0] && marker.length >= fenced.length && line.trim() === marker) fenced = void 0;
366
+ return line;
367
+ }
368
+ if (marker) {
369
+ fenced = marker;
370
+ return line;
371
+ }
372
+ const ref = REFERENCE.exec(line);
373
+ if (ref) {
374
+ const href = ref[2].startsWith("<") ? ref[2].slice(1, -1) : ref[2];
375
+ return ref[1] + destination(to(href)) + line.slice(ref[0].length);
376
+ }
377
+ return line.split(/(`+[^`]*`+)/).map((part, i) => i % 2 === 1 ? part : part.replace(INLINE_LINK, (_, open, space, dest) => open + space + destination(to(dest.startsWith("<") ? dest.slice(1, -1) : dest.replace(/\\(.)/g, "$1")))).replace(HTML_URL, (_, before, _q, d, s) => `${before}"${to(d ?? s ?? "").replace(/"/g, "&quot;")}"`)).join("");
378
+ }).join("\n");
379
+ }
380
+
381
+ // src/modules/llms.ts
382
+ function llmsPlugin(options = {}) {
383
+ return { name: "ssqch/llms", builtin: "ssqch/llms", options };
384
+ }
385
+ function copyUrl(url) {
386
+ if (url.endsWith("/")) return `${url}index.md`;
387
+ return url.replace(/\.html?$/, "") + ".md";
388
+ }
389
+ function sectionOf(url) {
390
+ const first = url.split("/").filter(Boolean);
391
+ if (first.length < 2 && !url.endsWith("/")) return "Pages";
392
+ if (first.length === 0) return "Pages";
393
+ const name = first[0].replace(/[-_]+/g, " ");
394
+ return name.charAt(0).toUpperCase() + name.slice(1);
395
+ }
396
+ var oneLine = (s) => typeof s === "string" ? s.replace(/\s+/g, " ").trim() : "";
397
+ var isPageUrl = (url) => url.endsWith("/") || url.endsWith(".html");
398
+ var keyOf = (url) => url.replace(/\/index\.html$/, "/");
399
+ function pageText(markdown) {
400
+ const out = [];
401
+ let fenced;
402
+ let raw;
403
+ for (const line of markdown.split("\n")) {
404
+ if (raw !== void 0) {
405
+ if (new RegExp(`</${raw}\\s*>`, "i").test(line)) raw = void 0;
406
+ continue;
407
+ }
408
+ const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
409
+ if (fenced !== void 0) {
410
+ if (marker && marker[0] === fenced[0] && marker.length >= fenced.length && line.trim() === marker) fenced = void 0;
411
+ out.push(line);
412
+ continue;
413
+ }
414
+ if (marker) {
415
+ fenced = marker;
416
+ out.push(line);
417
+ continue;
418
+ }
419
+ const open = /^\s{0,3}<(script|style)\b/i.exec(line);
420
+ if (open) {
421
+ if (!new RegExp(`</${open[1]}\\s*>`, "i").test(line)) raw = open[1].toLowerCase();
422
+ continue;
423
+ }
424
+ if (/^\s*(?:<img\b[^>]*\balt=(?:""|'')[^>]*>\s*)+$/i.test(line)) continue;
425
+ if (line.trim() === "" && (out.length === 0 || out[out.length - 1].trim() === "")) continue;
426
+ out.push(line);
427
+ }
428
+ return out.join("\n").replace(/^\s+/, "");
429
+ }
430
+ function publishedImages(markdown, outputPath, base, output) {
431
+ let html;
432
+ try {
433
+ html = fs.readFileSync(outputPath, "utf8");
434
+ } catch {
435
+ return markdown;
436
+ }
437
+ const attr = (tag, name) => new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(tag)?.slice(1).find((v) => v !== void 0);
438
+ const byAlt = /* @__PURE__ */ new Map();
439
+ for (const [tag] of html.matchAll(/<img\b[^>]*>/gi)) {
440
+ const alt = decodeEntities(attr(tag, "alt") ?? "");
441
+ let src = attr(tag, "src");
442
+ if (src === void 0 || /^[a-z][a-z0-9+.-]*:/i.test(src)) continue;
443
+ src = decodeEntities(src);
444
+ if (base && src.startsWith(`${base}/`)) src = src.slice(base.length);
445
+ byAlt.set(alt, [...byAlt.get(alt) ?? [], src]);
446
+ }
447
+ const byText = /* @__PURE__ */ new Map();
448
+ for (const [, href, text] of html.matchAll(/<a\b[^>]*\shref\s*=\s*"([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi)) {
449
+ const key = decodeEntities(text.replace(/<[^>]+>/g, "")).replace(/\s+/g, " ").trim();
450
+ if (key) byText.set(key, [...byText.get(key) ?? [], base && href.startsWith(`${base}/`) ? href.slice(base.length) : href]);
451
+ }
452
+ if (!byAlt.size && !byText.size) return markdown;
453
+ const next = (alt) => byAlt.get(alt)?.shift();
454
+ const became = /* @__PURE__ */ new Map();
455
+ const out = !byAlt.size ? markdown : markdown.replace(/(!\[([^\]]*)\]\()(<[^>]*>|[^\s)]+)|<img\b[^>]*>/gi, (whole, open, alt, dest) => {
456
+ if (open !== void 0) {
457
+ const src2 = next((alt ?? "").replace(/\\(.)/g, "$1"));
458
+ if (src2 === void 0) return whole;
459
+ became.set((dest ?? "").replace(/^<|>$/g, ""), src2);
460
+ return open + src2;
461
+ }
462
+ const src = next(decodeEntities(attr(whole, "alt") ?? ""));
463
+ if (src === void 0) return whole;
464
+ const was = attr(whole, "src");
465
+ if (was !== void 0) became.set(decodeEntities(was), src);
466
+ return whole.replace(/(\ssrc\s*=\s*)(?:"[^"]*"|'[^']*'|[^\s>]+)/i, `$1"${src}"`);
467
+ });
468
+ const missing = (href) => href.startsWith("/") && !href.startsWith("//") && !fs.existsSync(path.join(output, decodeURIComponent(href.split(/[?#]/)[0])));
469
+ return out.replace(/(\[([^\]]*)\]\()([^\s)]+)/g, (whole, open, text, href) => {
470
+ if (became.has(href)) return open + became.get(href);
471
+ const instead = missing(href) ? byText.get(text.replace(/\\(.)/g, "$1").replace(/[*_`]/g, "").trim())?.find((h) => !missing(h)) : void 0;
472
+ return instead === void 0 ? whole : open + instead;
473
+ }).replace(/(<a\b[^>]*\shref\s*=\s*)(?:"([^"]*)"|'([^']*)')/gi, (whole, open, d, q) => {
474
+ const href = decodeEntities(d ?? q ?? "");
475
+ return became.has(href) ? `${open}"${became.get(href)}"` : whole;
476
+ });
477
+ }
478
+ BUILTINS.set("ssqch/llms", (config, given) => {
479
+ if (given !== null && typeof given === "object" && Object.hasOwn(given, "hint")) bail('`hint` is gone: a build adds no markup of its own. Link the copy from your layout\'s <head> instead: <link rel="alternate" type="text/markdown" href="{{ markdownCopy(page.url) }}">');
480
+ const o = new Options(given, ["title", "description", "details", "url", "exclude", "copies", "full", "section", "sort"]);
481
+ const url = o.string("url");
482
+ if (url !== void 0 && url !== "" && !/^https?:\/\//.test(url)) bail(`url must be the site's address, like "https://example.com" (got ${debugString(url)})`);
483
+ const exclude = o.list("exclude") ?? [];
484
+ for (const glob of exclude) if (!glob.startsWith("/")) bail(`exclude: ${debugString(glob)} must be a URL path or glob starting with /, like "/blog/**"`);
485
+ const excluded = exclude.length ? globSet("exclude", exclude) : () => false;
486
+ const copies = o.bool("copies") ?? true;
487
+ const full = o.bool("full") ?? true;
488
+ const section = o.get("section");
489
+ if (section !== void 0 && typeof section !== "function") bail(`section must be a function that gets each page and returns its section's name, like (page) => page.data.category (got ${typeof section})`);
490
+ const sort = o.get("sort");
491
+ if (sort !== void 0 && typeof sort !== "function") bail(`sort must be a function that compares two pages, like (a, b) => a.data.order - b.data.order (got ${typeof sort})`);
492
+ const title = o.string("title");
493
+ const description = o.string("description");
494
+ const details = o.string("details");
495
+ const address = (url ?? "").replace(/\/+$/, "");
496
+ const listedUrl = (pageUrl) => isPageUrl(pageUrl) && !excluded(pageUrl) && pageUrl !== "/404.html" && pageUrl !== "/404/";
497
+ const listed = (p) => p.outputPath.endsWith(".html") && listedUrl(p.url) && p.data.llms !== false;
498
+ const sources = /* @__PURE__ */ new Map();
499
+ config.markdownSources = sources;
500
+ const converted = /* @__PURE__ */ new Map();
501
+ const titles = /* @__PURE__ */ new Map();
502
+ config.htmlTransforms.push(["llms", (html, page) => {
503
+ if (copies || full) {
504
+ if (page.outputPath.endsWith(".html") && listedUrl(page.url)) {
505
+ if (!sources.has(page.url)) converted.set(page.url, htmlToMarkdown(html));
506
+ const title2 = /<title[^>]*>([^<]*)<\/title>/i.exec(html)?.[1];
507
+ if (title2) titles.set(page.url, decodeEntities(title2).replace(/\s+/g, " ").trim());
508
+ }
509
+ }
510
+ return html;
511
+ }]);
512
+ config.filters.set("markdownCopy", (value) => {
513
+ const pageUrl = value === void 0 || value === null ? "" : String(value);
514
+ if (!copies || !listedUrl(pageUrl)) return "";
515
+ const data = currentRendering()?.data;
516
+ const page = data?.page;
517
+ if (page && page.url === pageUrl && data?.llms === false) return "";
518
+ return copyUrl(pageUrl);
519
+ });
520
+ config.generators.push(["ssqch/llms", (config2, pages) => {
521
+ const base = config2.base.replace(/\/$/, "");
522
+ const output = path.resolve(config2.root, config2.output);
523
+ const whole = (u) => `${address}${base}${u}`;
524
+ const files = [];
525
+ const chosen = pages.filter(listed).sort((a, b) => compareText(a.url, b.url));
526
+ if (typeof sort === "function") {
527
+ try {
528
+ chosen.sort(sort);
529
+ } catch (e) {
530
+ bail(`sort(): ${e instanceof Error ? e.message : String(e)}`);
531
+ }
532
+ }
533
+ const withCopy = new Set(chosen);
534
+ const byUrl = new Map(pages.map((p) => [keyOf(p.url), p]));
535
+ const byFile = new Map(pages.map((p) => [path.resolve(p.inputPath), p]));
536
+ const linkTo = (page) => copies && withCopy.has(page) ? copyUrl(page.url) : page.url;
537
+ const target = (href, from) => {
538
+ if (href === "" || href.startsWith("#") || href.startsWith("//") || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(href)) return href;
539
+ const cut = href.search(/[?#]/);
540
+ const [file, rest] = cut === -1 ? [href, ""] : [href.slice(0, cut), href.slice(cut)];
541
+ if (/\.(?:md|markdown)$/i.test(file) && !file.startsWith("/")) {
542
+ const page2 = byFile.get(path.resolve(path.dirname(from.inputPath), decodeURIComponent(file)));
543
+ if (page2) return whole(linkTo(page2)) + rest;
544
+ }
545
+ let resolved;
546
+ try {
547
+ resolved = new URL(file, `https://ssqch.invalid${from.url}`).pathname;
548
+ } catch {
549
+ return href;
550
+ }
551
+ const page = byUrl.get(keyOf(resolved)) ?? byUrl.get(keyOf(`${resolved}/`));
552
+ return whole(page ? linkTo(page) : resolved) + rest;
553
+ };
554
+ const entries = [];
555
+ for (const p of chosen) {
556
+ const source = sources.get(p.url);
557
+ let body = source !== void 0 ? pageText(source) : converted.get(p.url) ?? "";
558
+ const pageTitle = oneLine(p.data.title) || /^#\s+(.+)$/m.exec(body)?.[1]?.trim() || titles.get(p.url) || p.url;
559
+ if (!/^#\s/.test(body) && oneLine(p.data.title)) body = `# ${oneLine(p.data.title)}
560
+
561
+ ${body}`;
562
+ body = publishedImages(body, p.outputPath, base, output);
563
+ body = rewriteLinks(body, (href) => target(href, p));
564
+ let name = sectionOf(p.url);
565
+ if (typeof section === "function") {
566
+ let out;
567
+ try {
568
+ out = section(p);
569
+ } catch (e) {
570
+ bail(`section(), for ${p.url}: ${e instanceof Error ? e.message : String(e)}`);
571
+ }
572
+ if (typeof out === "string" && out.trim() !== "") name = out.trim();
573
+ }
574
+ entries.push({ url: p.url, copy: copyUrl(p.url), title: pageTitle, description: oneLine(p.data.description), section: name, markdown: body.replace(/\s+$/, "") + "\n" });
575
+ }
576
+ sources.clear();
577
+ converted.clear();
578
+ titles.clear();
579
+ const site = pages[0]?.data.site;
580
+ const siteTitle = title ?? (oneLine(site !== null && typeof site === "object" ? site.title : void 0) || entries.find((e) => e.url === "/")?.title || "Pages");
581
+ let head = `# ${siteTitle}
582
+ `;
583
+ if (description) head += `
584
+ > ${oneLine(description)}
585
+ `;
586
+ if (details?.trim()) head += `
587
+ ${details.trim()}
588
+ `;
589
+ let txt = head;
590
+ const sections = /* @__PURE__ */ new Map();
591
+ for (const e of entries) sections.set(e.section, [...sections.get(e.section) ?? [], e]);
592
+ for (const [name, list2] of sections) {
593
+ txt += `
594
+ ## ${name}
595
+
596
+ `;
597
+ for (const e of list2) txt += `- [${e.title.replace(/([[\]])/g, "\\$1")}](${whole(copies ? e.copy : e.url)})${e.description ? `: ${e.description}` : ""}
598
+ `;
599
+ }
600
+ files.push({ path: "/llms.txt", contents: txt });
601
+ if (copies) for (const e of entries) files.push({ path: e.copy, contents: e.markdown });
602
+ if (full) files.push({ path: "/llms-full.txt", contents: `${head}
603
+ ${entries.map((e) => `---
604
+ url: ${whole(e.url)}
605
+ ---
606
+
607
+ ${e.markdown}`).join("\n")}` });
608
+ return files;
609
+ }]);
610
+ });
611
+ export {
612
+ llmsPlugin
613
+ };
package/lib/minify.js CHANGED
@@ -2,36 +2,38 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  compressCss
5
- } from "./chunk-XS4EJSEK.js";
5
+ } from "./chunk-K5WZ2VYK.js";
6
6
  import "./chunk-3NYSSA2C.js";
7
7
  import {
8
8
  Options
9
- } from "./chunk-RBNPBTDP.js";
9
+ } from "./chunk-SNQOHNXE.js";
10
10
  import {
11
11
  BUILTINS,
12
12
  RustPlugin,
13
13
  compilePlugin
14
- } from "./chunk-Z44IAMNG.js";
15
- import "./chunk-2QTJTEBV.js";
16
- import "./chunk-ERAIEV3O.js";
14
+ } from "./chunk-VILOEVK7.js";
15
+ import "./chunk-ULCT3PAV.js";
16
+ import "./chunk-6U5VIQVY.js";
17
17
  import "./chunk-AD3HAW3W.js";
18
18
  import "./chunk-YCOTX2VM.js";
19
- import "./chunk-GS5B3CBW.js";
20
- import "./chunk-JC54PHIT.js";
21
- import "./chunk-HFSWUTXX.js";
19
+ import "./chunk-DDV6JEC2.js";
20
+ import "./chunk-6OUCRDYI.js";
21
+ import "./chunk-SPIFZBIW.js";
22
22
  import {
23
23
  closest
24
24
  } from "./chunk-FVZ5JBRI.js";
25
- import "./chunk-UU43WIZG.js";
26
- import "./chunk-IOBC665M.js";
25
+ import "./chunk-FJML7INB.js";
26
+ import "./chunk-4AZFCSGJ.js";
27
27
  import "./chunk-CMUWRPSQ.js";
28
28
  import {
29
29
  BuildError,
30
- displayPath,
31
30
  messageOf,
32
31
  warn,
33
32
  warning
34
- } from "./chunk-AIMEXBTK.js";
33
+ } from "./chunk-YNJNMQWU.js";
34
+ import {
35
+ displayPath
36
+ } from "./chunk-VJWQSYEG.js";
35
37
  import "./chunk-I3PS26CI.js";
36
38
 
37
39
  // src/modules/minify.ts