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