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