@pretextbook/pretext-html 0.5.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 +6 -0
- package/assets/preview-html.xsl +14 -0
- package/dist/{cli-DZsyZERX.js → cli-DF7XOWN7.js} +204 -174
- package/dist/cli.js +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +348 -325
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -16
- package/dist/knowls.d.ts +43 -0
- package/dist/renderer.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
import { fromXml as E } from "xast-util-from-xml";
|
|
2
|
-
import { toXml as
|
|
2
|
+
import { toXml as $ } from "xast-util-to-xml";
|
|
3
3
|
const D = "/";
|
|
4
|
-
function
|
|
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
20
|
function h(...e) {
|
|
21
|
-
let
|
|
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
31
|
function b(e) {
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
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
|
|
46
|
-
let
|
|
47
|
-
function
|
|
48
|
-
|
|
45
|
+
const be = "https://cdn.jsdelivr.net/npm/@pretextbook/pretext-html@0.6.0/assets";
|
|
46
|
+
let Q;
|
|
47
|
+
function St(e) {
|
|
48
|
+
Q = e.replace(/\/+$/, "");
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
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
56
|
const U = /* @__PURE__ */ new Map();
|
|
57
|
-
function
|
|
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
|
-
})(), U.set(e,
|
|
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
|
}
|
|
@@ -103,51 +103,73 @@ async function ee(e, n) {
|
|
|
103
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);
|
|
116
119
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
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
|
+
);
|
|
133
|
+
}
|
|
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
149
|
const o = C.get(i);
|
|
128
|
-
return o !== void 0 ?
|
|
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
|
-
L || (L = globalThis.fetch, globalThis.fetch =
|
|
160
|
+
function ie() {
|
|
161
|
+
L || (L = globalThis.fetch, globalThis.fetch = Re);
|
|
140
162
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
return C.set(
|
|
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
|
|
168
|
+
function Le(e) {
|
|
147
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
174
|
const A = `<?xml version="1.0" encoding="UTF-8"?>
|
|
153
175
|
<publication>
|
|
@@ -158,41 +180,41 @@ const A = `<?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 g(e,
|
|
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]))
|
|
174
196
|
return;
|
|
175
|
-
const r =
|
|
176
|
-
r.attributes = { ...r.attributes, theme:
|
|
197
|
+
const r = n ?? g(e, "css");
|
|
198
|
+
r.attributes = { ...r.attributes, theme: t };
|
|
177
199
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
200
|
+
function je(e, t) {
|
|
201
|
+
const n = w(e, "appearance");
|
|
202
|
+
if (n?.attributes?.theme)
|
|
181
203
|
return;
|
|
182
|
-
const r =
|
|
183
|
-
r.attributes = { ...r.attributes, theme:
|
|
204
|
+
const r = n ?? g(e, "appearance");
|
|
205
|
+
r.attributes = { ...r.attributes, theme: t };
|
|
184
206
|
}
|
|
185
|
-
function
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
...
|
|
207
|
+
function Fe(e) {
|
|
208
|
+
const t = g(e, "resources");
|
|
209
|
+
t.attributes = {
|
|
210
|
+
...t.attributes,
|
|
189
211
|
host: "cdn",
|
|
190
212
|
math: "online"
|
|
191
213
|
};
|
|
192
214
|
}
|
|
193
|
-
function
|
|
194
|
-
const
|
|
195
|
-
if (!e && !
|
|
215
|
+
function Oe(e, t = {}) {
|
|
216
|
+
const n = t.cssTheme?.trim(), r = t.revealTheme?.trim(), i = t.target === "slides";
|
|
217
|
+
if (!e && !n && !i)
|
|
196
218
|
return A;
|
|
197
219
|
const o = E(e ?? A), s = w(o, "publication");
|
|
198
220
|
if (!s)
|
|
@@ -200,18 +222,18 @@ function Le(e, n = {}) {
|
|
|
200
222
|
"Invalid publication file: no root <publication> element found"
|
|
201
223
|
);
|
|
202
224
|
const a = g(s, "html"), u = g(a, "platform");
|
|
203
|
-
if (u.attributes = { ...u.attributes, portable: "yes" },
|
|
204
|
-
const
|
|
205
|
-
|
|
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);
|
|
206
228
|
}
|
|
207
|
-
return
|
|
229
|
+
return $(o);
|
|
208
230
|
}
|
|
209
231
|
function V(e) {
|
|
210
232
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
211
233
|
return e.endsWith("/") ? e : `${e}/`;
|
|
212
234
|
}
|
|
213
|
-
function
|
|
214
|
-
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(
|
|
215
237
|
i?.attributes?.external ?? void 0
|
|
216
238
|
), s = V(
|
|
217
239
|
i?.attributes?.generated ?? void 0
|
|
@@ -222,18 +244,18 @@ function Ae(e) {
|
|
|
222
244
|
managed: o !== void 0 && s !== void 0
|
|
223
245
|
};
|
|
224
246
|
}
|
|
225
|
-
function
|
|
247
|
+
function kt(e) {
|
|
226
248
|
return e === "slides" || e === "scroll";
|
|
227
249
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
230
|
-
const
|
|
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));
|
|
231
253
|
return {
|
|
232
|
-
width: Math.round(
|
|
233
|
-
height: Math.round(
|
|
254
|
+
width: Math.round(se / n),
|
|
255
|
+
height: Math.round(ae / n)
|
|
234
256
|
};
|
|
235
257
|
}
|
|
236
|
-
function
|
|
258
|
+
function Ue(e) {
|
|
237
259
|
return {
|
|
238
260
|
view: "scroll",
|
|
239
261
|
scrollLayout: "compact",
|
|
@@ -243,11 +265,11 @@ function Fe(e) {
|
|
|
243
265
|
controls: !1,
|
|
244
266
|
controlsTutorial: !1,
|
|
245
267
|
hash: !1,
|
|
246
|
-
...
|
|
247
|
-
margin:
|
|
268
|
+
...He(e.zoom),
|
|
269
|
+
margin: Xe
|
|
248
270
|
};
|
|
249
271
|
}
|
|
250
|
-
function
|
|
272
|
+
function Ne() {
|
|
251
273
|
return {
|
|
252
274
|
// Explicitly null rather than absent: the same page may have been
|
|
253
275
|
// delivered in scroll view a moment ago, and an embedder that re-injects
|
|
@@ -259,11 +281,11 @@ function We() {
|
|
|
259
281
|
// size with a percentage width renders its text far larger, relative to
|
|
260
282
|
// the slide, than the same deck will on a projector. No zoom margin
|
|
261
283
|
// though — presenting means filling whatever it is shown in.
|
|
262
|
-
width:
|
|
263
|
-
height:
|
|
284
|
+
width: se,
|
|
285
|
+
height: ae
|
|
264
286
|
};
|
|
265
287
|
}
|
|
266
|
-
const
|
|
288
|
+
const Ve = [
|
|
267
289
|
"<style>",
|
|
268
290
|
".reveal-viewport.reveal-scroll .scroll-page section {",
|
|
269
291
|
" box-shadow: inset 0 0 0 calc(1px / var(--slide-scale, 1))",
|
|
@@ -271,18 +293,18 @@ const Be = [
|
|
|
271
293
|
"}",
|
|
272
294
|
"</style>"
|
|
273
295
|
].join(`
|
|
274
|
-
`),
|
|
296
|
+
`), ze = [
|
|
275
297
|
" var paused = document.querySelectorAll('.reveal .fragment');",
|
|
276
298
|
" for (var i = 0; i < paused.length; i++) {",
|
|
277
299
|
" paused[i].classList.remove('fragment');",
|
|
278
300
|
" }"
|
|
279
301
|
];
|
|
280
|
-
function
|
|
281
|
-
const
|
|
302
|
+
function Je(e, t = {}) {
|
|
303
|
+
const n = e === "scroll" ? Ue(t) : Ne();
|
|
282
304
|
return [
|
|
283
305
|
"<script>",
|
|
284
306
|
"(function () {",
|
|
285
|
-
" var OVERRIDES = " + JSON.stringify(
|
|
307
|
+
" var OVERRIDES = " + JSON.stringify(n) + ";",
|
|
286
308
|
// Nothing to wrap if reveal.js failed to load (offline, CDN blocked). The
|
|
287
309
|
// deck is broken either way, but throwing here would replace the browser's
|
|
288
310
|
// useful network error with a confusing one from an injected script.
|
|
@@ -306,7 +328,7 @@ function Xe(e, n = {}) {
|
|
|
306
328
|
// Inside the wrapper rather than at top level: this script sits in <head>,
|
|
307
329
|
// where the slides have not been parsed yet, but the deck calls initialize
|
|
308
330
|
// from the end of the document, by which time they have.
|
|
309
|
-
...e === "scroll" ?
|
|
331
|
+
...e === "scroll" ? ze : [],
|
|
310
332
|
" return initialize(merged);",
|
|
311
333
|
" };",
|
|
312
334
|
"})();",
|
|
@@ -314,71 +336,71 @@ function Xe(e, n = {}) {
|
|
|
314
336
|
].join(`
|
|
315
337
|
`);
|
|
316
338
|
}
|
|
317
|
-
const
|
|
318
|
-
function
|
|
319
|
-
const r =
|
|
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);
|
|
320
342
|
if (!o)
|
|
321
343
|
return i;
|
|
322
344
|
const s = o.index + o[0].length, a = `
|
|
323
|
-
${
|
|
324
|
-
${
|
|
325
|
-
${
|
|
326
|
-
${
|
|
345
|
+
${Ke}
|
|
346
|
+
${Ve}
|
|
347
|
+
${Je(t, n)}
|
|
348
|
+
${Ye}`;
|
|
327
349
|
return i.slice(0, s) + a + i.slice(s);
|
|
328
350
|
}
|
|
329
|
-
const
|
|
330
|
-
async function
|
|
331
|
-
return e.includes("include") ? (await
|
|
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;
|
|
332
354
|
}
|
|
333
|
-
async function
|
|
355
|
+
async function le(e, t, n) {
|
|
334
356
|
const r = E(e), i = {
|
|
335
|
-
projectDir: h(
|
|
336
|
-
stack: [h(
|
|
357
|
+
projectDir: h(n),
|
|
358
|
+
stack: [h(t)]
|
|
337
359
|
}, o = await y(
|
|
338
360
|
r,
|
|
339
|
-
b(h(
|
|
361
|
+
b(h(t)),
|
|
340
362
|
{ "": "" },
|
|
341
363
|
i
|
|
342
364
|
);
|
|
343
|
-
return { tree: r, content: o ?
|
|
365
|
+
return { tree: r, content: o ? $(r) : e };
|
|
344
366
|
}
|
|
345
|
-
function
|
|
367
|
+
function et(e) {
|
|
346
368
|
return e.data?.ptxIncludedFile;
|
|
347
369
|
}
|
|
348
|
-
function
|
|
349
|
-
const
|
|
350
|
-
|
|
370
|
+
function tt(e, t) {
|
|
371
|
+
const n = e.data ?? (e.data = {});
|
|
372
|
+
n.ptxIncludedFile = t;
|
|
351
373
|
}
|
|
352
|
-
function _(e,
|
|
353
|
-
let
|
|
354
|
-
for (const [r, i] of Object.entries(
|
|
355
|
-
(r === "xmlns" || r.startsWith("xmlns:")) && (
|
|
356
|
-
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;
|
|
357
379
|
}
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
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;
|
|
361
383
|
}
|
|
362
|
-
async function y(e,
|
|
384
|
+
async function y(e, t, n, r) {
|
|
363
385
|
let i = !1;
|
|
364
386
|
for (let o = 0; o < e.children.length; o++) {
|
|
365
387
|
const s = e.children[o];
|
|
366
388
|
if (s.type !== "element")
|
|
367
389
|
continue;
|
|
368
|
-
const a = _(
|
|
369
|
-
if (
|
|
370
|
-
const u = await
|
|
390
|
+
const a = _(n, s);
|
|
391
|
+
if (ue(s, a)) {
|
|
392
|
+
const u = await de(
|
|
371
393
|
s,
|
|
372
|
-
|
|
394
|
+
t,
|
|
373
395
|
a,
|
|
374
396
|
r
|
|
375
397
|
);
|
|
376
398
|
e.children.splice(o, 1, ...u), o += u.length - 1, i = !0;
|
|
377
|
-
} else await y(s,
|
|
399
|
+
} else await y(s, t, a, r) && (i = !0);
|
|
378
400
|
}
|
|
379
401
|
return i;
|
|
380
402
|
}
|
|
381
|
-
async function
|
|
403
|
+
async function de(e, t, n, r) {
|
|
382
404
|
const i = r.stack[r.stack.length - 1];
|
|
383
405
|
if (e.attributes.xpointer)
|
|
384
406
|
throw new Error(
|
|
@@ -392,7 +414,7 @@ async function ue(e, n, t, r) {
|
|
|
392
414
|
s = decodeURIComponent(o);
|
|
393
415
|
} catch {
|
|
394
416
|
}
|
|
395
|
-
const a = h(
|
|
417
|
+
const a = h(t, s);
|
|
396
418
|
if (a !== r.projectDir && !a.startsWith(r.projectDir + D))
|
|
397
419
|
throw new Error(
|
|
398
420
|
`xi:include escapes the project directory: ${o} (in ${i})`
|
|
@@ -401,20 +423,20 @@ async function ue(e, n, t, r) {
|
|
|
401
423
|
throw new Error(
|
|
402
424
|
`Circular xi:include: ${[...r.stack, a].join(" -> ")}`
|
|
403
425
|
);
|
|
404
|
-
if (r.stack.length >=
|
|
405
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
426
|
+
if (r.stack.length >= z)
|
|
427
|
+
throw new Error(`xi:include nesting exceeds ${z} levels`);
|
|
406
428
|
const u = await P(a);
|
|
407
429
|
if (u === void 0) {
|
|
408
|
-
const f =
|
|
430
|
+
const f = rt(e, n);
|
|
409
431
|
if (f)
|
|
410
|
-
return await y(f,
|
|
432
|
+
return await y(f, t, n, r), f.children;
|
|
411
433
|
throw new Error(`xi:include target not found: ${o} (in ${i})`);
|
|
412
434
|
}
|
|
413
435
|
if (e.attributes.parse === "text")
|
|
414
436
|
return [{ type: "text", value: u }];
|
|
415
|
-
let
|
|
437
|
+
let l;
|
|
416
438
|
try {
|
|
417
|
-
|
|
439
|
+
l = E(u);
|
|
418
440
|
} catch (f) {
|
|
419
441
|
throw new Error(
|
|
420
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.)`
|
|
@@ -422,48 +444,48 @@ async function ue(e, n, t, r) {
|
|
|
422
444
|
}
|
|
423
445
|
r.stack.push(a);
|
|
424
446
|
try {
|
|
425
|
-
await y(
|
|
447
|
+
await y(l, b(a), { "": "" }, r);
|
|
426
448
|
} finally {
|
|
427
449
|
r.stack.pop();
|
|
428
450
|
}
|
|
429
|
-
const d =
|
|
451
|
+
const d = l.children.filter(
|
|
430
452
|
(f) => f.type === "element"
|
|
431
453
|
);
|
|
432
454
|
for (const f of d)
|
|
433
|
-
|
|
455
|
+
tt(f, a);
|
|
434
456
|
return d;
|
|
435
457
|
}
|
|
436
|
-
function
|
|
458
|
+
function J(e) {
|
|
437
459
|
return e.name === "docinfo";
|
|
438
460
|
}
|
|
439
|
-
async function
|
|
461
|
+
async function nt(e, t, n) {
|
|
440
462
|
try {
|
|
441
463
|
const i = E(e).children.find(
|
|
442
|
-
(
|
|
464
|
+
(l) => l.type === "element"
|
|
443
465
|
);
|
|
444
466
|
if (!i)
|
|
445
467
|
return;
|
|
446
|
-
const o = h(
|
|
447
|
-
projectDir: h(
|
|
468
|
+
const o = h(t), s = b(o), a = {
|
|
469
|
+
projectDir: h(n),
|
|
448
470
|
stack: [o]
|
|
449
471
|
}, u = _({ "": "" }, i);
|
|
450
|
-
for (const
|
|
451
|
-
if (
|
|
472
|
+
for (const l of i.children) {
|
|
473
|
+
if (l.type !== "element")
|
|
452
474
|
continue;
|
|
453
|
-
const d = _(u,
|
|
454
|
-
if (
|
|
455
|
-
return await y(
|
|
456
|
-
if (
|
|
457
|
-
const p = (await
|
|
458
|
-
|
|
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,
|
|
459
481
|
s,
|
|
460
482
|
d,
|
|
461
483
|
a
|
|
462
484
|
)).find(
|
|
463
|
-
(m) => m.type === "element" &&
|
|
485
|
+
(m) => m.type === "element" && J(m)
|
|
464
486
|
);
|
|
465
487
|
if (p)
|
|
466
|
-
return
|
|
488
|
+
return $(p);
|
|
467
489
|
continue;
|
|
468
490
|
}
|
|
469
491
|
break;
|
|
@@ -473,37 +495,37 @@ async function Ke(e, n, t) {
|
|
|
473
495
|
return;
|
|
474
496
|
}
|
|
475
497
|
}
|
|
476
|
-
function
|
|
477
|
-
for (const
|
|
478
|
-
if (
|
|
498
|
+
function rt(e, t) {
|
|
499
|
+
for (const n of e.children) {
|
|
500
|
+
if (n.type !== "element")
|
|
479
501
|
continue;
|
|
480
|
-
const r = _(
|
|
481
|
-
if ((i === -1 ?
|
|
482
|
-
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;
|
|
483
505
|
}
|
|
484
506
|
}
|
|
485
|
-
function
|
|
507
|
+
function fe(e) {
|
|
486
508
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
487
509
|
}
|
|
488
|
-
function
|
|
510
|
+
function it(e) {
|
|
489
511
|
return /^(pf|xhtml):/.test(e.name);
|
|
490
512
|
}
|
|
491
|
-
function
|
|
492
|
-
const r = [], i = e.children.find(
|
|
513
|
+
function ot(e, t, n) {
|
|
514
|
+
const r = [], i = e.children.find(fe);
|
|
493
515
|
if (i) {
|
|
494
|
-
const o =
|
|
495
|
-
|
|
516
|
+
const o = n?.parentId ?? "root";
|
|
517
|
+
he(i, o, n?.position ?? 1, t, o, r);
|
|
496
518
|
}
|
|
497
519
|
return r;
|
|
498
520
|
}
|
|
499
|
-
function
|
|
500
|
-
const s =
|
|
521
|
+
function he(e, t, n, r, i, o) {
|
|
522
|
+
const s = et(e) ?? r;
|
|
501
523
|
let a, u;
|
|
502
|
-
if (
|
|
524
|
+
if (it(e))
|
|
503
525
|
u = "root";
|
|
504
526
|
else {
|
|
505
527
|
const d = e.attributes.label ?? e.attributes["xml:id"];
|
|
506
|
-
a = d ?? `${
|
|
528
|
+
a = d ?? `${t}-${n}`, o.push({
|
|
507
529
|
id: a,
|
|
508
530
|
file: s,
|
|
509
531
|
line: e.position?.start.line ?? 1,
|
|
@@ -512,39 +534,39 @@ function fe(e, n, t, r, i, o) {
|
|
|
512
534
|
parent: i
|
|
513
535
|
}), u = a;
|
|
514
536
|
}
|
|
515
|
-
let
|
|
537
|
+
let l = 0;
|
|
516
538
|
for (const d of e.children)
|
|
517
|
-
|
|
539
|
+
fe(d) && (l += 1, he(
|
|
518
540
|
d,
|
|
519
541
|
u,
|
|
520
|
-
|
|
542
|
+
l,
|
|
521
543
|
s,
|
|
522
544
|
a ?? i,
|
|
523
545
|
o
|
|
524
546
|
));
|
|
525
547
|
}
|
|
526
|
-
function
|
|
527
|
-
let
|
|
548
|
+
function It(e, t) {
|
|
549
|
+
let n;
|
|
528
550
|
for (const r of e)
|
|
529
|
-
r.line <=
|
|
530
|
-
return
|
|
551
|
+
r.line <= t && (n = r);
|
|
552
|
+
return n ?? e[0];
|
|
531
553
|
}
|
|
532
|
-
function
|
|
533
|
-
const
|
|
534
|
-
return /<\s*slide(?:show)?[\s/>]/.test(
|
|
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";
|
|
535
557
|
}
|
|
536
|
-
const
|
|
537
|
-
function
|
|
558
|
+
const pe = "pretext-html:set-theme";
|
|
559
|
+
function Rt(e) {
|
|
538
560
|
return e === "dark" || e === "light" || e === "system";
|
|
539
561
|
}
|
|
540
|
-
function
|
|
541
|
-
return { type:
|
|
562
|
+
function Mt(e) {
|
|
563
|
+
return { type: pe, theme: e };
|
|
542
564
|
}
|
|
543
|
-
function
|
|
565
|
+
function at(e) {
|
|
544
566
|
return [
|
|
545
567
|
"<script>",
|
|
546
568
|
"(function () {",
|
|
547
|
-
" var CFG = " + JSON.stringify({ msg:
|
|
569
|
+
" var CFG = " + JSON.stringify({ msg: pe, initial: e }) + ";",
|
|
548
570
|
// Where the last requested theme is remembered so it survives an in-place
|
|
549
571
|
// document rewrite (same Window) and outranks the baked initial value.
|
|
550
572
|
" var KEY = '__ptxPreviewTheme';",
|
|
@@ -614,57 +636,57 @@ function tt(e) {
|
|
|
614
636
|
].join(`
|
|
615
637
|
`);
|
|
616
638
|
}
|
|
617
|
-
function
|
|
618
|
-
const
|
|
639
|
+
function ct(e, t) {
|
|
640
|
+
const n = at(t);
|
|
619
641
|
return /<head[^>]*>/i.test(e) ? e.replace(/<head([^>]*)>/i, `<head$1>
|
|
620
|
-
${
|
|
642
|
+
${n}`) : e;
|
|
621
643
|
}
|
|
622
|
-
function
|
|
623
|
-
return
|
|
644
|
+
function lt() {
|
|
645
|
+
return ee(S(), "xsl");
|
|
624
646
|
}
|
|
625
|
-
function
|
|
647
|
+
function ut() {
|
|
626
648
|
return "Suspending" in WebAssembly;
|
|
627
649
|
}
|
|
628
|
-
function
|
|
629
|
-
if (!
|
|
650
|
+
function dt() {
|
|
651
|
+
if (!ut())
|
|
630
652
|
throw new Error(
|
|
631
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)."
|
|
632
654
|
);
|
|
633
655
|
}
|
|
634
|
-
function
|
|
635
|
-
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}'`;
|
|
636
658
|
}
|
|
637
|
-
function
|
|
659
|
+
function ft(e) {
|
|
638
660
|
return e.replace(
|
|
639
661
|
/from '\.\/(https:\/\/[^']+)'/g,
|
|
640
|
-
(
|
|
662
|
+
(t, n) => `from '${n}'`
|
|
641
663
|
);
|
|
642
664
|
}
|
|
643
|
-
const
|
|
644
|
-
function
|
|
665
|
+
const ht = "https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@latest/dist/";
|
|
666
|
+
function pt(e) {
|
|
645
667
|
return e.replace(
|
|
646
668
|
/(<link\b[^>]*\bhref=["'])_static\//gi,
|
|
647
|
-
`$1${
|
|
669
|
+
`$1${ht}_static/`
|
|
648
670
|
);
|
|
649
671
|
}
|
|
650
|
-
function
|
|
672
|
+
function mt(e) {
|
|
651
673
|
return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
|
|
652
674
|
}
|
|
653
|
-
async function
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
675
|
+
async function K(e) {
|
|
676
|
+
const t = await P(e);
|
|
677
|
+
if (t === void 0)
|
|
656
678
|
throw new Error(
|
|
657
679
|
`Could not read ${e}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
|
|
658
680
|
);
|
|
659
|
-
return
|
|
681
|
+
return t;
|
|
660
682
|
}
|
|
661
|
-
async function
|
|
662
|
-
const
|
|
683
|
+
async function wt(e, t) {
|
|
684
|
+
const n = h(e), r = await P(n);
|
|
663
685
|
if (r !== void 0)
|
|
664
|
-
return
|
|
686
|
+
return nt(r, n, t);
|
|
665
687
|
}
|
|
666
|
-
function
|
|
667
|
-
const i = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), o =
|
|
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";
|
|
668
690
|
return `<pretext>
|
|
669
691
|
${r?.trim() ? `${r.trim()}
|
|
670
692
|
` : ""}<${o}>
|
|
@@ -674,183 +696,184 @@ ${i}
|
|
|
674
696
|
</pretext>
|
|
675
697
|
`;
|
|
676
698
|
}
|
|
677
|
-
let
|
|
678
|
-
function
|
|
699
|
+
let me = !1;
|
|
700
|
+
function vt(e) {
|
|
679
701
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
680
702
|
}
|
|
681
|
-
function
|
|
703
|
+
function bt(e) {
|
|
682
704
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
683
705
|
}
|
|
684
|
-
function
|
|
685
|
-
if (
|
|
706
|
+
function yt() {
|
|
707
|
+
if (me)
|
|
686
708
|
throw new Error(
|
|
687
709
|
"The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
|
|
688
710
|
);
|
|
689
711
|
}
|
|
690
712
|
function Y(e) {
|
|
691
|
-
if (
|
|
692
|
-
throw
|
|
713
|
+
if (vt(e))
|
|
714
|
+
throw me = !0, new Error(
|
|
693
715
|
"The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
|
|
694
716
|
{ cause: e }
|
|
695
717
|
);
|
|
696
|
-
if (
|
|
718
|
+
if (bt(e))
|
|
697
719
|
throw new Error(
|
|
698
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.",
|
|
699
721
|
{ cause: e }
|
|
700
722
|
);
|
|
701
723
|
}
|
|
702
|
-
let
|
|
703
|
-
async function
|
|
704
|
-
return
|
|
705
|
-
const [e,
|
|
724
|
+
let R;
|
|
725
|
+
async function we() {
|
|
726
|
+
return R || (R = (async () => {
|
|
727
|
+
const [e, t] = await Promise.all([
|
|
706
728
|
import("@pretextbook/libxslt-wasm"),
|
|
707
729
|
import("@pretextbook/libxslt-wasm/exslt")
|
|
708
730
|
]);
|
|
709
|
-
return
|
|
710
|
-
})()),
|
|
731
|
+
return t.registerAll(), e;
|
|
732
|
+
})()), R;
|
|
711
733
|
}
|
|
712
|
-
const M = /* @__PURE__ */ new Map(),
|
|
734
|
+
const M = /* @__PURE__ */ new Map(), Et = {
|
|
713
735
|
html: "preview-html.xsl",
|
|
714
736
|
slides: "preview-revealjs.xsl"
|
|
715
737
|
};
|
|
716
|
-
async function
|
|
717
|
-
const
|
|
738
|
+
async function xt(e, t) {
|
|
739
|
+
const n = Et[t], r = `${t}\0${e}`;
|
|
718
740
|
let i = M.get(r);
|
|
719
741
|
return i || (i = (async () => {
|
|
720
|
-
const { XmlDocument: o, XsltStylesheet: s } = await
|
|
742
|
+
const { XmlDocument: o, XsltStylesheet: s } = await we(), a = oe(e), u = await te(S(), `/${n}`);
|
|
721
743
|
if (u === void 0)
|
|
722
744
|
throw new Error(
|
|
723
|
-
`Could not read ${
|
|
745
|
+
`Could not read ${n} from ${S()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
|
|
724
746
|
);
|
|
725
|
-
const
|
|
726
|
-
url: `${a}/${
|
|
747
|
+
const l = new TextDecoder().decode(u), d = await o.fromString(l, {
|
|
748
|
+
url: `${a}/${n}`,
|
|
727
749
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
728
750
|
});
|
|
729
751
|
return s.fromXmlDocument(d);
|
|
730
752
|
})(), M.set(r, i), i.catch(() => M.delete(r))), i;
|
|
731
753
|
}
|
|
732
|
-
let
|
|
733
|
-
function
|
|
734
|
-
const
|
|
735
|
-
() =>
|
|
736
|
-
() =>
|
|
754
|
+
let q = Promise.resolve();
|
|
755
|
+
function Dt(e) {
|
|
756
|
+
const t = q.then(
|
|
757
|
+
() => Z(e),
|
|
758
|
+
() => Z(e)
|
|
737
759
|
);
|
|
738
|
-
return
|
|
739
|
-
}),
|
|
740
|
-
}
|
|
741
|
-
async function
|
|
742
|
-
|
|
743
|
-
const { XmlDocument:
|
|
744
|
-
e.projectDir ?? b(
|
|
745
|
-
), i = e.sourceContent ?? await
|
|
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);
|
|
746
768
|
if (o.startsWith(".."))
|
|
747
769
|
throw new Error(
|
|
748
|
-
`sourcePath (${
|
|
770
|
+
`sourcePath (${n}) must live inside projectDir (${r})`
|
|
749
771
|
);
|
|
750
|
-
const s =
|
|
772
|
+
const s = I(
|
|
751
773
|
r,
|
|
752
|
-
h(e.mainSourcePath ??
|
|
753
|
-
), a = s.startsWith("..") ? o : s, u =
|
|
774
|
+
h(e.mainSourcePath ?? n)
|
|
775
|
+
), a = s.startsWith("..") ? o : s, u = oe(r);
|
|
754
776
|
try {
|
|
755
|
-
let
|
|
777
|
+
let l, d = `${u}/__pretext-preview-publication.xml`;
|
|
756
778
|
if (e.publicationPath) {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
const v =
|
|
779
|
+
const c = h(e.publicationPath);
|
|
780
|
+
l = await K(c);
|
|
781
|
+
const v = I(r, c);
|
|
760
782
|
v.startsWith("..") || (d = `${u}/${v.split(D).join("/")}`);
|
|
761
783
|
}
|
|
762
784
|
let f, p;
|
|
763
785
|
if (e.sourceMap) {
|
|
764
|
-
const
|
|
786
|
+
const c = await le(
|
|
765
787
|
i,
|
|
766
|
-
|
|
788
|
+
n,
|
|
767
789
|
r
|
|
768
790
|
);
|
|
769
|
-
f =
|
|
791
|
+
f = c.tree, p = c.content;
|
|
770
792
|
} else
|
|
771
|
-
p = await
|
|
793
|
+
p = await Qe(
|
|
772
794
|
i,
|
|
773
|
-
|
|
795
|
+
n,
|
|
774
796
|
r
|
|
775
797
|
);
|
|
776
|
-
const m = e.target ??
|
|
798
|
+
const m = e.target ?? st(p), ge = await xt(e.xslDir ?? lt(), m), j = Oe(l, {
|
|
777
799
|
cssTheme: e.cssTheme,
|
|
778
800
|
revealTheme: e.revealTheme,
|
|
779
801
|
target: m
|
|
780
802
|
});
|
|
781
|
-
|
|
782
|
-
const x =
|
|
803
|
+
Ae(d, j);
|
|
804
|
+
const x = We(j), F = b(h(r, a)), O = x.external !== void 0 && x.generated !== void 0 ? {
|
|
783
805
|
external: h(F, x.external),
|
|
784
806
|
generated: h(F, x.generated)
|
|
785
|
-
} : void 0, T =
|
|
786
|
-
let
|
|
807
|
+
} : void 0, T = mt(p);
|
|
808
|
+
let W = { parentId: "root", position: 1 };
|
|
787
809
|
if (T !== "pretext" && T !== "mathbook")
|
|
788
810
|
if (e.fragment) {
|
|
789
|
-
const
|
|
790
|
-
p =
|
|
811
|
+
const c = e.docinfo ?? (e.docinfoSourcePath ? await wt(e.docinfoSourcePath, r) : void 0);
|
|
812
|
+
p = gt(
|
|
791
813
|
p,
|
|
792
814
|
T,
|
|
793
815
|
m,
|
|
794
|
-
|
|
795
|
-
),
|
|
816
|
+
c
|
|
817
|
+
), W = { parentId: c?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
796
818
|
} else
|
|
797
819
|
throw new Error(
|
|
798
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.`
|
|
799
821
|
);
|
|
800
|
-
const
|
|
822
|
+
const B = f ? ot(f, n, W) : void 0, X = await t.fromString(p, {
|
|
801
823
|
url: `${u}/${a.split(D).join("/")}`,
|
|
802
824
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
803
825
|
}), H = {
|
|
804
|
-
publisher:
|
|
826
|
+
publisher: G(d)
|
|
805
827
|
};
|
|
806
|
-
for (const [
|
|
807
|
-
H[
|
|
808
|
-
let
|
|
828
|
+
for (const [c, v] of Object.entries(e.stringParams ?? {}))
|
|
829
|
+
H[c] = G(v);
|
|
830
|
+
let k;
|
|
809
831
|
try {
|
|
810
|
-
|
|
811
|
-
} catch (
|
|
812
|
-
throw Y(
|
|
832
|
+
k = await ge.apply(X, H);
|
|
833
|
+
} catch (c) {
|
|
834
|
+
throw Y(c), new Error(
|
|
813
835
|
"PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
|
|
814
|
-
{ cause:
|
|
836
|
+
{ cause: c }
|
|
815
837
|
);
|
|
816
838
|
} finally {
|
|
817
839
|
X.delete();
|
|
818
840
|
}
|
|
819
841
|
try {
|
|
820
|
-
let
|
|
821
|
-
return m === "slides" ? (
|
|
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", {
|
|
822
844
|
zoom: e.revealZoom
|
|
823
|
-
})) : e.theme && (
|
|
824
|
-
html:
|
|
845
|
+
})) : e.theme && (c = ct(c, e.theme)), {
|
|
846
|
+
html: c,
|
|
825
847
|
target: m,
|
|
826
|
-
...
|
|
827
|
-
...
|
|
848
|
+
...B ? { sourceMap: B } : {},
|
|
849
|
+
...O ? { assetDirs: O } : {}
|
|
828
850
|
};
|
|
829
|
-
} catch (
|
|
830
|
-
throw Y(
|
|
851
|
+
} catch (c) {
|
|
852
|
+
throw Y(c), c;
|
|
831
853
|
} finally {
|
|
832
|
-
|
|
854
|
+
k.delete();
|
|
833
855
|
}
|
|
834
856
|
} finally {
|
|
835
|
-
|
|
857
|
+
Le(u);
|
|
836
858
|
}
|
|
837
859
|
}
|
|
838
860
|
export {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
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
|
|
856
879
|
};
|