@pretextbook/pretext-html 0.5.0 → 0.7.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.
Files changed (99) hide show
  1. package/README.md +6 -0
  2. package/assets/preview-html.xsl +14 -0
  3. package/assets/upstream.json +1 -1
  4. package/assets/xsl/LICENSE-pretext +1 -1
  5. package/assets/xsl/README.md +43 -25
  6. package/assets/xsl/entities.ent +4 -4
  7. package/assets/xsl/extract-asymptote.xsl +5 -5
  8. package/assets/xsl/extract-biblio-csl.xsl +1 -1
  9. package/assets/xsl/extract-datafile.xsl +1 -1
  10. package/assets/xsl/extract-dynamic.xsl +1 -1
  11. package/assets/xsl/extract-identity.xsl +5 -5
  12. package/assets/xsl/extract-interactive.xsl +1 -1
  13. package/assets/xsl/extract-latex-image.xsl +5 -5
  14. package/assets/xsl/extract-mermaid.xsl +1 -1
  15. package/assets/xsl/extract-mom.xsl +5 -5
  16. package/assets/xsl/extract-pg.xsl +1 -1
  17. package/assets/xsl/extract-prefigure.xsl +5 -5
  18. package/assets/xsl/extract-qrcode.xsl +1 -1
  19. package/assets/xsl/extract-runestone-page-template.xsl +1 -1
  20. package/assets/xsl/extract-sageplot.xsl +5 -5
  21. package/assets/xsl/extract-stack.xsl +1 -1
  22. package/assets/xsl/extract-trace.xsl +1 -1
  23. package/assets/xsl/extract-youtube.xsl +5 -5
  24. package/assets/xsl/latex/pretext-latex-AIM.xsl +1 -1
  25. package/assets/xsl/latex/pretext-latex-chaos.xsl +1 -1
  26. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +1 -1
  27. package/assets/xsl/latex/pretext-latex-guide.xsl +1 -1
  28. package/assets/xsl/localizations/README.md +25 -25
  29. package/assets/xsl/localizations/af-ZA.xml +1 -1
  30. package/assets/xsl/localizations/bg-BG.xml +1 -1
  31. package/assets/xsl/localizations/ca-ES.xml +1 -1
  32. package/assets/xsl/localizations/cs-CZ.xml +1 -1
  33. package/assets/xsl/localizations/de-DE.xml +1 -1
  34. package/assets/xsl/localizations/en-US.xml +1 -1
  35. package/assets/xsl/localizations/es-ES.xml +1 -1
  36. package/assets/xsl/localizations/fi-FI.xml +1 -1
  37. package/assets/xsl/localizations/fr-CA.xml +1 -1
  38. package/assets/xsl/localizations/fr-FR.xml +1 -1
  39. package/assets/xsl/localizations/hu-HU.xml +1 -1
  40. package/assets/xsl/localizations/it-IT.xml +1 -1
  41. package/assets/xsl/localizations/ku-CKB.xml +1 -1
  42. package/assets/xsl/localizations/localizations.xml +1 -1
  43. package/assets/xsl/localizations/nl-NL.xml +1 -1
  44. package/assets/xsl/localizations/pt-BR.xml +1 -1
  45. package/assets/xsl/localizations/pt-PT.xml +1 -1
  46. package/assets/xsl/localizations/zh-HANS.xml +1 -1
  47. package/assets/xsl/pretext-assembly.xsl +64 -1
  48. package/assets/xsl/pretext-basic-html.xsl +5 -5
  49. package/assets/xsl/pretext-braille-preprint.xsl +5 -5
  50. package/assets/xsl/pretext-common.xsl +104 -30
  51. package/assets/xsl/pretext-dynamic.xsl +1 -1
  52. package/assets/xsl/pretext-epub.xsl +90 -84
  53. package/assets/xsl/pretext-fo.xsl +1 -1
  54. package/assets/xsl/pretext-html.xsl +57 -34
  55. package/assets/xsl/pretext-json-manifest.xsl +1 -1
  56. package/assets/xsl/pretext-jupyter.xsl +5 -5
  57. package/assets/xsl/pretext-latex-classic.xsl +1 -1
  58. package/assets/xsl/pretext-latex-common.xsl +7 -5
  59. package/assets/xsl/pretext-latex.xsl +3 -3
  60. package/assets/xsl/pretext-litprog.xsl +9 -2
  61. package/assets/xsl/pretext-markdown.xsl +1 -1
  62. package/assets/xsl/pretext-numbers.xsl +1 -1
  63. package/assets/xsl/pretext-runestone-fitb.xsl +18 -0
  64. package/assets/xsl/pretext-runestone-static.xsl +13 -1
  65. package/assets/xsl/pretext-runestone.xsl +34 -6
  66. package/assets/xsl/pretext-sage-doctest.xsl +18 -0
  67. package/assets/xsl/pretext-solution-manual-latex.xsl +4 -4
  68. package/assets/xsl/pretext-text-utilities.xsl +1 -1
  69. package/assets/xsl/pretext-text.xsl +5 -5
  70. package/assets/xsl/pretext-units.xsl +5 -5
  71. package/assets/xsl/pretext-view-source.xsl +1 -1
  72. package/assets/xsl/pretext-ww-problem-sets.xsl +15 -12
  73. package/assets/xsl/publisher-variables.xsl +104 -36
  74. package/assets/xsl/support/README.md +19 -0
  75. package/assets/xsl/support/extract-math.xsl +1 -1
  76. package/assets/xsl/support/package-math.xsl +1 -1
  77. package/assets/xsl/support/play-button/README.md +3 -1
  78. package/assets/xsl/support/webpack_static_imports.xml +19 -0
  79. package/assets/xsl/tests/README.md +20 -1
  80. package/assets/xsl/tests/null.xml +19 -0
  81. package/assets/xsl/tests/pretext-text-utilities-test.xsl +1 -1
  82. package/assets/xsl/utilities/README.md +27 -6
  83. package/assets/xsl/utilities/author-report.xsl +1 -1
  84. package/assets/xsl/utilities/fix-deprecations.xsl +5 -5
  85. package/assets/xsl/utilities/pretext-enhanced-source.xsl +1 -1
  86. package/assets/xsl/utilities/report-publisher-variables.xsl +5 -5
  87. package/assets/xsl/xml-to-json.xsl +4 -4
  88. package/assets/xsl-bundle.json +1 -1
  89. package/dist/banner.d.ts +51 -0
  90. package/dist/{cli-DZsyZERX.js → cli-D0m0Ha1j.js} +358 -196
  91. package/dist/cli.js +2 -2
  92. package/dist/index.browser.d.ts +3 -0
  93. package/dist/index.browser.js +477 -322
  94. package/dist/index.d.ts +3 -0
  95. package/dist/index.js +25 -21
  96. package/dist/knowls.d.ts +43 -0
  97. package/dist/renderer.d.ts +26 -0
  98. package/package.json +1 -1
  99. package/assets/xsl/pretext-smc.xsl +0 -492
@@ -1,23 +1,23 @@
1
- import { fromXml as E } from "xast-util-from-xml";
2
- import { toXml as S } from "xast-util-to-xml";
3
- const D = "/";
1
+ import { fromXml as x } from "xast-util-from-xml";
2
+ import { toXml as $ } from "xast-util-to-xml";
3
+ const M = "/";
4
4
  function ge(e) {
5
5
  if (!e)
6
6
  return ".";
7
7
  const n = e.startsWith("/"), t = e.length > 1 && e.endsWith("/"), r = [];
8
- for (const o of e.split("/"))
9
- if (!(!o || o === ".")) {
10
- if (o === "..") {
11
- const s = r[r.length - 1];
12
- r.length > 0 && s !== ".." ? r.pop() : n || r.push("..");
8
+ for (const s of e.split("/"))
9
+ if (!(!s || s === ".")) {
10
+ if (s === "..") {
11
+ const o = r[r.length - 1];
12
+ r.length > 0 && o !== ".." ? r.pop() : n || r.push("..");
13
13
  continue;
14
14
  }
15
- r.push(o);
15
+ r.push(s);
16
16
  }
17
17
  let i = r.join("/");
18
18
  return n && (i = `/${i}`), i ? (t && !i.endsWith("/") && (i += "/"), i) : n ? "/" : ".";
19
19
  }
20
- function h(...e) {
20
+ function p(...e) {
21
21
  let n = "";
22
22
  for (let r = e.length - 1; r >= 0; r--) {
23
23
  const i = e[r];
@@ -28,40 +28,169 @@ function h(...e) {
28
28
  const t = ge(n);
29
29
  return t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
30
30
  }
31
- function b(e) {
31
+ function g(e) {
32
32
  const n = e.replace(/\/+$/, "");
33
33
  if (!n)
34
34
  return e.startsWith("/") ? "/" : ".";
35
35
  const t = n.lastIndexOf("/");
36
36
  return t < 0 ? "." : t === 0 ? "/" : n.slice(0, t);
37
37
  }
38
- function k(e, n) {
39
- const t = h(e).split("/").filter(Boolean), r = h(n).split("/").filter(Boolean);
38
+ function I(e, n) {
39
+ const t = p(e).split("/").filter(Boolean), r = p(n).split("/").filter(Boolean);
40
40
  let i = 0;
41
41
  for (; i < t.length && i < r.length && t[i] === r[i]; )
42
42
  i += 1;
43
43
  return [...new Array(t.length - i).fill(".."), ...r.slice(i)].join("/");
44
44
  }
45
- const ve = "https://cdn.jsdelivr.net/npm/@pretextbook/pretext-html@0.5.0/assets";
46
- let Z;
47
- function bt(e) {
48
- Z = e.replace(/\/+$/, "");
45
+ const ye = "ptxPreviewBannerDismissed", xe = "About live preview";
46
+ function X(e) {
47
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
49
48
  }
50
- function $() {
51
- return Z ?? ve;
49
+ function Ee(e) {
50
+ return [
51
+ '<div id="ptx-preview-banner" class="ptx-preview-banner" role="note">',
52
+ ` <span class="ptx-preview-banner-text">${X(e)}</span>`,
53
+ ' <button type="button" class="ptx-preview-banner-dismiss" aria-label="Dismiss">&times;</button>',
54
+ "</div>",
55
+ `<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${X(xe)}</button>`
56
+ ].join(`
57
+ `);
58
+ }
59
+ function Te() {
60
+ return [
61
+ "<style>",
62
+ ".ptx-preview-banner {",
63
+ " display: flex;",
64
+ " align-items: center;",
65
+ " gap: 0.75em;",
66
+ " padding: 0.5em 1em;",
67
+ " font-size: 0.9em;",
68
+ " background: #fff8e1;",
69
+ " color: #6b5300;",
70
+ " border-bottom: 1px solid #f0c36d;",
71
+ "}",
72
+ // The [hidden] content attribute only hides an element via the
73
+ // user-agent stylesheet's `[hidden] { display: none }` rule, and a
74
+ // normal-priority *author* rule always wins over a normal-priority UA
75
+ // rule regardless of selector specificity — so the unconditional
76
+ // `display: flex` above would otherwise keep the banner visible even
77
+ // after previewBannerScript sets `banner.hidden = true`.
78
+ ".ptx-preview-banner[hidden] {",
79
+ " display: none;",
80
+ "}",
81
+ ".ptx-preview-banner-text {",
82
+ " flex: 1 1 auto;",
83
+ "}",
84
+ ".ptx-preview-banner-dismiss {",
85
+ " flex: 0 0 auto;",
86
+ " background: transparent;",
87
+ " border: none;",
88
+ " font-size: 1.2em;",
89
+ " line-height: 1;",
90
+ " cursor: pointer;",
91
+ " color: inherit;",
92
+ " padding: 0 0.25em;",
93
+ "}",
94
+ "html.dark-mode .ptx-preview-banner {",
95
+ " background: #3a2f00;",
96
+ " color: #f2d27a;",
97
+ " border-bottom-color: #6b5300;",
98
+ "}",
99
+ ".ptx-preview-banner-restore {",
100
+ " position: fixed;",
101
+ " right: 0.5em;",
102
+ " bottom: 0.5em;",
103
+ " z-index: 1000;",
104
+ " background: transparent;",
105
+ " border: none;",
106
+ " padding: 0.15em 0.4em;",
107
+ " font-size: 0.75em;",
108
+ " color: inherit;",
109
+ " opacity: 0.45;",
110
+ " text-decoration: underline;",
111
+ " cursor: pointer;",
112
+ "}",
113
+ ".ptx-preview-banner-restore:hover {",
114
+ " opacity: 0.85;",
115
+ "}",
116
+ "</style>"
117
+ ].join(`
118
+ `);
119
+ }
120
+ function $e() {
121
+ return [
122
+ "<script>",
123
+ "(function () {",
124
+ " var KEY = " + JSON.stringify(ye) + ";",
125
+ ' var banner = document.getElementById("ptx-preview-banner");',
126
+ ' var restore = document.getElementById("ptx-preview-banner-restore");',
127
+ " if (!banner || !restore) { return; }",
128
+ // localStorage can throw (disabled cookies/storage, sandboxed iframe);
129
+ // fall back to always showing the banner rather than crashing the page.
130
+ " function isDismissed() {",
131
+ " try { return window.localStorage.getItem(KEY) === '1'; }",
132
+ " catch (e) { return false; }",
133
+ " }",
134
+ " function setDismissed(value) {",
135
+ " try {",
136
+ " if (value) { window.localStorage.setItem(KEY, '1'); }",
137
+ " else { window.localStorage.removeItem(KEY); }",
138
+ " } catch (e) {}",
139
+ " }",
140
+ " function apply(dismissed) {",
141
+ " banner.hidden = dismissed;",
142
+ " restore.hidden = !dismissed;",
143
+ " }",
144
+ " apply(isDismissed());",
145
+ ' var dismissBtn = banner.querySelector(".ptx-preview-banner-dismiss");',
146
+ " if (dismissBtn) {",
147
+ " dismissBtn.addEventListener('click', function () {",
148
+ " setDismissed(true);",
149
+ " apply(true);",
150
+ " });",
151
+ " }",
152
+ " restore.addEventListener('click', function () {",
153
+ " setDismissed(false);",
154
+ " apply(false);",
155
+ " });",
156
+ "})();",
157
+ "<\/script>"
158
+ ].join(`
159
+ `);
52
160
  }
53
- function Q(e, n) {
161
+ const Se = "<!--ptx-preview-banner-->", _e = "<!--/ptx-preview-banner-->", ke = /\n?<!--ptx-preview-banner-->[\s\S]*?<!--\/ptx-preview-banner-->/;
162
+ function Ie(e, n) {
163
+ const t = ke.exec(e), r = t ? e.slice(0, t.index) + e.slice(t.index + t[0].length) : e;
164
+ if (!/<body[^>]*>/i.test(r))
165
+ return r;
166
+ const i = `
167
+ ${Se}
168
+ ${Te()}
169
+ ${Ee(n.message)}
170
+ ${$e()}
171
+ ${_e}`;
172
+ return r.replace(/<body([^>]*)>/i, `<body$1>${i}`);
173
+ }
174
+ const De = "https://cdn.jsdelivr.net/npm/@pretextbook/pretext-html@0.7.0/assets";
175
+ let ee;
176
+ function Ct(e) {
177
+ ee = e.replace(/\/+$/, "");
178
+ }
179
+ function S() {
180
+ return ee ?? De;
181
+ }
182
+ function te(e, n) {
54
183
  return `${e.replace(/\/+$/, "")}/${n.replace(/^\/+/, "")}`;
55
184
  }
56
185
  const U = /* @__PURE__ */ new Map();
57
- function be(e) {
186
+ function Re(e) {
58
187
  return `${e.replace(/\/+$/, "")}-bundle.json`;
59
188
  }
60
- function ye(e) {
189
+ function Me(e) {
61
190
  let n = U.get(e);
62
191
  return n || (n = (async () => {
63
192
  try {
64
- const t = await fetch(be(e));
193
+ const t = await fetch(Re(e));
65
194
  if (!t.ok)
66
195
  return /* @__PURE__ */ new Map();
67
196
  const r = await t.json();
@@ -71,14 +200,14 @@ function ye(e) {
71
200
  }
72
201
  })(), U.set(e, n)), n;
73
202
  }
74
- function Ee(e) {
75
- return e === Q($(), "xsl");
203
+ function Le(e) {
204
+ return e === te(S(), "xsl");
76
205
  }
77
- async function ee(e, n) {
78
- if (Ee(e)) {
79
- const o = (await ye(e)).get(n.replace(/^\/+/, ""));
80
- if (o !== void 0)
81
- return new TextEncoder().encode(o);
206
+ async function ne(e, n) {
207
+ if (Le(e)) {
208
+ const s = (await Me(e)).get(n.replace(/^\/+/, ""));
209
+ if (s !== void 0)
210
+ return new TextEncoder().encode(s);
82
211
  }
83
212
  const t = `${e.replace(/\/+$/, "")}/`;
84
213
  let r;
@@ -100,7 +229,7 @@ async function ee(e, n) {
100
229
  return;
101
230
  }
102
231
  }
103
- async function P(e) {
232
+ async function B(e) {
104
233
  if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e))
105
234
  try {
106
235
  const n = await fetch(e);
@@ -109,13 +238,35 @@ async function P(e) {
109
238
  return;
110
239
  }
111
240
  }
112
- const C = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
113
- let L, xe = 0, ne = ee;
114
- function yt(e) {
115
- ne = e;
241
+ const Ae = "born-hidden-knowl", Be = /<details\b([^>]*)>(\s*)(?:<summary\b([^>]*)>)?/g;
242
+ function Ce(e) {
243
+ const n = /\bclass="([^"]*)"/.exec(e);
244
+ return n ? n[1].trim().split(/\s+/) : [];
245
+ }
246
+ function Pe(e) {
247
+ return /(^|\s)open(\s|=|$)/.test(e);
248
+ }
249
+ function V(e) {
250
+ return Pe(e) ? e : ` open${e}`;
251
+ }
252
+ function je(e) {
253
+ return e.replace(
254
+ Be,
255
+ (n, t, r, i) => {
256
+ if (!Ce(t).includes(Ae))
257
+ return n;
258
+ const s = `<details${V(t)}>`;
259
+ return i === void 0 ? `${s}${r}` : `${s}${r}<summary${V(i)}>`;
260
+ }
261
+ );
116
262
  }
117
- function Te(e, n) {
118
- const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, r = te.get(t);
263
+ const C = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
264
+ let L, Oe = 0, ie = ne;
265
+ function Pt(e) {
266
+ ie = e;
267
+ }
268
+ function We(e, n) {
269
+ const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, r = re.get(t);
119
270
  if (r !== void 0)
120
271
  return Promise.resolve(new Response(r, { status: 200 }));
121
272
  let i;
@@ -124,30 +275,30 @@ function Te(e, n) {
124
275
  } catch {
125
276
  i = "";
126
277
  }
127
- const o = C.get(i);
128
- return o !== void 0 ? $e(o, t) : L(e, n);
278
+ const s = C.get(i);
279
+ return s !== void 0 ? Ne(s, t) : L(e, n);
129
280
  }
130
- const Se = '<?xml version="1.0"?><pretext-preview-missing-file/>';
131
- async function $e(e, n) {
132
- const t = decodeURIComponent(new URL(n).pathname), r = await ne(e, t);
281
+ const Fe = '<?xml version="1.0"?><pretext-preview-missing-file/>';
282
+ async function Ne(e, n) {
283
+ const t = decodeURIComponent(new URL(n).pathname), r = await ie(e, t);
133
284
  if (r === void 0)
134
- return new Response(Se, { status: 200 });
285
+ return new Response(Fe, { status: 200 });
135
286
  const i = typeof r == "string" ? r : new Uint8Array(r);
136
287
  return new Response(i, { status: 200 });
137
288
  }
138
- function re() {
139
- L || (L = globalThis.fetch, globalThis.fetch = Te);
289
+ function se() {
290
+ L || (L = globalThis.fetch, globalThis.fetch = We);
140
291
  }
141
- function ie(e) {
142
- re();
143
- const n = `mnt${++xe}.ptx.invalid`;
292
+ function oe(e) {
293
+ se();
294
+ const n = `mnt${++Oe}.ptx.invalid`;
144
295
  return C.set(n, e), `http://${n}`;
145
296
  }
146
- function _e(e) {
297
+ function He(e) {
147
298
  C.delete(new URL(e).host);
148
299
  }
149
- function Re(e, n) {
150
- re(), te.set(e, n);
300
+ function Xe(e, n) {
301
+ se(), re.set(e, n);
151
302
  }
152
303
  const A = `<?xml version="1.0" encoding="UTF-8"?>
153
304
  <publication>
@@ -158,82 +309,82 @@ const A = `<?xml version="1.0" encoding="UTF-8"?>
158
309
  <platform portable="yes"/>
159
310
  </html>
160
311
  </publication>
161
- `, ke = ["theme", "style", "shell"];
312
+ `, Ue = ["theme", "style", "shell"];
162
313
  function w(e, n) {
163
314
  for (const t of e.children)
164
315
  if (t.type === "element" && t.name === n)
165
316
  return t;
166
317
  }
167
- function g(e, n) {
318
+ function v(e, n) {
168
319
  let t = w(e, n);
169
320
  return t || (t = { type: "element", name: n, attributes: {}, children: [] }, e.children.push(t)), t;
170
321
  }
171
- function Ie(e, n) {
322
+ function Ve(e, n) {
172
323
  const t = w(e, "css");
173
- if (t && ke.some((i) => t.attributes?.[i]))
324
+ if (t && Ue.some((i) => t.attributes?.[i]))
174
325
  return;
175
- const r = t ?? g(e, "css");
326
+ const r = t ?? v(e, "css");
176
327
  r.attributes = { ...r.attributes, theme: n };
177
328
  }
178
- function Me(e, n) {
329
+ function ze(e, n) {
179
330
  const t = w(e, "appearance");
180
331
  if (t?.attributes?.theme)
181
332
  return;
182
- const r = t ?? g(e, "appearance");
333
+ const r = t ?? v(e, "appearance");
183
334
  r.attributes = { ...r.attributes, theme: n };
184
335
  }
185
- function De(e) {
186
- const n = g(e, "resources");
336
+ function Je(e) {
337
+ const n = v(e, "resources");
187
338
  n.attributes = {
188
339
  ...n.attributes,
189
340
  host: "cdn",
190
341
  math: "online"
191
342
  };
192
343
  }
193
- function Le(e, n = {}) {
344
+ function Ke(e, n = {}) {
194
345
  const t = n.cssTheme?.trim(), r = n.revealTheme?.trim(), i = n.target === "slides";
195
346
  if (!e && !t && !i)
196
347
  return A;
197
- const o = E(e ?? A), s = w(o, "publication");
198
- if (!s)
348
+ const s = x(e ?? A), o = w(s, "publication");
349
+ if (!o)
199
350
  throw new Error(
200
351
  "Invalid publication file: no root <publication> element found"
201
352
  );
202
- const a = g(s, "html"), u = g(a, "platform");
203
- if (u.attributes = { ...u.attributes, portable: "yes" }, t && Ie(a, t), i) {
204
- const c = g(s, "revealjs");
205
- De(c), r && Me(c, r);
353
+ const a = v(o, "html"), d = v(a, "platform");
354
+ if (d.attributes = { ...d.attributes, portable: "yes" }, t && Ve(a, t), i) {
355
+ const l = v(o, "revealjs");
356
+ Je(l), r && ze(l, r);
206
357
  }
207
- return S(o);
358
+ return $(s);
208
359
  }
209
- function V(e) {
360
+ function z(e) {
210
361
  if (!(e === void 0 || e === "" || e.startsWith("/")))
211
362
  return e.endsWith("/") ? e : `${e}/`;
212
363
  }
213
- function Ae(e) {
214
- const n = E(e ?? A), t = w(n, "publication"), r = t && w(t, "source"), i = r && w(r, "directories"), o = V(
364
+ function Ye(e) {
365
+ const n = x(e ?? A), t = w(n, "publication"), r = t && w(t, "source"), i = r && w(r, "directories"), s = z(
215
366
  i?.attributes?.external ?? void 0
216
- ), s = V(
367
+ ), o = z(
217
368
  i?.attributes?.generated ?? void 0
218
369
  );
219
370
  return {
220
- external: o,
221
- generated: s,
222
- managed: o !== void 0 && s !== void 0
371
+ external: s,
372
+ generated: o,
373
+ managed: s !== void 0 && o !== void 0
223
374
  };
224
375
  }
225
- function Et(e) {
376
+ function jt(e) {
226
377
  return e === "slides" || e === "scroll";
227
378
  }
228
- const oe = 960, se = 700, Pe = 1, Ce = 0.04;
229
- function je(e) {
230
- const n = typeof e == "number" && isFinite(e) ? e : Pe, t = Math.min(1, Math.max(0.25, n));
379
+ const ae = 960, ce = 700, Ge = 1, qe = 0.04;
380
+ function Ze(e) {
381
+ const n = typeof e == "number" && isFinite(e) ? e : Ge, t = Math.min(1, Math.max(0.25, n));
231
382
  return {
232
- width: Math.round(oe / t),
233
- height: Math.round(se / t)
383
+ width: Math.round(ae / t),
384
+ height: Math.round(ce / t)
234
385
  };
235
386
  }
236
- function Fe(e) {
387
+ function Qe(e) {
237
388
  return {
238
389
  view: "scroll",
239
390
  scrollLayout: "compact",
@@ -243,11 +394,11 @@ function Fe(e) {
243
394
  controls: !1,
244
395
  controlsTutorial: !1,
245
396
  hash: !1,
246
- ...je(e.zoom),
247
- margin: Ce
397
+ ...Ze(e.zoom),
398
+ margin: qe
248
399
  };
249
400
  }
250
- function We() {
401
+ function et() {
251
402
  return {
252
403
  // Explicitly null rather than absent: the same page may have been
253
404
  // delivered in scroll view a moment ago, and an embedder that re-injects
@@ -259,11 +410,11 @@ function We() {
259
410
  // size with a percentage width renders its text far larger, relative to
260
411
  // the slide, than the same deck will on a projector. No zoom margin
261
412
  // though — presenting means filling whatever it is shown in.
262
- width: oe,
263
- height: se
413
+ width: ae,
414
+ height: ce
264
415
  };
265
416
  }
266
- const Be = [
417
+ const tt = [
267
418
  "<style>",
268
419
  ".reveal-viewport.reveal-scroll .scroll-page section {",
269
420
  " box-shadow: inset 0 0 0 calc(1px / var(--slide-scale, 1))",
@@ -271,14 +422,14 @@ const Be = [
271
422
  "}",
272
423
  "</style>"
273
424
  ].join(`
274
- `), Oe = [
425
+ `), nt = [
275
426
  " var paused = document.querySelectorAll('.reveal .fragment');",
276
427
  " for (var i = 0; i < paused.length; i++) {",
277
428
  " paused[i].classList.remove('fragment');",
278
429
  " }"
279
430
  ];
280
- function Xe(e, n = {}) {
281
- const t = e === "scroll" ? Fe(n) : We();
431
+ function rt(e, n = {}) {
432
+ const t = e === "scroll" ? Qe(n) : et();
282
433
  return [
283
434
  "<script>",
284
435
  "(function () {",
@@ -306,7 +457,7 @@ function Xe(e, n = {}) {
306
457
  // Inside the wrapper rather than at top level: this script sits in <head>,
307
458
  // where the slides have not been parsed yet, but the deck calls initialize
308
459
  // from the end of the document, by which time they have.
309
- ...e === "scroll" ? Oe : [],
460
+ ...e === "scroll" ? nt : [],
310
461
  " return initialize(merged);",
311
462
  " };",
312
463
  "})();",
@@ -314,38 +465,38 @@ function Xe(e, n = {}) {
314
465
  ].join(`
315
466
  `);
316
467
  }
317
- const He = /<script\b[^>]*\bsrc=["'][^"']*\breveal\.js["'][^>]*>\s*<\/script>/i, Ue = "<!--ptx-reveal-view-->", Ve = "<!--/ptx-reveal-view-->", Ne = /\n?<!--ptx-reveal-view-->[\s\S]*?<!--\/ptx-reveal-view-->/;
318
- function ze(e, n, t = {}) {
319
- const r = Ne.exec(e), i = r ? e.slice(0, r.index) + e.slice(r.index + r[0].length) : e, o = He.exec(i);
320
- if (!o)
468
+ const it = /<script\b[^>]*\bsrc=["'][^"']*\breveal\.js["'][^>]*>\s*<\/script>/i, st = "<!--ptx-reveal-view-->", ot = "<!--/ptx-reveal-view-->", at = /\n?<!--ptx-reveal-view-->[\s\S]*?<!--\/ptx-reveal-view-->/;
469
+ function ct(e, n, t = {}) {
470
+ const r = at.exec(e), i = r ? e.slice(0, r.index) + e.slice(r.index + r[0].length) : e, s = it.exec(i);
471
+ if (!s)
321
472
  return i;
322
- const s = o.index + o[0].length, a = `
323
- ${Ue}
324
- ${Be}
325
- ${Xe(n, t)}
326
- ${Ve}`;
327
- return i.slice(0, s) + a + i.slice(s);
328
- }
329
- const ae = "http://www.w3.org/2001/XInclude", N = 64;
330
- async function Je(e, n, t) {
331
- return e.includes("include") ? (await ce(e, n, t)).content : e;
332
- }
333
- async function ce(e, n, t) {
334
- const r = E(e), i = {
335
- projectDir: h(t),
336
- stack: [h(n)]
337
- }, o = await y(
473
+ const o = s.index + s[0].length, a = `
474
+ ${st}
475
+ ${tt}
476
+ ${rt(n, t)}
477
+ ${ot}`;
478
+ return i.slice(0, o) + a + i.slice(o);
479
+ }
480
+ const le = "http://www.w3.org/2001/XInclude", J = 64;
481
+ async function lt(e, n, t) {
482
+ return e.includes("include") ? (await de(e, n, t)).content : e;
483
+ }
484
+ async function de(e, n, t) {
485
+ const r = x(e), i = {
486
+ projectDir: p(t),
487
+ stack: [p(n)]
488
+ }, s = await y(
338
489
  r,
339
- b(h(n)),
490
+ g(p(n)),
340
491
  { "": "" },
341
492
  i
342
493
  );
343
- return { tree: r, content: o ? S(r) : e };
494
+ return { tree: r, content: s ? $(r) : e };
344
495
  }
345
- function Ge(e) {
496
+ function dt(e) {
346
497
  return e.data?.ptxIncludedFile;
347
498
  }
348
- function Ye(e, n) {
499
+ function ut(e, n) {
349
500
  const t = e.data ?? (e.data = {});
350
501
  t.ptxIncludedFile = n;
351
502
  }
@@ -355,66 +506,66 @@ function _(e, n) {
355
506
  (r === "xmlns" || r.startsWith("xmlns:")) && (t === e && (t = { ...e }), t[r === "xmlns" ? "" : r.slice(6)] = i ?? "");
356
507
  return t;
357
508
  }
358
- function le(e, n) {
509
+ function ue(e, n) {
359
510
  const t = e.name.indexOf(":"), r = t === -1 ? "" : e.name.slice(0, t);
360
- return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && n[r] === ae;
511
+ return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && n[r] === le;
361
512
  }
362
513
  async function y(e, n, t, r) {
363
514
  let i = !1;
364
- for (let o = 0; o < e.children.length; o++) {
365
- const s = e.children[o];
366
- if (s.type !== "element")
515
+ for (let s = 0; s < e.children.length; s++) {
516
+ const o = e.children[s];
517
+ if (o.type !== "element")
367
518
  continue;
368
- const a = _(t, s);
369
- if (le(s, a)) {
370
- const u = await ue(
371
- s,
519
+ const a = _(t, o);
520
+ if (ue(o, a)) {
521
+ const d = await fe(
522
+ o,
372
523
  n,
373
524
  a,
374
525
  r
375
526
  );
376
- e.children.splice(o, 1, ...u), o += u.length - 1, i = !0;
377
- } else await y(s, n, a, r) && (i = !0);
527
+ e.children.splice(s, 1, ...d), s += d.length - 1, i = !0;
528
+ } else await y(o, n, a, r) && (i = !0);
378
529
  }
379
530
  return i;
380
531
  }
381
- async function ue(e, n, t, r) {
532
+ async function fe(e, n, t, r) {
382
533
  const i = r.stack[r.stack.length - 1];
383
534
  if (e.attributes.xpointer)
384
535
  throw new Error(
385
536
  `xi:include with xpointer is not supported by the JS preview build (in ${i})`
386
537
  );
387
- const o = e.attributes.href;
388
- if (!o)
538
+ const s = e.attributes.href;
539
+ if (!s)
389
540
  throw new Error(`xi:include without href (in ${i})`);
390
- let s = o;
541
+ let o = s;
391
542
  try {
392
- s = decodeURIComponent(o);
543
+ o = decodeURIComponent(s);
393
544
  } catch {
394
545
  }
395
- const a = h(n, s);
396
- if (a !== r.projectDir && !a.startsWith(r.projectDir + D))
546
+ const a = p(n, o);
547
+ if (a !== r.projectDir && !a.startsWith(r.projectDir + M))
397
548
  throw new Error(
398
- `xi:include escapes the project directory: ${o} (in ${i})`
549
+ `xi:include escapes the project directory: ${s} (in ${i})`
399
550
  );
400
551
  if (r.stack.includes(a))
401
552
  throw new Error(
402
553
  `Circular xi:include: ${[...r.stack, a].join(" -> ")}`
403
554
  );
404
- if (r.stack.length >= N)
405
- throw new Error(`xi:include nesting exceeds ${N} levels`);
406
- const u = await P(a);
407
- if (u === void 0) {
408
- const f = qe(e, t);
555
+ if (r.stack.length >= J)
556
+ throw new Error(`xi:include nesting exceeds ${J} levels`);
557
+ const d = await B(a);
558
+ if (d === void 0) {
559
+ const f = pt(e, t);
409
560
  if (f)
410
561
  return await y(f, n, t, r), f.children;
411
- throw new Error(`xi:include target not found: ${o} (in ${i})`);
562
+ throw new Error(`xi:include target not found: ${s} (in ${i})`);
412
563
  }
413
564
  if (e.attributes.parse === "text")
414
- return [{ type: "text", value: u }];
415
- let c;
565
+ return [{ type: "text", value: d }];
566
+ let l;
416
567
  try {
417
- c = E(u);
568
+ l = x(d);
418
569
  } catch (f) {
419
570
  throw new Error(
420
571
  `Could not parse xi:include target ${a} as XML: ${f instanceof Error ? f.message : f}. (Included files must be well-formed, with a single root element.)`
@@ -422,48 +573,48 @@ async function ue(e, n, t, r) {
422
573
  }
423
574
  r.stack.push(a);
424
575
  try {
425
- await y(c, b(a), { "": "" }, r);
576
+ await y(l, g(a), { "": "" }, r);
426
577
  } finally {
427
578
  r.stack.pop();
428
579
  }
429
- const d = c.children.filter(
580
+ const u = l.children.filter(
430
581
  (f) => f.type === "element"
431
582
  );
432
- for (const f of d)
433
- Ye(f, a);
434
- return d;
583
+ for (const f of u)
584
+ ut(f, a);
585
+ return u;
435
586
  }
436
- function z(e) {
587
+ function K(e) {
437
588
  return e.name === "docinfo";
438
589
  }
439
- async function Ke(e, n, t) {
590
+ async function ft(e, n, t) {
440
591
  try {
441
- const i = E(e).children.find(
442
- (c) => c.type === "element"
592
+ const i = x(e).children.find(
593
+ (l) => l.type === "element"
443
594
  );
444
595
  if (!i)
445
596
  return;
446
- const o = h(n), s = b(o), a = {
447
- projectDir: h(t),
448
- stack: [o]
449
- }, u = _({ "": "" }, i);
450
- for (const c of i.children) {
451
- if (c.type !== "element")
597
+ const s = p(n), o = g(s), a = {
598
+ projectDir: p(t),
599
+ stack: [s]
600
+ }, d = _({ "": "" }, i);
601
+ for (const l of i.children) {
602
+ if (l.type !== "element")
452
603
  continue;
453
- const d = _(u, c);
454
- if (z(c))
455
- return await y(c, s, d, a), S(c);
456
- if (le(c, d)) {
457
- const p = (await ue(
458
- c,
459
- s,
460
- d,
604
+ const u = _(d, l);
605
+ if (K(l))
606
+ return await y(l, o, u, a), $(l);
607
+ if (ue(l, u)) {
608
+ const h = (await fe(
609
+ l,
610
+ o,
611
+ u,
461
612
  a
462
613
  )).find(
463
- (m) => m.type === "element" && z(m)
614
+ (m) => m.type === "element" && K(m)
464
615
  );
465
- if (p)
466
- return S(p);
616
+ if (h)
617
+ return $(h);
467
618
  continue;
468
619
  }
469
620
  break;
@@ -473,78 +624,78 @@ async function Ke(e, n, t) {
473
624
  return;
474
625
  }
475
626
  }
476
- function qe(e, n) {
627
+ function pt(e, n) {
477
628
  for (const t of e.children) {
478
629
  if (t.type !== "element")
479
630
  continue;
480
- const r = _(n, t), i = t.name.indexOf(":"), o = i === -1 ? "" : t.name.slice(0, i);
481
- if ((i === -1 ? t.name : t.name.slice(i + 1)) === "fallback" && r[o] === ae)
631
+ const r = _(n, t), i = t.name.indexOf(":"), s = i === -1 ? "" : t.name.slice(0, i);
632
+ if ((i === -1 ? t.name : t.name.slice(i + 1)) === "fallback" && r[s] === le)
482
633
  return t;
483
634
  }
484
635
  }
485
- function de(e) {
636
+ function pe(e) {
486
637
  return typeof e == "object" && e !== null && e.type === "element";
487
638
  }
488
- function Ze(e) {
639
+ function ht(e) {
489
640
  return /^(pf|xhtml):/.test(e.name);
490
641
  }
491
- function Qe(e, n, t) {
492
- const r = [], i = e.children.find(de);
642
+ function mt(e, n, t) {
643
+ const r = [], i = e.children.find(pe);
493
644
  if (i) {
494
- const o = t?.parentId ?? "root";
495
- fe(i, o, t?.position ?? 1, n, o, r);
645
+ const s = t?.parentId ?? "root";
646
+ he(i, s, t?.position ?? 1, n, s, r);
496
647
  }
497
648
  return r;
498
649
  }
499
- function fe(e, n, t, r, i, o) {
500
- const s = Ge(e) ?? r;
501
- let a, u;
502
- if (Ze(e))
503
- u = "root";
650
+ function he(e, n, t, r, i, s) {
651
+ const o = dt(e) ?? r;
652
+ let a, d;
653
+ if (ht(e))
654
+ d = "root";
504
655
  else {
505
- const d = e.attributes.label ?? e.attributes["xml:id"];
506
- a = d ?? `${n}-${t}`, o.push({
656
+ const u = e.attributes.label ?? e.attributes["xml:id"];
657
+ a = u ?? `${n}-${t}`, s.push({
507
658
  id: a,
508
- file: s,
659
+ file: o,
509
660
  line: e.position?.start.line ?? 1,
510
661
  column: e.position?.start.column ?? 1,
511
662
  endLine: e.position?.end.line ?? e.position?.start.line ?? 1,
512
663
  parent: i
513
- }), u = a;
664
+ }), d = a;
514
665
  }
515
- let c = 0;
516
- for (const d of e.children)
517
- de(d) && (c += 1, fe(
518
- d,
666
+ let l = 0;
667
+ for (const u of e.children)
668
+ pe(u) && (l += 1, he(
519
669
  u,
520
- c,
521
- s,
670
+ d,
671
+ l,
672
+ o,
522
673
  a ?? i,
523
- o
674
+ s
524
675
  ));
525
676
  }
526
- function xt(e, n) {
677
+ function Ot(e, n) {
527
678
  let t;
528
679
  for (const r of e)
529
680
  r.line <= n && (t = r);
530
681
  return t ?? e[0];
531
682
  }
532
- function et(e) {
683
+ function wt(e) {
533
684
  const n = e.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, " ");
534
685
  return /<\s*slide(?:show)?[\s/>]/.test(n) ? "slides" : "html";
535
686
  }
536
- const he = "pretext-html:set-theme";
537
- function Tt(e) {
687
+ const me = "pretext-html:set-theme";
688
+ function Wt(e) {
538
689
  return e === "dark" || e === "light" || e === "system";
539
690
  }
540
- function St(e) {
541
- return { type: he, theme: e };
691
+ function Ft(e) {
692
+ return { type: me, theme: e };
542
693
  }
543
- function tt(e) {
694
+ function vt(e) {
544
695
  return [
545
696
  "<script>",
546
697
  "(function () {",
547
- " var CFG = " + JSON.stringify({ msg: he, initial: e }) + ";",
698
+ " var CFG = " + JSON.stringify({ msg: me, initial: e }) + ";",
548
699
  // Where the last requested theme is remembered so it survives an in-place
549
700
  // document rewrite (same Window) and outranks the baked initial value.
550
701
  " var KEY = '__ptxPreviewTheme';",
@@ -614,243 +765,247 @@ function tt(e) {
614
765
  ].join(`
615
766
  `);
616
767
  }
617
- function nt(e, n) {
618
- const t = tt(n);
768
+ function bt(e, n) {
769
+ const t = vt(n);
619
770
  return /<head[^>]*>/i.test(e) ? e.replace(/<head([^>]*)>/i, `<head$1>
620
771
  ${t}`) : e;
621
772
  }
622
- function rt() {
623
- return Q($(), "xsl");
773
+ function gt() {
774
+ return te(S(), "xsl");
624
775
  }
625
- function it() {
776
+ function yt() {
626
777
  return "Suspending" in WebAssembly;
627
778
  }
628
- function ot() {
629
- if (!it())
779
+ function xt() {
780
+ if (!yt())
630
781
  throw new Error(
631
782
  "WebAssembly JSPI is not enabled. Run Node with --experimental-wasm-jspi (or use the pretext-html CLI, which re-launches itself with the flag)."
632
783
  );
633
784
  }
634
- function J(e) {
785
+ function Y(e) {
635
786
  return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((t) => `'${t}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
636
787
  }
637
- function st(e) {
788
+ function Et(e) {
638
789
  return e.replace(
639
790
  /from '\.\/(https:\/\/[^']+)'/g,
640
791
  (n, t) => `from '${t}'`
641
792
  );
642
793
  }
643
- const at = "https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@latest/dist/";
644
- function ct(e) {
794
+ const Tt = "https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@latest/dist/";
795
+ function $t(e) {
645
796
  return e.replace(
646
797
  /(<link\b[^>]*\bhref=["'])_static\//gi,
647
- `$1${at}_static/`
798
+ `$1${Tt}_static/`
648
799
  );
649
800
  }
650
- function lt(e) {
801
+ function St(e) {
651
802
  return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
652
803
  }
653
804
  async function G(e) {
654
- const n = await P(e);
805
+ const n = await B(e);
655
806
  if (n === void 0)
656
807
  throw new Error(
657
808
  `Could not read ${e}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
658
809
  );
659
810
  return n;
660
811
  }
661
- async function ut(e, n) {
662
- const t = h(e), r = await P(t);
812
+ async function _t(e, n) {
813
+ const t = p(e), r = await B(t);
663
814
  if (r !== void 0)
664
- return Ke(r, t, n);
815
+ return ft(r, t, n);
665
816
  }
666
- function dt(e, n, t, r) {
667
- const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), o = t === "slides" ? "slideshow" : n === "chapter" || n === "part" ? "book" : "article";
817
+ function kt(e, n, t, r) {
818
+ const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), s = t === "slides" ? "slideshow" : n === "chapter" || n === "part" ? "book" : "article";
668
819
  return `<pretext>
669
820
  ${r?.trim() ? `${r.trim()}
670
- ` : ""}<${o}>
821
+ ` : ""}<${s}>
671
822
  <title/>
672
823
  ${i}
673
- </${o}>
824
+ </${s}>
674
825
  </pretext>
675
826
  `;
676
827
  }
677
- let pe = !1;
678
- function ft(e) {
828
+ let we = !1;
829
+ function It(e) {
679
830
  return e instanceof Error && /\bAborted\(/.test(e.message);
680
831
  }
681
- function ht(e) {
832
+ function Dt(e) {
682
833
  return e instanceof Error && /memory access|out of bounds/i.test(e.message);
683
834
  }
684
- function pt() {
685
- if (pe)
835
+ function Rt() {
836
+ if (we)
686
837
  throw new Error(
687
838
  "The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
688
839
  );
689
840
  }
690
- function Y(e) {
691
- if (ft(e))
692
- throw pe = !0, new Error(
841
+ function q(e) {
842
+ if (It(e))
843
+ throw we = !0, new Error(
693
844
  "The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
694
845
  { cause: e }
695
846
  );
696
- if (ht(e))
847
+ if (Dt(e))
697
848
  throw new Error(
698
849
  "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.",
699
850
  { cause: e }
700
851
  );
701
852
  }
702
- let I;
703
- async function me() {
704
- return I || (I = (async () => {
853
+ let D;
854
+ async function ve() {
855
+ return D || (D = (async () => {
705
856
  const [e, n] = await Promise.all([
706
857
  import("@pretextbook/libxslt-wasm"),
707
858
  import("@pretextbook/libxslt-wasm/exslt")
708
859
  ]);
709
860
  return n.registerAll(), e;
710
- })()), I;
861
+ })()), D;
711
862
  }
712
- const M = /* @__PURE__ */ new Map(), mt = {
863
+ const R = /* @__PURE__ */ new Map(), Mt = {
713
864
  html: "preview-html.xsl",
714
865
  slides: "preview-revealjs.xsl"
715
866
  };
716
- async function wt(e, n) {
717
- const t = mt[n], r = `${n}\0${e}`;
718
- let i = M.get(r);
867
+ async function Lt(e, n) {
868
+ const t = Mt[n], r = `${n}\0${e}`;
869
+ let i = R.get(r);
719
870
  return i || (i = (async () => {
720
- const { XmlDocument: o, XsltStylesheet: s } = await me(), a = ie(e), u = await ee($(), `/${t}`);
721
- if (u === void 0)
871
+ const { XmlDocument: s, XsltStylesheet: o } = await ve(), a = oe(e), d = await ne(S(), `/${t}`);
872
+ if (d === void 0)
722
873
  throw new Error(
723
- `Could not read ${t} from ${$()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
874
+ `Could not read ${t} from ${S()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
724
875
  );
725
- const c = new TextDecoder().decode(u), d = await o.fromString(c, {
876
+ const l = new TextDecoder().decode(d), u = await s.fromString(l, {
726
877
  url: `${a}/${t}`,
727
878
  options: { noEnt: !0, dtdLoad: !0, huge: !0 }
728
879
  });
729
- return s.fromXmlDocument(d);
730
- })(), M.set(r, i), i.catch(() => M.delete(r))), i;
731
- }
732
- let K = Promise.resolve();
733
- function $t(e) {
734
- const n = K.then(
735
- () => q(e),
736
- () => q(e)
880
+ return o.fromXmlDocument(u);
881
+ })(), R.set(r, i), i.catch(() => R.delete(r))), i;
882
+ }
883
+ let Z = Promise.resolve();
884
+ function Nt(e) {
885
+ const n = Z.then(
886
+ () => Q(e),
887
+ () => Q(e)
737
888
  );
738
- return K = n.catch(() => {
889
+ return Z = n.catch(() => {
739
890
  }), n;
740
891
  }
741
- async function q(e) {
742
- ot(), pt();
743
- const { XmlDocument: n } = await me(), t = h(e.sourcePath), r = h(
744
- e.projectDir ?? b(t)
745
- ), i = e.sourceContent ?? await G(t), o = k(r, t);
746
- if (o.startsWith(".."))
892
+ async function Q(e) {
893
+ xt(), Rt();
894
+ const { XmlDocument: n } = await ve(), t = p(e.sourcePath), r = p(
895
+ e.projectDir ?? g(t)
896
+ ), i = e.sourceContent ?? await G(t), s = I(r, t);
897
+ if (s.startsWith(".."))
747
898
  throw new Error(
748
899
  `sourcePath (${t}) must live inside projectDir (${r})`
749
900
  );
750
- const s = k(
901
+ const o = I(
751
902
  r,
752
- h(e.mainSourcePath ?? t)
753
- ), a = s.startsWith("..") ? o : s, u = ie(r);
903
+ p(e.mainSourcePath ?? t)
904
+ ), a = o.startsWith("..") ? s : o, d = oe(r);
754
905
  try {
755
- let c, d = `${u}/__pretext-preview-publication.xml`;
906
+ let l, u = `${d}/__pretext-preview-publication.xml`;
756
907
  if (e.publicationPath) {
757
- const l = h(e.publicationPath);
758
- c = await G(l);
759
- const v = k(r, l);
760
- v.startsWith("..") || (d = `${u}/${v.split(D).join("/")}`);
908
+ const c = p(e.publicationPath);
909
+ l = await G(c);
910
+ const b = I(r, c);
911
+ b.startsWith("..") || (u = `${d}/${b.split(M).join("/")}`);
761
912
  }
762
- let f, p;
913
+ let f, h;
763
914
  if (e.sourceMap) {
764
- const l = await ce(
915
+ const c = await de(
765
916
  i,
766
917
  t,
767
918
  r
768
919
  );
769
- f = l.tree, p = l.content;
920
+ f = c.tree, h = c.content;
770
921
  } else
771
- p = await Je(
922
+ h = await lt(
772
923
  i,
773
924
  t,
774
925
  r
775
926
  );
776
- const m = e.target ?? et(p), we = await wt(e.xslDir ?? rt(), m), j = Le(c, {
927
+ const m = e.target ?? wt(h), be = await Lt(e.xslDir ?? gt(), m), P = Ke(l, {
777
928
  cssTheme: e.cssTheme,
778
929
  revealTheme: e.revealTheme,
779
930
  target: m
780
931
  });
781
- Re(d, j);
782
- const x = Ae(j), F = b(h(r, a)), W = x.external !== void 0 && x.generated !== void 0 ? {
783
- external: h(F, x.external),
784
- generated: h(F, x.generated)
785
- } : void 0, T = lt(p);
786
- let B = { parentId: "root", position: 1 };
932
+ Xe(u, P);
933
+ const E = Ye(P), j = g(p(r, a)), O = E.external !== void 0 && E.generated !== void 0 ? {
934
+ external: p(j, E.external),
935
+ generated: p(j, E.generated)
936
+ } : void 0, T = St(h);
937
+ let W = { parentId: "root", position: 1 };
787
938
  if (T !== "pretext" && T !== "mathbook")
788
939
  if (e.fragment) {
789
- const l = e.docinfo ?? (e.docinfoSourcePath ? await ut(e.docinfoSourcePath, r) : void 0);
790
- p = dt(
791
- p,
940
+ const c = e.docinfo ?? (e.docinfoSourcePath ? await _t(e.docinfoSourcePath, r) : void 0);
941
+ h = kt(
942
+ h,
792
943
  T,
793
944
  m,
794
- l
795
- ), B = { parentId: l?.trim() ? "root-1-2" : "root-1-1", position: 2 };
945
+ c
946
+ ), W = { parentId: c?.trim() ? "root-1-2" : "root-1-1", position: 2 };
796
947
  } else
797
948
  throw new Error(
798
949
  `The document root is <${T ?? "?"}>, not <pretext> — this looks like an xi:included fragment. Render the project's main source file instead, or pass the fragment option.`
799
950
  );
800
- const O = f ? Qe(f, t, B) : void 0, X = await n.fromString(p, {
801
- url: `${u}/${a.split(D).join("/")}`,
951
+ const F = f ? mt(f, t, W) : void 0, N = await n.fromString(h, {
952
+ url: `${d}/${a.split(M).join("/")}`,
802
953
  options: { noEnt: !0, dtdLoad: !0, huge: !0 }
803
954
  }), H = {
804
- publisher: J(d)
955
+ publisher: Y(u)
805
956
  };
806
- for (const [l, v] of Object.entries(e.stringParams ?? {}))
807
- H[l] = J(v);
808
- let R;
957
+ for (const [c, b] of Object.entries(e.stringParams ?? {}))
958
+ H[c] = Y(b);
959
+ let k;
809
960
  try {
810
- R = await we.apply(X, H);
811
- } catch (l) {
812
- throw Y(l), new Error(
961
+ k = await be.apply(N, H);
962
+ } catch (c) {
963
+ throw q(c), new Error(
813
964
  "PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
814
- { cause: l }
965
+ { cause: c }
815
966
  );
816
967
  } finally {
817
- X.delete();
968
+ N.delete();
818
969
  }
819
970
  try {
820
- let l = st(R.toHtmlString());
821
- return m === "slides" ? (l = ct(l), l = ze(l, e.revealView ?? "scroll", {
971
+ let c = Et(k.toHtmlString());
972
+ return (e.openKnowls ?? !0) && (c = je(c)), m === "slides" ? (c = $t(c), c = ct(c, e.revealView ?? "scroll", {
822
973
  zoom: e.revealZoom
823
- })) : e.theme && (l = nt(l, e.theme)), {
824
- html: l,
974
+ })) : e.theme && (c = bt(c, e.theme)), e.previewBanner && (c = Ie(c, e.previewBanner)), {
975
+ html: c,
825
976
  target: m,
826
- ...O ? { sourceMap: O } : {},
827
- ...W ? { assetDirs: W } : {}
977
+ ...F ? { sourceMap: F } : {},
978
+ ...O ? { assetDirs: O } : {}
828
979
  };
829
- } catch (l) {
830
- throw Y(l), l;
980
+ } catch (c) {
981
+ throw q(c), c;
831
982
  } finally {
832
- R.delete();
983
+ k.delete();
833
984
  }
834
985
  } finally {
835
- _e(u);
986
+ He(d);
836
987
  }
837
988
  }
838
989
  export {
839
- he as PREVIEW_THEME_MESSAGE,
840
- rt as defaultXslDir,
841
- et as detectRenderTarget,
842
- xt as findSourceMapEntry,
843
- Le as forcePortablePublication,
844
- ze as injectRevealBridge,
845
- nt as injectThemeBridge,
846
- it as isJspiAvailable,
847
- Tt as isPreviewTheme,
848
- Et as isRevealView,
849
- St as previewThemeMessage,
850
- $t as renderHtml,
851
- Xe as revealBridgeScript,
852
- bt as setAssetsBase,
853
- yt as setMountReader,
854
- tt as themeBridgeScript,
855
- J as xpathStringLiteral
990
+ ye as PREVIEW_BANNER_STORAGE_KEY,
991
+ me as PREVIEW_THEME_MESSAGE,
992
+ gt as defaultXslDir,
993
+ wt as detectRenderTarget,
994
+ Ot as findSourceMapEntry,
995
+ Ke as forcePortablePublication,
996
+ Ie as injectPreviewBanner,
997
+ ct as injectRevealBridge,
998
+ bt as injectThemeBridge,
999
+ yt as isJspiAvailable,
1000
+ Wt as isPreviewTheme,
1001
+ jt as isRevealView,
1002
+ je as openBornHiddenKnowls,
1003
+ $e as previewBannerScript,
1004
+ Ft as previewThemeMessage,
1005
+ Nt as renderHtml,
1006
+ rt as revealBridgeScript,
1007
+ Ct as setAssetsBase,
1008
+ Pt as setMountReader,
1009
+ vt as themeBridgeScript,
1010
+ Y as xpathStringLiteral
856
1011
  };