@pretextbook/pretext-html 0.16.1 → 0.18.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 +163 -18
- package/assets/preview-html.xsl +81 -14
- package/assets/preview-revealjs.xsl +7 -2
- package/dist/assets.d.ts +9 -5
- package/dist/banner.d.ts +2 -2
- package/dist/cli-CKAOX3L6.js +1494 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.js +8 -3
- package/dist/index.browser.d.ts +10 -5
- package/dist/index.browser.js +1182 -856
- package/dist/index.d.ts +10 -4
- package/dist/index.js +49 -44
- package/dist/publication.d.ts +75 -21
- package/dist/renderer.d.ts +151 -23
- package/dist/skeleton.d.ts +68 -7
- package/dist/source-cache.d.ts +36 -0
- package/dist/sourcemap.d.ts +11 -1
- package/dist/subtree.d.ts +79 -0
- package/dist/target.d.ts +1 -1
- package/dist/xinclude.d.ts +40 -3
- package/package.json +1 -1
- package/dist/cli-DzlCZymu.js +0 -1145
package/dist/index.browser.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { fromXml as
|
|
2
|
-
import { toXml as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { fromXml as ne } from "xast-util-from-xml";
|
|
2
|
+
import { toXml as te } from "xast-util-to-xml";
|
|
3
|
+
const Ae = "/";
|
|
4
|
+
function Ge(e) {
|
|
5
5
|
if (!e)
|
|
6
6
|
return ".";
|
|
7
|
-
const
|
|
7
|
+
const t = e.startsWith("/"), n = e.length > 1 && e.endsWith("/"), r = [];
|
|
8
8
|
for (const o of e.split("/"))
|
|
9
9
|
if (!(!o || o === ".")) {
|
|
10
10
|
if (o === "..") {
|
|
11
|
-
const
|
|
12
|
-
r.length > 0 &&
|
|
11
|
+
const a = r[r.length - 1];
|
|
12
|
+
r.length > 0 && a !== ".." ? r.pop() : t || r.push("..");
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
15
|
r.push(o);
|
|
16
16
|
}
|
|
17
17
|
let i = r.join("/");
|
|
18
|
-
return
|
|
18
|
+
return t && (i = `/${i}`), i ? (n && !i.endsWith("/") && (i += "/"), i) : t ? "/" : ".";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
let
|
|
20
|
+
function S(...e) {
|
|
21
|
+
let t = "";
|
|
22
22
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
23
23
|
const i = e[r];
|
|
24
|
-
if (i && (
|
|
24
|
+
if (i && (t = t ? `${i}/${t}` : i, i.startsWith("/")))
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return
|
|
27
|
+
t.startsWith("/") || (t = `/${t}`);
|
|
28
|
+
const n = Ge(t);
|
|
29
|
+
return n.length > 1 && n.endsWith("/") ? n.slice(0, -1) : n;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
return
|
|
31
|
+
function It(...e) {
|
|
32
|
+
const t = e.filter(Boolean).join("/");
|
|
33
|
+
return t ? Ge(t) : ".";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
35
|
+
function K(e) {
|
|
36
|
+
const t = e.replace(/\/+$/, "");
|
|
37
|
+
if (!t)
|
|
38
38
|
return e.startsWith("/") ? "/" : ".";
|
|
39
|
-
const
|
|
40
|
-
return
|
|
39
|
+
const n = t.lastIndexOf("/");
|
|
40
|
+
return n < 0 ? "." : n === 0 ? "/" : t.slice(0, n);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
42
|
+
function ye(e, t) {
|
|
43
|
+
const n = S(e).split("/").filter(Boolean), r = S(t).split("/").filter(Boolean);
|
|
44
44
|
let i = 0;
|
|
45
|
-
for (; i <
|
|
45
|
+
for (; i < n.length && i < r.length && n[i] === r[i]; )
|
|
46
46
|
i += 1;
|
|
47
|
-
return [...new Array(
|
|
47
|
+
return [...new Array(n.length - i).fill(".."), ...r.slice(i)].join("/");
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
function
|
|
49
|
+
const At = "ptxPreviewBannerDismissed", Lt = "About live preview";
|
|
50
|
+
function Oe(e) {
|
|
51
51
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function _t(e) {
|
|
54
54
|
return [
|
|
55
55
|
'<div id="ptx-preview-banner" class="ptx-preview-banner" role="note">',
|
|
56
|
-
` <span class="ptx-preview-banner-text">${
|
|
56
|
+
` <span class="ptx-preview-banner-text">${Oe(e)}</span>`,
|
|
57
57
|
' <button type="button" class="ptx-preview-banner-dismiss" aria-label="Dismiss">×</button>',
|
|
58
58
|
"</div>",
|
|
59
|
-
`<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${
|
|
59
|
+
`<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${Oe(Lt)}</button>`
|
|
60
60
|
].join(`
|
|
61
61
|
`);
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function $t() {
|
|
64
64
|
return [
|
|
65
65
|
"<style>",
|
|
66
66
|
".ptx-preview-banner {",
|
|
@@ -129,11 +129,11 @@ function dt() {
|
|
|
129
129
|
].join(`
|
|
130
130
|
`);
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function kt() {
|
|
133
133
|
return [
|
|
134
134
|
"<script>",
|
|
135
135
|
"(function () {",
|
|
136
|
-
" var KEY = " + JSON.stringify(
|
|
136
|
+
" var KEY = " + JSON.stringify(At) + ";",
|
|
137
137
|
' var banner = document.getElementById("ptx-preview-banner");',
|
|
138
138
|
' var restore = document.getElementById("ptx-preview-banner-restore");',
|
|
139
139
|
" if (!banner || !restore) { return; }",
|
|
@@ -170,67 +170,67 @@ function ft() {
|
|
|
170
170
|
].join(`
|
|
171
171
|
`);
|
|
172
172
|
}
|
|
173
|
-
const
|
|
174
|
-
function
|
|
175
|
-
const
|
|
173
|
+
const Nt = "<!--ptx-preview-banner-->", Rt = "<!--/ptx-preview-banner-->", Pt = /\n?<!--ptx-preview-banner-->[\s\S]*?<!--\/ptx-preview-banner-->/;
|
|
174
|
+
function Ct(e, t) {
|
|
175
|
+
const n = Pt.exec(e), r = n ? e.slice(0, n.index) + e.slice(n.index + n[0].length) : e;
|
|
176
176
|
if (!/<body[^>]*>/i.test(r))
|
|
177
177
|
return r;
|
|
178
178
|
const i = `
|
|
179
|
-
${
|
|
180
|
-
${
|
|
181
|
-
${
|
|
182
|
-
${
|
|
183
|
-
${
|
|
179
|
+
${Nt}
|
|
180
|
+
${$t()}
|
|
181
|
+
${_t(t.message)}
|
|
182
|
+
${kt()}
|
|
183
|
+
${Rt}`;
|
|
184
184
|
return r.replace(/<body([^>]*)>/i, `<body$1>${i}`);
|
|
185
185
|
}
|
|
186
|
-
const
|
|
187
|
-
let
|
|
188
|
-
function
|
|
189
|
-
|
|
186
|
+
const Dt = "https://cdn.jsdelivr.net/npm/@pretextbook/pretext-html@0.18.0/assets";
|
|
187
|
+
let Je;
|
|
188
|
+
function $r(e) {
|
|
189
|
+
Je = e.replace(/\/+$/, "");
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
191
|
+
function fe() {
|
|
192
|
+
return Je ?? Dt;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
return `${e.replace(/\/+$/, "")}/${
|
|
194
|
+
function Ke(e, t) {
|
|
195
|
+
return `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`;
|
|
196
196
|
}
|
|
197
|
-
const
|
|
198
|
-
function
|
|
197
|
+
const Me = /* @__PURE__ */ new Map();
|
|
198
|
+
function Ot(e) {
|
|
199
199
|
return `${e.replace(/\/+$/, "")}-bundle.json`;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
let
|
|
203
|
-
return
|
|
201
|
+
function Mt(e) {
|
|
202
|
+
let t = Me.get(e);
|
|
203
|
+
return t || (t = (async () => {
|
|
204
204
|
try {
|
|
205
|
-
const
|
|
206
|
-
if (!
|
|
205
|
+
const n = await fetch(Ot(e));
|
|
206
|
+
if (!n.ok)
|
|
207
207
|
return /* @__PURE__ */ new Map();
|
|
208
|
-
const r = await
|
|
208
|
+
const r = await n.json();
|
|
209
209
|
return new Map(Object.entries(r));
|
|
210
210
|
} catch {
|
|
211
211
|
return /* @__PURE__ */ new Map();
|
|
212
212
|
}
|
|
213
|
-
})(),
|
|
213
|
+
})(), Me.set(e, t)), t;
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
return e ===
|
|
215
|
+
function Bt(e) {
|
|
216
|
+
return e === Ke(fe(), "xsl");
|
|
217
217
|
}
|
|
218
|
-
async function
|
|
219
|
-
if (
|
|
220
|
-
const o = (await
|
|
218
|
+
async function Ye(e, t) {
|
|
219
|
+
if (Bt(e)) {
|
|
220
|
+
const o = (await Mt(e)).get(t.replace(/^\/+/, ""));
|
|
221
221
|
if (o !== void 0)
|
|
222
222
|
return new TextEncoder().encode(o);
|
|
223
223
|
}
|
|
224
|
-
const
|
|
224
|
+
const n = `${e.replace(/\/+$/, "")}/`;
|
|
225
225
|
let r;
|
|
226
226
|
try {
|
|
227
|
-
r = new URL(
|
|
227
|
+
r = new URL(t.replace(/^\/+/, ""), n);
|
|
228
228
|
} catch {
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
-
if (!r.href.startsWith(
|
|
231
|
+
if (!r.href.startsWith(n)) {
|
|
232
232
|
console.error(
|
|
233
|
-
`pretext-html: refusing to serve ${
|
|
233
|
+
`pretext-html: refusing to serve ${t} from outside ${e}`
|
|
234
234
|
);
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
@@ -241,115 +241,115 @@ async function Be(e, n) {
|
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
async function
|
|
244
|
+
async function jt(e) {
|
|
245
245
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e))
|
|
246
246
|
try {
|
|
247
|
-
const
|
|
248
|
-
return
|
|
247
|
+
const t = await fetch(e);
|
|
248
|
+
return t.ok ? await t.text() : void 0;
|
|
249
249
|
} catch {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
const
|
|
253
|
+
const qe = "2.55.0", Ut = "8.3.3", Ft = [
|
|
254
254
|
"prefix-runtime.dd07797f77620576.bundle.js",
|
|
255
255
|
"prefix-926.5c7038c8ef173faf.bundle.js",
|
|
256
256
|
"prefix-runestone.11d27cdc38930c2c.bundle.js"
|
|
257
|
-
],
|
|
257
|
+
], Wt = [
|
|
258
258
|
"prefix-926.229729d09512acc9.css",
|
|
259
259
|
"prefix-runestone.347e2ecdeacfed99.css"
|
|
260
|
-
],
|
|
261
|
-
function
|
|
262
|
-
const
|
|
263
|
-
return
|
|
260
|
+
], Ht = "born-hidden-knowl", Vt = /<details\b([^>]*)>(\s*)(?:<summary\b([^>]*)>)?/g;
|
|
261
|
+
function Xt(e) {
|
|
262
|
+
const t = /\bclass="([^"]*)"/.exec(e);
|
|
263
|
+
return t ? t[1].trim().split(/\s+/) : [];
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function zt(e) {
|
|
266
266
|
return /(^|\s)open(\s|=|$)/.test(e);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
return
|
|
268
|
+
function Be(e) {
|
|
269
|
+
return zt(e) ? e : ` open${e}`;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function Gt(e) {
|
|
272
272
|
return e.replace(
|
|
273
|
-
|
|
274
|
-
(
|
|
275
|
-
if (!
|
|
276
|
-
return
|
|
277
|
-
const o = `<details${
|
|
278
|
-
return i === void 0 ? `${o}${r}` : `${o}${r}<summary${
|
|
273
|
+
Vt,
|
|
274
|
+
(t, n, r, i) => {
|
|
275
|
+
if (!Xt(n).includes(Ht))
|
|
276
|
+
return t;
|
|
277
|
+
const o = `<details${Be(n)}>`;
|
|
278
|
+
return i === void 0 ? `${o}${r}` : `${o}${r}<summary${Be(i)}>`;
|
|
279
279
|
}
|
|
280
280
|
);
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
let
|
|
284
|
-
function
|
|
285
|
-
|
|
282
|
+
const ke = /* @__PURE__ */ new Map(), Ze = /* @__PURE__ */ new Map();
|
|
283
|
+
let Le, Jt = 0, Qe = Ye;
|
|
284
|
+
function kr(e) {
|
|
285
|
+
Qe = e;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
const
|
|
287
|
+
function Kt(e, t) {
|
|
288
|
+
const n = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, r = Ze.get(n);
|
|
289
289
|
if (r !== void 0)
|
|
290
290
|
return Promise.resolve(new Response(r, { status: 200 }));
|
|
291
291
|
let i;
|
|
292
292
|
try {
|
|
293
|
-
i = new URL(
|
|
293
|
+
i = new URL(n).host;
|
|
294
294
|
} catch {
|
|
295
295
|
i = "";
|
|
296
296
|
}
|
|
297
|
-
const o =
|
|
298
|
-
return o !== void 0 ?
|
|
297
|
+
const o = ke.get(i);
|
|
298
|
+
return o !== void 0 ? qt(o, n) : Le(e, t);
|
|
299
299
|
}
|
|
300
|
-
const
|
|
301
|
-
async function
|
|
302
|
-
const
|
|
300
|
+
const Yt = '<?xml version="1.0"?><pretext-preview-missing-file/>';
|
|
301
|
+
async function qt(e, t) {
|
|
302
|
+
const n = decodeURIComponent(new URL(t).pathname), r = await Qe(e, n);
|
|
303
303
|
if (r === void 0)
|
|
304
|
-
return new Response(
|
|
304
|
+
return new Response(Yt, { status: 200 });
|
|
305
305
|
const i = typeof r == "string" ? r : new Uint8Array(r);
|
|
306
306
|
return new Response(i, { status: 200 });
|
|
307
307
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
308
|
+
function et() {
|
|
309
|
+
Le || (Le = globalThis.fetch, globalThis.fetch = Kt);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
return
|
|
311
|
+
function tt(e) {
|
|
312
|
+
et();
|
|
313
|
+
const t = `mnt${++Jt}.ptx.invalid`;
|
|
314
|
+
return ke.set(t, e), `http://${t}`;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
316
|
+
function Zt(e) {
|
|
317
|
+
ke.delete(new URL(e).host);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
320
|
-
|
|
319
|
+
function Qt(e, t) {
|
|
320
|
+
et(), Ze.set(e, t);
|
|
321
321
|
}
|
|
322
|
-
const
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
return
|
|
322
|
+
const en = /<a\b[^>]*\bdata-printout="[^"]*"[^>]*>/gi;
|
|
323
|
+
function le(e, t) {
|
|
324
|
+
const n = new RegExp(`\\b${t}="([^"]*)"`, "i").exec(e);
|
|
325
|
+
return n ? tn(n[1]) : void 0;
|
|
326
326
|
}
|
|
327
|
-
function
|
|
327
|
+
function tn(e) {
|
|
328
328
|
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'|'/g, "'").replace(/'/gi, "'").replace(/&/g, "&");
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
const r = [e,
|
|
332
|
-
return r &&
|
|
330
|
+
function nn(e, t, n) {
|
|
331
|
+
const r = [e, t].filter(Boolean).join(" ");
|
|
332
|
+
return r && n ? `${r}: ${n}` : r || n;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
const
|
|
336
|
-
for (const [r] of e.matchAll(
|
|
337
|
-
const i =
|
|
338
|
-
if (!i ||
|
|
334
|
+
function nt(e) {
|
|
335
|
+
const t = [], n = /* @__PURE__ */ new Set();
|
|
336
|
+
for (const [r] of e.matchAll(en)) {
|
|
337
|
+
const i = le(r, "data-printout");
|
|
338
|
+
if (!i || n.has(i))
|
|
339
339
|
continue;
|
|
340
|
-
|
|
341
|
-
const o =
|
|
342
|
-
|
|
340
|
+
n.add(i);
|
|
341
|
+
const o = le(r, "data-printout-type") ?? "", a = le(r, "data-printout-number") ?? "", l = le(r, "data-printout-title") ?? "";
|
|
342
|
+
t.push({
|
|
343
343
|
id: i,
|
|
344
344
|
type: o,
|
|
345
|
-
number:
|
|
346
|
-
title:
|
|
347
|
-
label:
|
|
345
|
+
number: a,
|
|
346
|
+
title: l,
|
|
347
|
+
label: nn(o, a, l)
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
|
-
return
|
|
350
|
+
return t;
|
|
351
351
|
}
|
|
352
|
-
const
|
|
352
|
+
const rn = /* @__PURE__ */ new Set([
|
|
353
353
|
"worksheet",
|
|
354
354
|
"handout",
|
|
355
355
|
"project",
|
|
@@ -357,18 +357,18 @@ const Bt = /* @__PURE__ */ new Set([
|
|
|
357
357
|
"exploration",
|
|
358
358
|
"investigation"
|
|
359
359
|
]);
|
|
360
|
-
function
|
|
361
|
-
if (!(!
|
|
360
|
+
function on(e, t) {
|
|
361
|
+
if (!(!t || !rn.has(t)))
|
|
362
362
|
return e[0]?.id;
|
|
363
363
|
}
|
|
364
|
-
const
|
|
365
|
-
function
|
|
366
|
-
const
|
|
364
|
+
const sn = "__ptxPrintPreview";
|
|
365
|
+
function an(e) {
|
|
366
|
+
const t = JSON.stringify(e ?? null);
|
|
367
367
|
return [
|
|
368
368
|
"<script>",
|
|
369
369
|
"(function () {",
|
|
370
|
-
" var KEY = " + JSON.stringify(
|
|
371
|
-
" window[KEY] = " +
|
|
370
|
+
" var KEY = " + JSON.stringify(sn) + ";",
|
|
371
|
+
" window[KEY] = " + t + ";",
|
|
372
372
|
// Pin the page to light mode for the print layout; see printPreviewCss.
|
|
373
373
|
// `data-darkmode="disabled"` is upstream's own switch — pretext-core.js
|
|
374
374
|
// checks it in both isDarkMode and setDarkMode, the only two places that
|
|
@@ -402,7 +402,7 @@ function Ft(e) {
|
|
|
402
402
|
].join(`
|
|
403
403
|
`);
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function cn() {
|
|
406
406
|
return [
|
|
407
407
|
"<style>",
|
|
408
408
|
":root {",
|
|
@@ -422,19 +422,19 @@ function Wt() {
|
|
|
422
422
|
].join(`
|
|
423
423
|
`);
|
|
424
424
|
}
|
|
425
|
-
const
|
|
426
|
-
function
|
|
427
|
-
const
|
|
425
|
+
const ln = "<!--ptx-print-preview-->", un = "<!--/ptx-print-preview-->", fn = /\n?<!--ptx-print-preview-->[\s\S]*?<!--\/ptx-print-preview-->/;
|
|
426
|
+
function dn(e, t) {
|
|
427
|
+
const n = fn.exec(e), r = n ? e.slice(0, n.index) + e.slice(n.index + n[0].length) : e, i = /<head[^>]*>/i.exec(r);
|
|
428
428
|
if (!i)
|
|
429
429
|
return r;
|
|
430
|
-
const o =
|
|
431
|
-
${
|
|
432
|
-
${
|
|
433
|
-
${o ? `${
|
|
434
|
-
` : ""}${
|
|
435
|
-
return r.slice(0,
|
|
436
|
-
}
|
|
437
|
-
const
|
|
430
|
+
const o = t && nt(r).some((d) => d.id === t) ? t : void 0, a = `
|
|
431
|
+
${ln}
|
|
432
|
+
${an(o)}
|
|
433
|
+
${o ? `${cn()}
|
|
434
|
+
` : ""}${un}`, l = i.index + i[0].length;
|
|
435
|
+
return r.slice(0, l) + a + r.slice(l);
|
|
436
|
+
}
|
|
437
|
+
const Ne = `<?xml version="1.0" encoding="UTF-8"?>
|
|
438
438
|
<publication>
|
|
439
439
|
<source>
|
|
440
440
|
<directories external="../assets" generated="../generated-assets" />
|
|
@@ -442,86 +442,120 @@ const we = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
442
442
|
<common>
|
|
443
443
|
<tableofcontents level="0"/>
|
|
444
444
|
</common>
|
|
445
|
-
<html>
|
|
446
|
-
<platform portable="yes"/>
|
|
447
|
-
</html>
|
|
448
445
|
</publication>
|
|
449
|
-
`,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
function
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
446
|
+
`, hn = [
|
|
447
|
+
[["html", "resources"], "host", "cdn"],
|
|
448
|
+
[["html", "platform"], "portable", "no"],
|
|
449
|
+
[["html", "cross-references"], "knowled", "never"],
|
|
450
|
+
[["common", "chunking"], "level", "0"]
|
|
451
|
+
], pn = ["theme", "style", "shell"];
|
|
452
|
+
function O(e, t) {
|
|
453
|
+
for (const n of e.children)
|
|
454
|
+
if (n.type === "element" && n.name === t)
|
|
455
|
+
return n;
|
|
456
|
+
}
|
|
457
|
+
function ee(e, t) {
|
|
458
|
+
let n = O(e, t);
|
|
459
|
+
return n || (n = { type: "element", name: t, attributes: {}, children: [] }, e.children.push(n)), n;
|
|
460
|
+
}
|
|
461
|
+
function mn(e, t) {
|
|
462
|
+
const n = O(e, "css");
|
|
463
|
+
if (n && pn.some((i) => n.attributes?.[i]))
|
|
462
464
|
return;
|
|
463
|
-
const r =
|
|
464
|
-
r.attributes = { ...r.attributes, theme:
|
|
465
|
+
const r = n ?? ee(e, "css");
|
|
466
|
+
r.attributes = { ...r.attributes, theme: t };
|
|
465
467
|
}
|
|
466
|
-
function
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
468
|
+
function vn(e, t) {
|
|
469
|
+
const n = O(e, "appearance");
|
|
470
|
+
if (n?.attributes?.theme)
|
|
469
471
|
return;
|
|
470
|
-
const r =
|
|
471
|
-
r.attributes = { ...r.attributes, theme:
|
|
472
|
+
const r = n ?? ee(e, "appearance");
|
|
473
|
+
r.attributes = { ...r.attributes, theme: t };
|
|
472
474
|
}
|
|
473
|
-
function
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
...
|
|
475
|
+
function wn(e) {
|
|
476
|
+
const t = ee(e, "resources");
|
|
477
|
+
t.attributes = {
|
|
478
|
+
...t.attributes,
|
|
477
479
|
host: "cdn",
|
|
478
480
|
math: "online"
|
|
479
481
|
};
|
|
480
482
|
}
|
|
481
|
-
function
|
|
482
|
-
const
|
|
483
|
-
if (!
|
|
484
|
-
return we;
|
|
485
|
-
const o = X(e ?? we), l = W(o, "publication");
|
|
486
|
-
if (!l)
|
|
483
|
+
function rt(e, t = {}) {
|
|
484
|
+
const n = t.cssTheme?.trim(), r = t.revealTheme?.trim(), i = t.target === "slides", o = ne(e ?? Ne), a = O(o, "publication");
|
|
485
|
+
if (!a)
|
|
487
486
|
throw new Error(
|
|
488
487
|
"Invalid publication file: no root <publication> element found"
|
|
489
488
|
);
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
489
|
+
for (const [d, p, m] of hn) {
|
|
490
|
+
const h = d.reduce(
|
|
491
|
+
(T, x) => ee(T, x),
|
|
492
|
+
a
|
|
493
|
+
);
|
|
494
|
+
h.attributes = { ...h.attributes, [p]: m };
|
|
494
495
|
}
|
|
495
|
-
|
|
496
|
+
const l = ee(a, "html");
|
|
497
|
+
if (n && mn(l, n), i) {
|
|
498
|
+
const d = ee(a, "revealjs");
|
|
499
|
+
wn(d), r && vn(d, r);
|
|
500
|
+
}
|
|
501
|
+
return te(o);
|
|
496
502
|
}
|
|
497
|
-
|
|
503
|
+
const Nr = rt, bn = "generated/";
|
|
504
|
+
function Ee(e) {
|
|
498
505
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
499
506
|
return e.endsWith("/") ? e : `${e}/`;
|
|
500
507
|
}
|
|
501
|
-
function
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
508
|
+
function je(e) {
|
|
509
|
+
const t = e?.attributes?.level;
|
|
510
|
+
if (t == null || t === "") return;
|
|
511
|
+
const n = Number(t);
|
|
512
|
+
return Number.isFinite(n) && n >= 0 ? n : void 0;
|
|
513
|
+
}
|
|
514
|
+
function gn(e) {
|
|
515
|
+
const t = ne(e ?? Ne), n = O(t, "publication"), r = n && O(n, "common"), i = r && O(r, "tableofcontents"), o = n && O(n, "numbering");
|
|
516
|
+
let a, l;
|
|
517
|
+
for (const d of o?.children ?? []) {
|
|
518
|
+
if (d.type !== "element") continue;
|
|
519
|
+
const p = je(d);
|
|
520
|
+
p !== void 0 && (d.name === "divisions" ? l = p : a = Math.max(a ?? 0, p));
|
|
521
|
+
}
|
|
507
522
|
return {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
523
|
+
tocLevel: je(i),
|
|
524
|
+
numberingLevel: a,
|
|
525
|
+
maxNumberingLevel: l
|
|
511
526
|
};
|
|
512
527
|
}
|
|
513
|
-
function
|
|
528
|
+
function yn(e, t) {
|
|
529
|
+
const n = ne(e ?? Ne), r = O(n, "publication"), i = r && O(r, "source"), o = i && O(i, "directories"), a = (p) => {
|
|
530
|
+
const m = o?.attributes?.[p];
|
|
531
|
+
return m == null ? void 0 : String(m);
|
|
532
|
+
}, l = Ee(t !== void 0 ? t : a("external")), d = Ee(a("generated")) ?? bn;
|
|
533
|
+
return l === void 0 ? { generated: d } : { external: l, generated: d };
|
|
534
|
+
}
|
|
535
|
+
function ue(e) {
|
|
536
|
+
if (typeof e == "string")
|
|
537
|
+
try {
|
|
538
|
+
return ue(ne(e));
|
|
539
|
+
} catch {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
const t = e.children.find(
|
|
543
|
+
(o) => o.type === "element"
|
|
544
|
+
), n = t?.name === "docinfo" ? t : t && O(t, "docinfo"), i = (n && O(n, "directories"))?.attributes?.external;
|
|
545
|
+
return i == null ? void 0 : String(i);
|
|
546
|
+
}
|
|
547
|
+
function Rr(e) {
|
|
514
548
|
return e === "slides" || e === "scroll";
|
|
515
549
|
}
|
|
516
|
-
const
|
|
517
|
-
function
|
|
518
|
-
const
|
|
550
|
+
const it = 960, ot = 700, En = 1, xn = 0.04;
|
|
551
|
+
function Sn(e) {
|
|
552
|
+
const t = typeof e == "number" && isFinite(e) ? e : En, n = Math.min(1, Math.max(0.25, t));
|
|
519
553
|
return {
|
|
520
|
-
width: Math.round(
|
|
521
|
-
height: Math.round(
|
|
554
|
+
width: Math.round(it / n),
|
|
555
|
+
height: Math.round(ot / n)
|
|
522
556
|
};
|
|
523
557
|
}
|
|
524
|
-
function
|
|
558
|
+
function Tn(e) {
|
|
525
559
|
return {
|
|
526
560
|
view: "scroll",
|
|
527
561
|
scrollLayout: "compact",
|
|
@@ -531,11 +565,11 @@ function nn(e) {
|
|
|
531
565
|
controls: !1,
|
|
532
566
|
controlsTutorial: !1,
|
|
533
567
|
hash: !1,
|
|
534
|
-
...
|
|
535
|
-
margin:
|
|
568
|
+
...Sn(e.zoom),
|
|
569
|
+
margin: xn
|
|
536
570
|
};
|
|
537
571
|
}
|
|
538
|
-
function
|
|
572
|
+
function In() {
|
|
539
573
|
return {
|
|
540
574
|
// Explicitly null rather than absent: the same page may have been
|
|
541
575
|
// delivered in scroll view a moment ago, and an embedder that re-injects
|
|
@@ -547,11 +581,11 @@ function rn() {
|
|
|
547
581
|
// size with a percentage width renders its text far larger, relative to
|
|
548
582
|
// the slide, than the same deck will on a projector. No zoom margin
|
|
549
583
|
// though — presenting means filling whatever it is shown in.
|
|
550
|
-
width:
|
|
551
|
-
height:
|
|
584
|
+
width: it,
|
|
585
|
+
height: ot
|
|
552
586
|
};
|
|
553
587
|
}
|
|
554
|
-
const
|
|
588
|
+
const An = [
|
|
555
589
|
"<style>",
|
|
556
590
|
".reveal-viewport.reveal-scroll .scroll-page section {",
|
|
557
591
|
" box-shadow: inset 0 0 0 calc(1px / var(--slide-scale, 1))",
|
|
@@ -559,18 +593,18 @@ const on = [
|
|
|
559
593
|
"}",
|
|
560
594
|
"</style>"
|
|
561
595
|
].join(`
|
|
562
|
-
`),
|
|
596
|
+
`), Ln = [
|
|
563
597
|
" var paused = document.querySelectorAll('.reveal .fragment');",
|
|
564
598
|
" for (var i = 0; i < paused.length; i++) {",
|
|
565
599
|
" paused[i].classList.remove('fragment');",
|
|
566
600
|
" }"
|
|
567
601
|
];
|
|
568
|
-
function
|
|
569
|
-
const
|
|
602
|
+
function _n(e, t = {}) {
|
|
603
|
+
const n = e === "scroll" ? Tn(t) : In();
|
|
570
604
|
return [
|
|
571
605
|
"<script>",
|
|
572
606
|
"(function () {",
|
|
573
|
-
" var OVERRIDES = " + JSON.stringify(
|
|
607
|
+
" var OVERRIDES = " + JSON.stringify(n) + ";",
|
|
574
608
|
// Nothing to wrap if reveal.js failed to load (offline, CDN blocked). The
|
|
575
609
|
// deck is broken either way, but throwing here would replace the browser's
|
|
576
610
|
// useful network error with a confusing one from an injected script.
|
|
@@ -594,7 +628,7 @@ function an(e, n = {}) {
|
|
|
594
628
|
// Inside the wrapper rather than at top level: this script sits in <head>,
|
|
595
629
|
// where the slides have not been parsed yet, but the deck calls initialize
|
|
596
630
|
// from the end of the document, by which time they have.
|
|
597
|
-
...e === "scroll" ?
|
|
631
|
+
...e === "scroll" ? Ln : [],
|
|
598
632
|
" return initialize(merged);",
|
|
599
633
|
" };",
|
|
600
634
|
"})();",
|
|
@@ -602,71 +636,82 @@ function an(e, n = {}) {
|
|
|
602
636
|
].join(`
|
|
603
637
|
`);
|
|
604
638
|
}
|
|
605
|
-
const
|
|
606
|
-
function
|
|
607
|
-
const r =
|
|
639
|
+
const $n = /<script\b[^>]*\bsrc=["'][^"']*\breveal\.js["'][^>]*>\s*<\/script>/i, kn = "<!--ptx-reveal-view-->", Nn = "<!--/ptx-reveal-view-->", Rn = /\n?<!--ptx-reveal-view-->[\s\S]*?<!--\/ptx-reveal-view-->/;
|
|
640
|
+
function Pn(e, t, n = {}) {
|
|
641
|
+
const r = Rn.exec(e), i = r ? e.slice(0, r.index) + e.slice(r.index + r[0].length) : e, o = $n.exec(i);
|
|
608
642
|
if (!o)
|
|
609
643
|
return i;
|
|
610
|
-
const
|
|
611
|
-
${
|
|
612
|
-
${
|
|
613
|
-
${
|
|
614
|
-
${
|
|
615
|
-
return i.slice(0,
|
|
616
|
-
}
|
|
617
|
-
const
|
|
618
|
-
async function
|
|
619
|
-
return e
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
r,
|
|
627
|
-
|
|
644
|
+
const a = o.index + o[0].length, l = `
|
|
645
|
+
${kn}
|
|
646
|
+
${An}
|
|
647
|
+
${_n(t, n)}
|
|
648
|
+
${Nn}`;
|
|
649
|
+
return i.slice(0, a) + l + i.slice(a);
|
|
650
|
+
}
|
|
651
|
+
const st = "http://www.w3.org/2001/XInclude", Ue = 64;
|
|
652
|
+
async function we(e, t) {
|
|
653
|
+
return (e?.readSource ? await e.readSource(t) : void 0) ?? await jt(t);
|
|
654
|
+
}
|
|
655
|
+
function Re(e, t, n) {
|
|
656
|
+
return e.cache ? e.cache.parse(t, n) : ne(n);
|
|
657
|
+
}
|
|
658
|
+
async function Pe(e, t, n, r = {}) {
|
|
659
|
+
const i = S(t), o = Re(r, i, e), a = {
|
|
660
|
+
...r,
|
|
661
|
+
projectDir: S(n),
|
|
662
|
+
stack: [i],
|
|
663
|
+
files: [i],
|
|
664
|
+
bytes: e.length
|
|
665
|
+
}, l = await oe(
|
|
666
|
+
o,
|
|
667
|
+
K(i),
|
|
628
668
|
{ "": "" },
|
|
629
|
-
|
|
669
|
+
a
|
|
630
670
|
);
|
|
631
|
-
return {
|
|
671
|
+
return {
|
|
672
|
+
tree: o,
|
|
673
|
+
content: l ? te(o) : e,
|
|
674
|
+
files: a.files,
|
|
675
|
+
bytes: a.bytes
|
|
676
|
+
};
|
|
632
677
|
}
|
|
633
|
-
function
|
|
678
|
+
function at(e) {
|
|
634
679
|
return e.data?.ptxIncludedFile;
|
|
635
680
|
}
|
|
636
|
-
function
|
|
637
|
-
const
|
|
638
|
-
|
|
681
|
+
function ct(e, t) {
|
|
682
|
+
const n = e.data ?? (e.data = {});
|
|
683
|
+
n.ptxIncludedFile = t;
|
|
639
684
|
}
|
|
640
|
-
function
|
|
641
|
-
let
|
|
642
|
-
for (const [r, i] of Object.entries(
|
|
643
|
-
(r === "xmlns" || r.startsWith("xmlns:")) && (
|
|
644
|
-
return
|
|
685
|
+
function de(e, t) {
|
|
686
|
+
let n = e;
|
|
687
|
+
for (const [r, i] of Object.entries(t.attributes))
|
|
688
|
+
(r === "xmlns" || r.startsWith("xmlns:")) && (n === e && (n = { ...e }), n[r === "xmlns" ? "" : r.slice(6)] = i ?? "");
|
|
689
|
+
return n;
|
|
645
690
|
}
|
|
646
|
-
function
|
|
647
|
-
const
|
|
648
|
-
return (
|
|
691
|
+
function lt(e, t) {
|
|
692
|
+
const n = e.name.indexOf(":"), r = n === -1 ? "" : e.name.slice(0, n);
|
|
693
|
+
return (n === -1 ? e.name : e.name.slice(n + 1)) === "include" && t[r] === st;
|
|
649
694
|
}
|
|
650
|
-
async function
|
|
695
|
+
async function oe(e, t, n, r) {
|
|
651
696
|
let i = !1;
|
|
652
697
|
for (let o = 0; o < e.children.length; o++) {
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
698
|
+
const a = e.children[o];
|
|
699
|
+
if (a.type !== "element")
|
|
655
700
|
continue;
|
|
656
|
-
const
|
|
657
|
-
if (
|
|
658
|
-
const
|
|
701
|
+
const l = de(n, a);
|
|
702
|
+
if (lt(a, l)) {
|
|
703
|
+
const d = await ut(
|
|
704
|
+
a,
|
|
705
|
+
t,
|
|
659
706
|
l,
|
|
660
|
-
n,
|
|
661
|
-
u,
|
|
662
707
|
r
|
|
663
708
|
);
|
|
664
|
-
e.children.splice(o, 1, ...
|
|
665
|
-
} else await
|
|
709
|
+
e.children.splice(o, 1, ...d), o += d.length - 1, i = !0;
|
|
710
|
+
} else await oe(a, t, l, r) && (i = !0);
|
|
666
711
|
}
|
|
667
712
|
return i;
|
|
668
713
|
}
|
|
669
|
-
async function
|
|
714
|
+
async function ut(e, t, n, r) {
|
|
670
715
|
const i = r.stack[r.stack.length - 1];
|
|
671
716
|
if (e.attributes.xpointer)
|
|
672
717
|
throw new Error(
|
|
@@ -675,83 +720,86 @@ async function Ke(e, n, t, r) {
|
|
|
675
720
|
const o = e.attributes.href;
|
|
676
721
|
if (!o)
|
|
677
722
|
throw new Error(`xi:include without href (in ${i})`);
|
|
678
|
-
let
|
|
723
|
+
let a = o;
|
|
679
724
|
try {
|
|
680
|
-
|
|
725
|
+
a = decodeURIComponent(o);
|
|
681
726
|
} catch {
|
|
682
727
|
}
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
728
|
+
const l = S(t, a);
|
|
729
|
+
if (l !== r.projectDir && !l.startsWith(r.projectDir + Ae))
|
|
685
730
|
throw new Error(
|
|
686
731
|
`xi:include escapes the project directory: ${o} (in ${i})`
|
|
687
732
|
);
|
|
688
|
-
if (r.stack.includes(
|
|
733
|
+
if (r.stack.includes(l))
|
|
689
734
|
throw new Error(
|
|
690
|
-
`Circular xi:include: ${[...r.stack,
|
|
735
|
+
`Circular xi:include: ${[...r.stack, l].join(" -> ")}`
|
|
691
736
|
);
|
|
692
|
-
if (r.stack.length >=
|
|
693
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
696
|
-
const
|
|
697
|
-
if (
|
|
698
|
-
return await
|
|
737
|
+
if (r.stack.length >= Ue)
|
|
738
|
+
throw new Error(`xi:include nesting exceeds ${Ue} levels`);
|
|
739
|
+
const d = await we(r, l);
|
|
740
|
+
if (d === void 0) {
|
|
741
|
+
const h = Dn(e, n);
|
|
742
|
+
if (h)
|
|
743
|
+
return await oe(h, t, n, r), h.children;
|
|
699
744
|
throw new Error(`xi:include target not found: ${o} (in ${i})`);
|
|
700
745
|
}
|
|
701
|
-
if (e.attributes.parse === "text")
|
|
702
|
-
return [{ type: "text", value:
|
|
703
|
-
let
|
|
746
|
+
if (r.files.includes(l) || r.files.push(l), r.bytes += d.length, e.attributes.parse === "text")
|
|
747
|
+
return [{ type: "text", value: d }];
|
|
748
|
+
let p;
|
|
704
749
|
try {
|
|
705
|
-
|
|
706
|
-
} catch (
|
|
750
|
+
p = Re(r, l, d);
|
|
751
|
+
} catch (h) {
|
|
707
752
|
throw new Error(
|
|
708
|
-
`Could not parse xi:include target ${
|
|
753
|
+
`Could not parse xi:include target ${l} as XML: ${h instanceof Error ? h.message : h}. (Included files must be well-formed, with a single root element.)`
|
|
709
754
|
);
|
|
710
755
|
}
|
|
711
|
-
r.stack.push(
|
|
756
|
+
r.stack.push(l);
|
|
712
757
|
try {
|
|
713
|
-
await
|
|
758
|
+
await oe(p, K(l), { "": "" }, r);
|
|
714
759
|
} finally {
|
|
715
760
|
r.stack.pop();
|
|
716
761
|
}
|
|
717
|
-
const
|
|
718
|
-
(
|
|
762
|
+
const m = p.children.filter(
|
|
763
|
+
(h) => h.type === "element"
|
|
719
764
|
);
|
|
720
|
-
for (const
|
|
721
|
-
|
|
722
|
-
return
|
|
765
|
+
for (const h of m)
|
|
766
|
+
ct(h, l);
|
|
767
|
+
return m;
|
|
723
768
|
}
|
|
724
|
-
function
|
|
769
|
+
function Fe(e) {
|
|
725
770
|
return e.name === "docinfo";
|
|
726
771
|
}
|
|
727
|
-
async function
|
|
772
|
+
async function Cn(e, t, n, r = {}) {
|
|
728
773
|
try {
|
|
729
|
-
const i =
|
|
730
|
-
(
|
|
774
|
+
const i = S(t), a = Re(r, i, e).children.find(
|
|
775
|
+
(m) => m.type === "element"
|
|
731
776
|
);
|
|
732
|
-
if (!
|
|
777
|
+
if (!a)
|
|
733
778
|
return;
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
779
|
+
const l = K(i), d = {
|
|
780
|
+
...r,
|
|
781
|
+
projectDir: S(n),
|
|
782
|
+
stack: [i],
|
|
783
|
+
files: [i],
|
|
784
|
+
bytes: e.length
|
|
785
|
+
}, p = de({ "": "" }, a);
|
|
786
|
+
for (const m of a.children) {
|
|
787
|
+
if (m.type !== "element")
|
|
740
788
|
continue;
|
|
741
|
-
const
|
|
742
|
-
if (
|
|
743
|
-
return await
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
|
|
789
|
+
const h = de(p, m);
|
|
790
|
+
if (Fe(m))
|
|
791
|
+
return await oe(m, l, h, d), te(m);
|
|
792
|
+
if (lt(m, h)) {
|
|
793
|
+
const x = (await ut(
|
|
794
|
+
m,
|
|
747
795
|
l,
|
|
748
|
-
|
|
749
|
-
|
|
796
|
+
h,
|
|
797
|
+
d
|
|
750
798
|
)).find(
|
|
751
|
-
(
|
|
799
|
+
(_) => _.type === "element" && Fe(_)
|
|
752
800
|
);
|
|
753
|
-
if (
|
|
754
|
-
return
|
|
801
|
+
if (x)
|
|
802
|
+
return te(x);
|
|
755
803
|
continue;
|
|
756
804
|
}
|
|
757
805
|
break;
|
|
@@ -761,78 +809,94 @@ async function wn(e, n, t) {
|
|
|
761
809
|
return;
|
|
762
810
|
}
|
|
763
811
|
}
|
|
764
|
-
function
|
|
765
|
-
for (const
|
|
766
|
-
if (
|
|
812
|
+
function Dn(e, t) {
|
|
813
|
+
for (const n of e.children) {
|
|
814
|
+
if (n.type !== "element")
|
|
767
815
|
continue;
|
|
768
|
-
const r =
|
|
769
|
-
if ((i === -1 ?
|
|
770
|
-
return
|
|
816
|
+
const r = de(t, n), i = n.name.indexOf(":"), o = i === -1 ? "" : n.name.slice(0, i);
|
|
817
|
+
if ((i === -1 ? n.name : n.name.slice(i + 1)) === "fallback" && r[o] === st)
|
|
818
|
+
return n;
|
|
771
819
|
}
|
|
772
820
|
}
|
|
773
|
-
function
|
|
821
|
+
function ft(e) {
|
|
774
822
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
775
823
|
}
|
|
776
|
-
function
|
|
824
|
+
function On(e) {
|
|
777
825
|
return /^(pf|xhtml):/.test(e.name);
|
|
778
826
|
}
|
|
779
|
-
function
|
|
780
|
-
const r = []
|
|
827
|
+
function Mn(e, t, n) {
|
|
828
|
+
const r = [];
|
|
829
|
+
return dt(e, t, n, (i, o, a, l) => {
|
|
830
|
+
r.push({
|
|
831
|
+
id: o,
|
|
832
|
+
file: a,
|
|
833
|
+
line: i.position?.start.line ?? 1,
|
|
834
|
+
column: i.position?.start.column ?? 1,
|
|
835
|
+
endLine: i.position?.end.line ?? i.position?.start.line ?? 1,
|
|
836
|
+
parent: l
|
|
837
|
+
});
|
|
838
|
+
}), r;
|
|
839
|
+
}
|
|
840
|
+
function Bn(e, t, n) {
|
|
841
|
+
let r;
|
|
842
|
+
return dt(e, "", n, (i, o) => {
|
|
843
|
+
if (i === t)
|
|
844
|
+
return r = o, !1;
|
|
845
|
+
}), r;
|
|
846
|
+
}
|
|
847
|
+
function dt(e, t, n, r) {
|
|
848
|
+
const i = e.children.find(ft);
|
|
781
849
|
if (i) {
|
|
782
|
-
const o =
|
|
783
|
-
|
|
850
|
+
const o = n?.parentId ?? "root";
|
|
851
|
+
ht(i, o, n?.position ?? 1, t, o, r);
|
|
784
852
|
}
|
|
785
|
-
return r;
|
|
786
853
|
}
|
|
787
|
-
function
|
|
788
|
-
const
|
|
789
|
-
let
|
|
790
|
-
if (
|
|
791
|
-
|
|
854
|
+
function ht(e, t, n, r, i, o) {
|
|
855
|
+
const a = at(e) ?? r;
|
|
856
|
+
let l, d;
|
|
857
|
+
if (On(e))
|
|
858
|
+
d = "root";
|
|
792
859
|
else {
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
line: e.position?.start.line ?? 1,
|
|
798
|
-
column: e.position?.start.column ?? 1,
|
|
799
|
-
endLine: e.position?.end.line ?? e.position?.start.line ?? 1,
|
|
800
|
-
parent: i
|
|
801
|
-
}), m = u;
|
|
860
|
+
const m = e.attributes.label ?? e.attributes["xml:id"];
|
|
861
|
+
if (l = m ?? `${t}-${n}`, o(e, l, a, i) === !1)
|
|
862
|
+
return !1;
|
|
863
|
+
d = l;
|
|
802
864
|
}
|
|
803
|
-
let
|
|
804
|
-
for (const
|
|
805
|
-
|
|
806
|
-
v,
|
|
865
|
+
let p = 0;
|
|
866
|
+
for (const m of e.children)
|
|
867
|
+
if (ft(m) && (p += 1, !ht(
|
|
807
868
|
m,
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
869
|
+
d,
|
|
870
|
+
p,
|
|
871
|
+
a,
|
|
872
|
+
l ?? i,
|
|
811
873
|
o
|
|
812
|
-
))
|
|
874
|
+
)))
|
|
875
|
+
return !1;
|
|
876
|
+
return !0;
|
|
813
877
|
}
|
|
814
|
-
function
|
|
815
|
-
let
|
|
878
|
+
function Pr(e, t) {
|
|
879
|
+
let n;
|
|
816
880
|
for (const r of e)
|
|
817
|
-
r.line <=
|
|
818
|
-
return
|
|
881
|
+
r.line <= t && (n = r);
|
|
882
|
+
return n ?? e[0];
|
|
819
883
|
}
|
|
820
|
-
function
|
|
821
|
-
const
|
|
822
|
-
return /<\s*slide(?:show)?[\s/>]/.test(
|
|
884
|
+
function jn(e) {
|
|
885
|
+
const t = e.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, " ");
|
|
886
|
+
return /<\s*slide(?:show)?[\s/>]/.test(t) ? "slides" : "html";
|
|
823
887
|
}
|
|
824
|
-
const
|
|
825
|
-
function
|
|
888
|
+
const pt = "pretext-html:set-theme";
|
|
889
|
+
function Cr(e) {
|
|
826
890
|
return e === "dark" || e === "light" || e === "system";
|
|
827
891
|
}
|
|
828
|
-
function
|
|
829
|
-
return { type:
|
|
892
|
+
function Dr(e) {
|
|
893
|
+
return { type: pt, theme: e };
|
|
830
894
|
}
|
|
831
|
-
function
|
|
895
|
+
function Un(e) {
|
|
832
896
|
return [
|
|
833
897
|
"<script>",
|
|
834
898
|
"(function () {",
|
|
835
|
-
" var CFG = " + JSON.stringify({ msg:
|
|
899
|
+
" var CFG = " + JSON.stringify({ msg: pt, initial: e }) + ";",
|
|
836
900
|
// Where the last requested theme is remembered so it survives an in-place
|
|
837
901
|
// document rewrite (same Window) and outranks the baked initial value.
|
|
838
902
|
" var KEY = '__ptxPreviewTheme';",
|
|
@@ -902,12 +966,12 @@ function yn(e) {
|
|
|
902
966
|
].join(`
|
|
903
967
|
`);
|
|
904
968
|
}
|
|
905
|
-
function
|
|
906
|
-
const
|
|
969
|
+
function Fn(e, t) {
|
|
970
|
+
const n = Un(t);
|
|
907
971
|
return /<head[^>]*>/i.test(e) ? e.replace(/<head([^>]*)>/i, `<head$1>
|
|
908
|
-
${
|
|
972
|
+
${n}`) : e;
|
|
909
973
|
}
|
|
910
|
-
const
|
|
974
|
+
const mt = /* @__PURE__ */ new Set([
|
|
911
975
|
"colophon",
|
|
912
976
|
"biography",
|
|
913
977
|
"dedication",
|
|
@@ -927,216 +991,446 @@ const Qe = /* @__PURE__ */ new Set([
|
|
|
927
991
|
"glossary",
|
|
928
992
|
"worksheet",
|
|
929
993
|
"handout"
|
|
930
|
-
]),
|
|
994
|
+
]), vt = /* @__PURE__ */ new Set([
|
|
931
995
|
"book",
|
|
932
996
|
"article",
|
|
933
997
|
"slideshow",
|
|
934
998
|
"letter",
|
|
935
999
|
"memo"
|
|
936
|
-
]),
|
|
937
|
-
...
|
|
938
|
-
...
|
|
1000
|
+
]), z = /* @__PURE__ */ new Set([
|
|
1001
|
+
...vt,
|
|
1002
|
+
...mt,
|
|
939
1003
|
"part",
|
|
1004
|
+
"foreword",
|
|
940
1005
|
"frontmatter",
|
|
941
1006
|
"backmatter"
|
|
942
|
-
])
|
|
1007
|
+
]);
|
|
1008
|
+
function be(e) {
|
|
1009
|
+
return z.has(e.name);
|
|
1010
|
+
}
|
|
1011
|
+
const Wn = /* @__PURE__ */ new Set(["docinfo"]), wt = /* @__PURE__ */ new Set([
|
|
943
1012
|
"title",
|
|
944
1013
|
"shorttitle",
|
|
945
1014
|
"plaintitle",
|
|
946
1015
|
"subtitle",
|
|
947
1016
|
"caption"
|
|
948
1017
|
]);
|
|
949
|
-
function
|
|
1018
|
+
function R(e) {
|
|
950
1019
|
return e.type === "element";
|
|
951
1020
|
}
|
|
952
|
-
function
|
|
1021
|
+
function bt(e) {
|
|
953
1022
|
return e.attributes["xml:id"] ?? void 0;
|
|
954
1023
|
}
|
|
955
|
-
function
|
|
956
|
-
for (const
|
|
957
|
-
if (!
|
|
958
|
-
if (
|
|
959
|
-
const r =
|
|
1024
|
+
function he(e, t) {
|
|
1025
|
+
for (const n of e.children) {
|
|
1026
|
+
if (!R(n)) continue;
|
|
1027
|
+
if (bt(n) === t) return n;
|
|
1028
|
+
const r = he(n, t);
|
|
960
1029
|
if (r) return r;
|
|
961
1030
|
}
|
|
962
1031
|
}
|
|
963
|
-
function
|
|
964
|
-
for (const
|
|
965
|
-
if (!
|
|
966
|
-
if (
|
|
967
|
-
const r =
|
|
968
|
-
if (r) return [
|
|
1032
|
+
function X(e, t) {
|
|
1033
|
+
for (const n of e.children) {
|
|
1034
|
+
if (!R(n)) continue;
|
|
1035
|
+
if (n === t) return [n];
|
|
1036
|
+
const r = X(n, t);
|
|
1037
|
+
if (r) return [n, ...r];
|
|
969
1038
|
}
|
|
970
1039
|
}
|
|
971
|
-
function
|
|
972
|
-
|
|
1040
|
+
function gt(e, t, n, r) {
|
|
1041
|
+
return vt.has(n) ? 0 : n === "frontmatter" || n === "backmatter" || n === "part" ? t === "book" && r ? 1 : 0 : mt.has(n) ? e + 1 : e;
|
|
1042
|
+
}
|
|
1043
|
+
function pe(e, t) {
|
|
1044
|
+
let n = 0;
|
|
973
1045
|
for (const [r, i] of e.entries()) {
|
|
974
1046
|
const o = r === 0 ? void 0 : e[r - 1];
|
|
975
|
-
|
|
1047
|
+
n = gt(n, o?.name, i.name, t);
|
|
976
1048
|
}
|
|
977
|
-
return
|
|
1049
|
+
return n;
|
|
1050
|
+
}
|
|
1051
|
+
function Ce(e) {
|
|
1052
|
+
return e?.name === "book" && e.children.some(
|
|
1053
|
+
(t) => R(t) && t.name === "part"
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
function Q(e, t) {
|
|
1057
|
+
return e.children.some(
|
|
1058
|
+
(n) => R(n) && t.includes(n.name)
|
|
1059
|
+
);
|
|
978
1060
|
}
|
|
979
|
-
function
|
|
980
|
-
if (!
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1061
|
+
function Hn(e) {
|
|
1062
|
+
if (!e) return 0;
|
|
1063
|
+
const t = e.name;
|
|
1064
|
+
if (t === "book") {
|
|
1065
|
+
const n = Ce(e), r = n ? e.children.some(
|
|
1066
|
+
(o) => R(o) && o.name === "part" && Q(o, ["chapter"])
|
|
1067
|
+
) : Q(e, ["chapter"]), i = (n ? e.children.flatMap(
|
|
1068
|
+
(o) => R(o) && o.name === "part" ? o.children : []
|
|
1069
|
+
) : e.children).some(
|
|
1070
|
+
(o) => R(o) && o.name === "chapter" && Q(o, ["section"])
|
|
1071
|
+
);
|
|
1072
|
+
return n && i ? 3 : n && r || i ? 2 : r ? 1 : 0;
|
|
1073
|
+
}
|
|
1074
|
+
if (t === "article") {
|
|
1075
|
+
const n = e.children.filter(
|
|
1076
|
+
(r) => R(r) && r.name === "section"
|
|
1077
|
+
);
|
|
1078
|
+
if (n.some((r) => Q(r, ["subsection"])))
|
|
1079
|
+
return 2;
|
|
1080
|
+
if (n.length > 0 || Q(e, ["worksheet", "handout"]))
|
|
1081
|
+
return 1;
|
|
984
1082
|
}
|
|
1083
|
+
return 0;
|
|
1084
|
+
}
|
|
1085
|
+
function Vn(e) {
|
|
1086
|
+
return e ? e.name === "book" ? Ce(e) ? 3 : 2 : e.name === "article" && Q(e, ["section", "worksheet", "handout"]) ? 1 : 0 : 0;
|
|
985
1087
|
}
|
|
986
|
-
function
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1088
|
+
function De(e) {
|
|
1089
|
+
if (!wt.has(e.name)) {
|
|
1090
|
+
e.children = e.children.filter(R);
|
|
1091
|
+
for (const t of e.children)
|
|
1092
|
+
De(t);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function Xn(e) {
|
|
1096
|
+
for (const t of e.children)
|
|
1097
|
+
R(t) && !z.has(t.name) && De(t);
|
|
1098
|
+
}
|
|
1099
|
+
function zn(e, t = !1) {
|
|
1100
|
+
const n = /* @__PURE__ */ new Set(), r = (i) => {
|
|
1101
|
+
if (!(t && i !== e && z.has(i.name))) {
|
|
1102
|
+
if (i.name === "xref") {
|
|
1103
|
+
const o = [
|
|
1104
|
+
i.attributes.ref,
|
|
1105
|
+
i.attributes.first,
|
|
1106
|
+
i.attributes.last
|
|
1107
|
+
];
|
|
1108
|
+
for (const a of o)
|
|
1109
|
+
for (const l of a?.split(/[\s,]+/) ?? [])
|
|
1110
|
+
l && n.add(l);
|
|
1111
|
+
}
|
|
1112
|
+
for (const o of i.children)
|
|
1113
|
+
R(o) && r(o);
|
|
1003
1114
|
}
|
|
1004
|
-
for (const i of r.children)
|
|
1005
|
-
O(i) && t(i);
|
|
1006
1115
|
};
|
|
1007
|
-
return
|
|
1116
|
+
return r(e), n;
|
|
1008
1117
|
}
|
|
1009
|
-
function
|
|
1118
|
+
function Gn(e, t, n) {
|
|
1010
1119
|
const r = (i) => {
|
|
1011
|
-
for (const [o,
|
|
1012
|
-
if (
|
|
1013
|
-
if (
|
|
1014
|
-
return i.children[o] =
|
|
1015
|
-
if (r(
|
|
1120
|
+
for (const [o, a] of i.children.entries())
|
|
1121
|
+
if (R(a)) {
|
|
1122
|
+
if (bt(a) === t)
|
|
1123
|
+
return i.children[o] = n, !0;
|
|
1124
|
+
if (r(a)) return !0;
|
|
1016
1125
|
}
|
|
1017
1126
|
return !1;
|
|
1018
1127
|
};
|
|
1019
1128
|
return r(e);
|
|
1020
1129
|
}
|
|
1021
|
-
function
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
|
|
1130
|
+
function yt(e, t, n) {
|
|
1131
|
+
const r = n.contentKept.has(e), i = n.chain.has(e), o = [];
|
|
1132
|
+
for (const a of e.children) {
|
|
1133
|
+
if (!R(a)) {
|
|
1134
|
+
r && o.push(a);
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1137
|
+
if (n.verbatim.has(a) || Wn.has(a.name) || wt.has(a.name))
|
|
1138
|
+
o.push(a);
|
|
1139
|
+
else if (z.has(a.name)) {
|
|
1140
|
+
const l = gt(
|
|
1141
|
+
t,
|
|
1142
|
+
e.name,
|
|
1143
|
+
a.name,
|
|
1144
|
+
n.hasParts
|
|
1145
|
+
);
|
|
1146
|
+
(n.chain.has(a) || i || l <= n.tocLevel) && (yt(a, l, n), o.push(a));
|
|
1147
|
+
} else r && o.push(a);
|
|
1148
|
+
}
|
|
1149
|
+
e.children = o;
|
|
1150
|
+
}
|
|
1151
|
+
function Jn(e, t, n = {}) {
|
|
1152
|
+
const r = he(e, t);
|
|
1025
1153
|
if (!r) return;
|
|
1026
|
-
const i = r
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
(
|
|
1030
|
-
),
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1154
|
+
const i = X(e, r);
|
|
1155
|
+
if (!i) return;
|
|
1156
|
+
const o = (n.collapseChildren ?? !1) && r.children.some(
|
|
1157
|
+
(g) => R(g) && z.has(g.name)
|
|
1158
|
+
), a = (g) => g.name === "pretext" || g.name === "mathbook", l = i.filter((g) => !a(g)), d = l[0], p = Ce(d), m = pe(l, p), h = (g) => {
|
|
1159
|
+
const N = X(e, g)?.filter((E) => !a(E)) ?? [];
|
|
1160
|
+
return pe(N, p);
|
|
1161
|
+
}, T = n.maxNumberingLevel ?? 1 / 0, x = Math.min(
|
|
1162
|
+
n.numberingLevel ?? Vn(d),
|
|
1163
|
+
T
|
|
1164
|
+
), _ = n.tocLevel ?? Hn(d), I = {
|
|
1165
|
+
verbatim: /* @__PURE__ */ new Set(),
|
|
1166
|
+
chain: new Set(i),
|
|
1167
|
+
contentKept: /* @__PURE__ */ new Set(),
|
|
1168
|
+
tocLevel: _,
|
|
1169
|
+
hasParts: p
|
|
1170
|
+
}, F = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
|
|
1171
|
+
o ? I.contentKept.add(r) : I.verbatim.add(r);
|
|
1172
|
+
const Y = (g) => {
|
|
1173
|
+
const N = X(e, g);
|
|
1174
|
+
if (!N) return;
|
|
1175
|
+
const E = N.filter(($) => z.has($.name)), j = E[E.length - 1];
|
|
1176
|
+
if (!j || j === r) return;
|
|
1177
|
+
if (i.includes(j)) {
|
|
1178
|
+
I.contentKept.add(j), M.add(j);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
let C = j;
|
|
1182
|
+
for (let $ = E.length - 1; $ >= 0 && !(h(E[$]) <= x || i.includes(E[$ - 1])); $--)
|
|
1183
|
+
C = E[$ - 1] ?? C;
|
|
1184
|
+
if (!I.verbatim.has(C)) {
|
|
1185
|
+
I.verbatim.add(C), F.add(C);
|
|
1186
|
+
for (const $ of X(e, C) ?? []) I.chain.add($);
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
for (const g of zn(r, o)) {
|
|
1190
|
+
const N = he(e, g);
|
|
1191
|
+
N && N !== r && Y(N);
|
|
1192
|
+
}
|
|
1193
|
+
for (const g of [...I.chain]) {
|
|
1194
|
+
if (!z.has(g.name) || h(g) <= x)
|
|
1195
|
+
continue;
|
|
1196
|
+
const N = X(e, g)?.at(-2);
|
|
1197
|
+
if (N)
|
|
1198
|
+
for (const E of N.children) {
|
|
1199
|
+
if (E === g) break;
|
|
1200
|
+
!R(E) || !z.has(E.name) || I.verbatim.has(E) || I.chain.has(E) || (I.verbatim.add(E), F.add(E));
|
|
1042
1201
|
}
|
|
1202
|
+
}
|
|
1203
|
+
const B = e.children.find(R);
|
|
1204
|
+
B && yt(B, 0, I);
|
|
1205
|
+
for (const g of F)
|
|
1206
|
+
De(g);
|
|
1207
|
+
for (const g of M)
|
|
1208
|
+
Xn(g);
|
|
1209
|
+
return { content: te(e), divisionId: t, level: m, collapsed: o };
|
|
1210
|
+
}
|
|
1211
|
+
class Kn {
|
|
1212
|
+
entries = /* @__PURE__ */ new Map();
|
|
1213
|
+
maxEntries;
|
|
1214
|
+
/** Cumulative hit/miss counts, for diagnostics and tests. */
|
|
1215
|
+
hits = 0;
|
|
1216
|
+
misses = 0;
|
|
1217
|
+
constructor(t = {}) {
|
|
1218
|
+
this.maxEntries = Math.max(1, t.maxEntries ?? 1024);
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* The parse of `content`, as a fresh tree the caller may mutate freely.
|
|
1222
|
+
* `key` names the file — a path — so that a changed file replaces its own
|
|
1223
|
+
* entry instead of accumulating one per version.
|
|
1224
|
+
*
|
|
1225
|
+
* Throws what `fromXml` throws for malformed content; nothing is cached
|
|
1226
|
+
* then.
|
|
1227
|
+
*/
|
|
1228
|
+
parse(t, n) {
|
|
1229
|
+
const r = this.entries.get(t);
|
|
1230
|
+
if (r && r.content === n)
|
|
1231
|
+
return this.hits += 1, this.entries.delete(t), this.entries.set(t, r), _e(r.tree);
|
|
1232
|
+
this.misses += 1;
|
|
1233
|
+
const i = ne(n);
|
|
1234
|
+
for (this.entries.delete(t), this.entries.set(t, { content: n, tree: i }); this.entries.size > this.maxEntries; ) {
|
|
1235
|
+
const o = this.entries.keys().next().value;
|
|
1236
|
+
if (o === void 0) break;
|
|
1237
|
+
this.entries.delete(o);
|
|
1043
1238
|
}
|
|
1044
|
-
|
|
1045
|
-
if (b === t) break;
|
|
1046
|
-
ve(b, m);
|
|
1239
|
+
return _e(i);
|
|
1047
1240
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1241
|
+
/** Number of files currently held. */
|
|
1242
|
+
get size() {
|
|
1243
|
+
return this.entries.size;
|
|
1244
|
+
}
|
|
1245
|
+
/** Drop one file (when the host knows it is gone), or everything. */
|
|
1246
|
+
invalidate(t) {
|
|
1247
|
+
t === void 0 ? this.entries.clear() : this.entries.delete(t);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function _e(e) {
|
|
1251
|
+
const t = { ...e };
|
|
1252
|
+
return t.attributes && (t.attributes = { ...t.attributes }), t.children && (t.children = t.children.map((n) => _e(n))), t.data && (t.data = { ...t.data }), t;
|
|
1253
|
+
}
|
|
1254
|
+
function me(e) {
|
|
1255
|
+
return typeof e == "object" && e !== null && e.type === "element";
|
|
1256
|
+
}
|
|
1257
|
+
function Yn(e) {
|
|
1258
|
+
for (let t = e.length - 1; t >= 0; t--)
|
|
1259
|
+
if (be(e[t])) return e[t];
|
|
1260
|
+
}
|
|
1261
|
+
function qn(e, t, n) {
|
|
1262
|
+
const r = [], i = (a, l, d) => {
|
|
1263
|
+
const p = at(a) ?? l, m = [...d, a];
|
|
1264
|
+
p === n && be(a) && r.push({ element: a, chain: m });
|
|
1265
|
+
for (const h of a.children)
|
|
1266
|
+
me(h) && i(h, p, m);
|
|
1267
|
+
}, o = e.children.find(me);
|
|
1268
|
+
return o && i(o, t, []), r;
|
|
1269
|
+
}
|
|
1270
|
+
function Zn(e, t, n, r) {
|
|
1271
|
+
const i = qn(e, t, n);
|
|
1272
|
+
let o, a, l;
|
|
1273
|
+
for (const { element: d } of i) {
|
|
1274
|
+
const p = d.position?.start.line, m = d.position?.end.line ?? p;
|
|
1275
|
+
p === void 0 || m === void 0 || (p <= r && r <= m ? o = d : p > r ? a ??= d : l = d);
|
|
1276
|
+
}
|
|
1277
|
+
return o ?? a ?? l;
|
|
1059
1278
|
}
|
|
1060
|
-
function
|
|
1279
|
+
function Qn(e, t, n) {
|
|
1280
|
+
let r;
|
|
1281
|
+
if (t.id !== void 0) {
|
|
1282
|
+
const h = he(e, t.id), T = h && X(e, h);
|
|
1283
|
+
r = T && Yn(T);
|
|
1284
|
+
} else if (t.line !== void 0) {
|
|
1285
|
+
const h = S(n), T = S(t.file ?? n);
|
|
1286
|
+
r = Zn(e, h, T, t.line);
|
|
1287
|
+
}
|
|
1288
|
+
if (!r) return;
|
|
1289
|
+
const i = t.level ?? 1 / 0;
|
|
1290
|
+
let o = !1;
|
|
1291
|
+
const l = (X(e, r) ?? [r]).filter(
|
|
1292
|
+
(h) => h.name !== "pretext" && h.name !== "mathbook"
|
|
1293
|
+
), d = l[0], p = d?.name === "book" && d.children.some(
|
|
1294
|
+
(h) => me(h) && h.name === "part"
|
|
1295
|
+
), m = pe(l, p);
|
|
1296
|
+
if (m > i)
|
|
1297
|
+
for (let h = 0; h < l.length; h++) {
|
|
1298
|
+
const T = l[h];
|
|
1299
|
+
if (be(T) && pe(l.slice(0, h + 1), p) >= i) {
|
|
1300
|
+
r = T;
|
|
1301
|
+
break;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
else m < i && (o = !0);
|
|
1305
|
+
return { element: r, id: Et(e, r), collapse: o };
|
|
1306
|
+
}
|
|
1307
|
+
function Et(e, t) {
|
|
1308
|
+
const n = t.attributes["xml:id"];
|
|
1309
|
+
if (n) return n;
|
|
1310
|
+
const r = Bn(e, t) ?? "root-1";
|
|
1311
|
+
return t.attributes["xml:id"] = r, r;
|
|
1312
|
+
}
|
|
1313
|
+
function ve(e) {
|
|
1314
|
+
let t = 0;
|
|
1315
|
+
for (const n of e.children)
|
|
1316
|
+
me(n) && (t += 1 + ve(n));
|
|
1317
|
+
return t;
|
|
1318
|
+
}
|
|
1319
|
+
const er = "This live preview shows a single division, so links into the rest of the document do not work here.", tr = /<a\b([^>]*)>/g, nr = /\sid="([^"]*)"/g, xe = /\shref="([^"]*)"/, rr = /\\href\{([^{}]*)\}/g, We = /\stitle="([^"]*)"/;
|
|
1320
|
+
function ir(e) {
|
|
1321
|
+
const t = /* @__PURE__ */ new Set();
|
|
1322
|
+
for (const n of e.matchAll(nr))
|
|
1323
|
+
t.add(n[1]);
|
|
1324
|
+
return t;
|
|
1325
|
+
}
|
|
1326
|
+
function Se(e) {
|
|
1061
1327
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
1062
1328
|
}
|
|
1063
|
-
function
|
|
1329
|
+
function He(e, t) {
|
|
1064
1330
|
if (e.startsWith("#") || e === "") return { kind: "keep" };
|
|
1065
1331
|
if (/^[a-z][a-z0-9+.-]*:/i.test(e) || e.startsWith("//"))
|
|
1066
1332
|
return { kind: "keep" };
|
|
1067
|
-
const
|
|
1068
|
-
if (
|
|
1069
|
-
const
|
|
1070
|
-
return
|
|
1071
|
-
}
|
|
1072
|
-
function
|
|
1073
|
-
const
|
|
1074
|
-
return e.replace(
|
|
1075
|
-
const
|
|
1076
|
-
if (!
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
if (
|
|
1080
|
-
return `<a${
|
|
1081
|
-
const
|
|
1082
|
-
return `<a${
|
|
1083
|
-
}).replace(
|
|
1084
|
-
const
|
|
1085
|
-
return
|
|
1333
|
+
const n = e.indexOf("#"), i = (n === -1 ? e : e.slice(0, n)).replace(/\.html?$/i, "");
|
|
1334
|
+
if (n === -1) return { kind: "off-page", division: i };
|
|
1335
|
+
const o = e.slice(n + 1);
|
|
1336
|
+
return t.has(o) && o !== "" ? { kind: "same-page", id: o } : { kind: "off-page", division: i, ...o ? { id: o } : {} };
|
|
1337
|
+
}
|
|
1338
|
+
function or(e, t = {}) {
|
|
1339
|
+
const n = t.offPageMessage ?? er, r = ir(e);
|
|
1340
|
+
return e.replace(tr, (o, a) => {
|
|
1341
|
+
const l = xe.exec(a);
|
|
1342
|
+
if (!l) return o;
|
|
1343
|
+
const d = He(l[1], r);
|
|
1344
|
+
if (d.kind === "keep") return o;
|
|
1345
|
+
if (d.kind === "same-page")
|
|
1346
|
+
return `<a${a.replace(xe, ` href="#${d.id}"`)}>`;
|
|
1347
|
+
const p = We.exec(a), m = Se(n), h = p ? `${p[1]} — ${m}` : m, x = a.replace(xe, "").replace(We, ""), _ = ` data-ptx-division="${Se(d.division)}"` + (d.id ? ` data-ptx-id="${Se(d.id)}"` : "");
|
|
1348
|
+
return `<a${x} title="${h}" aria-disabled="true" style="cursor:default"${_}>`;
|
|
1349
|
+
}).replace(rr, (o, a) => {
|
|
1350
|
+
const l = He(a, r);
|
|
1351
|
+
return l.kind === "same-page" ? `\\href{#${l.id}}` : o;
|
|
1086
1352
|
});
|
|
1087
1353
|
}
|
|
1088
|
-
function
|
|
1089
|
-
return
|
|
1354
|
+
function sr() {
|
|
1355
|
+
return Ke(fe(), "xsl");
|
|
1090
1356
|
}
|
|
1091
|
-
function
|
|
1357
|
+
function ar() {
|
|
1092
1358
|
return "Suspending" in WebAssembly;
|
|
1093
1359
|
}
|
|
1094
|
-
function
|
|
1095
|
-
if (!
|
|
1360
|
+
function cr() {
|
|
1361
|
+
if (!ar())
|
|
1096
1362
|
throw new Error(
|
|
1097
1363
|
"WebAssembly JSPI is not enabled. Run Node with --experimental-wasm-jspi (or use the pretext-html CLI, which re-launches itself with the flag)."
|
|
1098
1364
|
);
|
|
1099
1365
|
}
|
|
1100
|
-
function
|
|
1101
|
-
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((
|
|
1366
|
+
function ie(e) {
|
|
1367
|
+
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((n) => `'${n}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
|
|
1102
1368
|
}
|
|
1103
|
-
function
|
|
1369
|
+
function lr(e) {
|
|
1104
1370
|
return e.replace(
|
|
1105
1371
|
/from '\.\/(https:\/\/[^']+)'/g,
|
|
1106
|
-
(
|
|
1372
|
+
(t, n) => `from '${n}'`
|
|
1107
1373
|
);
|
|
1108
1374
|
}
|
|
1109
|
-
const
|
|
1110
|
-
"cli.version":
|
|
1375
|
+
const ur = `https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@${qe}/dist/`, fr = {
|
|
1376
|
+
"cli.version": qe,
|
|
1111
1377
|
// Colon-delimited: pretext-runestone.xsl splits them with str:tokenize.
|
|
1112
|
-
"rs-js":
|
|
1113
|
-
"rs-css":
|
|
1114
|
-
"rs-version":
|
|
1378
|
+
"rs-js": Ft.join(":"),
|
|
1379
|
+
"rs-css": Wt.join(":"),
|
|
1380
|
+
"rs-version": Ut
|
|
1115
1381
|
};
|
|
1116
|
-
function
|
|
1382
|
+
function dr(e) {
|
|
1117
1383
|
return e.replace(
|
|
1118
1384
|
/(<link\b[^>]*\bhref=["'])_static\//gi,
|
|
1119
|
-
`$1${
|
|
1385
|
+
`$1${ur}_static/`
|
|
1120
1386
|
);
|
|
1121
1387
|
}
|
|
1122
|
-
function
|
|
1388
|
+
function hr(e) {
|
|
1123
1389
|
return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
|
|
1124
1390
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1391
|
+
let pr;
|
|
1392
|
+
function mr() {
|
|
1393
|
+
return pr ??= new Kn();
|
|
1394
|
+
}
|
|
1395
|
+
function xt(e) {
|
|
1396
|
+
const t = e.files ? new Map(
|
|
1397
|
+
Object.entries(e.files).map(([o, a]) => [
|
|
1398
|
+
S(o),
|
|
1399
|
+
a
|
|
1400
|
+
])
|
|
1401
|
+
) : void 0, n = e.readSource, r = t || n ? async (o) => t?.get(o) ?? await n?.(o) : void 0, i = e.cache === !1 ? void 0 : e.cache ?? mr();
|
|
1402
|
+
return { readSource: r, cache: i };
|
|
1403
|
+
}
|
|
1404
|
+
async function $e(e, t) {
|
|
1405
|
+
const n = await we(e, t);
|
|
1127
1406
|
if (n === void 0)
|
|
1128
1407
|
throw new Error(
|
|
1129
|
-
`Could not read ${
|
|
1408
|
+
`Could not read ${t}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
|
|
1130
1409
|
);
|
|
1131
1410
|
return n;
|
|
1132
1411
|
}
|
|
1133
|
-
async function
|
|
1134
|
-
const
|
|
1135
|
-
if (
|
|
1136
|
-
return
|
|
1412
|
+
async function vr(e, t, n) {
|
|
1413
|
+
const r = S(e), i = await we(n, r);
|
|
1414
|
+
if (i !== void 0)
|
|
1415
|
+
return Cn(i, r, t, n);
|
|
1416
|
+
}
|
|
1417
|
+
async function Or(e) {
|
|
1418
|
+
const t = xt(e), n = S(e.sourcePath), r = S(
|
|
1419
|
+
e.projectDir ?? K(n)
|
|
1420
|
+
), i = e.sourceContent ?? await $e(t, n), o = await Pe(
|
|
1421
|
+
i,
|
|
1422
|
+
n,
|
|
1423
|
+
r,
|
|
1424
|
+
t
|
|
1425
|
+
);
|
|
1426
|
+
return {
|
|
1427
|
+
bytes: o.bytes,
|
|
1428
|
+
elements: ve(o.tree),
|
|
1429
|
+
files: o.files
|
|
1430
|
+
};
|
|
1137
1431
|
}
|
|
1138
|
-
function
|
|
1139
|
-
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), o =
|
|
1432
|
+
function wr(e, t, n, r) {
|
|
1433
|
+
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), o = n === "slides" ? "slideshow" : t === "chapter" || t === "part" ? "book" : "article";
|
|
1140
1434
|
return `<pretext>
|
|
1141
1435
|
${r?.trim() ? `${r.trim()}
|
|
1142
1436
|
` : ""}<${o}>
|
|
@@ -1146,207 +1440,235 @@ ${i}
|
|
|
1146
1440
|
</pretext>
|
|
1147
1441
|
`;
|
|
1148
1442
|
}
|
|
1149
|
-
async function
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
),
|
|
1153
|
-
if (
|
|
1154
|
-
|
|
1155
|
-
if (u === void 0) return;
|
|
1156
|
-
let m;
|
|
1443
|
+
async function br(e, t, n, r, i, o) {
|
|
1444
|
+
const a = e.attributes["xml:id"];
|
|
1445
|
+
if (!a) return;
|
|
1446
|
+
const l = S(n), d = i ?? await we(o, l);
|
|
1447
|
+
if (d === void 0) return;
|
|
1448
|
+
let p, m, h;
|
|
1157
1449
|
try {
|
|
1158
|
-
m =
|
|
1450
|
+
({ tree: p, files: m, bytes: h } = await Pe(
|
|
1451
|
+
d,
|
|
1452
|
+
l,
|
|
1453
|
+
r,
|
|
1454
|
+
o
|
|
1455
|
+
));
|
|
1159
1456
|
} catch {
|
|
1160
1457
|
return;
|
|
1161
1458
|
}
|
|
1162
|
-
if (
|
|
1163
|
-
|
|
1164
|
-
if (f)
|
|
1165
|
-
return { ...f, tree: m };
|
|
1459
|
+
if (ct(e, t), !!Gn(p, a, e))
|
|
1460
|
+
return m.includes(t) || m.push(t), { tree: p, divisionId: a, files: m, bytes: h };
|
|
1166
1461
|
}
|
|
1167
|
-
let
|
|
1168
|
-
function
|
|
1462
|
+
let St = !1;
|
|
1463
|
+
function gr(e) {
|
|
1169
1464
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
1170
1465
|
}
|
|
1171
|
-
function
|
|
1466
|
+
function yr(e) {
|
|
1172
1467
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
1173
1468
|
}
|
|
1174
|
-
function
|
|
1175
|
-
if (
|
|
1469
|
+
function Er() {
|
|
1470
|
+
if (St)
|
|
1176
1471
|
throw new Error(
|
|
1177
1472
|
"The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
|
|
1178
1473
|
);
|
|
1179
1474
|
}
|
|
1180
|
-
function
|
|
1181
|
-
if (
|
|
1182
|
-
throw
|
|
1475
|
+
function Ve(e) {
|
|
1476
|
+
if (gr(e))
|
|
1477
|
+
throw St = !0, new Error(
|
|
1183
1478
|
"The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
|
|
1184
1479
|
{ cause: e }
|
|
1185
1480
|
);
|
|
1186
|
-
if (
|
|
1481
|
+
if (yr(e))
|
|
1187
1482
|
throw new Error(
|
|
1188
1483
|
"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.",
|
|
1189
1484
|
{ cause: e }
|
|
1190
1485
|
);
|
|
1191
1486
|
}
|
|
1192
|
-
let
|
|
1193
|
-
async function
|
|
1194
|
-
return
|
|
1195
|
-
const [e,
|
|
1487
|
+
let Te;
|
|
1488
|
+
async function Tt() {
|
|
1489
|
+
return Te || (Te = (async () => {
|
|
1490
|
+
const [e, t] = await Promise.all([
|
|
1196
1491
|
import("@pretextbook/libxslt-wasm"),
|
|
1197
1492
|
import("@pretextbook/libxslt-wasm/exslt")
|
|
1198
1493
|
]);
|
|
1199
|
-
return
|
|
1200
|
-
})()),
|
|
1494
|
+
return t.registerAll(), e;
|
|
1495
|
+
})()), Te;
|
|
1201
1496
|
}
|
|
1202
|
-
const
|
|
1497
|
+
const Ie = /* @__PURE__ */ new Map(), xr = {
|
|
1203
1498
|
html: "preview-html.xsl",
|
|
1204
1499
|
slides: "preview-revealjs.xsl"
|
|
1205
1500
|
};
|
|
1206
|
-
async function
|
|
1207
|
-
const
|
|
1208
|
-
let i =
|
|
1501
|
+
async function Sr(e, t) {
|
|
1502
|
+
const n = xr[t], r = `${t}\0${e}`;
|
|
1503
|
+
let i = Ie.get(r);
|
|
1209
1504
|
return i || (i = (async () => {
|
|
1210
|
-
const { XmlDocument: o, XsltStylesheet:
|
|
1211
|
-
if (
|
|
1505
|
+
const { XmlDocument: o, XsltStylesheet: a } = await Tt(), l = tt(e), d = await Ye(fe(), `/${n}`);
|
|
1506
|
+
if (d === void 0)
|
|
1212
1507
|
throw new Error(
|
|
1213
|
-
`Could not read ${
|
|
1508
|
+
`Could not read ${n} from ${fe()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
|
|
1214
1509
|
);
|
|
1215
|
-
const
|
|
1216
|
-
url: `${
|
|
1510
|
+
const p = new TextDecoder().decode(d), m = await o.fromString(p, {
|
|
1511
|
+
url: `${l}/${n}`,
|
|
1217
1512
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
1218
1513
|
});
|
|
1219
|
-
return
|
|
1220
|
-
})(),
|
|
1221
|
-
}
|
|
1222
|
-
let
|
|
1223
|
-
function
|
|
1224
|
-
const
|
|
1225
|
-
() =>
|
|
1226
|
-
() =>
|
|
1514
|
+
return a.fromXmlDocument(m);
|
|
1515
|
+
})(), Ie.set(r, i), i.catch(() => Ie.delete(r))), i;
|
|
1516
|
+
}
|
|
1517
|
+
let Xe = Promise.resolve();
|
|
1518
|
+
function Mr(e) {
|
|
1519
|
+
const t = Xe.then(
|
|
1520
|
+
() => ze(e),
|
|
1521
|
+
() => ze(e)
|
|
1227
1522
|
);
|
|
1228
|
-
return
|
|
1229
|
-
}),
|
|
1230
|
-
}
|
|
1231
|
-
async function
|
|
1232
|
-
|
|
1233
|
-
const { XmlDocument:
|
|
1234
|
-
e.projectDir ??
|
|
1235
|
-
),
|
|
1236
|
-
if (
|
|
1523
|
+
return Xe = t.catch(() => {
|
|
1524
|
+
}), t;
|
|
1525
|
+
}
|
|
1526
|
+
async function ze(e) {
|
|
1527
|
+
cr(), Er();
|
|
1528
|
+
const { XmlDocument: t } = await Tt(), n = xt(e), r = S(e.sourcePath), i = S(
|
|
1529
|
+
e.projectDir ?? K(r)
|
|
1530
|
+
), o = e.sourceContent ?? await $e(n, r), a = ye(i, r);
|
|
1531
|
+
if (a.startsWith(".."))
|
|
1237
1532
|
throw new Error(
|
|
1238
|
-
`sourcePath (${
|
|
1533
|
+
`sourcePath (${r}) must live inside projectDir (${i})`
|
|
1239
1534
|
);
|
|
1240
|
-
const l =
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
),
|
|
1535
|
+
const l = ye(
|
|
1536
|
+
i,
|
|
1537
|
+
S(e.mainSourcePath ?? r)
|
|
1538
|
+
), d = l.startsWith("..") ? a : l, p = tt(i);
|
|
1244
1539
|
try {
|
|
1245
|
-
let
|
|
1540
|
+
let m, h = `${p}/__pretext-preview-publication.xml`;
|
|
1246
1541
|
if (e.publicationPath) {
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1542
|
+
const s = S(e.publicationPath);
|
|
1543
|
+
m = await $e(n, s);
|
|
1544
|
+
const u = ye(i, s);
|
|
1545
|
+
u.startsWith("..") || (h = `${p}/${u.split(Ae).join("/")}`);
|
|
1251
1546
|
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
} else
|
|
1261
|
-
b = await pn(
|
|
1262
|
-
i,
|
|
1263
|
-
t,
|
|
1264
|
-
r
|
|
1265
|
-
);
|
|
1266
|
-
const y = e.target ?? En(b), B = await Yn(e.xslDir ?? Mn(), y), $ = qt(f, {
|
|
1547
|
+
const T = await Pe(
|
|
1548
|
+
o,
|
|
1549
|
+
r,
|
|
1550
|
+
i,
|
|
1551
|
+
n
|
|
1552
|
+
);
|
|
1553
|
+
let x = T.tree, _ = T.content, I = T.files, F = T.bytes;
|
|
1554
|
+
const M = e.target ?? jn(_), Y = await Sr(e.xslDir ?? sr(), M), B = rt(m, {
|
|
1267
1555
|
cssTheme: e.cssTheme,
|
|
1268
1556
|
revealTheme: e.revealTheme,
|
|
1269
|
-
target:
|
|
1557
|
+
target: M
|
|
1270
1558
|
});
|
|
1271
|
-
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1559
|
+
Qt(h, B);
|
|
1560
|
+
const g = hr(_);
|
|
1561
|
+
let N = { parentId: "root", position: 1 }, E, j = r, C, $;
|
|
1562
|
+
const se = (s, u) => {
|
|
1563
|
+
C = { bytes: F, elements: ve(s), files: I };
|
|
1564
|
+
const f = e.subtree ? Qn(s, e.subtree, r) : void 0, b = f?.id ?? u;
|
|
1565
|
+
if (!b) return !1;
|
|
1566
|
+
const w = e.subtree?.wholeDocumentUpTo;
|
|
1567
|
+
if (w !== void 0 && C.elements <= w) return !1;
|
|
1568
|
+
const v = f?.collapse && f.element ? f.element.children.filter(
|
|
1569
|
+
(k) => k.type === "element" && be(k)
|
|
1570
|
+
).map((k) => Et(s, k)) : [], y = Jn(s, b, {
|
|
1571
|
+
collapseChildren: f?.collapse,
|
|
1572
|
+
...gn(B)
|
|
1573
|
+
});
|
|
1574
|
+
return y ? (_ = y.content, E = {
|
|
1575
|
+
id: y.divisionId,
|
|
1576
|
+
level: y.level,
|
|
1577
|
+
collapsed: y.collapsed,
|
|
1578
|
+
children: y.collapsed ? v : []
|
|
1579
|
+
}, !0) : !1;
|
|
1580
|
+
};
|
|
1581
|
+
if (g !== "pretext" && g !== "mathbook") {
|
|
1278
1582
|
if (!e.fragment)
|
|
1279
1583
|
throw new Error(
|
|
1280
|
-
`The document root is <${
|
|
1584
|
+
`The document root is <${g ?? "?"}>, not <pretext> — this looks like an xi:included fragment. Render the project's main source file instead, or pass the fragment option.`
|
|
1281
1585
|
);
|
|
1586
|
+
let s = !1;
|
|
1282
1587
|
if (e.contextSourcePath || e.contextSourceContent) {
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
|
|
1588
|
+
const u = e.contextSourcePath ?? It(K(r), "__pretext-preview-context.ptx"), f = x.children.find(
|
|
1589
|
+
(w) => w.type === "element"
|
|
1590
|
+
), b = f ? await br(
|
|
1591
|
+
f,
|
|
1286
1592
|
r,
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1593
|
+
u,
|
|
1594
|
+
i,
|
|
1595
|
+
e.contextSourceContent,
|
|
1596
|
+
n
|
|
1597
|
+
) : void 0;
|
|
1598
|
+
b && (s = !0, x = b.tree, $ = ue(x), I = b.files, F = b.bytes, j = S(u), se(x, b.divisionId) || (_ = te(x)));
|
|
1290
1599
|
}
|
|
1291
|
-
if (!
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1600
|
+
if (!s) {
|
|
1601
|
+
const u = e.docinfo ?? (e.docinfoSourcePath ? await vr(
|
|
1602
|
+
e.docinfoSourcePath,
|
|
1603
|
+
i,
|
|
1604
|
+
n
|
|
1605
|
+
) : void 0);
|
|
1606
|
+
_ = wr(
|
|
1607
|
+
_,
|
|
1608
|
+
g,
|
|
1609
|
+
M,
|
|
1610
|
+
u
|
|
1611
|
+
), $ = u === void 0 ? void 0 : ue(u), N = { parentId: u?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
1299
1612
|
}
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1613
|
+
} else
|
|
1614
|
+
$ = ue(x), e.subtree && se(x);
|
|
1615
|
+
C ??= { bytes: F, elements: ve(x), files: I };
|
|
1616
|
+
const q = yn(B, $), ae = K(S(i, d)), ge = {
|
|
1617
|
+
generated: S(ae, q.generated),
|
|
1618
|
+
...q.external !== void 0 ? { external: S(ae, q.external) } : {}
|
|
1619
|
+
}, re = e.sourceMap ? Mn(x, j, N) : void 0, Z = await t.fromString(_, {
|
|
1620
|
+
url: `${p}/${d.split(Ae).join("/")}`,
|
|
1303
1621
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
1304
|
-
}),
|
|
1305
|
-
publisher:
|
|
1622
|
+
}), H = {
|
|
1623
|
+
publisher: ie(h)
|
|
1306
1624
|
};
|
|
1307
|
-
for (const [
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1625
|
+
for (const [s, u] of Object.entries(fr))
|
|
1626
|
+
H[s] = ie(u);
|
|
1627
|
+
E && (H.subtree = ie(E.id), H["subtree-level"] = ie(
|
|
1628
|
+
String(E.level + (E.collapsed ? 1 : 0))
|
|
1629
|
+
));
|
|
1630
|
+
for (const [s, u] of Object.entries(e.stringParams ?? {}))
|
|
1631
|
+
H[s] = ie(u);
|
|
1632
|
+
let c;
|
|
1313
1633
|
try {
|
|
1314
|
-
|
|
1315
|
-
} catch (
|
|
1316
|
-
throw
|
|
1634
|
+
c = await Y.apply(Z, H);
|
|
1635
|
+
} catch (s) {
|
|
1636
|
+
throw Ve(s), new Error(
|
|
1317
1637
|
"PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
|
|
1318
|
-
{ cause:
|
|
1638
|
+
{ cause: s }
|
|
1319
1639
|
);
|
|
1320
1640
|
} finally {
|
|
1321
|
-
|
|
1641
|
+
Z.delete();
|
|
1322
1642
|
}
|
|
1323
1643
|
try {
|
|
1324
|
-
let
|
|
1325
|
-
|
|
1644
|
+
let s = lr(c.toHtmlString());
|
|
1645
|
+
s = or(s, {
|
|
1326
1646
|
...e.offPageMessage !== void 0 ? { offPageMessage: e.offPageMessage } : {}
|
|
1327
|
-
}), (e.openKnowls ?? !0) && (
|
|
1647
|
+
}), (e.openKnowls ?? !0) && (s = Gt(s)), M === "slides" ? (s = dr(s), s = Pn(s, e.revealView ?? "scroll", {
|
|
1328
1648
|
zoom: e.revealZoom
|
|
1329
|
-
})) : e.theme && (
|
|
1330
|
-
const
|
|
1331
|
-
return e.printPreview && (
|
|
1332
|
-
html:
|
|
1333
|
-
target:
|
|
1334
|
-
printouts:
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
...
|
|
1649
|
+
})) : e.theme && (s = Fn(s, e.theme)), e.previewBanner && (s = Ct(s, e.previewBanner));
|
|
1650
|
+
const u = M === "slides" ? [] : nt(s), f = on(u, g);
|
|
1651
|
+
return e.printPreview && (s = dn(s, e.printPreview)), {
|
|
1652
|
+
html: s,
|
|
1653
|
+
target: M,
|
|
1654
|
+
printouts: u,
|
|
1655
|
+
size: C,
|
|
1656
|
+
assetDirs: ge,
|
|
1657
|
+
...E ? { subtree: E } : {},
|
|
1658
|
+
...re ? { sourceMap: re } : {},
|
|
1659
|
+
...f ? { rootPrintout: f } : {}
|
|
1338
1660
|
};
|
|
1339
|
-
} catch (
|
|
1340
|
-
throw
|
|
1661
|
+
} catch (s) {
|
|
1662
|
+
throw Ve(s), s;
|
|
1341
1663
|
} finally {
|
|
1342
|
-
|
|
1664
|
+
c.delete();
|
|
1343
1665
|
}
|
|
1344
1666
|
} finally {
|
|
1345
|
-
|
|
1667
|
+
Zt(p);
|
|
1346
1668
|
}
|
|
1347
1669
|
}
|
|
1348
|
-
const
|
|
1349
|
-
function
|
|
1670
|
+
const Tr = "__ptxLivePatch";
|
|
1671
|
+
function Ir(e, t, n) {
|
|
1350
1672
|
const r = "script, #latex-macros, [data-component], .ptx-runestone-container", i = /* @__PURE__ */ new Set([
|
|
1351
1673
|
"BODY",
|
|
1352
1674
|
"MAIN",
|
|
@@ -1405,315 +1727,319 @@ function Zn(e, n, t) {
|
|
|
1405
1727
|
"U",
|
|
1406
1728
|
"VAR",
|
|
1407
1729
|
"WBR"
|
|
1408
|
-
]),
|
|
1409
|
-
function
|
|
1410
|
-
return { bail:
|
|
1730
|
+
]), a = ["clipboardable"], l = 25e4, d = 3, p = [], m = /* @__PURE__ */ new Map();
|
|
1731
|
+
function h(c) {
|
|
1732
|
+
return { bail: c };
|
|
1411
1733
|
}
|
|
1412
|
-
function
|
|
1413
|
-
return typeof
|
|
1734
|
+
function T(c) {
|
|
1735
|
+
return typeof c == "object" && c !== null && typeof c.bail == "string";
|
|
1414
1736
|
}
|
|
1415
|
-
function
|
|
1416
|
-
return
|
|
1737
|
+
function x(c) {
|
|
1738
|
+
return c.matches(r) || c.querySelector(r) !== null;
|
|
1417
1739
|
}
|
|
1418
|
-
function
|
|
1419
|
-
return
|
|
1740
|
+
function _(c) {
|
|
1741
|
+
return c.tagName === "SCRIPT" && !c.hasAttribute("src") && (c.textContent ?? "").indexOf("ptx_lunr_docs") !== -1;
|
|
1420
1742
|
}
|
|
1421
|
-
function
|
|
1422
|
-
if (!i.has(
|
|
1423
|
-
|
|
1743
|
+
function I(c) {
|
|
1744
|
+
if (!i.has(c.tagName) || c.matches(".process-math") || // Never looked inside: a change anywhere in one is a change to it.
|
|
1745
|
+
c.matches(r))
|
|
1424
1746
|
return !1;
|
|
1425
|
-
for (const
|
|
1426
|
-
if (
|
|
1747
|
+
for (const s of Array.from(c.childNodes))
|
|
1748
|
+
if (s.nodeType === d && /\S/.test(s.nodeValue ?? ""))
|
|
1427
1749
|
return !1;
|
|
1428
|
-
if (
|
|
1429
|
-
for (const
|
|
1430
|
-
if (o.has(
|
|
1750
|
+
if (c.tagName === "DIV" || c.tagName === "LI") {
|
|
1751
|
+
for (const s of Array.from(c.children))
|
|
1752
|
+
if (o.has(s.tagName.toUpperCase()))
|
|
1431
1753
|
return !1;
|
|
1432
1754
|
}
|
|
1433
1755
|
return !0;
|
|
1434
1756
|
}
|
|
1435
|
-
function
|
|
1436
|
-
return
|
|
1757
|
+
function F(c) {
|
|
1758
|
+
return a.indexOf(c) !== -1;
|
|
1437
1759
|
}
|
|
1438
|
-
function
|
|
1439
|
-
if (
|
|
1760
|
+
function M(c, s) {
|
|
1761
|
+
if (c.tagName !== s.tagName)
|
|
1440
1762
|
return !1;
|
|
1441
|
-
const
|
|
1442
|
-
if (
|
|
1763
|
+
const u = s.getAttribute("id");
|
|
1764
|
+
if (u !== null && c.getAttribute("id") !== u)
|
|
1443
1765
|
return !1;
|
|
1444
|
-
for (const
|
|
1445
|
-
if (!
|
|
1446
|
-
return
|
|
1766
|
+
for (const f of Array.from(s.classList))
|
|
1767
|
+
if (!F(f))
|
|
1768
|
+
return c.classList.contains(f);
|
|
1447
1769
|
return !0;
|
|
1448
1770
|
}
|
|
1449
|
-
function
|
|
1450
|
-
const
|
|
1451
|
-
let
|
|
1452
|
-
for (const
|
|
1453
|
-
let
|
|
1454
|
-
for (; !
|
|
1455
|
-
const
|
|
1456
|
-
|
|
1771
|
+
function Y(c, s) {
|
|
1772
|
+
const u = Array.from(c.children), f = [];
|
|
1773
|
+
let b = 0;
|
|
1774
|
+
for (const w of s) {
|
|
1775
|
+
let v = null;
|
|
1776
|
+
for (; !v && b < u.length; ) {
|
|
1777
|
+
const y = u[b++];
|
|
1778
|
+
M(y, w) ? v = { inner: y, outer: y } : y.tagName === "DIV" && a.some((k) => y.classList.contains(k)) && y.firstElementChild && M(y.firstElementChild, w) && (v = { inner: y.firstElementChild, outer: y });
|
|
1457
1779
|
}
|
|
1458
|
-
if (!
|
|
1780
|
+
if (!v)
|
|
1459
1781
|
return null;
|
|
1460
|
-
|
|
1782
|
+
f.push(v);
|
|
1461
1783
|
}
|
|
1462
|
-
return
|
|
1784
|
+
return f;
|
|
1463
1785
|
}
|
|
1464
|
-
function
|
|
1465
|
-
if (
|
|
1786
|
+
function B(c, s) {
|
|
1787
|
+
if (c.attributes.length !== s.attributes.length)
|
|
1466
1788
|
return !1;
|
|
1467
|
-
for (const
|
|
1468
|
-
if (
|
|
1789
|
+
for (const u of Array.from(c.attributes))
|
|
1790
|
+
if (s.getAttributeNS(u.namespaceURI, u.localName) !== u.value)
|
|
1469
1791
|
return !1;
|
|
1470
1792
|
return !0;
|
|
1471
1793
|
}
|
|
1472
|
-
function
|
|
1473
|
-
return
|
|
1794
|
+
function g(c) {
|
|
1795
|
+
return c.outerHTML.replace(/<([A-Za-z][^\s/>]*)\s[^>]*>/g, "<$1>");
|
|
1474
1796
|
}
|
|
1475
|
-
function
|
|
1476
|
-
let
|
|
1477
|
-
return
|
|
1797
|
+
function N(c) {
|
|
1798
|
+
let s = m.get(c);
|
|
1799
|
+
return s === void 0 && (s = c.outerHTML.replace(/<span class="codenumber">[^<]*<\/span>/g, "").replace(/<([A-Za-z][^\s/>]*)\s[^>]*>/g, "<$1>"), m.set(c, s)), s;
|
|
1478
1800
|
}
|
|
1479
|
-
function
|
|
1480
|
-
const
|
|
1481
|
-
const
|
|
1482
|
-
let
|
|
1483
|
-
return
|
|
1484
|
-
},
|
|
1485
|
-
for (let
|
|
1486
|
-
for (let
|
|
1487
|
-
|
|
1488
|
-
const
|
|
1489
|
-
let
|
|
1490
|
-
for (;
|
|
1491
|
-
|
|
1492
|
-
return
|
|
1801
|
+
function E(c, s, u, f, b) {
|
|
1802
|
+
const w = /* @__PURE__ */ new Map(), v = (W) => {
|
|
1803
|
+
const U = N(W);
|
|
1804
|
+
let ce = w.get(U);
|
|
1805
|
+
return ce === void 0 && (ce = w.size, w.set(U, ce)), ce;
|
|
1806
|
+
}, y = c.slice(u, f).map(v), k = s.slice(u, b).map(v), D = y.length, L = k.length, A = L + 1, P = new Uint32Array((D + 1) * A);
|
|
1807
|
+
for (let W = D - 1; W >= 0; W--)
|
|
1808
|
+
for (let U = L - 1; U >= 0; U--)
|
|
1809
|
+
P[W * A + U] = y[W] === k[U] ? P[(W + 1) * A + U + 1] + 1 : Math.max(P[(W + 1) * A + U], P[W * A + U + 1]);
|
|
1810
|
+
const V = [];
|
|
1811
|
+
let G = 0, J = 0;
|
|
1812
|
+
for (; G < D && J < L; )
|
|
1813
|
+
y[G] === k[J] ? (V.push([u + G, u + J]), G++, J++) : P[(G + 1) * A + J] >= P[G * A + J + 1] ? G++ : J++;
|
|
1814
|
+
return V;
|
|
1493
1815
|
}
|
|
1494
|
-
function
|
|
1495
|
-
const
|
|
1496
|
-
let
|
|
1497
|
-
for (;
|
|
1498
|
-
|
|
1499
|
-
let
|
|
1500
|
-
for (;
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1503
|
-
if (
|
|
1504
|
-
return
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
let
|
|
1508
|
-
for (const [
|
|
1509
|
-
for (;
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1816
|
+
function j(c, s) {
|
|
1817
|
+
const u = s.map(() => -1);
|
|
1818
|
+
let f = 0;
|
|
1819
|
+
for (; f < c.length && f < s.length && c[f].isEqualNode(s[f]); )
|
|
1820
|
+
u[f] = f, f++;
|
|
1821
|
+
let b = c.length, w = s.length;
|
|
1822
|
+
for (; b > f && w > f && c[b - 1].isEqualNode(s[w - 1]); )
|
|
1823
|
+
b--, w--, u[w] = b;
|
|
1824
|
+
const v = b - f, y = w - f;
|
|
1825
|
+
if (v === 0 || y === 0)
|
|
1826
|
+
return u;
|
|
1827
|
+
const k = (v > 1 || y > 1) && v * y <= l ? E(c, s, f, b, w) : [];
|
|
1828
|
+
k.push([b, w]);
|
|
1829
|
+
let D = f, L = f;
|
|
1830
|
+
for (const [A, P] of k) {
|
|
1831
|
+
for (; D < A && L < P; ) {
|
|
1832
|
+
if (c[D].tagName === s[L].tagName) {
|
|
1833
|
+
u[L++] = D++;
|
|
1512
1834
|
continue;
|
|
1513
1835
|
}
|
|
1514
|
-
let
|
|
1515
|
-
for (;
|
|
1516
|
-
|
|
1517
|
-
|
|
1836
|
+
let V = D + 1;
|
|
1837
|
+
for (; V < A && c[V].tagName !== s[L].tagName; )
|
|
1838
|
+
V++;
|
|
1839
|
+
V < A ? D = V : L++;
|
|
1518
1840
|
}
|
|
1519
|
-
|
|
1841
|
+
A < b && (u[P] = A), D = A + 1, L = P + 1;
|
|
1520
1842
|
}
|
|
1521
|
-
return
|
|
1843
|
+
return u;
|
|
1522
1844
|
}
|
|
1523
|
-
function
|
|
1524
|
-
if (
|
|
1525
|
-
throw
|
|
1526
|
-
return { next:
|
|
1845
|
+
function C(c, s) {
|
|
1846
|
+
if (x(c) || x(s))
|
|
1847
|
+
throw h(`<${s.tagName.toLowerCase()}> needs a full page load`);
|
|
1848
|
+
return { next: s, replace: !0 };
|
|
1527
1849
|
}
|
|
1528
|
-
function
|
|
1529
|
-
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1850
|
+
function $(c, s, u) {
|
|
1851
|
+
B(s, u) || p.push({ live: c, old: s, next: u });
|
|
1852
|
+
const f = Array.from(s.children), b = Array.from(u.children);
|
|
1853
|
+
if (f.length !== b.length)
|
|
1532
1854
|
return !1;
|
|
1533
|
-
let
|
|
1534
|
-
for (let
|
|
1535
|
-
if (!
|
|
1855
|
+
let w = null;
|
|
1856
|
+
for (let v = 0; v < f.length; v++)
|
|
1857
|
+
if (!f[v].isEqualNode(b[v]) && (w = w ?? Y(c, f), !w || !$(w[v].inner, f[v], b[v])))
|
|
1536
1858
|
return !1;
|
|
1537
1859
|
return !0;
|
|
1538
1860
|
}
|
|
1539
|
-
function
|
|
1540
|
-
if (
|
|
1541
|
-
return { next:
|
|
1542
|
-
if (
|
|
1543
|
-
const
|
|
1544
|
-
if (
|
|
1545
|
-
return
|
|
1546
|
-
} else if (
|
|
1547
|
-
const
|
|
1548
|
-
if (
|
|
1549
|
-
if (
|
|
1550
|
-
throw
|
|
1861
|
+
function se(c, s, u) {
|
|
1862
|
+
if (s.isEqualNode(u) || _(s) && _(u))
|
|
1863
|
+
return { next: u, outer: c.outer };
|
|
1864
|
+
if (s.tagName === u.tagName && I(s) && I(u)) {
|
|
1865
|
+
const f = q(c.inner, s, u);
|
|
1866
|
+
if (f)
|
|
1867
|
+
return B(s, u) || p.push({ live: c.inner, old: s, next: u }), { next: u, outer: c.outer, sub: f };
|
|
1868
|
+
} else if (g(s) === g(u)) {
|
|
1869
|
+
const f = p.length;
|
|
1870
|
+
if ($(c.inner, s, u)) {
|
|
1871
|
+
if (x(s))
|
|
1872
|
+
throw h(
|
|
1551
1873
|
"attributes changed inside an element that needs a full page load"
|
|
1552
1874
|
);
|
|
1553
|
-
return { next:
|
|
1875
|
+
return { next: u, outer: c.outer };
|
|
1554
1876
|
}
|
|
1555
|
-
|
|
1877
|
+
p.length = f;
|
|
1556
1878
|
}
|
|
1557
|
-
return { ...
|
|
1879
|
+
return { ...C(s, u), outer: c.outer };
|
|
1558
1880
|
}
|
|
1559
|
-
function
|
|
1560
|
-
const
|
|
1561
|
-
if (!
|
|
1881
|
+
function q(c, s, u) {
|
|
1882
|
+
const f = Array.from(s.children), b = Array.from(u.children), w = Y(c, f);
|
|
1883
|
+
if (!w)
|
|
1562
1884
|
return null;
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
const
|
|
1566
|
-
if (
|
|
1567
|
-
if (
|
|
1568
|
-
throw
|
|
1569
|
-
`new <${
|
|
1885
|
+
const v = j(f, b), y = f.map(() => !1), k = [];
|
|
1886
|
+
b.forEach((L, A) => {
|
|
1887
|
+
const P = v[A];
|
|
1888
|
+
if (P === -1) {
|
|
1889
|
+
if (x(L))
|
|
1890
|
+
throw h(
|
|
1891
|
+
`new <${L.tagName.toLowerCase()}> needs a full page load`
|
|
1570
1892
|
);
|
|
1571
|
-
|
|
1893
|
+
k.push({ next: L });
|
|
1572
1894
|
return;
|
|
1573
1895
|
}
|
|
1574
|
-
|
|
1896
|
+
y[P] = !0, k.push(se(w[P], f[P], L));
|
|
1575
1897
|
});
|
|
1576
|
-
const
|
|
1577
|
-
return
|
|
1578
|
-
if (!
|
|
1579
|
-
if (
|
|
1580
|
-
throw
|
|
1581
|
-
`removing <${
|
|
1898
|
+
const D = [];
|
|
1899
|
+
return f.forEach((L, A) => {
|
|
1900
|
+
if (!y[A]) {
|
|
1901
|
+
if (x(L))
|
|
1902
|
+
throw h(
|
|
1903
|
+
`removing <${L.tagName.toLowerCase()}> needs a full page load`
|
|
1582
1904
|
);
|
|
1583
|
-
|
|
1905
|
+
D.push(w[A].outer);
|
|
1584
1906
|
}
|
|
1585
1907
|
}), {
|
|
1586
|
-
live:
|
|
1587
|
-
first:
|
|
1588
|
-
items:
|
|
1589
|
-
removed:
|
|
1908
|
+
live: c,
|
|
1909
|
+
first: w.length ? w[0].outer : null,
|
|
1910
|
+
items: k,
|
|
1911
|
+
removed: D
|
|
1590
1912
|
};
|
|
1591
1913
|
}
|
|
1592
|
-
function
|
|
1593
|
-
const
|
|
1594
|
-
if (
|
|
1595
|
-
throw
|
|
1596
|
-
let
|
|
1597
|
-
for (let
|
|
1598
|
-
const
|
|
1599
|
-
if (!
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
1602
|
-
else if (
|
|
1603
|
-
throw
|
|
1914
|
+
function ae() {
|
|
1915
|
+
const c = Array.from(t.head.children), s = Array.from(n.head.children);
|
|
1916
|
+
if (c.length !== s.length)
|
|
1917
|
+
throw h("the page head changed");
|
|
1918
|
+
let u = null;
|
|
1919
|
+
for (let f = 0; f < c.length; f++) {
|
|
1920
|
+
const b = c[f], w = s[f];
|
|
1921
|
+
if (!b.isEqualNode(w)) {
|
|
1922
|
+
if (b.tagName === "TITLE" && w.tagName === "TITLE")
|
|
1923
|
+
u = w.textContent ?? "";
|
|
1924
|
+
else if (b.tagName !== "META" || w.tagName !== "META")
|
|
1925
|
+
throw h("the page head changed");
|
|
1604
1926
|
}
|
|
1605
1927
|
}
|
|
1606
|
-
return
|
|
1928
|
+
return u;
|
|
1607
1929
|
}
|
|
1608
|
-
function
|
|
1609
|
-
const { live:
|
|
1610
|
-
for (const
|
|
1611
|
-
|
|
1612
|
-
for (const
|
|
1613
|
-
|
|
1614
|
-
const
|
|
1615
|
-
for (const
|
|
1616
|
-
|
|
1617
|
-
for (const
|
|
1618
|
-
|
|
1930
|
+
function ge(c) {
|
|
1931
|
+
const { live: s, old: u, next: f } = c;
|
|
1932
|
+
for (const v of Array.from(u.attributes))
|
|
1933
|
+
v.name !== "class" && !f.hasAttributeNS(v.namespaceURI, v.localName) && s.removeAttributeNS(v.namespaceURI, v.localName);
|
|
1934
|
+
for (const v of Array.from(f.attributes))
|
|
1935
|
+
v.name !== "class" && u.getAttributeNS(v.namespaceURI, v.localName) !== v.value && s.setAttributeNS(v.namespaceURI, v.name, v.value);
|
|
1936
|
+
const b = Array.from(u.classList), w = Array.from(f.classList);
|
|
1937
|
+
for (const v of b)
|
|
1938
|
+
w.indexOf(v) === -1 && s.classList.remove(v);
|
|
1939
|
+
for (const v of w)
|
|
1940
|
+
b.indexOf(v) === -1 && s.classList.add(v);
|
|
1619
1941
|
}
|
|
1620
|
-
const
|
|
1621
|
-
function
|
|
1622
|
-
let
|
|
1623
|
-
for (const
|
|
1624
|
-
if (!
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1942
|
+
const re = [], Z = [];
|
|
1943
|
+
function H(c) {
|
|
1944
|
+
let s = null;
|
|
1945
|
+
for (const u of c.items) {
|
|
1946
|
+
if (!u.outer || u.replace) {
|
|
1947
|
+
const f = e.importNode(u.next, !0);
|
|
1948
|
+
u.outer ? (u.outer.replaceWith(f), Z.push(u.outer)) : s ? s.after(f) : c.first ? c.first.before(f) : c.live.appendChild(f), re.push(f), s = f;
|
|
1627
1949
|
continue;
|
|
1628
1950
|
}
|
|
1629
|
-
|
|
1951
|
+
u.sub && H(u.sub), s = u.outer;
|
|
1630
1952
|
}
|
|
1631
|
-
for (const
|
|
1632
|
-
|
|
1953
|
+
for (const u of c.removed)
|
|
1954
|
+
u.remove(), Z.push(u);
|
|
1633
1955
|
}
|
|
1634
1956
|
try {
|
|
1635
|
-
const
|
|
1957
|
+
const c = ae(), s = {
|
|
1636
1958
|
live: e.documentElement,
|
|
1637
|
-
old:
|
|
1638
|
-
next:
|
|
1959
|
+
old: t.documentElement,
|
|
1960
|
+
next: n.documentElement
|
|
1639
1961
|
};
|
|
1640
|
-
if (
|
|
1641
|
-
throw
|
|
1642
|
-
const
|
|
1643
|
-
if (!
|
|
1644
|
-
throw
|
|
1645
|
-
return
|
|
1646
|
-
} catch (
|
|
1647
|
-
if (
|
|
1962
|
+
if (B(s.old, s.next) || p.push(s), !e.body || !I(t.body) || !I(n.body))
|
|
1963
|
+
throw h("the page body is not patchable");
|
|
1964
|
+
const u = q(e.body, t.body, n.body);
|
|
1965
|
+
if (!u)
|
|
1966
|
+
throw h("the live page no longer matches the previous render");
|
|
1967
|
+
return B(t.body, n.body) || p.push({ live: e.body, old: t.body, next: n.body }), p.forEach(ge), H(u), c !== null && e.title !== c && (e.title = c), { ok: !0, added: re, removed: Z, attributeUpdates: p.length };
|
|
1968
|
+
} catch (c) {
|
|
1969
|
+
if (T(c))
|
|
1648
1970
|
return {
|
|
1649
1971
|
ok: !1,
|
|
1650
|
-
reason:
|
|
1972
|
+
reason: c.bail,
|
|
1651
1973
|
added: [],
|
|
1652
1974
|
removed: [],
|
|
1653
1975
|
attributeUpdates: 0
|
|
1654
1976
|
};
|
|
1655
|
-
throw
|
|
1977
|
+
throw c;
|
|
1656
1978
|
}
|
|
1657
1979
|
}
|
|
1658
|
-
function
|
|
1659
|
-
const
|
|
1660
|
-
if (!
|
|
1980
|
+
function Ar(e, t) {
|
|
1981
|
+
const n = e.MathJax, r = n && n.startup;
|
|
1982
|
+
if (!n || !r || !r.promise || typeof n.typesetPromise != "function")
|
|
1661
1983
|
return Promise.resolve();
|
|
1662
1984
|
const i = [];
|
|
1663
|
-
for (const
|
|
1664
|
-
|
|
1665
|
-
const o =
|
|
1985
|
+
for (const l of t.added)
|
|
1986
|
+
l.matches(".process-math") ? i.push(l) : i.push(...Array.from(l.querySelectorAll(".process-math")));
|
|
1987
|
+
const o = t.removed;
|
|
1666
1988
|
if (i.length === 0 && o.length === 0)
|
|
1667
1989
|
return Promise.resolve();
|
|
1668
|
-
const
|
|
1990
|
+
const a = r.promise.then(() => (o.length && typeof n.typesetClear == "function" && n.typesetClear(o), i.length && n.typesetPromise ? n.typesetPromise(i) : void 0)).then(
|
|
1669
1991
|
() => {
|
|
1670
1992
|
},
|
|
1671
|
-
(
|
|
1672
|
-
console.error("pretext-html: typesetting a live patch failed",
|
|
1993
|
+
(l) => {
|
|
1994
|
+
console.error("pretext-html: typesetting a live patch failed", l);
|
|
1673
1995
|
}
|
|
1674
1996
|
);
|
|
1675
|
-
return r.promise =
|
|
1997
|
+
return r.promise = a, a;
|
|
1676
1998
|
}
|
|
1677
|
-
function
|
|
1999
|
+
function Br() {
|
|
1678
2000
|
return [
|
|
1679
2001
|
"<script>",
|
|
1680
|
-
`window[${JSON.stringify(
|
|
1681
|
-
` patchDocument: ${
|
|
1682
|
-
` typeset: ${
|
|
2002
|
+
`window[${JSON.stringify(Tr)}] = {`,
|
|
2003
|
+
` patchDocument: ${Ir.toString()},`,
|
|
2004
|
+
` typeset: ${Ar.toString()}`,
|
|
1683
2005
|
"};",
|
|
1684
2006
|
"<\/script>"
|
|
1685
2007
|
].join(`
|
|
1686
2008
|
`);
|
|
1687
2009
|
}
|
|
1688
2010
|
export {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
2011
|
+
Tr as LIVE_PATCH_GLOBAL,
|
|
2012
|
+
At as PREVIEW_BANNER_STORAGE_KEY,
|
|
2013
|
+
pt as PREVIEW_THEME_MESSAGE,
|
|
2014
|
+
sn as PRINT_PREVIEW_GLOBAL,
|
|
2015
|
+
Kn as SourceCache,
|
|
2016
|
+
mr as defaultSourceCache,
|
|
2017
|
+
sr as defaultXslDir,
|
|
2018
|
+
jn as detectRenderTarget,
|
|
2019
|
+
Pr as findSourceMapEntry,
|
|
2020
|
+
Nr as forcePortablePublication,
|
|
2021
|
+
rt as forcePreviewPublication,
|
|
2022
|
+
Ct as injectPreviewBanner,
|
|
2023
|
+
dn as injectPrintPreview,
|
|
2024
|
+
Pn as injectRevealBridge,
|
|
2025
|
+
Fn as injectThemeBridge,
|
|
2026
|
+
ar as isJspiAvailable,
|
|
2027
|
+
Cr as isPreviewTheme,
|
|
2028
|
+
Rr as isRevealView,
|
|
2029
|
+
nt as listPrintouts,
|
|
2030
|
+
Br as livePatchScript,
|
|
2031
|
+
Or as measureDocument,
|
|
2032
|
+
Gt as openBornHiddenKnowls,
|
|
2033
|
+
Ir as patchDocument,
|
|
2034
|
+
kt as previewBannerScript,
|
|
2035
|
+
Dr as previewThemeMessage,
|
|
2036
|
+
an as printPreviewBridgeScript,
|
|
2037
|
+
Mr as renderHtml,
|
|
2038
|
+
_n as revealBridgeScript,
|
|
2039
|
+
on as rootPrintoutId,
|
|
2040
|
+
$r as setAssetsBase,
|
|
2041
|
+
kr as setMountReader,
|
|
2042
|
+
Un as themeBridgeScript,
|
|
2043
|
+
Ar as typesetPatch,
|
|
2044
|
+
ie as xpathStringLiteral
|
|
1719
2045
|
};
|