@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.
- package/README.md +6 -0
- package/assets/preview-html.xsl +14 -0
- package/assets/upstream.json +1 -1
- package/assets/xsl/LICENSE-pretext +1 -1
- package/assets/xsl/README.md +43 -25
- package/assets/xsl/entities.ent +4 -4
- package/assets/xsl/extract-asymptote.xsl +5 -5
- package/assets/xsl/extract-biblio-csl.xsl +1 -1
- package/assets/xsl/extract-datafile.xsl +1 -1
- package/assets/xsl/extract-dynamic.xsl +1 -1
- package/assets/xsl/extract-identity.xsl +5 -5
- package/assets/xsl/extract-interactive.xsl +1 -1
- package/assets/xsl/extract-latex-image.xsl +5 -5
- package/assets/xsl/extract-mermaid.xsl +1 -1
- package/assets/xsl/extract-mom.xsl +5 -5
- package/assets/xsl/extract-pg.xsl +1 -1
- package/assets/xsl/extract-prefigure.xsl +5 -5
- package/assets/xsl/extract-qrcode.xsl +1 -1
- package/assets/xsl/extract-runestone-page-template.xsl +1 -1
- package/assets/xsl/extract-sageplot.xsl +5 -5
- package/assets/xsl/extract-stack.xsl +1 -1
- package/assets/xsl/extract-trace.xsl +1 -1
- package/assets/xsl/extract-youtube.xsl +5 -5
- package/assets/xsl/latex/pretext-latex-AIM.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-chaos.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-guide.xsl +1 -1
- package/assets/xsl/localizations/README.md +25 -25
- package/assets/xsl/localizations/af-ZA.xml +1 -1
- package/assets/xsl/localizations/bg-BG.xml +1 -1
- package/assets/xsl/localizations/ca-ES.xml +1 -1
- package/assets/xsl/localizations/cs-CZ.xml +1 -1
- package/assets/xsl/localizations/de-DE.xml +1 -1
- package/assets/xsl/localizations/en-US.xml +1 -1
- package/assets/xsl/localizations/es-ES.xml +1 -1
- package/assets/xsl/localizations/fi-FI.xml +1 -1
- package/assets/xsl/localizations/fr-CA.xml +1 -1
- package/assets/xsl/localizations/fr-FR.xml +1 -1
- package/assets/xsl/localizations/hu-HU.xml +1 -1
- package/assets/xsl/localizations/it-IT.xml +1 -1
- package/assets/xsl/localizations/ku-CKB.xml +1 -1
- package/assets/xsl/localizations/localizations.xml +1 -1
- package/assets/xsl/localizations/nl-NL.xml +1 -1
- package/assets/xsl/localizations/pt-BR.xml +1 -1
- package/assets/xsl/localizations/pt-PT.xml +1 -1
- package/assets/xsl/localizations/zh-HANS.xml +1 -1
- package/assets/xsl/pretext-assembly.xsl +64 -1
- package/assets/xsl/pretext-basic-html.xsl +5 -5
- package/assets/xsl/pretext-braille-preprint.xsl +5 -5
- package/assets/xsl/pretext-common.xsl +104 -30
- package/assets/xsl/pretext-dynamic.xsl +1 -1
- package/assets/xsl/pretext-epub.xsl +90 -84
- package/assets/xsl/pretext-fo.xsl +1 -1
- package/assets/xsl/pretext-html.xsl +57 -34
- package/assets/xsl/pretext-json-manifest.xsl +1 -1
- package/assets/xsl/pretext-jupyter.xsl +5 -5
- package/assets/xsl/pretext-latex-classic.xsl +1 -1
- package/assets/xsl/pretext-latex-common.xsl +7 -5
- package/assets/xsl/pretext-latex.xsl +3 -3
- package/assets/xsl/pretext-litprog.xsl +9 -2
- package/assets/xsl/pretext-markdown.xsl +1 -1
- package/assets/xsl/pretext-numbers.xsl +1 -1
- package/assets/xsl/pretext-runestone-fitb.xsl +18 -0
- package/assets/xsl/pretext-runestone-static.xsl +13 -1
- package/assets/xsl/pretext-runestone.xsl +34 -6
- package/assets/xsl/pretext-sage-doctest.xsl +18 -0
- package/assets/xsl/pretext-solution-manual-latex.xsl +4 -4
- package/assets/xsl/pretext-text-utilities.xsl +1 -1
- package/assets/xsl/pretext-text.xsl +5 -5
- package/assets/xsl/pretext-units.xsl +5 -5
- package/assets/xsl/pretext-view-source.xsl +1 -1
- package/assets/xsl/pretext-ww-problem-sets.xsl +15 -12
- package/assets/xsl/publisher-variables.xsl +104 -36
- package/assets/xsl/support/README.md +19 -0
- package/assets/xsl/support/extract-math.xsl +1 -1
- package/assets/xsl/support/package-math.xsl +1 -1
- package/assets/xsl/support/play-button/README.md +3 -1
- package/assets/xsl/support/webpack_static_imports.xml +19 -0
- package/assets/xsl/tests/README.md +20 -1
- package/assets/xsl/tests/null.xml +19 -0
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +1 -1
- package/assets/xsl/utilities/README.md +27 -6
- package/assets/xsl/utilities/author-report.xsl +1 -1
- package/assets/xsl/utilities/fix-deprecations.xsl +5 -5
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +1 -1
- package/assets/xsl/utilities/report-publisher-variables.xsl +5 -5
- package/assets/xsl/xml-to-json.xsl +4 -4
- package/assets/xsl-bundle.json +1 -1
- package/dist/banner.d.ts +51 -0
- package/dist/{cli-DZsyZERX.js → cli-D0m0Ha1j.js} +358 -196
- package/dist/cli.js +2 -2
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.js +477 -322
- package/dist/index.d.ts +3 -0
- package/dist/index.js +25 -21
- package/dist/knowls.d.ts +43 -0
- package/dist/renderer.d.ts +26 -0
- package/package.json +1 -1
- package/assets/xsl/pretext-smc.xsl +0 -492
package/dist/index.browser.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { fromXml as
|
|
2
|
-
import { toXml as
|
|
3
|
-
const
|
|
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
|
|
9
|
-
if (!(!
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
r.length > 0 &&
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
39
|
-
const t =
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Z = e.replace(/\/+$/, "");
|
|
45
|
+
const ye = "ptxPreviewBannerDismissed", xe = "About live preview";
|
|
46
|
+
function X(e) {
|
|
47
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
49
48
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
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">×</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
|
-
|
|
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
|
|
186
|
+
function Re(e) {
|
|
58
187
|
return `${e.replace(/\/+$/, "")}-bundle.json`;
|
|
59
188
|
}
|
|
60
|
-
function
|
|
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(
|
|
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
|
|
75
|
-
return e ===
|
|
203
|
+
function Le(e) {
|
|
204
|
+
return e === te(S(), "xsl");
|
|
76
205
|
}
|
|
77
|
-
async function
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return new TextEncoder().encode(
|
|
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
|
|
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
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
|
128
|
-
return
|
|
278
|
+
const s = C.get(i);
|
|
279
|
+
return s !== void 0 ? Ne(s, t) : L(e, n);
|
|
129
280
|
}
|
|
130
|
-
const
|
|
131
|
-
async function
|
|
132
|
-
const t = decodeURIComponent(new URL(n).pathname), r = await
|
|
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(
|
|
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
|
|
139
|
-
L || (L = globalThis.fetch, globalThis.fetch =
|
|
289
|
+
function se() {
|
|
290
|
+
L || (L = globalThis.fetch, globalThis.fetch = We);
|
|
140
291
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
const n = `mnt${++
|
|
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
|
|
297
|
+
function He(e) {
|
|
147
298
|
C.delete(new URL(e).host);
|
|
148
299
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
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
|
-
`,
|
|
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
|
|
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
|
|
322
|
+
function Ve(e, n) {
|
|
172
323
|
const t = w(e, "css");
|
|
173
|
-
if (t &&
|
|
324
|
+
if (t && Ue.some((i) => t.attributes?.[i]))
|
|
174
325
|
return;
|
|
175
|
-
const r = t ??
|
|
326
|
+
const r = t ?? v(e, "css");
|
|
176
327
|
r.attributes = { ...r.attributes, theme: n };
|
|
177
328
|
}
|
|
178
|
-
function
|
|
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 ??
|
|
333
|
+
const r = t ?? v(e, "appearance");
|
|
183
334
|
r.attributes = { ...r.attributes, theme: n };
|
|
184
335
|
}
|
|
185
|
-
function
|
|
186
|
-
const n =
|
|
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
|
|
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
|
|
198
|
-
if (!
|
|
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 =
|
|
203
|
-
if (
|
|
204
|
-
const
|
|
205
|
-
|
|
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
|
|
358
|
+
return $(s);
|
|
208
359
|
}
|
|
209
|
-
function
|
|
360
|
+
function z(e) {
|
|
210
361
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
211
362
|
return e.endsWith("/") ? e : `${e}/`;
|
|
212
363
|
}
|
|
213
|
-
function
|
|
214
|
-
const n =
|
|
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
|
-
),
|
|
367
|
+
), o = z(
|
|
217
368
|
i?.attributes?.generated ?? void 0
|
|
218
369
|
);
|
|
219
370
|
return {
|
|
220
|
-
external:
|
|
221
|
-
generated:
|
|
222
|
-
managed:
|
|
371
|
+
external: s,
|
|
372
|
+
generated: o,
|
|
373
|
+
managed: s !== void 0 && o !== void 0
|
|
223
374
|
};
|
|
224
375
|
}
|
|
225
|
-
function
|
|
376
|
+
function jt(e) {
|
|
226
377
|
return e === "slides" || e === "scroll";
|
|
227
378
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
230
|
-
const n = typeof e == "number" && isFinite(e) ? e :
|
|
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(
|
|
233
|
-
height: Math.round(
|
|
383
|
+
width: Math.round(ae / t),
|
|
384
|
+
height: Math.round(ce / t)
|
|
234
385
|
};
|
|
235
386
|
}
|
|
236
|
-
function
|
|
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
|
-
...
|
|
247
|
-
margin:
|
|
397
|
+
...Ze(e.zoom),
|
|
398
|
+
margin: qe
|
|
248
399
|
};
|
|
249
400
|
}
|
|
250
|
-
function
|
|
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:
|
|
263
|
-
height:
|
|
413
|
+
width: ae,
|
|
414
|
+
height: ce
|
|
264
415
|
};
|
|
265
416
|
}
|
|
266
|
-
const
|
|
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
|
-
`),
|
|
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
|
|
281
|
-
const t = e === "scroll" ?
|
|
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" ?
|
|
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
|
|
318
|
-
function
|
|
319
|
-
const r =
|
|
320
|
-
if (!
|
|
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
|
|
323
|
-
${
|
|
324
|
-
${
|
|
325
|
-
${
|
|
326
|
-
${
|
|
327
|
-
return i.slice(0,
|
|
328
|
-
}
|
|
329
|
-
const
|
|
330
|
-
async function
|
|
331
|
-
return e.includes("include") ? (await
|
|
332
|
-
}
|
|
333
|
-
async function
|
|
334
|
-
const r =
|
|
335
|
-
projectDir:
|
|
336
|
-
stack: [
|
|
337
|
-
},
|
|
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
|
-
|
|
490
|
+
g(p(n)),
|
|
340
491
|
{ "": "" },
|
|
341
492
|
i
|
|
342
493
|
);
|
|
343
|
-
return { tree: r, content:
|
|
494
|
+
return { tree: r, content: s ? $(r) : e };
|
|
344
495
|
}
|
|
345
|
-
function
|
|
496
|
+
function dt(e) {
|
|
346
497
|
return e.data?.ptxIncludedFile;
|
|
347
498
|
}
|
|
348
|
-
function
|
|
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
|
|
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] ===
|
|
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
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
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,
|
|
369
|
-
if (
|
|
370
|
-
const
|
|
371
|
-
|
|
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(
|
|
377
|
-
} else await y(
|
|
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
|
|
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
|
|
388
|
-
if (!
|
|
538
|
+
const s = e.attributes.href;
|
|
539
|
+
if (!s)
|
|
389
540
|
throw new Error(`xi:include without href (in ${i})`);
|
|
390
|
-
let
|
|
541
|
+
let o = s;
|
|
391
542
|
try {
|
|
392
|
-
|
|
543
|
+
o = decodeURIComponent(s);
|
|
393
544
|
} catch {
|
|
394
545
|
}
|
|
395
|
-
const a =
|
|
396
|
-
if (a !== r.projectDir && !a.startsWith(r.projectDir +
|
|
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: ${
|
|
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 >=
|
|
405
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
408
|
-
const f =
|
|
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: ${
|
|
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:
|
|
415
|
-
let
|
|
565
|
+
return [{ type: "text", value: d }];
|
|
566
|
+
let l;
|
|
416
567
|
try {
|
|
417
|
-
|
|
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(
|
|
576
|
+
await y(l, g(a), { "": "" }, r);
|
|
426
577
|
} finally {
|
|
427
578
|
r.stack.pop();
|
|
428
579
|
}
|
|
429
|
-
const
|
|
580
|
+
const u = l.children.filter(
|
|
430
581
|
(f) => f.type === "element"
|
|
431
582
|
);
|
|
432
|
-
for (const f of
|
|
433
|
-
|
|
434
|
-
return
|
|
583
|
+
for (const f of u)
|
|
584
|
+
ut(f, a);
|
|
585
|
+
return u;
|
|
435
586
|
}
|
|
436
|
-
function
|
|
587
|
+
function K(e) {
|
|
437
588
|
return e.name === "docinfo";
|
|
438
589
|
}
|
|
439
|
-
async function
|
|
590
|
+
async function ft(e, n, t) {
|
|
440
591
|
try {
|
|
441
|
-
const i =
|
|
442
|
-
(
|
|
592
|
+
const i = x(e).children.find(
|
|
593
|
+
(l) => l.type === "element"
|
|
443
594
|
);
|
|
444
595
|
if (!i)
|
|
445
596
|
return;
|
|
446
|
-
const
|
|
447
|
-
projectDir:
|
|
448
|
-
stack: [
|
|
449
|
-
},
|
|
450
|
-
for (const
|
|
451
|
-
if (
|
|
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
|
|
454
|
-
if (
|
|
455
|
-
return await y(
|
|
456
|
-
if (
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
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" &&
|
|
614
|
+
(m) => m.type === "element" && K(m)
|
|
464
615
|
);
|
|
465
|
-
if (
|
|
466
|
-
return
|
|
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
|
|
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(":"),
|
|
481
|
-
if ((i === -1 ? t.name : t.name.slice(i + 1)) === "fallback" && r[
|
|
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
|
|
636
|
+
function pe(e) {
|
|
486
637
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
487
638
|
}
|
|
488
|
-
function
|
|
639
|
+
function ht(e) {
|
|
489
640
|
return /^(pf|xhtml):/.test(e.name);
|
|
490
641
|
}
|
|
491
|
-
function
|
|
492
|
-
const r = [], i = e.children.find(
|
|
642
|
+
function mt(e, n, t) {
|
|
643
|
+
const r = [], i = e.children.find(pe);
|
|
493
644
|
if (i) {
|
|
494
|
-
const
|
|
495
|
-
|
|
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
|
|
500
|
-
const
|
|
501
|
-
let a,
|
|
502
|
-
if (
|
|
503
|
-
|
|
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
|
|
506
|
-
a =
|
|
656
|
+
const u = e.attributes.label ?? e.attributes["xml:id"];
|
|
657
|
+
a = u ?? `${n}-${t}`, s.push({
|
|
507
658
|
id: a,
|
|
508
|
-
file:
|
|
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
|
-
}),
|
|
664
|
+
}), d = a;
|
|
514
665
|
}
|
|
515
|
-
let
|
|
516
|
-
for (const
|
|
517
|
-
|
|
518
|
-
d,
|
|
666
|
+
let l = 0;
|
|
667
|
+
for (const u of e.children)
|
|
668
|
+
pe(u) && (l += 1, he(
|
|
519
669
|
u,
|
|
520
|
-
|
|
521
|
-
|
|
670
|
+
d,
|
|
671
|
+
l,
|
|
672
|
+
o,
|
|
522
673
|
a ?? i,
|
|
523
|
-
|
|
674
|
+
s
|
|
524
675
|
));
|
|
525
676
|
}
|
|
526
|
-
function
|
|
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
|
|
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
|
|
537
|
-
function
|
|
687
|
+
const me = "pretext-html:set-theme";
|
|
688
|
+
function Wt(e) {
|
|
538
689
|
return e === "dark" || e === "light" || e === "system";
|
|
539
690
|
}
|
|
540
|
-
function
|
|
541
|
-
return { type:
|
|
691
|
+
function Ft(e) {
|
|
692
|
+
return { type: me, theme: e };
|
|
542
693
|
}
|
|
543
|
-
function
|
|
694
|
+
function vt(e) {
|
|
544
695
|
return [
|
|
545
696
|
"<script>",
|
|
546
697
|
"(function () {",
|
|
547
|
-
" var CFG = " + JSON.stringify({ msg:
|
|
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
|
|
618
|
-
const t =
|
|
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
|
|
623
|
-
return
|
|
773
|
+
function gt() {
|
|
774
|
+
return te(S(), "xsl");
|
|
624
775
|
}
|
|
625
|
-
function
|
|
776
|
+
function yt() {
|
|
626
777
|
return "Suspending" in WebAssembly;
|
|
627
778
|
}
|
|
628
|
-
function
|
|
629
|
-
if (!
|
|
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
|
|
785
|
+
function Y(e) {
|
|
635
786
|
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((t) => `'${t}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
|
|
636
787
|
}
|
|
637
|
-
function
|
|
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
|
|
644
|
-
function
|
|
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${
|
|
798
|
+
`$1${Tt}_static/`
|
|
648
799
|
);
|
|
649
800
|
}
|
|
650
|
-
function
|
|
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
|
|
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
|
|
662
|
-
const t =
|
|
812
|
+
async function _t(e, n) {
|
|
813
|
+
const t = p(e), r = await B(t);
|
|
663
814
|
if (r !== void 0)
|
|
664
|
-
return
|
|
815
|
+
return ft(r, t, n);
|
|
665
816
|
}
|
|
666
|
-
function
|
|
667
|
-
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""),
|
|
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
|
-
` : ""}<${
|
|
821
|
+
` : ""}<${s}>
|
|
671
822
|
<title/>
|
|
672
823
|
${i}
|
|
673
|
-
</${
|
|
824
|
+
</${s}>
|
|
674
825
|
</pretext>
|
|
675
826
|
`;
|
|
676
827
|
}
|
|
677
|
-
let
|
|
678
|
-
function
|
|
828
|
+
let we = !1;
|
|
829
|
+
function It(e) {
|
|
679
830
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
680
831
|
}
|
|
681
|
-
function
|
|
832
|
+
function Dt(e) {
|
|
682
833
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
683
834
|
}
|
|
684
|
-
function
|
|
685
|
-
if (
|
|
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
|
|
691
|
-
if (
|
|
692
|
-
throw
|
|
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 (
|
|
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
|
|
703
|
-
async function
|
|
704
|
-
return
|
|
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
|
-
})()),
|
|
861
|
+
})()), D;
|
|
711
862
|
}
|
|
712
|
-
const
|
|
863
|
+
const R = /* @__PURE__ */ new Map(), Mt = {
|
|
713
864
|
html: "preview-html.xsl",
|
|
714
865
|
slides: "preview-revealjs.xsl"
|
|
715
866
|
};
|
|
716
|
-
async function
|
|
717
|
-
const t =
|
|
718
|
-
let i =
|
|
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:
|
|
721
|
-
if (
|
|
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 ${
|
|
874
|
+
`Could not read ${t} from ${S()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
|
|
724
875
|
);
|
|
725
|
-
const
|
|
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
|
|
730
|
-
})(),
|
|
731
|
-
}
|
|
732
|
-
let
|
|
733
|
-
function
|
|
734
|
-
const n =
|
|
735
|
-
() =>
|
|
736
|
-
() =>
|
|
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
|
|
889
|
+
return Z = n.catch(() => {
|
|
739
890
|
}), n;
|
|
740
891
|
}
|
|
741
|
-
async function
|
|
742
|
-
|
|
743
|
-
const { XmlDocument: n } = await
|
|
744
|
-
e.projectDir ??
|
|
745
|
-
), i = e.sourceContent ?? await G(t),
|
|
746
|
-
if (
|
|
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
|
|
901
|
+
const o = I(
|
|
751
902
|
r,
|
|
752
|
-
|
|
753
|
-
), a =
|
|
903
|
+
p(e.mainSourcePath ?? t)
|
|
904
|
+
), a = o.startsWith("..") ? s : o, d = oe(r);
|
|
754
905
|
try {
|
|
755
|
-
let
|
|
906
|
+
let l, u = `${d}/__pretext-preview-publication.xml`;
|
|
756
907
|
if (e.publicationPath) {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
|
|
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,
|
|
913
|
+
let f, h;
|
|
763
914
|
if (e.sourceMap) {
|
|
764
|
-
const
|
|
915
|
+
const c = await de(
|
|
765
916
|
i,
|
|
766
917
|
t,
|
|
767
918
|
r
|
|
768
919
|
);
|
|
769
|
-
f =
|
|
920
|
+
f = c.tree, h = c.content;
|
|
770
921
|
} else
|
|
771
|
-
|
|
922
|
+
h = await lt(
|
|
772
923
|
i,
|
|
773
924
|
t,
|
|
774
925
|
r
|
|
775
926
|
);
|
|
776
|
-
const m = e.target ??
|
|
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
|
-
|
|
782
|
-
const
|
|
783
|
-
external:
|
|
784
|
-
generated:
|
|
785
|
-
} : void 0, T =
|
|
786
|
-
let
|
|
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
|
|
790
|
-
|
|
791
|
-
|
|
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
|
-
|
|
795
|
-
),
|
|
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
|
|
801
|
-
url: `${
|
|
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:
|
|
955
|
+
publisher: Y(u)
|
|
805
956
|
};
|
|
806
|
-
for (const [
|
|
807
|
-
H[
|
|
808
|
-
let
|
|
957
|
+
for (const [c, b] of Object.entries(e.stringParams ?? {}))
|
|
958
|
+
H[c] = Y(b);
|
|
959
|
+
let k;
|
|
809
960
|
try {
|
|
810
|
-
|
|
811
|
-
} catch (
|
|
812
|
-
throw
|
|
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:
|
|
965
|
+
{ cause: c }
|
|
815
966
|
);
|
|
816
967
|
} finally {
|
|
817
|
-
|
|
968
|
+
N.delete();
|
|
818
969
|
}
|
|
819
970
|
try {
|
|
820
|
-
let
|
|
821
|
-
return m === "slides" ? (
|
|
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 && (
|
|
824
|
-
html:
|
|
974
|
+
})) : e.theme && (c = bt(c, e.theme)), e.previewBanner && (c = Ie(c, e.previewBanner)), {
|
|
975
|
+
html: c,
|
|
825
976
|
target: m,
|
|
826
|
-
...
|
|
827
|
-
...
|
|
977
|
+
...F ? { sourceMap: F } : {},
|
|
978
|
+
...O ? { assetDirs: O } : {}
|
|
828
979
|
};
|
|
829
|
-
} catch (
|
|
830
|
-
throw
|
|
980
|
+
} catch (c) {
|
|
981
|
+
throw q(c), c;
|
|
831
982
|
} finally {
|
|
832
|
-
|
|
983
|
+
k.delete();
|
|
833
984
|
}
|
|
834
985
|
} finally {
|
|
835
|
-
|
|
986
|
+
He(d);
|
|
836
987
|
}
|
|
837
988
|
}
|
|
838
989
|
export {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
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
|
};
|