ssqch 0.12.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.
- package/bundled/completions/bash +66 -8
- package/bundled/completions/elvish +23 -4
- package/bundled/completions/fish +36 -25
- package/bundled/completions/powershell +25 -4
- package/bundled/completions/zsh +44 -10
- package/bundled/docs/agents.md +2 -2
- package/bundled/docs/build-summary.md +1 -1
- package/bundled/docs/comparing-builds.md +2 -2
- package/bundled/docs/configuring.md +3 -6
- package/bundled/docs/deploying.md +1 -1
- package/bundled/docs/field-guide.md +4 -4
- package/bundled/docs/github-pages.md +1 -0
- package/bundled/docs/index.md +1 -1
- package/bundled/docs/install.md +1 -1
- package/bundled/docs/known-gaps.md +1 -1
- package/bundled/docs/markdown.md +8 -12
- package/bundled/docs/nav.yml +5 -1
- package/bundled/docs/netlify.md +4 -2
- package/bundled/docs/patrol.md +48 -0
- package/bundled/docs/plugins.md +6 -6
- package/bundled/docs/robots.md +72 -0
- package/bundled/docs/seo.md +2 -38
- package/bundled/docs/serving-markdown.md +142 -0
- package/bundled/docs/template-languages.md +1 -1
- package/bundled/docs/templates.md +1 -1
- package/bundled/docs/trailheads/from-hugo.md +5 -3
- package/bundled/docs/trailheads/from-jekyll.md +54 -13
- package/bundled/docs/trailheads/from-mkdocs.md +15 -12
- package/bundled/docs/trailheads/from-vitepress.md +13 -11
- package/bundled/docs/trailheads.md +3 -3
- package/bundled/docs/where-values-come-from.md +5 -5
- package/bundled/docs/writing-plugins.md +69 -0
- package/bundled/ssqch.d.ts +111 -43
- package/bundled/starter/engines/index.edge +1 -0
- package/bundled/starter/engines/index.ejs +1 -0
- package/bundled/starter/engines/index.hbs +1 -0
- package/bundled/starter/engines/index.liquid +1 -0
- package/bundled/starter/engines/layout.edge +7 -0
- package/bundled/starter/engines/layout.ejs +4 -0
- package/bundled/starter/engines/layout.hbs +4 -0
- package/bundled/starter/engines/layout.liquid +4 -0
- package/bundled/starter/src/_data/site.json +1 -0
- package/bundled/starter/src/_includes/layout.jinja +4 -0
- package/bundled/starter/src/index.jinja +1 -0
- package/bundled/starter/ssqch.config.js +14 -1
- package/bundled/starter-docs/engines/edge/base.edge +7 -0
- package/bundled/starter-docs/engines/edge/doc.edge +4 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
- package/bundled/starter-docs/src/_data/site.json +1 -0
- package/bundled/starter-docs/src/_includes/base.jinja +4 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
- package/bundled/starter-docs/src/assets/docs.css +4 -0
- package/bundled/starter-docs/src/assets/docs.js +17 -0
- package/bundled/starter-docs/ssqch.config.js +14 -1
- package/lib/assets.js +9 -9
- package/lib/chunk-25WERNDD.js +112 -0
- package/lib/{chunk-4ZMNLWE4.js → chunk-2BJFGKOE.js} +2 -2
- package/lib/chunk-2FKYWYAB.js +268 -0
- package/lib/{chunk-M2BBE2C3.js → chunk-3ZTRIO6O.js} +18 -17
- package/lib/{chunk-57HLSKZS.js → chunk-4AZFCSGJ.js} +2 -2
- package/lib/{chunk-ULQHJ4TS.js → chunk-55WXDGO4.js} +3 -3
- package/lib/{chunk-JX43SJHU.js → chunk-6FY77I4M.js} +24 -22
- package/lib/{chunk-RY3KLUQ3.js → chunk-6OUCRDYI.js} +267 -202
- package/lib/{chunk-EVFNYUTR.js → chunk-6U5VIQVY.js} +5 -5
- package/lib/{chunk-N3IZ44XY.js → chunk-7U5GWTEH.js} +88 -54
- package/lib/{chunk-VTYQ3JKL.js → chunk-AIJNG6MJ.js} +2 -2
- package/lib/{chunk-IIBZPHAW.js → chunk-C2Q7JKFI.js} +8 -8
- package/lib/{chunk-6CSH757V.js → chunk-DFJFHULZ.js} +33 -8
- package/lib/{chunk-XVV7JJK7.js → chunk-ENWDM2RW.js} +40 -39
- package/lib/{chunk-JUALMFW3.js → chunk-ER72RPD6.js} +1 -1
- package/lib/{chunk-RFREB3SI.js → chunk-F3JPNFCZ.js} +7 -7
- package/lib/{chunk-LLOA3QXV.js → chunk-FENJHLNM.js} +3 -2
- package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
- package/lib/{chunk-IZCF4UH3.js → chunk-FQZDUDFK.js} +1 -1
- package/lib/{chunk-GVHQ37JE.js → chunk-GSNRAGKQ.js} +10 -5
- package/lib/{chunk-L2IY4P6O.js → chunk-GU7BBYWB.js} +3 -3
- package/lib/{chunk-RGYJQYW3.js → chunk-HDKU6LRI.js} +32 -5
- package/lib/{chunk-IQUGLVZY.js → chunk-K5WZ2VYK.js} +4 -4
- package/lib/{chunk-JVT5ZRRH.js → chunk-OOKBXQAY.js} +5 -5
- package/lib/{chunk-MOLTDO5A.js → chunk-SNQOHNXE.js} +1 -1
- package/lib/{chunk-Z3XH4KWX.js → chunk-SPIFZBIW.js} +1 -1
- package/lib/{chunk-FNNXRVSU.js → chunk-T5IUI7W7.js} +10 -10
- package/lib/{chunk-5HEZ3WUQ.js → chunk-TGSVSG2G.js} +2 -2
- package/lib/{chunk-3GROJ3TY.js → chunk-U2KEMVXO.js} +24 -17
- package/lib/{chunk-4B3N44SN.js → chunk-UHRBPZ4A.js} +3 -3
- package/lib/{chunk-GWWA5Y3X.js → chunk-ULCT3PAV.js} +1 -1
- package/lib/{chunk-7RGEWDLF.js → chunk-UZNUS7RP.js} +10 -8
- package/lib/{chunk-DZ5F5XSI.js → chunk-V3G2QGL3.js} +10 -105
- package/lib/{chunk-DOHOKUGB.js → chunk-VILOEVK7.js} +50 -26
- package/lib/{chunk-DXMDXHV7.js → chunk-WGAIE3DD.js} +15 -14
- package/lib/{chunk-G3RFQDKO.js → chunk-WUCRAV36.js} +8 -6
- package/lib/{chunk-52ROOMBZ.js → chunk-XYAWJTHM.js} +9 -9
- package/lib/{chunk-L3K7MMFC.js → chunk-YA23NDMW.js} +2 -2
- package/lib/{chunk-R7PBREXL.js → chunk-YNJNMQWU.js} +8 -5
- package/lib/{chunk-AK7ZKSZP.js → chunk-ZMG25MXF.js} +17 -16
- package/lib/cli.js +56 -34
- package/lib/elements.js +9 -9
- package/lib/from-hugo.js +36 -0
- package/lib/from-jekyll.js +41 -0
- package/lib/from-mkdocs.js +49 -0
- package/lib/from-vitepress.js +49 -0
- package/lib/image.js +10 -10
- package/lib/links.js +9 -9
- package/lib/llms.js +521 -47
- package/lib/minify.js +10 -10
- package/lib/redirects.js +9 -9
- package/lib/robots.js +87 -0
- package/lib/rss.js +22 -12
- package/lib/sass.js +10 -10
- package/lib/sitemap.js +22 -33
- package/lib/ssqch.js +5 -5
- package/lib/vue.js +14 -13
- package/package.json +21 -1
- package/types/from-hugo.d.ts +5 -0
- package/types/from-jekyll.d.ts +11 -0
- package/types/from-mkdocs.d.ts +11 -0
- package/types/from-vitepress.d.ts +5 -0
- package/types/index.d.ts +45 -29
- package/types/llms.d.ts +12 -8
- package/types/robots.d.ts +13 -0
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +3 -5
- package/wasm/markdown.wasm +0 -0
- /package/lib/{chunk-JX43SJHU.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
- /package/lib/{chunk-R7PBREXL.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
package/lib/llms.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
decodeEntities
|
|
5
|
+
} from "./chunk-25WERNDD.js";
|
|
3
6
|
import {
|
|
4
7
|
Options
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SNQOHNXE.js";
|
|
6
9
|
import {
|
|
7
10
|
BUILTINS,
|
|
8
11
|
debugString
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-VILOEVK7.js";
|
|
13
|
+
import "./chunk-ULCT3PAV.js";
|
|
14
|
+
import "./chunk-6U5VIQVY.js";
|
|
12
15
|
import "./chunk-AD3HAW3W.js";
|
|
13
16
|
import "./chunk-YCOTX2VM.js";
|
|
14
17
|
import "./chunk-DDV6JEC2.js";
|
|
15
18
|
import {
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-FVZ5JBRI.js";
|
|
19
|
+
currentRendering
|
|
20
|
+
} from "./chunk-6OUCRDYI.js";
|
|
19
21
|
import {
|
|
20
22
|
globSet
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-SPIFZBIW.js";
|
|
24
|
+
import "./chunk-FVZ5JBRI.js";
|
|
25
|
+
import "./chunk-FJML7INB.js";
|
|
26
|
+
import "./chunk-4AZFCSGJ.js";
|
|
24
27
|
import "./chunk-CMUWRPSQ.js";
|
|
25
28
|
import {
|
|
26
|
-
bail
|
|
27
|
-
|
|
28
|
-
} from "./chunk-R7PBREXL.js";
|
|
29
|
+
bail
|
|
30
|
+
} from "./chunk-YNJNMQWU.js";
|
|
29
31
|
import {
|
|
30
32
|
compareText
|
|
31
33
|
} from "./chunk-VJWQSYEG.js";
|
|
@@ -34,13 +36,355 @@ import "./chunk-I3PS26CI.js";
|
|
|
34
36
|
// src/modules/llms.ts
|
|
35
37
|
import fs from "node:fs";
|
|
36
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 += `)})`;
|
|
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, """)}"`)).join("");
|
|
378
|
+
}).join("\n");
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/modules/llms.ts
|
|
37
382
|
function llmsPlugin(options = {}) {
|
|
38
383
|
return { name: "ssqch/llms", builtin: "ssqch/llms", options };
|
|
39
384
|
}
|
|
40
385
|
function copyUrl(url) {
|
|
41
|
-
if (url
|
|
42
|
-
|
|
43
|
-
return `${bare}.md`;
|
|
386
|
+
if (url.endsWith("/")) return `${url}index.md`;
|
|
387
|
+
return url.replace(/\.html?$/, "") + ".md";
|
|
44
388
|
}
|
|
45
389
|
function sectionOf(url) {
|
|
46
390
|
const first = url.split("/").filter(Boolean);
|
|
@@ -49,10 +393,91 @@ function sectionOf(url) {
|
|
|
49
393
|
const name = first[0].replace(/[-_]+/g, " ");
|
|
50
394
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
51
395
|
}
|
|
52
|
-
var isMarkdown = (file) => /\.(?:md|markdown)$/i.test(file);
|
|
53
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
|
+
}
|
|
54
478
|
BUILTINS.set("ssqch/llms", (config, given) => {
|
|
55
|
-
|
|
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"]);
|
|
56
481
|
const url = o.string("url");
|
|
57
482
|
if (url !== void 0 && url !== "" && !/^https?:\/\//.test(url)) bail(`url must be the site's address, like "https://example.com" (got ${debugString(url)})`);
|
|
58
483
|
const exclude = o.list("exclude") ?? [];
|
|
@@ -60,41 +485,82 @@ BUILTINS.set("ssqch/llms", (config, given) => {
|
|
|
60
485
|
const excluded = exclude.length ? globSet("exclude", exclude) : () => false;
|
|
61
486
|
const copies = o.bool("copies") ?? true;
|
|
62
487
|
const full = o.bool("full") ?? true;
|
|
63
|
-
const hint = o.bool("hint") ?? false;
|
|
64
488
|
const section = o.get("section");
|
|
65
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})`);
|
|
66
492
|
const title = o.string("title");
|
|
67
493
|
const description = o.string("description");
|
|
494
|
+
const details = o.string("details");
|
|
68
495
|
const address = (url ?? "").replace(/\/+$/, "");
|
|
69
|
-
const
|
|
70
|
-
const listed = (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
});
|
|
79
520
|
config.generators.push(["ssqch/llms", (config2, pages) => {
|
|
80
521
|
const base = config2.base.replace(/\/$/, "");
|
|
81
|
-
const
|
|
522
|
+
const output = path.resolve(config2.root, config2.output);
|
|
523
|
+
const whole = (u) => `${address}${base}${u}`;
|
|
82
524
|
const files = [];
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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;
|
|
87
546
|
try {
|
|
88
|
-
|
|
547
|
+
resolved = new URL(file, `https://ssqch.invalid${from.url}`).pathname;
|
|
89
548
|
} catch {
|
|
90
|
-
|
|
549
|
+
return href;
|
|
91
550
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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)}
|
|
96
560
|
|
|
97
561
|
${body}`;
|
|
562
|
+
body = publishedImages(body, p.outputPath, base, output);
|
|
563
|
+
body = rewriteLinks(body, (href) => target(href, p));
|
|
98
564
|
let name = sectionOf(p.url);
|
|
99
565
|
if (typeof section === "function") {
|
|
100
566
|
let out;
|
|
@@ -107,30 +573,38 @@ ${body}`;
|
|
|
107
573
|
}
|
|
108
574
|
entries.push({ url: p.url, copy: copyUrl(p.url), title: pageTitle, description: oneLine(p.data.description), section: name, markdown: body.replace(/\s+$/, "") + "\n" });
|
|
109
575
|
}
|
|
576
|
+
sources.clear();
|
|
577
|
+
converted.clear();
|
|
578
|
+
titles.clear();
|
|
110
579
|
const site = pages[0]?.data.site;
|
|
111
580
|
const siteTitle = title ?? (oneLine(site !== null && typeof site === "object" ? site.title : void 0) || entries.find((e) => e.url === "/")?.title || "Pages");
|
|
112
|
-
let
|
|
581
|
+
let head = `# ${siteTitle}
|
|
113
582
|
`;
|
|
114
|
-
if (description)
|
|
583
|
+
if (description) head += `
|
|
115
584
|
> ${oneLine(description)}
|
|
116
585
|
`;
|
|
586
|
+
if (details?.trim()) head += `
|
|
587
|
+
${details.trim()}
|
|
588
|
+
`;
|
|
589
|
+
let txt = head;
|
|
117
590
|
const sections = /* @__PURE__ */ new Map();
|
|
118
591
|
for (const e of entries) sections.set(e.section, [...sections.get(e.section) ?? [], e]);
|
|
119
|
-
for (const [name,
|
|
592
|
+
for (const [name, list2] of sections) {
|
|
120
593
|
txt += `
|
|
121
594
|
## ${name}
|
|
122
595
|
|
|
123
596
|
`;
|
|
124
|
-
for (const e of
|
|
597
|
+
for (const e of list2) txt += `- [${e.title.replace(/([[\]])/g, "\\$1")}](${whole(copies ? e.copy : e.url)})${e.description ? `: ${e.description}` : ""}
|
|
125
598
|
`;
|
|
126
599
|
}
|
|
127
600
|
files.push({ path: "/llms.txt", contents: txt });
|
|
128
601
|
if (copies) for (const e of entries) files.push({ path: e.copy, contents: e.markdown });
|
|
129
|
-
if (full) files.push({ path: "/llms-full.txt", contents:
|
|
130
|
-
|
|
602
|
+
if (full) files.push({ path: "/llms-full.txt", contents: `${head}
|
|
603
|
+
${entries.map((e) => `---
|
|
604
|
+
url: ${whole(e.url)}
|
|
131
605
|
---
|
|
132
606
|
|
|
133
|
-
${e.markdown}`).join("\n") });
|
|
607
|
+
${e.markdown}`).join("\n")}` });
|
|
134
608
|
return files;
|
|
135
609
|
}]);
|
|
136
610
|
});
|