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