@pretextbook/pretext-html 0.8.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/assets/preview-html.xsl +16 -0
- package/assets/upstream.json +1 -1
- 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/it-IT.xml +37 -41
- package/assets/xsl/pretext-assembly.xsl +188 -24
- package/assets/xsl/pretext-beamer.xsl +57 -12
- package/assets/xsl/pretext-common.xsl +156 -28
- package/assets/xsl/pretext-epub.xsl +0 -5
- package/assets/xsl/pretext-fo.xsl +110 -48
- package/assets/xsl/pretext-html.xsl +147 -54
- package/assets/xsl/pretext-jupyter.xsl +1 -0
- package/assets/xsl/pretext-latex-classic.xsl +2 -2
- package/assets/xsl/pretext-latex-common.xsl +268 -134
- package/assets/xsl/pretext-latex.xsl +16 -6
- package/assets/xsl/pretext-numbers.xsl +10 -0
- package/assets/xsl/pretext-revealjs.xsl +68 -1
- package/assets/xsl/pretext-runestone-fitb.xsl +179 -84
- package/assets/xsl/pretext-runestone-static.xsl +72 -20
- package/assets/xsl/pretext-runestone.xsl +27 -4
- package/assets/xsl/pretext-text-utilities.xsl +7 -0
- package/assets/xsl/pretext-text.xsl +17 -0
- package/assets/xsl/publisher-variables.xsl +39 -0
- 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 +2 -2
- package/dist/index.browser.js +595 -386
- package/dist/index.d.ts +4 -0
- package/dist/index.js +35 -30
- package/dist/renderer.d.ts +35 -0
- package/dist/skeleton.d.ts +41 -0
- package/dist/xrefs.d.ts +54 -0
- package/package.json +1 -1
- package/dist/cli-Bcn4t3B1.js +0 -871
package/dist/index.browser.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { fromXml as
|
|
2
|
-
import { toXml as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { fromXml as y } from "xast-util-from-xml";
|
|
2
|
+
import { toXml as $ } from "xast-util-to-xml";
|
|
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 Se() {
|
|
|
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 Le(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,42 +238,42 @@ async function C(e) {
|
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
const
|
|
242
|
-
"prefix-runtime.
|
|
241
|
+
const he = "2.48.1", Ke = "8.2.4", Ye = [
|
|
242
|
+
"prefix-runtime.40bd1420d3277749.bundle.js",
|
|
243
243
|
"prefix-926.5c7038c8ef173faf.bundle.js",
|
|
244
|
-
"prefix-runestone.
|
|
245
|
-
],
|
|
244
|
+
"prefix-runestone.b388362b5f43738a.bundle.js"
|
|
245
|
+
], qe = [
|
|
246
246
|
"prefix-926.229729d09512acc9.css",
|
|
247
247
|
"prefix-runestone.8086b62682b271d1.css"
|
|
248
|
-
],
|
|
249
|
-
function
|
|
248
|
+
], Ze = "born-hidden-knowl", Qe = /<details\b([^>]*)>(\s*)(?:<summary\b([^>]*)>)?/g;
|
|
249
|
+
function et(e) {
|
|
250
250
|
const n = /\bclass="([^"]*)"/.exec(e);
|
|
251
251
|
return n ? n[1].trim().split(/\s+/) : [];
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function tt(e) {
|
|
254
254
|
return /(^|\s)open(\s|=|$)/.test(e);
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
return
|
|
256
|
+
function te(e) {
|
|
257
|
+
return tt(e) ? e : ` open${e}`;
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function nt(e) {
|
|
260
260
|
return e.replace(
|
|
261
|
-
|
|
261
|
+
Qe,
|
|
262
262
|
(n, t, r, i) => {
|
|
263
|
-
if (!
|
|
263
|
+
if (!et(t).includes(Ze))
|
|
264
264
|
return n;
|
|
265
|
-
const
|
|
266
|
-
return i === void 0 ? `${
|
|
265
|
+
const o = `<details${te(t)}>`;
|
|
266
|
+
return i === void 0 ? `${o}${r}` : `${o}${r}<summary${te(i)}>`;
|
|
267
267
|
}
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
|
-
const
|
|
271
|
-
let
|
|
272
|
-
function
|
|
273
|
-
|
|
270
|
+
const X = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map();
|
|
271
|
+
let W, rt = 0, we = pe;
|
|
272
|
+
function wn(e) {
|
|
273
|
+
we = e;
|
|
274
274
|
}
|
|
275
|
-
function
|
|
276
|
-
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);
|
|
277
277
|
if (r !== void 0)
|
|
278
278
|
return Promise.resolve(new Response(r, { status: 200 }));
|
|
279
279
|
let i;
|
|
@@ -282,32 +282,32 @@ function He(e, n) {
|
|
|
282
282
|
} catch {
|
|
283
283
|
i = "";
|
|
284
284
|
}
|
|
285
|
-
const
|
|
286
|
-
return
|
|
285
|
+
const o = X.get(i);
|
|
286
|
+
return o !== void 0 ? st(o, t) : W(e, n);
|
|
287
287
|
}
|
|
288
|
-
const
|
|
289
|
-
async function
|
|
290
|
-
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);
|
|
291
291
|
if (r === void 0)
|
|
292
|
-
return new Response(
|
|
292
|
+
return new Response(ot, { status: 200 });
|
|
293
293
|
const i = typeof r == "string" ? r : new Uint8Array(r);
|
|
294
294
|
return new Response(i, { status: 200 });
|
|
295
295
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
296
|
+
function ve() {
|
|
297
|
+
W || (W = globalThis.fetch, globalThis.fetch = it);
|
|
298
298
|
}
|
|
299
|
-
function
|
|
300
|
-
|
|
301
|
-
const n = `mnt${++
|
|
302
|
-
return
|
|
299
|
+
function ge(e) {
|
|
300
|
+
ve();
|
|
301
|
+
const n = `mnt${++rt}.ptx.invalid`;
|
|
302
|
+
return X.set(n, e), `http://${n}`;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
305
|
-
|
|
304
|
+
function at(e) {
|
|
305
|
+
X.delete(new URL(e).host);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
307
|
+
function ct(e, n) {
|
|
308
|
+
ve(), me.set(e, n);
|
|
309
309
|
}
|
|
310
|
-
const
|
|
310
|
+
const H = `<?xml version="1.0" encoding="UTF-8"?>
|
|
311
311
|
<publication>
|
|
312
312
|
<source>
|
|
313
313
|
<directories external="../assets" generated="../generated-assets" />
|
|
@@ -316,82 +316,82 @@ const B = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
316
316
|
<platform portable="yes"/>
|
|
317
317
|
</html>
|
|
318
318
|
</publication>
|
|
319
|
-
`,
|
|
320
|
-
function
|
|
319
|
+
`, lt = ["theme", "style", "shell"];
|
|
320
|
+
function x(e, n) {
|
|
321
321
|
for (const t of e.children)
|
|
322
322
|
if (t.type === "element" && t.name === n)
|
|
323
323
|
return t;
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
let t =
|
|
325
|
+
function E(e, n) {
|
|
326
|
+
let t = x(e, n);
|
|
327
327
|
return t || (t = { type: "element", name: n, attributes: {}, children: [] }, e.children.push(t)), t;
|
|
328
328
|
}
|
|
329
|
-
function
|
|
330
|
-
const t =
|
|
331
|
-
if (t &&
|
|
329
|
+
function dt(e, n) {
|
|
330
|
+
const t = x(e, "css");
|
|
331
|
+
if (t && lt.some((i) => t.attributes?.[i]))
|
|
332
332
|
return;
|
|
333
|
-
const r = t ??
|
|
333
|
+
const r = t ?? E(e, "css");
|
|
334
334
|
r.attributes = { ...r.attributes, theme: n };
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
const t =
|
|
336
|
+
function ut(e, n) {
|
|
337
|
+
const t = x(e, "appearance");
|
|
338
338
|
if (t?.attributes?.theme)
|
|
339
339
|
return;
|
|
340
|
-
const r = t ??
|
|
340
|
+
const r = t ?? E(e, "appearance");
|
|
341
341
|
r.attributes = { ...r.attributes, theme: n };
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
const n =
|
|
343
|
+
function ft(e) {
|
|
344
|
+
const n = E(e, "resources");
|
|
345
345
|
n.attributes = {
|
|
346
346
|
...n.attributes,
|
|
347
347
|
host: "cdn",
|
|
348
348
|
math: "online"
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function pt(e, n = {}) {
|
|
352
352
|
const t = n.cssTheme?.trim(), r = n.revealTheme?.trim(), i = n.target === "slides";
|
|
353
353
|
if (!e && !t && !i)
|
|
354
|
-
return
|
|
355
|
-
const
|
|
356
|
-
if (!
|
|
354
|
+
return H;
|
|
355
|
+
const o = y(e ?? H), s = x(o, "publication");
|
|
356
|
+
if (!s)
|
|
357
357
|
throw new Error(
|
|
358
358
|
"Invalid publication file: no root <publication> element found"
|
|
359
359
|
);
|
|
360
|
-
const a =
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
|
|
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);
|
|
364
364
|
}
|
|
365
|
-
return
|
|
365
|
+
return $(o);
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function ne(e) {
|
|
368
368
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
369
369
|
return e.endsWith("/") ? e : `${e}/`;
|
|
370
370
|
}
|
|
371
|
-
function
|
|
372
|
-
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(
|
|
373
373
|
i?.attributes?.external ?? void 0
|
|
374
|
-
),
|
|
374
|
+
), s = ne(
|
|
375
375
|
i?.attributes?.generated ?? void 0
|
|
376
376
|
);
|
|
377
377
|
return {
|
|
378
|
-
external:
|
|
379
|
-
generated:
|
|
380
|
-
managed:
|
|
378
|
+
external: o,
|
|
379
|
+
generated: s,
|
|
380
|
+
managed: o !== void 0 && s !== void 0
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function vn(e) {
|
|
384
384
|
return e === "slides" || e === "scroll";
|
|
385
385
|
}
|
|
386
|
-
const
|
|
387
|
-
function
|
|
388
|
-
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));
|
|
389
389
|
return {
|
|
390
|
-
width: Math.round(
|
|
391
|
-
height: Math.round(
|
|
390
|
+
width: Math.round(be / t),
|
|
391
|
+
height: Math.round(xe / t)
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function gt(e) {
|
|
395
395
|
return {
|
|
396
396
|
view: "scroll",
|
|
397
397
|
scrollLayout: "compact",
|
|
@@ -401,11 +401,11 @@ function rt(e) {
|
|
|
401
401
|
controls: !1,
|
|
402
402
|
controlsTutorial: !1,
|
|
403
403
|
hash: !1,
|
|
404
|
-
...
|
|
405
|
-
margin:
|
|
404
|
+
...vt(e.zoom),
|
|
405
|
+
margin: wt
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function bt() {
|
|
409
409
|
return {
|
|
410
410
|
// Explicitly null rather than absent: the same page may have been
|
|
411
411
|
// delivered in scroll view a moment ago, and an embedder that re-injects
|
|
@@ -417,11 +417,11 @@ function it() {
|
|
|
417
417
|
// size with a percentage width renders its text far larger, relative to
|
|
418
418
|
// the slide, than the same deck will on a projector. No zoom margin
|
|
419
419
|
// though — presenting means filling whatever it is shown in.
|
|
420
|
-
width:
|
|
421
|
-
height:
|
|
420
|
+
width: be,
|
|
421
|
+
height: xe
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
|
-
const
|
|
424
|
+
const xt = [
|
|
425
425
|
"<style>",
|
|
426
426
|
".reveal-viewport.reveal-scroll .scroll-page section {",
|
|
427
427
|
" box-shadow: inset 0 0 0 calc(1px / var(--slide-scale, 1))",
|
|
@@ -429,14 +429,14 @@ const st = [
|
|
|
429
429
|
"}",
|
|
430
430
|
"</style>"
|
|
431
431
|
].join(`
|
|
432
|
-
`),
|
|
432
|
+
`), Et = [
|
|
433
433
|
" var paused = document.querySelectorAll('.reveal .fragment');",
|
|
434
434
|
" for (var i = 0; i < paused.length; i++) {",
|
|
435
435
|
" paused[i].classList.remove('fragment');",
|
|
436
436
|
" }"
|
|
437
437
|
];
|
|
438
|
-
function
|
|
439
|
-
const t = e === "scroll" ?
|
|
438
|
+
function yt(e, n = {}) {
|
|
439
|
+
const t = e === "scroll" ? gt(n) : bt();
|
|
440
440
|
return [
|
|
441
441
|
"<script>",
|
|
442
442
|
"(function () {",
|
|
@@ -464,7 +464,7 @@ function at(e, n = {}) {
|
|
|
464
464
|
// Inside the wrapper rather than at top level: this script sits in <head>,
|
|
465
465
|
// where the slides have not been parsed yet, but the deck calls initialize
|
|
466
466
|
// from the end of the document, by which time they have.
|
|
467
|
-
...e === "scroll" ?
|
|
467
|
+
...e === "scroll" ? Et : [],
|
|
468
468
|
" return initialize(merged);",
|
|
469
469
|
" };",
|
|
470
470
|
"})();",
|
|
@@ -472,156 +472,156 @@ function at(e, n = {}) {
|
|
|
472
472
|
].join(`
|
|
473
473
|
`);
|
|
474
474
|
}
|
|
475
|
-
const
|
|
476
|
-
function
|
|
477
|
-
const r =
|
|
478
|
-
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)
|
|
479
479
|
return i;
|
|
480
|
-
const
|
|
481
|
-
${
|
|
482
|
-
${
|
|
483
|
-
${
|
|
484
|
-
${
|
|
485
|
-
return i.slice(0,
|
|
486
|
-
}
|
|
487
|
-
const
|
|
488
|
-
async function
|
|
489
|
-
return e.includes("include") ? (await
|
|
490
|
-
}
|
|
491
|
-
async function
|
|
492
|
-
const r =
|
|
493
|
-
projectDir:
|
|
494
|
-
stack: [
|
|
495
|
-
},
|
|
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 _(
|
|
496
496
|
r,
|
|
497
|
-
|
|
497
|
+
I(h(n)),
|
|
498
498
|
{ "": "" },
|
|
499
499
|
i
|
|
500
500
|
);
|
|
501
|
-
return { tree: r, content:
|
|
501
|
+
return { tree: r, content: o ? $(r) : e };
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function Rt(e) {
|
|
504
504
|
return e.data?.ptxIncludedFile;
|
|
505
505
|
}
|
|
506
|
-
function
|
|
506
|
+
function Dt(e, n) {
|
|
507
507
|
const t = e.data ?? (e.data = {});
|
|
508
508
|
t.ptxIncludedFile = n;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function L(e, n) {
|
|
511
511
|
let t = e;
|
|
512
512
|
for (const [r, i] of Object.entries(n.attributes))
|
|
513
513
|
(r === "xmlns" || r.startsWith("xmlns:")) && (t === e && (t = { ...e }), t[r === "xmlns" ? "" : r.slice(6)] = i ?? "");
|
|
514
514
|
return t;
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function ye(e, n) {
|
|
517
517
|
const t = e.name.indexOf(":"), r = t === -1 ? "" : e.name.slice(0, t);
|
|
518
|
-
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;
|
|
519
519
|
}
|
|
520
|
-
async function
|
|
520
|
+
async function _(e, n, t, r) {
|
|
521
521
|
let i = !1;
|
|
522
|
-
for (let
|
|
523
|
-
const
|
|
524
|
-
if (
|
|
522
|
+
for (let o = 0; o < e.children.length; o++) {
|
|
523
|
+
const s = e.children[o];
|
|
524
|
+
if (s.type !== "element")
|
|
525
525
|
continue;
|
|
526
|
-
const a =
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
|
|
526
|
+
const a = L(t, s);
|
|
527
|
+
if (ye(s, a)) {
|
|
528
|
+
const l = await Te(
|
|
529
|
+
s,
|
|
530
530
|
n,
|
|
531
531
|
a,
|
|
532
532
|
r
|
|
533
533
|
);
|
|
534
|
-
e.children.splice(
|
|
535
|
-
} else await
|
|
534
|
+
e.children.splice(o, 1, ...l), o += l.length - 1, i = !0;
|
|
535
|
+
} else await _(s, n, a, r) && (i = !0);
|
|
536
536
|
}
|
|
537
537
|
return i;
|
|
538
538
|
}
|
|
539
|
-
async function
|
|
539
|
+
async function Te(e, n, t, r) {
|
|
540
540
|
const i = r.stack[r.stack.length - 1];
|
|
541
541
|
if (e.attributes.xpointer)
|
|
542
542
|
throw new Error(
|
|
543
543
|
`xi:include with xpointer is not supported by the JS preview build (in ${i})`
|
|
544
544
|
);
|
|
545
|
-
const
|
|
546
|
-
if (!
|
|
545
|
+
const o = e.attributes.href;
|
|
546
|
+
if (!o)
|
|
547
547
|
throw new Error(`xi:include without href (in ${i})`);
|
|
548
|
-
let
|
|
548
|
+
let s = o;
|
|
549
549
|
try {
|
|
550
|
-
|
|
550
|
+
s = decodeURIComponent(o);
|
|
551
551
|
} catch {
|
|
552
552
|
}
|
|
553
|
-
const a =
|
|
554
|
-
if (a !== r.projectDir && !a.startsWith(r.projectDir +
|
|
553
|
+
const a = h(n, s);
|
|
554
|
+
if (a !== r.projectDir && !a.startsWith(r.projectDir + N))
|
|
555
555
|
throw new Error(
|
|
556
|
-
`xi:include escapes the project directory: ${
|
|
556
|
+
`xi:include escapes the project directory: ${o} (in ${i})`
|
|
557
557
|
);
|
|
558
558
|
if (r.stack.includes(a))
|
|
559
559
|
throw new Error(
|
|
560
560
|
`Circular xi:include: ${[...r.stack, a].join(" -> ")}`
|
|
561
561
|
);
|
|
562
|
-
if (r.stack.length >=
|
|
563
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
564
|
-
const
|
|
565
|
-
if (
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
return await
|
|
569
|
-
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})`);
|
|
570
570
|
}
|
|
571
571
|
if (e.attributes.parse === "text")
|
|
572
|
-
return [{ type: "text", value:
|
|
573
|
-
let
|
|
572
|
+
return [{ type: "text", value: l }];
|
|
573
|
+
let d;
|
|
574
574
|
try {
|
|
575
|
-
|
|
576
|
-
} catch (
|
|
575
|
+
d = y(l);
|
|
576
|
+
} catch (p) {
|
|
577
577
|
throw new Error(
|
|
578
|
-
`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.)`
|
|
579
579
|
);
|
|
580
580
|
}
|
|
581
581
|
r.stack.push(a);
|
|
582
582
|
try {
|
|
583
|
-
await
|
|
583
|
+
await _(d, I(a), { "": "" }, r);
|
|
584
584
|
} finally {
|
|
585
585
|
r.stack.pop();
|
|
586
586
|
}
|
|
587
|
-
const
|
|
588
|
-
(
|
|
587
|
+
const f = d.children.filter(
|
|
588
|
+
(p) => p.type === "element"
|
|
589
589
|
);
|
|
590
|
-
for (const
|
|
591
|
-
|
|
592
|
-
return
|
|
590
|
+
for (const p of f)
|
|
591
|
+
Dt(p, a);
|
|
592
|
+
return f;
|
|
593
593
|
}
|
|
594
|
-
function
|
|
594
|
+
function ie(e) {
|
|
595
595
|
return e.name === "docinfo";
|
|
596
596
|
}
|
|
597
|
-
async function
|
|
597
|
+
async function Mt(e, n, t) {
|
|
598
598
|
try {
|
|
599
|
-
const i =
|
|
600
|
-
(
|
|
599
|
+
const i = y(e).children.find(
|
|
600
|
+
(d) => d.type === "element"
|
|
601
601
|
);
|
|
602
602
|
if (!i)
|
|
603
603
|
return;
|
|
604
|
-
const
|
|
605
|
-
projectDir:
|
|
606
|
-
stack: [
|
|
607
|
-
},
|
|
608
|
-
for (const
|
|
609
|
-
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")
|
|
610
610
|
continue;
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
return await
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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,
|
|
619
619
|
a
|
|
620
620
|
)).find(
|
|
621
|
-
(m) => m.type === "element" &&
|
|
621
|
+
(m) => m.type === "element" && ie(m)
|
|
622
622
|
);
|
|
623
|
-
if (
|
|
624
|
-
return
|
|
623
|
+
if (u)
|
|
624
|
+
return $(u);
|
|
625
625
|
continue;
|
|
626
626
|
}
|
|
627
627
|
break;
|
|
@@ -631,78 +631,78 @@ async function wt(e, n, t) {
|
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function At(e, n) {
|
|
635
635
|
for (const t of e.children) {
|
|
636
636
|
if (t.type !== "element")
|
|
637
637
|
continue;
|
|
638
|
-
const r =
|
|
639
|
-
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)
|
|
640
640
|
return t;
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
|
-
function
|
|
643
|
+
function Se(e) {
|
|
644
644
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function Lt(e) {
|
|
647
647
|
return /^(pf|xhtml):/.test(e.name);
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
const r = [], i = e.children.find(
|
|
649
|
+
function Pt(e, n, t) {
|
|
650
|
+
const r = [], i = e.children.find(Se);
|
|
651
651
|
if (i) {
|
|
652
|
-
const
|
|
653
|
-
|
|
652
|
+
const o = t?.parentId ?? "root";
|
|
653
|
+
ke(i, o, t?.position ?? 1, n, o, r);
|
|
654
654
|
}
|
|
655
655
|
return r;
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
const
|
|
659
|
-
let a,
|
|
660
|
-
if (
|
|
661
|
-
|
|
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";
|
|
662
662
|
else {
|
|
663
|
-
const
|
|
664
|
-
a =
|
|
663
|
+
const f = e.attributes.label ?? e.attributes["xml:id"];
|
|
664
|
+
a = f ?? `${n}-${t}`, o.push({
|
|
665
665
|
id: a,
|
|
666
|
-
file:
|
|
666
|
+
file: s,
|
|
667
667
|
line: e.position?.start.line ?? 1,
|
|
668
668
|
column: e.position?.start.column ?? 1,
|
|
669
669
|
endLine: e.position?.end.line ?? e.position?.start.line ?? 1,
|
|
670
670
|
parent: i
|
|
671
|
-
}),
|
|
671
|
+
}), l = a;
|
|
672
672
|
}
|
|
673
|
-
let
|
|
674
|
-
for (const
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
d,
|
|
673
|
+
let d = 0;
|
|
674
|
+
for (const f of e.children)
|
|
675
|
+
Se(f) && (d += 1, ke(
|
|
676
|
+
f,
|
|
678
677
|
l,
|
|
679
|
-
|
|
678
|
+
d,
|
|
679
|
+
s,
|
|
680
680
|
a ?? i,
|
|
681
|
-
|
|
681
|
+
o
|
|
682
682
|
));
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function gn(e, n) {
|
|
685
685
|
let t;
|
|
686
686
|
for (const r of e)
|
|
687
687
|
r.line <= n && (t = r);
|
|
688
688
|
return t ?? e[0];
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function Ot(e) {
|
|
691
691
|
const n = e.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, " ");
|
|
692
692
|
return /<\s*slide(?:show)?[\s/>]/.test(n) ? "slides" : "html";
|
|
693
693
|
}
|
|
694
|
-
const
|
|
695
|
-
function
|
|
694
|
+
const $e = "pretext-html:set-theme";
|
|
695
|
+
function bn(e) {
|
|
696
696
|
return e === "dark" || e === "light" || e === "system";
|
|
697
697
|
}
|
|
698
|
-
function
|
|
699
|
-
return { type:
|
|
698
|
+
function xn(e) {
|
|
699
|
+
return { type: $e, theme: e };
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function Bt(e) {
|
|
702
702
|
return [
|
|
703
703
|
"<script>",
|
|
704
704
|
"(function () {",
|
|
705
|
-
" var CFG = " + JSON.stringify({ msg:
|
|
705
|
+
" var CFG = " + JSON.stringify({ msg: $e, initial: e }) + ";",
|
|
706
706
|
// Where the last requested theme is remembered so it survives an in-place
|
|
707
707
|
// document rewrite (same Window) and outranks the baked initial value.
|
|
708
708
|
" var KEY = '__ptxPreviewTheme';",
|
|
@@ -772,255 +772,464 @@ function xt(e) {
|
|
|
772
772
|
].join(`
|
|
773
773
|
`);
|
|
774
774
|
}
|
|
775
|
-
function
|
|
776
|
-
const t =
|
|
775
|
+
function Ct(e, n) {
|
|
776
|
+
const t = Bt(n);
|
|
777
777
|
return /<head[^>]*>/i.test(e) ? e.replace(/<head([^>]*)>/i, `<head$1>
|
|
778
778
|
${t}`) : e;
|
|
779
779
|
}
|
|
780
|
-
|
|
781
|
-
|
|
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;
|
|
861
|
+
}
|
|
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;
|
|
782
929
|
}
|
|
783
|
-
function
|
|
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() {
|
|
784
962
|
return "Suspending" in WebAssembly;
|
|
785
963
|
}
|
|
786
|
-
function
|
|
787
|
-
if (!
|
|
964
|
+
function Zt() {
|
|
965
|
+
if (!qt())
|
|
788
966
|
throw new Error(
|
|
789
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)."
|
|
790
968
|
);
|
|
791
969
|
}
|
|
792
|
-
function
|
|
970
|
+
function k(e) {
|
|
793
971
|
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((t) => `'${t}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
|
|
794
972
|
}
|
|
795
|
-
function
|
|
973
|
+
function Qt(e) {
|
|
796
974
|
return e.replace(
|
|
797
975
|
/from '\.\/(https:\/\/[^']+)'/g,
|
|
798
976
|
(n, t) => `from '${t}'`
|
|
799
977
|
);
|
|
800
978
|
}
|
|
801
|
-
const
|
|
802
|
-
"cli.version":
|
|
979
|
+
const en = `https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@${he}/dist/`, tn = {
|
|
980
|
+
"cli.version": he,
|
|
803
981
|
// Colon-delimited: pretext-runestone.xsl splits them with str:tokenize.
|
|
804
|
-
"rs-js":
|
|
805
|
-
"rs-css":
|
|
806
|
-
"rs-version":
|
|
982
|
+
"rs-js": Ye.join(":"),
|
|
983
|
+
"rs-css": qe.join(":"),
|
|
984
|
+
"rs-version": Ke
|
|
807
985
|
};
|
|
808
|
-
function
|
|
986
|
+
function nn(e) {
|
|
809
987
|
return e.replace(
|
|
810
988
|
/(<link\b[^>]*\bhref=["'])_static\//gi,
|
|
811
|
-
`$1${
|
|
989
|
+
`$1${en}_static/`
|
|
812
990
|
);
|
|
813
991
|
}
|
|
814
|
-
function
|
|
992
|
+
function rn(e) {
|
|
815
993
|
return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
|
|
816
994
|
}
|
|
817
|
-
async function
|
|
818
|
-
const n = await
|
|
995
|
+
async function ae(e) {
|
|
996
|
+
const n = await P(e);
|
|
819
997
|
if (n === void 0)
|
|
820
998
|
throw new Error(
|
|
821
999
|
`Could not read ${e}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
|
|
822
1000
|
);
|
|
823
1001
|
return n;
|
|
824
1002
|
}
|
|
825
|
-
async function
|
|
826
|
-
const t =
|
|
1003
|
+
async function on(e, n) {
|
|
1004
|
+
const t = h(e), r = await P(t);
|
|
827
1005
|
if (r !== void 0)
|
|
828
|
-
return
|
|
1006
|
+
return Mt(r, t, n);
|
|
829
1007
|
}
|
|
830
|
-
function
|
|
831
|
-
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";
|
|
832
1010
|
return `<pretext>
|
|
833
1011
|
${r?.trim() ? `${r.trim()}
|
|
834
|
-
` : ""}<${
|
|
1012
|
+
` : ""}<${o}>
|
|
835
1013
|
<title/>
|
|
836
1014
|
${i}
|
|
837
|
-
</${
|
|
1015
|
+
</${o}>
|
|
838
1016
|
</pretext>
|
|
839
1017
|
`;
|
|
840
1018
|
}
|
|
841
|
-
|
|
842
|
-
|
|
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) {
|
|
843
1039
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
844
1040
|
}
|
|
845
|
-
function
|
|
1041
|
+
function ln(e) {
|
|
846
1042
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
847
1043
|
}
|
|
848
|
-
function
|
|
849
|
-
if (
|
|
1044
|
+
function dn() {
|
|
1045
|
+
if (Le)
|
|
850
1046
|
throw new Error(
|
|
851
1047
|
"The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
|
|
852
1048
|
);
|
|
853
1049
|
}
|
|
854
|
-
function
|
|
855
|
-
if (
|
|
856
|
-
throw
|
|
1050
|
+
function ce(e) {
|
|
1051
|
+
if (cn(e))
|
|
1052
|
+
throw Le = !0, new Error(
|
|
857
1053
|
"The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
|
|
858
1054
|
{ cause: e }
|
|
859
1055
|
);
|
|
860
|
-
if (
|
|
1056
|
+
if (ln(e))
|
|
861
1057
|
throw new Error(
|
|
862
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.",
|
|
863
1059
|
{ cause: e }
|
|
864
1060
|
);
|
|
865
1061
|
}
|
|
866
|
-
let
|
|
867
|
-
async function
|
|
868
|
-
return
|
|
1062
|
+
let j;
|
|
1063
|
+
async function Pe() {
|
|
1064
|
+
return j || (j = (async () => {
|
|
869
1065
|
const [e, n] = await Promise.all([
|
|
870
1066
|
import("@pretextbook/libxslt-wasm"),
|
|
871
1067
|
import("@pretextbook/libxslt-wasm/exslt")
|
|
872
1068
|
]);
|
|
873
1069
|
return n.registerAll(), e;
|
|
874
|
-
})()),
|
|
1070
|
+
})()), j;
|
|
875
1071
|
}
|
|
876
|
-
const
|
|
1072
|
+
const F = /* @__PURE__ */ new Map(), un = {
|
|
877
1073
|
html: "preview-html.xsl",
|
|
878
1074
|
slides: "preview-revealjs.xsl"
|
|
879
1075
|
};
|
|
880
|
-
async function
|
|
881
|
-
const t =
|
|
882
|
-
let i =
|
|
1076
|
+
async function fn(e, n) {
|
|
1077
|
+
const t = un[n], r = `${n}\0${e}`;
|
|
1078
|
+
let i = F.get(r);
|
|
883
1079
|
return i || (i = (async () => {
|
|
884
|
-
const { XmlDocument:
|
|
885
|
-
if (
|
|
1080
|
+
const { XmlDocument: o, XsltStylesheet: s } = await Pe(), a = ge(e), l = await pe(A(), `/${t}`);
|
|
1081
|
+
if (l === void 0)
|
|
886
1082
|
throw new Error(
|
|
887
|
-
`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).`
|
|
888
1084
|
);
|
|
889
|
-
const
|
|
1085
|
+
const d = new TextDecoder().decode(l), f = await o.fromString(d, {
|
|
890
1086
|
url: `${a}/${t}`,
|
|
891
1087
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
892
1088
|
});
|
|
893
|
-
return
|
|
894
|
-
})(),
|
|
895
|
-
}
|
|
896
|
-
let
|
|
897
|
-
function
|
|
898
|
-
const n =
|
|
899
|
-
() =>
|
|
900
|
-
() =>
|
|
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)
|
|
901
1097
|
);
|
|
902
|
-
return
|
|
1098
|
+
return le = n.catch(() => {
|
|
903
1099
|
}), n;
|
|
904
1100
|
}
|
|
905
|
-
async function
|
|
906
|
-
|
|
907
|
-
const { XmlDocument: n } = await
|
|
908
|
-
e.projectDir ??
|
|
909
|
-
), i = e.sourceContent ?? await
|
|
910
|
-
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(".."))
|
|
911
1107
|
throw new Error(
|
|
912
1108
|
`sourcePath (${t}) must live inside projectDir (${r})`
|
|
913
1109
|
);
|
|
914
|
-
const
|
|
1110
|
+
const s = B(
|
|
915
1111
|
r,
|
|
916
|
-
|
|
917
|
-
), a =
|
|
1112
|
+
h(e.mainSourcePath ?? t)
|
|
1113
|
+
), a = s.startsWith("..") ? o : s, l = ge(r);
|
|
918
1114
|
try {
|
|
919
|
-
let
|
|
1115
|
+
let d, f = `${l}/__pretext-preview-publication.xml`;
|
|
920
1116
|
if (e.publicationPath) {
|
|
921
|
-
const c =
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
|
|
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("/")}`);
|
|
925
1121
|
}
|
|
926
|
-
let
|
|
1122
|
+
let p, u;
|
|
927
1123
|
if (e.sourceMap) {
|
|
928
|
-
const c = await
|
|
1124
|
+
const c = await z(
|
|
929
1125
|
i,
|
|
930
1126
|
t,
|
|
931
1127
|
r
|
|
932
1128
|
);
|
|
933
|
-
|
|
1129
|
+
p = c.tree, u = c.content;
|
|
934
1130
|
} else
|
|
935
|
-
|
|
1131
|
+
u = await _t(
|
|
936
1132
|
i,
|
|
937
1133
|
t,
|
|
938
1134
|
r
|
|
939
1135
|
);
|
|
940
|
-
const m = e.target ??
|
|
1136
|
+
const m = e.target ?? Ot(u), R = await fn(e.xslDir ?? Yt(), m), g = pt(d, {
|
|
941
1137
|
cssTheme: e.cssTheme,
|
|
942
1138
|
revealTheme: e.revealTheme,
|
|
943
1139
|
target: m
|
|
944
1140
|
});
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
external:
|
|
948
|
-
generated:
|
|
949
|
-
} : void 0,
|
|
950
|
-
let
|
|
951
|
-
if (
|
|
952
|
-
if (e.fragment)
|
|
953
|
-
const c = e.docinfo ?? (e.docinfoSourcePath ? await Mt(e.docinfoSourcePath, r) : void 0);
|
|
954
|
-
h = Lt(
|
|
955
|
-
h,
|
|
956
|
-
T,
|
|
957
|
-
m,
|
|
958
|
-
c
|
|
959
|
-
), W = { parentId: c?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
960
|
-
} 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)
|
|
961
1149
|
throw new Error(
|
|
962
|
-
`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.`
|
|
963
1151
|
);
|
|
964
|
-
|
|
965
|
-
|
|
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("/")}`,
|
|
966
1172
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
967
|
-
}),
|
|
968
|
-
publisher:
|
|
1173
|
+
}), S = {
|
|
1174
|
+
publisher: k(f)
|
|
969
1175
|
};
|
|
970
|
-
for (const [c,
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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)));
|
|
1179
|
+
for (const [c, b] of Object.entries(e.stringParams ?? {}))
|
|
1180
|
+
S[c] = k(b);
|
|
1181
|
+
let O;
|
|
975
1182
|
try {
|
|
976
|
-
|
|
1183
|
+
O = await R.apply(Z, S);
|
|
977
1184
|
} catch (c) {
|
|
978
|
-
throw
|
|
1185
|
+
throw ce(c), new Error(
|
|
979
1186
|
"PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
|
|
980
1187
|
{ cause: c }
|
|
981
1188
|
);
|
|
982
1189
|
} finally {
|
|
983
|
-
|
|
1190
|
+
Z.delete();
|
|
984
1191
|
}
|
|
985
1192
|
try {
|
|
986
|
-
let c =
|
|
987
|
-
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", {
|
|
988
1197
|
zoom: e.revealZoom
|
|
989
|
-
})) : e.theme && (c =
|
|
1198
|
+
})) : e.theme && (c = Ct(c, e.theme)), e.previewBanner && (c = Ve(c, e.previewBanner)), {
|
|
990
1199
|
html: c,
|
|
991
1200
|
target: m,
|
|
992
|
-
...
|
|
993
|
-
...
|
|
1201
|
+
...q ? { sourceMap: q } : {},
|
|
1202
|
+
...G ? { assetDirs: G } : {}
|
|
994
1203
|
};
|
|
995
1204
|
} catch (c) {
|
|
996
|
-
throw
|
|
1205
|
+
throw ce(c), c;
|
|
997
1206
|
} finally {
|
|
998
|
-
|
|
1207
|
+
O.delete();
|
|
999
1208
|
}
|
|
1000
1209
|
} finally {
|
|
1001
|
-
|
|
1210
|
+
at(l);
|
|
1002
1211
|
}
|
|
1003
1212
|
}
|
|
1004
1213
|
export {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
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
|
|
1026
1235
|
};
|