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