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