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