@pretextbook/pretext-html 0.7.0 → 0.9.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/README.md +31 -2
- package/assets/preview-html.xsl +16 -0
- package/assets/upstream.json +1 -1
- package/assets/xsl/README.md +25 -24
- package/assets/xsl/entities.ent +11 -0
- package/assets/xsl/extract-dynamic.xsl +54 -3
- package/assets/xsl/extract-gdscript.xsl +61 -0
- package/assets/xsl/extract-sageplot.xsl +3 -0
- package/assets/xsl/localizations/README.md +24 -24
- package/assets/xsl/localizations/it-IT.xml +37 -41
- package/assets/xsl/pretext-assembly.xsl +190 -30
- package/assets/xsl/pretext-beamer.xsl +57 -12
- package/assets/xsl/pretext-common.xsl +175 -30
- package/assets/xsl/pretext-epub.xsl +4 -6
- package/assets/xsl/pretext-fo.xsl +127 -67
- package/assets/xsl/pretext-html.xsl +350 -94
- package/assets/xsl/pretext-jupyter.xsl +1 -0
- package/assets/xsl/pretext-latex-classic.xsl +2 -2
- package/assets/xsl/pretext-latex-common.xsl +296 -151
- package/assets/xsl/pretext-latex.xsl +16 -6
- package/assets/xsl/pretext-numbers.xsl +10 -0
- package/assets/xsl/pretext-revealjs.xsl +69 -4
- package/assets/xsl/pretext-runestone-fitb.xsl +179 -84
- package/assets/xsl/pretext-runestone-static.xsl +72 -20
- package/assets/xsl/pretext-runestone.xsl +32 -25
- package/assets/xsl/pretext-text-utilities.xsl +7 -0
- package/assets/xsl/pretext-text.xsl +17 -0
- package/assets/xsl/publisher-variables.xsl +109 -111
- package/assets/xsl/support/play-button/README.md +1 -3
- package/assets/xsl/tests/README.md +1 -1
- package/assets/xsl/utilities/README.md +6 -8
- package/assets/xsl-bundle.json +1 -1
- package/dist/cli-BUrNZxov.js +1098 -0
- package/dist/cli.js +1 -1
- package/dist/html-static.d.ts +20 -0
- package/dist/index.browser.js +598 -374
- package/dist/index.d.ts +4 -0
- package/dist/index.js +35 -30
- package/dist/renderer.d.ts +40 -1
- package/dist/skeleton.d.ts +41 -0
- package/dist/xrefs.d.ts +54 -0
- package/package.json +2 -1
- package/dist/cli-D0m0Ha1j.js +0 -856
package/dist/index.browser.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { fromXml as
|
|
1
|
+
import { fromXml as y } from "xast-util-from-xml";
|
|
2
2
|
import { toXml as $ } from "xast-util-to-xml";
|
|
3
|
-
const
|
|
4
|
-
function
|
|
3
|
+
const N = "/";
|
|
4
|
+
function Oe(e) {
|
|
5
5
|
if (!e)
|
|
6
6
|
return ".";
|
|
7
7
|
const n = e.startsWith("/"), t = e.length > 1 && e.endsWith("/"), r = [];
|
|
8
|
-
for (const
|
|
9
|
-
if (!(!
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
r.length > 0 &&
|
|
8
|
+
for (const o of e.split("/"))
|
|
9
|
+
if (!(!o || o === ".")) {
|
|
10
|
+
if (o === "..") {
|
|
11
|
+
const s = r[r.length - 1];
|
|
12
|
+
r.length > 0 && s !== ".." ? r.pop() : n || r.push("..");
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
|
-
r.push(
|
|
15
|
+
r.push(o);
|
|
16
16
|
}
|
|
17
17
|
let i = r.join("/");
|
|
18
18
|
return n && (i = `/${i}`), i ? (t && !i.endsWith("/") && (i += "/"), i) : n ? "/" : ".";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function h(...e) {
|
|
21
21
|
let n = "";
|
|
22
22
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
23
23
|
const i = e[r];
|
|
@@ -25,38 +25,38 @@ function p(...e) {
|
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
27
|
n.startsWith("/") || (n = `/${n}`);
|
|
28
|
-
const t =
|
|
28
|
+
const t = Oe(n);
|
|
29
29
|
return t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function I(e) {
|
|
32
32
|
const n = e.replace(/\/+$/, "");
|
|
33
33
|
if (!n)
|
|
34
34
|
return e.startsWith("/") ? "/" : ".";
|
|
35
35
|
const t = n.lastIndexOf("/");
|
|
36
36
|
return t < 0 ? "." : t === 0 ? "/" : n.slice(0, t);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
const t =
|
|
38
|
+
function B(e, n) {
|
|
39
|
+
const t = h(e).split("/").filter(Boolean), r = h(n).split("/").filter(Boolean);
|
|
40
40
|
let i = 0;
|
|
41
41
|
for (; i < t.length && i < r.length && t[i] === r[i]; )
|
|
42
42
|
i += 1;
|
|
43
43
|
return [...new Array(t.length - i).fill(".."), ...r.slice(i)].join("/");
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
45
|
+
const Be = "ptxPreviewBannerDismissed", Ce = "About live preview";
|
|
46
|
+
function Q(e) {
|
|
47
47
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function je(e) {
|
|
50
50
|
return [
|
|
51
51
|
'<div id="ptx-preview-banner" class="ptx-preview-banner" role="note">',
|
|
52
|
-
` <span class="ptx-preview-banner-text">${
|
|
52
|
+
` <span class="ptx-preview-banner-text">${Q(e)}</span>`,
|
|
53
53
|
' <button type="button" class="ptx-preview-banner-dismiss" aria-label="Dismiss">×</button>',
|
|
54
54
|
"</div>",
|
|
55
|
-
`<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${
|
|
55
|
+
`<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${Q(Ce)}</button>`
|
|
56
56
|
].join(`
|
|
57
57
|
`);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function Fe() {
|
|
60
60
|
return [
|
|
61
61
|
"<style>",
|
|
62
62
|
".ptx-preview-banner {",
|
|
@@ -117,11 +117,11 @@ function Te() {
|
|
|
117
117
|
].join(`
|
|
118
118
|
`);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Ne() {
|
|
121
121
|
return [
|
|
122
122
|
"<script>",
|
|
123
123
|
"(function () {",
|
|
124
|
-
" var KEY = " + JSON.stringify(
|
|
124
|
+
" var KEY = " + JSON.stringify(Be) + ";",
|
|
125
125
|
' var banner = document.getElementById("ptx-preview-banner");',
|
|
126
126
|
' var restore = document.getElementById("ptx-preview-banner-restore");',
|
|
127
127
|
" if (!banner || !restore) { return; }",
|
|
@@ -158,39 +158,39 @@ function $e() {
|
|
|
158
158
|
].join(`
|
|
159
159
|
`);
|
|
160
160
|
}
|
|
161
|
-
const
|
|
162
|
-
function
|
|
163
|
-
const t =
|
|
161
|
+
const We = "<!--ptx-preview-banner-->", He = "<!--/ptx-preview-banner-->", Ue = /\n?<!--ptx-preview-banner-->[\s\S]*?<!--\/ptx-preview-banner-->/;
|
|
162
|
+
function Ve(e, n) {
|
|
163
|
+
const t = Ue.exec(e), r = t ? e.slice(0, t.index) + e.slice(t.index + t[0].length) : e;
|
|
164
164
|
if (!/<body[^>]*>/i.test(r))
|
|
165
165
|
return r;
|
|
166
166
|
const i = `
|
|
167
|
-
${
|
|
168
|
-
${
|
|
169
|
-
${
|
|
170
|
-
${
|
|
171
|
-
${
|
|
167
|
+
${We}
|
|
168
|
+
${Fe()}
|
|
169
|
+
${je(n.message)}
|
|
170
|
+
${Ne()}
|
|
171
|
+
${He}`;
|
|
172
172
|
return r.replace(/<body([^>]*)>/i, `<body$1>${i}`);
|
|
173
173
|
}
|
|
174
|
-
const
|
|
175
|
-
let
|
|
176
|
-
function
|
|
177
|
-
|
|
174
|
+
const Xe = "https://cdn.jsdelivr.net/npm/@pretextbook/pretext-html@0.9.0/assets";
|
|
175
|
+
let ue;
|
|
176
|
+
function mn(e) {
|
|
177
|
+
ue = e.replace(/\/+$/, "");
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
return
|
|
179
|
+
function A() {
|
|
180
|
+
return ue ?? Xe;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function fe(e, n) {
|
|
183
183
|
return `${e.replace(/\/+$/, "")}/${n.replace(/^\/+/, "")}`;
|
|
184
184
|
}
|
|
185
|
-
const
|
|
186
|
-
function
|
|
185
|
+
const ee = /* @__PURE__ */ new Map();
|
|
186
|
+
function ze(e) {
|
|
187
187
|
return `${e.replace(/\/+$/, "")}-bundle.json`;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
let n =
|
|
189
|
+
function Je(e) {
|
|
190
|
+
let n = ee.get(e);
|
|
191
191
|
return n || (n = (async () => {
|
|
192
192
|
try {
|
|
193
|
-
const t = await fetch(
|
|
193
|
+
const t = await fetch(ze(e));
|
|
194
194
|
if (!t.ok)
|
|
195
195
|
return /* @__PURE__ */ new Map();
|
|
196
196
|
const r = await t.json();
|
|
@@ -198,16 +198,16 @@ function Me(e) {
|
|
|
198
198
|
} catch {
|
|
199
199
|
return /* @__PURE__ */ new Map();
|
|
200
200
|
}
|
|
201
|
-
})(),
|
|
201
|
+
})(), ee.set(e, n)), n;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
return e ===
|
|
203
|
+
function Ge(e) {
|
|
204
|
+
return e === fe(A(), "xsl");
|
|
205
205
|
}
|
|
206
|
-
async function
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
return new TextEncoder().encode(
|
|
206
|
+
async function pe(e, n) {
|
|
207
|
+
if (Ge(e)) {
|
|
208
|
+
const o = (await Je(e)).get(n.replace(/^\/+/, ""));
|
|
209
|
+
if (o !== void 0)
|
|
210
|
+
return new TextEncoder().encode(o);
|
|
211
211
|
}
|
|
212
212
|
const t = `${e.replace(/\/+$/, "")}/`;
|
|
213
213
|
let r;
|
|
@@ -229,7 +229,7 @@ async function ne(e, n) {
|
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
async function
|
|
232
|
+
async function P(e) {
|
|
233
233
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e))
|
|
234
234
|
try {
|
|
235
235
|
const n = await fetch(e);
|
|
@@ -238,35 +238,42 @@ async function B(e) {
|
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
const
|
|
242
|
-
|
|
241
|
+
const he = "2.48.1", Ke = "8.2.4", Ye = [
|
|
242
|
+
"prefix-runtime.40bd1420d3277749.bundle.js",
|
|
243
|
+
"prefix-926.5c7038c8ef173faf.bundle.js",
|
|
244
|
+
"prefix-runestone.b388362b5f43738a.bundle.js"
|
|
245
|
+
], qe = [
|
|
246
|
+
"prefix-926.229729d09512acc9.css",
|
|
247
|
+
"prefix-runestone.8086b62682b271d1.css"
|
|
248
|
+
], Ze = "born-hidden-knowl", Qe = /<details\b([^>]*)>(\s*)(?:<summary\b([^>]*)>)?/g;
|
|
249
|
+
function et(e) {
|
|
243
250
|
const n = /\bclass="([^"]*)"/.exec(e);
|
|
244
251
|
return n ? n[1].trim().split(/\s+/) : [];
|
|
245
252
|
}
|
|
246
|
-
function
|
|
253
|
+
function tt(e) {
|
|
247
254
|
return /(^|\s)open(\s|=|$)/.test(e);
|
|
248
255
|
}
|
|
249
|
-
function
|
|
250
|
-
return
|
|
256
|
+
function te(e) {
|
|
257
|
+
return tt(e) ? e : ` open${e}`;
|
|
251
258
|
}
|
|
252
|
-
function
|
|
259
|
+
function nt(e) {
|
|
253
260
|
return e.replace(
|
|
254
|
-
|
|
261
|
+
Qe,
|
|
255
262
|
(n, t, r, i) => {
|
|
256
|
-
if (!
|
|
263
|
+
if (!et(t).includes(Ze))
|
|
257
264
|
return n;
|
|
258
|
-
const
|
|
259
|
-
return i === void 0 ? `${
|
|
265
|
+
const o = `<details${te(t)}>`;
|
|
266
|
+
return i === void 0 ? `${o}${r}` : `${o}${r}<summary${te(i)}>`;
|
|
260
267
|
}
|
|
261
268
|
);
|
|
262
269
|
}
|
|
263
|
-
const
|
|
264
|
-
let
|
|
265
|
-
function
|
|
266
|
-
|
|
270
|
+
const X = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map();
|
|
271
|
+
let W, rt = 0, we = pe;
|
|
272
|
+
function wn(e) {
|
|
273
|
+
we = e;
|
|
267
274
|
}
|
|
268
|
-
function
|
|
269
|
-
const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, r =
|
|
275
|
+
function it(e, n) {
|
|
276
|
+
const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, r = me.get(t);
|
|
270
277
|
if (r !== void 0)
|
|
271
278
|
return Promise.resolve(new Response(r, { status: 200 }));
|
|
272
279
|
let i;
|
|
@@ -275,32 +282,32 @@ function We(e, n) {
|
|
|
275
282
|
} catch {
|
|
276
283
|
i = "";
|
|
277
284
|
}
|
|
278
|
-
const
|
|
279
|
-
return
|
|
285
|
+
const o = X.get(i);
|
|
286
|
+
return o !== void 0 ? st(o, t) : W(e, n);
|
|
280
287
|
}
|
|
281
|
-
const
|
|
282
|
-
async function
|
|
283
|
-
const t = decodeURIComponent(new URL(n).pathname), r = await
|
|
288
|
+
const ot = '<?xml version="1.0"?><pretext-preview-missing-file/>';
|
|
289
|
+
async function st(e, n) {
|
|
290
|
+
const t = decodeURIComponent(new URL(n).pathname), r = await we(e, t);
|
|
284
291
|
if (r === void 0)
|
|
285
|
-
return new Response(
|
|
292
|
+
return new Response(ot, { status: 200 });
|
|
286
293
|
const i = typeof r == "string" ? r : new Uint8Array(r);
|
|
287
294
|
return new Response(i, { status: 200 });
|
|
288
295
|
}
|
|
289
|
-
function
|
|
290
|
-
|
|
296
|
+
function ve() {
|
|
297
|
+
W || (W = globalThis.fetch, globalThis.fetch = it);
|
|
291
298
|
}
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
const n = `mnt${++
|
|
295
|
-
return
|
|
299
|
+
function ge(e) {
|
|
300
|
+
ve();
|
|
301
|
+
const n = `mnt${++rt}.ptx.invalid`;
|
|
302
|
+
return X.set(n, e), `http://${n}`;
|
|
296
303
|
}
|
|
297
|
-
function
|
|
298
|
-
|
|
304
|
+
function at(e) {
|
|
305
|
+
X.delete(new URL(e).host);
|
|
299
306
|
}
|
|
300
|
-
function
|
|
301
|
-
|
|
307
|
+
function ct(e, n) {
|
|
308
|
+
ve(), me.set(e, n);
|
|
302
309
|
}
|
|
303
|
-
const
|
|
310
|
+
const H = `<?xml version="1.0" encoding="UTF-8"?>
|
|
304
311
|
<publication>
|
|
305
312
|
<source>
|
|
306
313
|
<directories external="../assets" generated="../generated-assets" />
|
|
@@ -309,82 +316,82 @@ const A = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
309
316
|
<platform portable="yes"/>
|
|
310
317
|
</html>
|
|
311
318
|
</publication>
|
|
312
|
-
`,
|
|
313
|
-
function
|
|
319
|
+
`, lt = ["theme", "style", "shell"];
|
|
320
|
+
function x(e, n) {
|
|
314
321
|
for (const t of e.children)
|
|
315
322
|
if (t.type === "element" && t.name === n)
|
|
316
323
|
return t;
|
|
317
324
|
}
|
|
318
|
-
function
|
|
319
|
-
let t =
|
|
325
|
+
function E(e, n) {
|
|
326
|
+
let t = x(e, n);
|
|
320
327
|
return t || (t = { type: "element", name: n, attributes: {}, children: [] }, e.children.push(t)), t;
|
|
321
328
|
}
|
|
322
|
-
function
|
|
323
|
-
const t =
|
|
324
|
-
if (t &&
|
|
329
|
+
function dt(e, n) {
|
|
330
|
+
const t = x(e, "css");
|
|
331
|
+
if (t && lt.some((i) => t.attributes?.[i]))
|
|
325
332
|
return;
|
|
326
|
-
const r = t ??
|
|
333
|
+
const r = t ?? E(e, "css");
|
|
327
334
|
r.attributes = { ...r.attributes, theme: n };
|
|
328
335
|
}
|
|
329
|
-
function
|
|
330
|
-
const t =
|
|
336
|
+
function ut(e, n) {
|
|
337
|
+
const t = x(e, "appearance");
|
|
331
338
|
if (t?.attributes?.theme)
|
|
332
339
|
return;
|
|
333
|
-
const r = t ??
|
|
340
|
+
const r = t ?? E(e, "appearance");
|
|
334
341
|
r.attributes = { ...r.attributes, theme: n };
|
|
335
342
|
}
|
|
336
|
-
function
|
|
337
|
-
const n =
|
|
343
|
+
function ft(e) {
|
|
344
|
+
const n = E(e, "resources");
|
|
338
345
|
n.attributes = {
|
|
339
346
|
...n.attributes,
|
|
340
347
|
host: "cdn",
|
|
341
348
|
math: "online"
|
|
342
349
|
};
|
|
343
350
|
}
|
|
344
|
-
function
|
|
351
|
+
function pt(e, n = {}) {
|
|
345
352
|
const t = n.cssTheme?.trim(), r = n.revealTheme?.trim(), i = n.target === "slides";
|
|
346
353
|
if (!e && !t && !i)
|
|
347
|
-
return
|
|
348
|
-
const
|
|
349
|
-
if (!
|
|
354
|
+
return H;
|
|
355
|
+
const o = y(e ?? H), s = x(o, "publication");
|
|
356
|
+
if (!s)
|
|
350
357
|
throw new Error(
|
|
351
358
|
"Invalid publication file: no root <publication> element found"
|
|
352
359
|
);
|
|
353
|
-
const a =
|
|
354
|
-
if (
|
|
355
|
-
const
|
|
356
|
-
|
|
360
|
+
const a = E(s, "html"), l = E(a, "platform");
|
|
361
|
+
if (l.attributes = { ...l.attributes, portable: "yes" }, t && dt(a, t), i) {
|
|
362
|
+
const d = E(s, "revealjs");
|
|
363
|
+
ft(d), r && ut(d, r);
|
|
357
364
|
}
|
|
358
|
-
return $(
|
|
365
|
+
return $(o);
|
|
359
366
|
}
|
|
360
|
-
function
|
|
367
|
+
function ne(e) {
|
|
361
368
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
362
369
|
return e.endsWith("/") ? e : `${e}/`;
|
|
363
370
|
}
|
|
364
|
-
function
|
|
365
|
-
const n =
|
|
371
|
+
function ht(e) {
|
|
372
|
+
const n = y(e ?? H), t = x(n, "publication"), r = t && x(t, "source"), i = r && x(r, "directories"), o = ne(
|
|
366
373
|
i?.attributes?.external ?? void 0
|
|
367
|
-
),
|
|
374
|
+
), s = ne(
|
|
368
375
|
i?.attributes?.generated ?? void 0
|
|
369
376
|
);
|
|
370
377
|
return {
|
|
371
|
-
external:
|
|
372
|
-
generated:
|
|
373
|
-
managed:
|
|
378
|
+
external: o,
|
|
379
|
+
generated: s,
|
|
380
|
+
managed: o !== void 0 && s !== void 0
|
|
374
381
|
};
|
|
375
382
|
}
|
|
376
|
-
function
|
|
383
|
+
function vn(e) {
|
|
377
384
|
return e === "slides" || e === "scroll";
|
|
378
385
|
}
|
|
379
|
-
const
|
|
380
|
-
function
|
|
381
|
-
const n = typeof e == "number" && isFinite(e) ? e :
|
|
386
|
+
const be = 960, xe = 700, mt = 1, wt = 0.04;
|
|
387
|
+
function vt(e) {
|
|
388
|
+
const n = typeof e == "number" && isFinite(e) ? e : mt, t = Math.min(1, Math.max(0.25, n));
|
|
382
389
|
return {
|
|
383
|
-
width: Math.round(
|
|
384
|
-
height: Math.round(
|
|
390
|
+
width: Math.round(be / t),
|
|
391
|
+
height: Math.round(xe / t)
|
|
385
392
|
};
|
|
386
393
|
}
|
|
387
|
-
function
|
|
394
|
+
function gt(e) {
|
|
388
395
|
return {
|
|
389
396
|
view: "scroll",
|
|
390
397
|
scrollLayout: "compact",
|
|
@@ -394,11 +401,11 @@ function Qe(e) {
|
|
|
394
401
|
controls: !1,
|
|
395
402
|
controlsTutorial: !1,
|
|
396
403
|
hash: !1,
|
|
397
|
-
...
|
|
398
|
-
margin:
|
|
404
|
+
...vt(e.zoom),
|
|
405
|
+
margin: wt
|
|
399
406
|
};
|
|
400
407
|
}
|
|
401
|
-
function
|
|
408
|
+
function bt() {
|
|
402
409
|
return {
|
|
403
410
|
// Explicitly null rather than absent: the same page may have been
|
|
404
411
|
// delivered in scroll view a moment ago, and an embedder that re-injects
|
|
@@ -410,11 +417,11 @@ function et() {
|
|
|
410
417
|
// size with a percentage width renders its text far larger, relative to
|
|
411
418
|
// the slide, than the same deck will on a projector. No zoom margin
|
|
412
419
|
// though — presenting means filling whatever it is shown in.
|
|
413
|
-
width:
|
|
414
|
-
height:
|
|
420
|
+
width: be,
|
|
421
|
+
height: xe
|
|
415
422
|
};
|
|
416
423
|
}
|
|
417
|
-
const
|
|
424
|
+
const xt = [
|
|
418
425
|
"<style>",
|
|
419
426
|
".reveal-viewport.reveal-scroll .scroll-page section {",
|
|
420
427
|
" box-shadow: inset 0 0 0 calc(1px / var(--slide-scale, 1))",
|
|
@@ -422,14 +429,14 @@ const tt = [
|
|
|
422
429
|
"}",
|
|
423
430
|
"</style>"
|
|
424
431
|
].join(`
|
|
425
|
-
`),
|
|
432
|
+
`), Et = [
|
|
426
433
|
" var paused = document.querySelectorAll('.reveal .fragment');",
|
|
427
434
|
" for (var i = 0; i < paused.length; i++) {",
|
|
428
435
|
" paused[i].classList.remove('fragment');",
|
|
429
436
|
" }"
|
|
430
437
|
];
|
|
431
|
-
function
|
|
432
|
-
const t = e === "scroll" ?
|
|
438
|
+
function yt(e, n = {}) {
|
|
439
|
+
const t = e === "scroll" ? gt(n) : bt();
|
|
433
440
|
return [
|
|
434
441
|
"<script>",
|
|
435
442
|
"(function () {",
|
|
@@ -457,7 +464,7 @@ function rt(e, n = {}) {
|
|
|
457
464
|
// Inside the wrapper rather than at top level: this script sits in <head>,
|
|
458
465
|
// where the slides have not been parsed yet, but the deck calls initialize
|
|
459
466
|
// from the end of the document, by which time they have.
|
|
460
|
-
...e === "scroll" ?
|
|
467
|
+
...e === "scroll" ? Et : [],
|
|
461
468
|
" return initialize(merged);",
|
|
462
469
|
" };",
|
|
463
470
|
"})();",
|
|
@@ -465,156 +472,156 @@ function rt(e, n = {}) {
|
|
|
465
472
|
].join(`
|
|
466
473
|
`);
|
|
467
474
|
}
|
|
468
|
-
const
|
|
469
|
-
function
|
|
470
|
-
const r =
|
|
471
|
-
if (!
|
|
475
|
+
const Tt = /<script\b[^>]*\bsrc=["'][^"']*\breveal\.js["'][^>]*>\s*<\/script>/i, St = "<!--ptx-reveal-view-->", kt = "<!--/ptx-reveal-view-->", $t = /\n?<!--ptx-reveal-view-->[\s\S]*?<!--\/ptx-reveal-view-->/;
|
|
476
|
+
function It(e, n, t = {}) {
|
|
477
|
+
const r = $t.exec(e), i = r ? e.slice(0, r.index) + e.slice(r.index + r[0].length) : e, o = Tt.exec(i);
|
|
478
|
+
if (!o)
|
|
472
479
|
return i;
|
|
473
|
-
const
|
|
474
|
-
${
|
|
475
|
-
${
|
|
476
|
-
${
|
|
477
|
-
${
|
|
478
|
-
return i.slice(0,
|
|
479
|
-
}
|
|
480
|
-
const
|
|
481
|
-
async function
|
|
482
|
-
return e.includes("include") ? (await
|
|
483
|
-
}
|
|
484
|
-
async function
|
|
485
|
-
const r =
|
|
486
|
-
projectDir:
|
|
487
|
-
stack: [
|
|
488
|
-
},
|
|
480
|
+
const s = o.index + o[0].length, a = `
|
|
481
|
+
${St}
|
|
482
|
+
${xt}
|
|
483
|
+
${yt(n, t)}
|
|
484
|
+
${kt}`;
|
|
485
|
+
return i.slice(0, s) + a + i.slice(s);
|
|
486
|
+
}
|
|
487
|
+
const Ee = "http://www.w3.org/2001/XInclude", re = 64;
|
|
488
|
+
async function _t(e, n, t) {
|
|
489
|
+
return e.includes("include") ? (await z(e, n, t)).content : e;
|
|
490
|
+
}
|
|
491
|
+
async function z(e, n, t) {
|
|
492
|
+
const r = y(e), i = {
|
|
493
|
+
projectDir: h(t),
|
|
494
|
+
stack: [h(n)]
|
|
495
|
+
}, o = await _(
|
|
489
496
|
r,
|
|
490
|
-
|
|
497
|
+
I(h(n)),
|
|
491
498
|
{ "": "" },
|
|
492
499
|
i
|
|
493
500
|
);
|
|
494
|
-
return { tree: r, content:
|
|
501
|
+
return { tree: r, content: o ? $(r) : e };
|
|
495
502
|
}
|
|
496
|
-
function
|
|
503
|
+
function Rt(e) {
|
|
497
504
|
return e.data?.ptxIncludedFile;
|
|
498
505
|
}
|
|
499
|
-
function
|
|
506
|
+
function Dt(e, n) {
|
|
500
507
|
const t = e.data ?? (e.data = {});
|
|
501
508
|
t.ptxIncludedFile = n;
|
|
502
509
|
}
|
|
503
|
-
function
|
|
510
|
+
function L(e, n) {
|
|
504
511
|
let t = e;
|
|
505
512
|
for (const [r, i] of Object.entries(n.attributes))
|
|
506
513
|
(r === "xmlns" || r.startsWith("xmlns:")) && (t === e && (t = { ...e }), t[r === "xmlns" ? "" : r.slice(6)] = i ?? "");
|
|
507
514
|
return t;
|
|
508
515
|
}
|
|
509
|
-
function
|
|
516
|
+
function ye(e, n) {
|
|
510
517
|
const t = e.name.indexOf(":"), r = t === -1 ? "" : e.name.slice(0, t);
|
|
511
|
-
return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && n[r] ===
|
|
518
|
+
return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && n[r] === Ee;
|
|
512
519
|
}
|
|
513
|
-
async function
|
|
520
|
+
async function _(e, n, t, r) {
|
|
514
521
|
let i = !1;
|
|
515
|
-
for (let
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
522
|
+
for (let o = 0; o < e.children.length; o++) {
|
|
523
|
+
const s = e.children[o];
|
|
524
|
+
if (s.type !== "element")
|
|
518
525
|
continue;
|
|
519
|
-
const a =
|
|
520
|
-
if (
|
|
521
|
-
const
|
|
522
|
-
|
|
526
|
+
const a = L(t, s);
|
|
527
|
+
if (ye(s, a)) {
|
|
528
|
+
const l = await Te(
|
|
529
|
+
s,
|
|
523
530
|
n,
|
|
524
531
|
a,
|
|
525
532
|
r
|
|
526
533
|
);
|
|
527
|
-
e.children.splice(
|
|
528
|
-
} else await
|
|
534
|
+
e.children.splice(o, 1, ...l), o += l.length - 1, i = !0;
|
|
535
|
+
} else await _(s, n, a, r) && (i = !0);
|
|
529
536
|
}
|
|
530
537
|
return i;
|
|
531
538
|
}
|
|
532
|
-
async function
|
|
539
|
+
async function Te(e, n, t, r) {
|
|
533
540
|
const i = r.stack[r.stack.length - 1];
|
|
534
541
|
if (e.attributes.xpointer)
|
|
535
542
|
throw new Error(
|
|
536
543
|
`xi:include with xpointer is not supported by the JS preview build (in ${i})`
|
|
537
544
|
);
|
|
538
|
-
const
|
|
539
|
-
if (!
|
|
545
|
+
const o = e.attributes.href;
|
|
546
|
+
if (!o)
|
|
540
547
|
throw new Error(`xi:include without href (in ${i})`);
|
|
541
|
-
let
|
|
548
|
+
let s = o;
|
|
542
549
|
try {
|
|
543
|
-
|
|
550
|
+
s = decodeURIComponent(o);
|
|
544
551
|
} catch {
|
|
545
552
|
}
|
|
546
|
-
const a =
|
|
547
|
-
if (a !== r.projectDir && !a.startsWith(r.projectDir +
|
|
553
|
+
const a = h(n, s);
|
|
554
|
+
if (a !== r.projectDir && !a.startsWith(r.projectDir + N))
|
|
548
555
|
throw new Error(
|
|
549
|
-
`xi:include escapes the project directory: ${
|
|
556
|
+
`xi:include escapes the project directory: ${o} (in ${i})`
|
|
550
557
|
);
|
|
551
558
|
if (r.stack.includes(a))
|
|
552
559
|
throw new Error(
|
|
553
560
|
`Circular xi:include: ${[...r.stack, a].join(" -> ")}`
|
|
554
561
|
);
|
|
555
|
-
if (r.stack.length >=
|
|
556
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
return await
|
|
562
|
-
throw new Error(`xi:include target not found: ${
|
|
562
|
+
if (r.stack.length >= re)
|
|
563
|
+
throw new Error(`xi:include nesting exceeds ${re} levels`);
|
|
564
|
+
const l = await P(a);
|
|
565
|
+
if (l === void 0) {
|
|
566
|
+
const p = At(e, t);
|
|
567
|
+
if (p)
|
|
568
|
+
return await _(p, n, t, r), p.children;
|
|
569
|
+
throw new Error(`xi:include target not found: ${o} (in ${i})`);
|
|
563
570
|
}
|
|
564
571
|
if (e.attributes.parse === "text")
|
|
565
|
-
return [{ type: "text", value:
|
|
566
|
-
let
|
|
572
|
+
return [{ type: "text", value: l }];
|
|
573
|
+
let d;
|
|
567
574
|
try {
|
|
568
|
-
|
|
569
|
-
} catch (
|
|
575
|
+
d = y(l);
|
|
576
|
+
} catch (p) {
|
|
570
577
|
throw new Error(
|
|
571
|
-
`Could not parse xi:include target ${a} as XML: ${
|
|
578
|
+
`Could not parse xi:include target ${a} as XML: ${p instanceof Error ? p.message : p}. (Included files must be well-formed, with a single root element.)`
|
|
572
579
|
);
|
|
573
580
|
}
|
|
574
581
|
r.stack.push(a);
|
|
575
582
|
try {
|
|
576
|
-
await
|
|
583
|
+
await _(d, I(a), { "": "" }, r);
|
|
577
584
|
} finally {
|
|
578
585
|
r.stack.pop();
|
|
579
586
|
}
|
|
580
|
-
const
|
|
581
|
-
(
|
|
587
|
+
const f = d.children.filter(
|
|
588
|
+
(p) => p.type === "element"
|
|
582
589
|
);
|
|
583
|
-
for (const
|
|
584
|
-
|
|
585
|
-
return
|
|
590
|
+
for (const p of f)
|
|
591
|
+
Dt(p, a);
|
|
592
|
+
return f;
|
|
586
593
|
}
|
|
587
|
-
function
|
|
594
|
+
function ie(e) {
|
|
588
595
|
return e.name === "docinfo";
|
|
589
596
|
}
|
|
590
|
-
async function
|
|
597
|
+
async function Mt(e, n, t) {
|
|
591
598
|
try {
|
|
592
|
-
const i =
|
|
593
|
-
(
|
|
599
|
+
const i = y(e).children.find(
|
|
600
|
+
(d) => d.type === "element"
|
|
594
601
|
);
|
|
595
602
|
if (!i)
|
|
596
603
|
return;
|
|
597
|
-
const
|
|
598
|
-
projectDir:
|
|
599
|
-
stack: [
|
|
600
|
-
},
|
|
601
|
-
for (const
|
|
602
|
-
if (
|
|
604
|
+
const o = h(n), s = I(o), a = {
|
|
605
|
+
projectDir: h(t),
|
|
606
|
+
stack: [o]
|
|
607
|
+
}, l = L({ "": "" }, i);
|
|
608
|
+
for (const d of i.children) {
|
|
609
|
+
if (d.type !== "element")
|
|
603
610
|
continue;
|
|
604
|
-
const
|
|
605
|
-
if (
|
|
606
|
-
return await
|
|
607
|
-
if (
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
611
|
+
const f = L(l, d);
|
|
612
|
+
if (ie(d))
|
|
613
|
+
return await _(d, s, f, a), $(d);
|
|
614
|
+
if (ye(d, f)) {
|
|
615
|
+
const u = (await Te(
|
|
616
|
+
d,
|
|
617
|
+
s,
|
|
618
|
+
f,
|
|
612
619
|
a
|
|
613
620
|
)).find(
|
|
614
|
-
(m) => m.type === "element" &&
|
|
621
|
+
(m) => m.type === "element" && ie(m)
|
|
615
622
|
);
|
|
616
|
-
if (
|
|
617
|
-
return $(
|
|
623
|
+
if (u)
|
|
624
|
+
return $(u);
|
|
618
625
|
continue;
|
|
619
626
|
}
|
|
620
627
|
break;
|
|
@@ -624,78 +631,78 @@ async function ft(e, n, t) {
|
|
|
624
631
|
return;
|
|
625
632
|
}
|
|
626
633
|
}
|
|
627
|
-
function
|
|
634
|
+
function At(e, n) {
|
|
628
635
|
for (const t of e.children) {
|
|
629
636
|
if (t.type !== "element")
|
|
630
637
|
continue;
|
|
631
|
-
const r =
|
|
632
|
-
if ((i === -1 ? t.name : t.name.slice(i + 1)) === "fallback" && r[
|
|
638
|
+
const r = L(n, t), i = t.name.indexOf(":"), o = i === -1 ? "" : t.name.slice(0, i);
|
|
639
|
+
if ((i === -1 ? t.name : t.name.slice(i + 1)) === "fallback" && r[o] === Ee)
|
|
633
640
|
return t;
|
|
634
641
|
}
|
|
635
642
|
}
|
|
636
|
-
function
|
|
643
|
+
function Se(e) {
|
|
637
644
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
638
645
|
}
|
|
639
|
-
function
|
|
646
|
+
function Lt(e) {
|
|
640
647
|
return /^(pf|xhtml):/.test(e.name);
|
|
641
648
|
}
|
|
642
|
-
function
|
|
643
|
-
const r = [], i = e.children.find(
|
|
649
|
+
function Pt(e, n, t) {
|
|
650
|
+
const r = [], i = e.children.find(Se);
|
|
644
651
|
if (i) {
|
|
645
|
-
const
|
|
646
|
-
|
|
652
|
+
const o = t?.parentId ?? "root";
|
|
653
|
+
ke(i, o, t?.position ?? 1, n, o, r);
|
|
647
654
|
}
|
|
648
655
|
return r;
|
|
649
656
|
}
|
|
650
|
-
function
|
|
651
|
-
const
|
|
652
|
-
let a,
|
|
653
|
-
if (
|
|
654
|
-
|
|
657
|
+
function ke(e, n, t, r, i, o) {
|
|
658
|
+
const s = Rt(e) ?? r;
|
|
659
|
+
let a, l;
|
|
660
|
+
if (Lt(e))
|
|
661
|
+
l = "root";
|
|
655
662
|
else {
|
|
656
|
-
const
|
|
657
|
-
a =
|
|
663
|
+
const f = e.attributes.label ?? e.attributes["xml:id"];
|
|
664
|
+
a = f ?? `${n}-${t}`, o.push({
|
|
658
665
|
id: a,
|
|
659
|
-
file:
|
|
666
|
+
file: s,
|
|
660
667
|
line: e.position?.start.line ?? 1,
|
|
661
668
|
column: e.position?.start.column ?? 1,
|
|
662
669
|
endLine: e.position?.end.line ?? e.position?.start.line ?? 1,
|
|
663
670
|
parent: i
|
|
664
|
-
}),
|
|
671
|
+
}), l = a;
|
|
665
672
|
}
|
|
666
|
-
let
|
|
667
|
-
for (const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
d,
|
|
673
|
+
let d = 0;
|
|
674
|
+
for (const f of e.children)
|
|
675
|
+
Se(f) && (d += 1, ke(
|
|
676
|
+
f,
|
|
671
677
|
l,
|
|
672
|
-
|
|
678
|
+
d,
|
|
679
|
+
s,
|
|
673
680
|
a ?? i,
|
|
674
|
-
|
|
681
|
+
o
|
|
675
682
|
));
|
|
676
683
|
}
|
|
677
|
-
function
|
|
684
|
+
function gn(e, n) {
|
|
678
685
|
let t;
|
|
679
686
|
for (const r of e)
|
|
680
687
|
r.line <= n && (t = r);
|
|
681
688
|
return t ?? e[0];
|
|
682
689
|
}
|
|
683
|
-
function
|
|
690
|
+
function Ot(e) {
|
|
684
691
|
const n = e.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, " ");
|
|
685
692
|
return /<\s*slide(?:show)?[\s/>]/.test(n) ? "slides" : "html";
|
|
686
693
|
}
|
|
687
|
-
const
|
|
688
|
-
function
|
|
694
|
+
const $e = "pretext-html:set-theme";
|
|
695
|
+
function bn(e) {
|
|
689
696
|
return e === "dark" || e === "light" || e === "system";
|
|
690
697
|
}
|
|
691
|
-
function
|
|
692
|
-
return { type:
|
|
698
|
+
function xn(e) {
|
|
699
|
+
return { type: $e, theme: e };
|
|
693
700
|
}
|
|
694
|
-
function
|
|
701
|
+
function Bt(e) {
|
|
695
702
|
return [
|
|
696
703
|
"<script>",
|
|
697
704
|
"(function () {",
|
|
698
|
-
" var CFG = " + JSON.stringify({ msg:
|
|
705
|
+
" var CFG = " + JSON.stringify({ msg: $e, initial: e }) + ";",
|
|
699
706
|
// Where the last requested theme is remembered so it survives an in-place
|
|
700
707
|
// document rewrite (same Window) and outranks the baked initial value.
|
|
701
708
|
" var KEY = '__ptxPreviewTheme';",
|
|
@@ -765,247 +772,464 @@ function vt(e) {
|
|
|
765
772
|
].join(`
|
|
766
773
|
`);
|
|
767
774
|
}
|
|
768
|
-
function
|
|
769
|
-
const t =
|
|
775
|
+
function Ct(e, n) {
|
|
776
|
+
const t = Bt(n);
|
|
770
777
|
return /<head[^>]*>/i.test(e) ? e.replace(/<head([^>]*)>/i, `<head$1>
|
|
771
778
|
${t}`) : e;
|
|
772
779
|
}
|
|
773
|
-
|
|
774
|
-
|
|
780
|
+
const Ie = /* @__PURE__ */ new Set([
|
|
781
|
+
"colophon",
|
|
782
|
+
"biography",
|
|
783
|
+
"dedication",
|
|
784
|
+
"acknowledgement",
|
|
785
|
+
"preface",
|
|
786
|
+
"chapter",
|
|
787
|
+
"section",
|
|
788
|
+
"subsection",
|
|
789
|
+
"subsubsection",
|
|
790
|
+
"slide",
|
|
791
|
+
"appendix",
|
|
792
|
+
"index",
|
|
793
|
+
"exercises",
|
|
794
|
+
"reading-questions",
|
|
795
|
+
"references",
|
|
796
|
+
"solutions",
|
|
797
|
+
"glossary",
|
|
798
|
+
"worksheet",
|
|
799
|
+
"handout"
|
|
800
|
+
]), _e = /* @__PURE__ */ new Set([
|
|
801
|
+
"book",
|
|
802
|
+
"article",
|
|
803
|
+
"slideshow",
|
|
804
|
+
"letter",
|
|
805
|
+
"memo"
|
|
806
|
+
]), Re = /* @__PURE__ */ new Set([
|
|
807
|
+
..._e,
|
|
808
|
+
...Ie,
|
|
809
|
+
"part",
|
|
810
|
+
"frontmatter",
|
|
811
|
+
"backmatter"
|
|
812
|
+
]), jt = /* @__PURE__ */ new Set(["docinfo"]), De = /* @__PURE__ */ new Set([
|
|
813
|
+
"title",
|
|
814
|
+
"shorttitle",
|
|
815
|
+
"plaintitle",
|
|
816
|
+
"subtitle",
|
|
817
|
+
"caption"
|
|
818
|
+
]);
|
|
819
|
+
function v(e) {
|
|
820
|
+
return e.type === "element";
|
|
821
|
+
}
|
|
822
|
+
function Me(e) {
|
|
823
|
+
return e.attributes["xml:id"] ?? void 0;
|
|
824
|
+
}
|
|
825
|
+
function U(e, n) {
|
|
826
|
+
for (const t of e.children) {
|
|
827
|
+
if (!v(t)) continue;
|
|
828
|
+
if (Me(t) === n) return t;
|
|
829
|
+
const r = U(t, n);
|
|
830
|
+
if (r) return r;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function M(e, n) {
|
|
834
|
+
for (const t of e.children) {
|
|
835
|
+
if (!v(t)) continue;
|
|
836
|
+
if (t === n) return [t];
|
|
837
|
+
const r = M(t, n);
|
|
838
|
+
if (r) return [t, ...r];
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function Ft(e, n) {
|
|
842
|
+
let t = 0;
|
|
843
|
+
for (const [r, i] of e.entries()) {
|
|
844
|
+
const o = r === 0 ? void 0 : e[r - 1];
|
|
845
|
+
_e.has(i.name) ? t = 0 : i.name === "frontmatter" || i.name === "backmatter" || i.name === "part" ? t = o?.name === "book" && n ? 1 : 0 : Ie.has(i.name) && (t += 1);
|
|
846
|
+
}
|
|
847
|
+
return t;
|
|
848
|
+
}
|
|
849
|
+
function Ae(e) {
|
|
850
|
+
if (!De.has(e.name)) {
|
|
851
|
+
e.children = e.children.filter(v);
|
|
852
|
+
for (const n of e.children)
|
|
853
|
+
Ae(n);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function V(e, n) {
|
|
857
|
+
const t = [];
|
|
858
|
+
for (const r of e.children)
|
|
859
|
+
v(r) && (n.has(r) || jt.has(r.name) || De.has(r.name) ? t.push(r) : Re.has(r.name) && (V(r, n), t.push(r)));
|
|
860
|
+
e.children = t;
|
|
775
861
|
}
|
|
776
|
-
function
|
|
862
|
+
function Nt(e) {
|
|
863
|
+
const n = /* @__PURE__ */ new Set(), t = (r) => {
|
|
864
|
+
if (r.name === "xref") {
|
|
865
|
+
const i = [
|
|
866
|
+
r.attributes.ref,
|
|
867
|
+
r.attributes.first,
|
|
868
|
+
r.attributes.last
|
|
869
|
+
];
|
|
870
|
+
for (const o of i)
|
|
871
|
+
for (const s of o?.split(/[\s,]+/) ?? [])
|
|
872
|
+
s && n.add(s);
|
|
873
|
+
}
|
|
874
|
+
for (const i of r.children)
|
|
875
|
+
v(i) && t(i);
|
|
876
|
+
};
|
|
877
|
+
return t(e), n;
|
|
878
|
+
}
|
|
879
|
+
function Wt(e, n, t) {
|
|
880
|
+
const r = (i) => {
|
|
881
|
+
for (const [o, s] of i.children.entries())
|
|
882
|
+
if (v(s)) {
|
|
883
|
+
if (Me(s) === n)
|
|
884
|
+
return i.children[o] = t, !0;
|
|
885
|
+
if (r(s)) return !0;
|
|
886
|
+
}
|
|
887
|
+
return !1;
|
|
888
|
+
};
|
|
889
|
+
return r(e);
|
|
890
|
+
}
|
|
891
|
+
function Ht(e, n) {
|
|
892
|
+
const t = U(e, n);
|
|
893
|
+
if (!t) return;
|
|
894
|
+
const r = M(e, t);
|
|
895
|
+
if (!r) return;
|
|
896
|
+
const i = r.filter(
|
|
897
|
+
(u) => u.name !== "pretext" && u.name !== "mathbook"
|
|
898
|
+
), o = i[0], s = o?.name === "book" && o.children.some(
|
|
899
|
+
(u) => v(u) && u.name === "part"
|
|
900
|
+
), a = Ft(i, s), l = new Set(r), d = Nt(t), f = /* @__PURE__ */ new Set();
|
|
901
|
+
if (d.size > 0)
|
|
902
|
+
for (const u of d) {
|
|
903
|
+
const m = U(e, u);
|
|
904
|
+
if (!m || m === t) continue;
|
|
905
|
+
const R = M(e, m);
|
|
906
|
+
if (!R) continue;
|
|
907
|
+
const g = [...R].reverse().find((w) => Re.has(w.name));
|
|
908
|
+
if (g && g !== t) {
|
|
909
|
+
f.add(g);
|
|
910
|
+
for (const w of M(e, g) ?? [])
|
|
911
|
+
l.add(w);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
for (const u of r) {
|
|
915
|
+
if (u === t) break;
|
|
916
|
+
V(u, l);
|
|
917
|
+
}
|
|
918
|
+
for (const u of f)
|
|
919
|
+
Ae(u);
|
|
920
|
+
const p = e.children.find(v);
|
|
921
|
+
return p && !r.includes(p) && V(p, l), { content: $(e), divisionId: n, level: a };
|
|
922
|
+
}
|
|
923
|
+
const Ut = "This live preview shows a single division, so links into the rest of the document do not work here.", Vt = /<a\b([^>]*)>/g, Xt = /\sid="([^"]*)"/g, C = /\shref="([^"]*)"/, zt = /\\href\{([^{}]*)\}/g, oe = /\stitle="([^"]*)"/;
|
|
924
|
+
function Jt(e) {
|
|
925
|
+
const n = /* @__PURE__ */ new Set();
|
|
926
|
+
for (const t of e.matchAll(Xt))
|
|
927
|
+
n.add(t[1]);
|
|
928
|
+
return n;
|
|
929
|
+
}
|
|
930
|
+
function Gt(e) {
|
|
931
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
932
|
+
}
|
|
933
|
+
function se(e, n) {
|
|
934
|
+
if (e.startsWith("#") || e === "") return { kind: "keep" };
|
|
935
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(e) || e.startsWith("//"))
|
|
936
|
+
return { kind: "keep" };
|
|
937
|
+
const t = e.indexOf("#");
|
|
938
|
+
if (t === -1) return { kind: "off-page" };
|
|
939
|
+
const r = e.slice(t + 1);
|
|
940
|
+
return n.has(r) && r !== "" ? { kind: "same-page", id: r } : { kind: "off-page" };
|
|
941
|
+
}
|
|
942
|
+
function Kt(e, n = {}) {
|
|
943
|
+
const t = n.offPageMessage ?? Ut, r = Jt(e);
|
|
944
|
+
return e.replace(Vt, (o, s) => {
|
|
945
|
+
const a = C.exec(s);
|
|
946
|
+
if (!a) return o;
|
|
947
|
+
const l = se(a[1], r);
|
|
948
|
+
if (l.kind === "keep") return o;
|
|
949
|
+
if (l.kind === "same-page")
|
|
950
|
+
return `<a${s.replace(C, ` href="#${l.id}"`)}>`;
|
|
951
|
+
const d = oe.exec(s), f = Gt(t), p = d ? `${d[1]} — ${f}` : f;
|
|
952
|
+
return `<a${s.replace(C, "").replace(oe, "")} title="${p}" aria-disabled="true" style="cursor:default">`;
|
|
953
|
+
}).replace(zt, (o, s) => {
|
|
954
|
+
const a = se(s, r);
|
|
955
|
+
return a.kind === "same-page" ? `\\href{#${a.id}}` : o;
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
function Yt() {
|
|
959
|
+
return fe(A(), "xsl");
|
|
960
|
+
}
|
|
961
|
+
function qt() {
|
|
777
962
|
return "Suspending" in WebAssembly;
|
|
778
963
|
}
|
|
779
|
-
function
|
|
780
|
-
if (!
|
|
964
|
+
function Zt() {
|
|
965
|
+
if (!qt())
|
|
781
966
|
throw new Error(
|
|
782
967
|
"WebAssembly JSPI is not enabled. Run Node with --experimental-wasm-jspi (or use the pretext-html CLI, which re-launches itself with the flag)."
|
|
783
968
|
);
|
|
784
969
|
}
|
|
785
|
-
function
|
|
970
|
+
function k(e) {
|
|
786
971
|
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((t) => `'${t}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
|
|
787
972
|
}
|
|
788
|
-
function
|
|
973
|
+
function Qt(e) {
|
|
789
974
|
return e.replace(
|
|
790
975
|
/from '\.\/(https:\/\/[^']+)'/g,
|
|
791
976
|
(n, t) => `from '${t}'`
|
|
792
977
|
);
|
|
793
978
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
979
|
+
const en = `https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@${he}/dist/`, tn = {
|
|
980
|
+
"cli.version": he,
|
|
981
|
+
// Colon-delimited: pretext-runestone.xsl splits them with str:tokenize.
|
|
982
|
+
"rs-js": Ye.join(":"),
|
|
983
|
+
"rs-css": qe.join(":"),
|
|
984
|
+
"rs-version": Ke
|
|
985
|
+
};
|
|
986
|
+
function nn(e) {
|
|
796
987
|
return e.replace(
|
|
797
988
|
/(<link\b[^>]*\bhref=["'])_static\//gi,
|
|
798
|
-
`$1${
|
|
989
|
+
`$1${en}_static/`
|
|
799
990
|
);
|
|
800
991
|
}
|
|
801
|
-
function
|
|
992
|
+
function rn(e) {
|
|
802
993
|
return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
|
|
803
994
|
}
|
|
804
|
-
async function
|
|
805
|
-
const n = await
|
|
995
|
+
async function ae(e) {
|
|
996
|
+
const n = await P(e);
|
|
806
997
|
if (n === void 0)
|
|
807
998
|
throw new Error(
|
|
808
999
|
`Could not read ${e}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
|
|
809
1000
|
);
|
|
810
1001
|
return n;
|
|
811
1002
|
}
|
|
812
|
-
async function
|
|
813
|
-
const t =
|
|
1003
|
+
async function on(e, n) {
|
|
1004
|
+
const t = h(e), r = await P(t);
|
|
814
1005
|
if (r !== void 0)
|
|
815
|
-
return
|
|
1006
|
+
return Mt(r, t, n);
|
|
816
1007
|
}
|
|
817
|
-
function
|
|
818
|
-
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""),
|
|
1008
|
+
function sn(e, n, t, r) {
|
|
1009
|
+
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), o = t === "slides" ? "slideshow" : n === "chapter" || n === "part" ? "book" : "article";
|
|
819
1010
|
return `<pretext>
|
|
820
1011
|
${r?.trim() ? `${r.trim()}
|
|
821
|
-
` : ""}<${
|
|
1012
|
+
` : ""}<${o}>
|
|
822
1013
|
<title/>
|
|
823
1014
|
${i}
|
|
824
|
-
</${
|
|
1015
|
+
</${o}>
|
|
825
1016
|
</pretext>
|
|
826
1017
|
`;
|
|
827
1018
|
}
|
|
828
|
-
|
|
829
|
-
|
|
1019
|
+
async function an(e, n, t) {
|
|
1020
|
+
const r = y(e).children.find(
|
|
1021
|
+
(d) => d.type === "element"
|
|
1022
|
+
), i = r?.attributes["xml:id"];
|
|
1023
|
+
if (!r || !i) return;
|
|
1024
|
+
const o = h(n), s = await P(o);
|
|
1025
|
+
if (s === void 0) return;
|
|
1026
|
+
let a;
|
|
1027
|
+
try {
|
|
1028
|
+
a = (await z(s, o, t)).tree;
|
|
1029
|
+
} catch {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
if (!Wt(a, i, r)) return;
|
|
1033
|
+
const l = Ht(a, i);
|
|
1034
|
+
if (l)
|
|
1035
|
+
return { ...l, tree: a };
|
|
1036
|
+
}
|
|
1037
|
+
let Le = !1;
|
|
1038
|
+
function cn(e) {
|
|
830
1039
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
831
1040
|
}
|
|
832
|
-
function
|
|
1041
|
+
function ln(e) {
|
|
833
1042
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
834
1043
|
}
|
|
835
|
-
function
|
|
836
|
-
if (
|
|
1044
|
+
function dn() {
|
|
1045
|
+
if (Le)
|
|
837
1046
|
throw new Error(
|
|
838
1047
|
"The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
|
|
839
1048
|
);
|
|
840
1049
|
}
|
|
841
|
-
function
|
|
842
|
-
if (
|
|
843
|
-
throw
|
|
1050
|
+
function ce(e) {
|
|
1051
|
+
if (cn(e))
|
|
1052
|
+
throw Le = !0, new Error(
|
|
844
1053
|
"The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
|
|
845
1054
|
{ cause: e }
|
|
846
1055
|
);
|
|
847
|
-
if (
|
|
1056
|
+
if (ln(e))
|
|
848
1057
|
throw new Error(
|
|
849
1058
|
"The WebAssembly renderer hit a memory fault. Most often the document is too large for this build's stack — whole-book builds are a known limitation, so try a smaller document, or see the README about rebuilding libxslt-wasm with a larger stack. The same fault also results from running two renders concurrently against the shared libxslt state.",
|
|
850
1059
|
{ cause: e }
|
|
851
1060
|
);
|
|
852
1061
|
}
|
|
853
|
-
let
|
|
854
|
-
async function
|
|
855
|
-
return
|
|
1062
|
+
let j;
|
|
1063
|
+
async function Pe() {
|
|
1064
|
+
return j || (j = (async () => {
|
|
856
1065
|
const [e, n] = await Promise.all([
|
|
857
1066
|
import("@pretextbook/libxslt-wasm"),
|
|
858
1067
|
import("@pretextbook/libxslt-wasm/exslt")
|
|
859
1068
|
]);
|
|
860
1069
|
return n.registerAll(), e;
|
|
861
|
-
})()),
|
|
1070
|
+
})()), j;
|
|
862
1071
|
}
|
|
863
|
-
const
|
|
1072
|
+
const F = /* @__PURE__ */ new Map(), un = {
|
|
864
1073
|
html: "preview-html.xsl",
|
|
865
1074
|
slides: "preview-revealjs.xsl"
|
|
866
1075
|
};
|
|
867
|
-
async function
|
|
868
|
-
const t =
|
|
869
|
-
let i =
|
|
1076
|
+
async function fn(e, n) {
|
|
1077
|
+
const t = un[n], r = `${n}\0${e}`;
|
|
1078
|
+
let i = F.get(r);
|
|
870
1079
|
return i || (i = (async () => {
|
|
871
|
-
const { XmlDocument:
|
|
872
|
-
if (
|
|
1080
|
+
const { XmlDocument: o, XsltStylesheet: s } = await Pe(), a = ge(e), l = await pe(A(), `/${t}`);
|
|
1081
|
+
if (l === void 0)
|
|
873
1082
|
throw new Error(
|
|
874
|
-
`Could not read ${t} from ${
|
|
1083
|
+
`Could not read ${t} from ${A()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
|
|
875
1084
|
);
|
|
876
|
-
const
|
|
1085
|
+
const d = new TextDecoder().decode(l), f = await o.fromString(d, {
|
|
877
1086
|
url: `${a}/${t}`,
|
|
878
1087
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
879
1088
|
});
|
|
880
|
-
return
|
|
881
|
-
})(),
|
|
882
|
-
}
|
|
883
|
-
let
|
|
884
|
-
function
|
|
885
|
-
const n =
|
|
886
|
-
() =>
|
|
887
|
-
() =>
|
|
1089
|
+
return s.fromXmlDocument(f);
|
|
1090
|
+
})(), F.set(r, i), i.catch(() => F.delete(r))), i;
|
|
1091
|
+
}
|
|
1092
|
+
let le = Promise.resolve();
|
|
1093
|
+
function En(e) {
|
|
1094
|
+
const n = le.then(
|
|
1095
|
+
() => de(e),
|
|
1096
|
+
() => de(e)
|
|
888
1097
|
);
|
|
889
|
-
return
|
|
1098
|
+
return le = n.catch(() => {
|
|
890
1099
|
}), n;
|
|
891
1100
|
}
|
|
892
|
-
async function
|
|
893
|
-
|
|
894
|
-
const { XmlDocument: n } = await
|
|
895
|
-
e.projectDir ??
|
|
896
|
-
), i = e.sourceContent ?? await
|
|
897
|
-
if (
|
|
1101
|
+
async function de(e) {
|
|
1102
|
+
Zt(), dn();
|
|
1103
|
+
const { XmlDocument: n } = await Pe(), t = h(e.sourcePath), r = h(
|
|
1104
|
+
e.projectDir ?? I(t)
|
|
1105
|
+
), i = e.sourceContent ?? await ae(t), o = B(r, t);
|
|
1106
|
+
if (o.startsWith(".."))
|
|
898
1107
|
throw new Error(
|
|
899
1108
|
`sourcePath (${t}) must live inside projectDir (${r})`
|
|
900
1109
|
);
|
|
901
|
-
const
|
|
1110
|
+
const s = B(
|
|
902
1111
|
r,
|
|
903
|
-
|
|
904
|
-
), a =
|
|
1112
|
+
h(e.mainSourcePath ?? t)
|
|
1113
|
+
), a = s.startsWith("..") ? o : s, l = ge(r);
|
|
905
1114
|
try {
|
|
906
|
-
let
|
|
1115
|
+
let d, f = `${l}/__pretext-preview-publication.xml`;
|
|
907
1116
|
if (e.publicationPath) {
|
|
908
|
-
const c =
|
|
909
|
-
|
|
910
|
-
const b =
|
|
911
|
-
b.startsWith("..") || (
|
|
1117
|
+
const c = h(e.publicationPath);
|
|
1118
|
+
d = await ae(c);
|
|
1119
|
+
const b = B(r, c);
|
|
1120
|
+
b.startsWith("..") || (f = `${l}/${b.split(N).join("/")}`);
|
|
912
1121
|
}
|
|
913
|
-
let
|
|
1122
|
+
let p, u;
|
|
914
1123
|
if (e.sourceMap) {
|
|
915
|
-
const c = await
|
|
1124
|
+
const c = await z(
|
|
916
1125
|
i,
|
|
917
1126
|
t,
|
|
918
1127
|
r
|
|
919
1128
|
);
|
|
920
|
-
|
|
1129
|
+
p = c.tree, u = c.content;
|
|
921
1130
|
} else
|
|
922
|
-
|
|
1131
|
+
u = await _t(
|
|
923
1132
|
i,
|
|
924
1133
|
t,
|
|
925
1134
|
r
|
|
926
1135
|
);
|
|
927
|
-
const m = e.target ??
|
|
1136
|
+
const m = e.target ?? Ot(u), R = await fn(e.xslDir ?? Yt(), m), g = pt(d, {
|
|
928
1137
|
cssTheme: e.cssTheme,
|
|
929
1138
|
revealTheme: e.revealTheme,
|
|
930
1139
|
target: m
|
|
931
1140
|
});
|
|
932
|
-
|
|
933
|
-
const
|
|
934
|
-
external:
|
|
935
|
-
generated:
|
|
936
|
-
} : void 0,
|
|
937
|
-
let
|
|
938
|
-
if (
|
|
939
|
-
if (e.fragment)
|
|
940
|
-
const c = e.docinfo ?? (e.docinfoSourcePath ? await _t(e.docinfoSourcePath, r) : void 0);
|
|
941
|
-
h = kt(
|
|
942
|
-
h,
|
|
943
|
-
T,
|
|
944
|
-
m,
|
|
945
|
-
c
|
|
946
|
-
), W = { parentId: c?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
947
|
-
} else
|
|
1141
|
+
ct(f, g);
|
|
1142
|
+
const w = ht(g), J = I(h(r, a)), G = w.external !== void 0 && w.generated !== void 0 ? {
|
|
1143
|
+
external: h(J, w.external),
|
|
1144
|
+
generated: h(J, w.generated)
|
|
1145
|
+
} : void 0, D = rn(u);
|
|
1146
|
+
let K = { parentId: "root", position: 1 }, T, Y = t;
|
|
1147
|
+
if (D !== "pretext" && D !== "mathbook") {
|
|
1148
|
+
if (!e.fragment)
|
|
948
1149
|
throw new Error(
|
|
949
|
-
`The document root is <${
|
|
1150
|
+
`The document root is <${D ?? "?"}>, not <pretext> — this looks like an xi:included fragment. Render the project's main source file instead, or pass the fragment option.`
|
|
950
1151
|
);
|
|
951
|
-
|
|
952
|
-
|
|
1152
|
+
if (e.contextSourcePath) {
|
|
1153
|
+
const c = await an(
|
|
1154
|
+
u,
|
|
1155
|
+
e.contextSourcePath,
|
|
1156
|
+
r
|
|
1157
|
+
);
|
|
1158
|
+
c && (u = c.content, p = e.sourceMap ? c.tree : void 0, Y = h(e.contextSourcePath), T = { divisionId: c.divisionId, level: c.level });
|
|
1159
|
+
}
|
|
1160
|
+
if (!T) {
|
|
1161
|
+
const c = e.docinfo ?? (e.docinfoSourcePath ? await on(e.docinfoSourcePath, r) : void 0);
|
|
1162
|
+
u = sn(
|
|
1163
|
+
u,
|
|
1164
|
+
D,
|
|
1165
|
+
m,
|
|
1166
|
+
c
|
|
1167
|
+
), K = { parentId: c?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
const q = p ? Pt(p, Y, K) : void 0, Z = await n.fromString(u, {
|
|
1171
|
+
url: `${l}/${a.split(N).join("/")}`,
|
|
953
1172
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
954
|
-
}),
|
|
955
|
-
publisher:
|
|
1173
|
+
}), S = {
|
|
1174
|
+
publisher: k(f)
|
|
956
1175
|
};
|
|
1176
|
+
for (const [c, b] of Object.entries(tn))
|
|
1177
|
+
S[c] = k(b);
|
|
1178
|
+
T && (S.subtree = k(T.divisionId), S["subtree-level"] = k(String(T.level)));
|
|
957
1179
|
for (const [c, b] of Object.entries(e.stringParams ?? {}))
|
|
958
|
-
|
|
959
|
-
let
|
|
1180
|
+
S[c] = k(b);
|
|
1181
|
+
let O;
|
|
960
1182
|
try {
|
|
961
|
-
|
|
1183
|
+
O = await R.apply(Z, S);
|
|
962
1184
|
} catch (c) {
|
|
963
|
-
throw
|
|
1185
|
+
throw ce(c), new Error(
|
|
964
1186
|
"PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
|
|
965
1187
|
{ cause: c }
|
|
966
1188
|
);
|
|
967
1189
|
} finally {
|
|
968
|
-
|
|
1190
|
+
Z.delete();
|
|
969
1191
|
}
|
|
970
1192
|
try {
|
|
971
|
-
let c =
|
|
972
|
-
return
|
|
1193
|
+
let c = Qt(O.toHtmlString());
|
|
1194
|
+
return c = Kt(c, {
|
|
1195
|
+
...e.offPageMessage !== void 0 ? { offPageMessage: e.offPageMessage } : {}
|
|
1196
|
+
}), (e.openKnowls ?? !0) && (c = nt(c)), m === "slides" ? (c = nn(c), c = It(c, e.revealView ?? "scroll", {
|
|
973
1197
|
zoom: e.revealZoom
|
|
974
|
-
})) : e.theme && (c =
|
|
1198
|
+
})) : e.theme && (c = Ct(c, e.theme)), e.previewBanner && (c = Ve(c, e.previewBanner)), {
|
|
975
1199
|
html: c,
|
|
976
1200
|
target: m,
|
|
977
|
-
...
|
|
978
|
-
...
|
|
1201
|
+
...q ? { sourceMap: q } : {},
|
|
1202
|
+
...G ? { assetDirs: G } : {}
|
|
979
1203
|
};
|
|
980
1204
|
} catch (c) {
|
|
981
|
-
throw
|
|
1205
|
+
throw ce(c), c;
|
|
982
1206
|
} finally {
|
|
983
|
-
|
|
1207
|
+
O.delete();
|
|
984
1208
|
}
|
|
985
1209
|
} finally {
|
|
986
|
-
|
|
1210
|
+
at(l);
|
|
987
1211
|
}
|
|
988
1212
|
}
|
|
989
1213
|
export {
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1214
|
+
Be as PREVIEW_BANNER_STORAGE_KEY,
|
|
1215
|
+
$e as PREVIEW_THEME_MESSAGE,
|
|
1216
|
+
Yt as defaultXslDir,
|
|
1217
|
+
Ot as detectRenderTarget,
|
|
1218
|
+
gn as findSourceMapEntry,
|
|
1219
|
+
pt as forcePortablePublication,
|
|
1220
|
+
Ve as injectPreviewBanner,
|
|
1221
|
+
It as injectRevealBridge,
|
|
1222
|
+
Ct as injectThemeBridge,
|
|
1223
|
+
qt as isJspiAvailable,
|
|
1224
|
+
bn as isPreviewTheme,
|
|
1225
|
+
vn as isRevealView,
|
|
1226
|
+
nt as openBornHiddenKnowls,
|
|
1227
|
+
Ne as previewBannerScript,
|
|
1228
|
+
xn as previewThemeMessage,
|
|
1229
|
+
En as renderHtml,
|
|
1230
|
+
yt as revealBridgeScript,
|
|
1231
|
+
mn as setAssetsBase,
|
|
1232
|
+
wn as setMountReader,
|
|
1233
|
+
Bt as themeBridgeScript,
|
|
1234
|
+
k as xpathStringLiteral
|
|
1011
1235
|
};
|