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