@pretextbook/pretext-html 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/assets/upstream.json +1 -1
- package/assets/xsl/LICENSE-pretext +1 -1
- package/assets/xsl/README.md +19 -0
- package/assets/xsl/entities.ent +15 -4
- package/assets/xsl/extract-asymptote.xsl +5 -5
- package/assets/xsl/extract-biblio-csl.xsl +1 -1
- package/assets/xsl/extract-datafile.xsl +1 -1
- package/assets/xsl/extract-dynamic.xsl +1 -1
- package/assets/xsl/extract-identity.xsl +5 -5
- package/assets/xsl/extract-interactive.xsl +1 -1
- package/assets/xsl/extract-latex-image.xsl +5 -5
- package/assets/xsl/extract-mermaid.xsl +1 -1
- package/assets/xsl/extract-mom.xsl +5 -5
- package/assets/xsl/extract-pg.xsl +1 -1
- package/assets/xsl/extract-prefigure.xsl +5 -5
- package/assets/xsl/extract-qrcode.xsl +1 -1
- package/assets/xsl/extract-runestone-page-template.xsl +1 -1
- package/assets/xsl/extract-sageplot.xsl +5 -5
- package/assets/xsl/extract-stack.xsl +1 -1
- package/assets/xsl/extract-trace.xsl +1 -1
- package/assets/xsl/extract-youtube.xsl +5 -5
- package/assets/xsl/latex/pretext-latex-AIM.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-chaos.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-guide.xsl +1 -1
- package/assets/xsl/localizations/README.md +1 -1
- package/assets/xsl/localizations/af-ZA.xml +1 -1
- package/assets/xsl/localizations/bg-BG.xml +1 -1
- package/assets/xsl/localizations/ca-ES.xml +1 -1
- package/assets/xsl/localizations/cs-CZ.xml +1 -1
- package/assets/xsl/localizations/de-DE.xml +1 -1
- package/assets/xsl/localizations/en-US.xml +1 -1
- package/assets/xsl/localizations/es-ES.xml +1 -1
- package/assets/xsl/localizations/fi-FI.xml +1 -1
- package/assets/xsl/localizations/fr-CA.xml +1 -1
- package/assets/xsl/localizations/fr-FR.xml +1 -1
- package/assets/xsl/localizations/hu-HU.xml +1 -1
- package/assets/xsl/localizations/it-IT.xml +1 -1
- package/assets/xsl/localizations/ku-CKB.xml +1 -1
- package/assets/xsl/localizations/localizations.xml +1 -1
- package/assets/xsl/localizations/nl-NL.xml +1 -1
- package/assets/xsl/localizations/pt-BR.xml +1 -1
- package/assets/xsl/localizations/pt-PT.xml +1 -1
- package/assets/xsl/localizations/zh-HANS.xml +1 -1
- package/assets/xsl/pretext-assembly.xsl +66 -7
- package/assets/xsl/pretext-basic-html.xsl +5 -5
- package/assets/xsl/pretext-braille-preprint.xsl +5 -5
- package/assets/xsl/pretext-common.xsl +123 -32
- package/assets/xsl/pretext-dynamic.xsl +1 -1
- package/assets/xsl/pretext-epub.xsl +94 -85
- package/assets/xsl/pretext-fo.xsl +18 -20
- package/assets/xsl/pretext-html.xsl +260 -74
- package/assets/xsl/pretext-json-manifest.xsl +1 -1
- package/assets/xsl/pretext-jupyter.xsl +5 -5
- package/assets/xsl/pretext-latex-classic.xsl +1 -1
- package/assets/xsl/pretext-latex-common.xsl +35 -22
- package/assets/xsl/pretext-latex.xsl +3 -3
- package/assets/xsl/pretext-litprog.xsl +9 -2
- package/assets/xsl/pretext-markdown.xsl +1 -1
- package/assets/xsl/pretext-numbers.xsl +1 -1
- package/assets/xsl/pretext-revealjs.xsl +1 -3
- package/assets/xsl/pretext-runestone-fitb.xsl +18 -0
- package/assets/xsl/pretext-runestone-static.xsl +13 -1
- package/assets/xsl/pretext-runestone.xsl +39 -27
- package/assets/xsl/pretext-sage-doctest.xsl +18 -0
- package/assets/xsl/pretext-solution-manual-latex.xsl +4 -4
- package/assets/xsl/pretext-text-utilities.xsl +1 -1
- package/assets/xsl/pretext-text.xsl +5 -5
- package/assets/xsl/pretext-units.xsl +5 -5
- package/assets/xsl/pretext-view-source.xsl +1 -1
- package/assets/xsl/pretext-ww-problem-sets.xsl +15 -12
- package/assets/xsl/publisher-variables.xsl +160 -133
- package/assets/xsl/support/README.md +19 -0
- package/assets/xsl/support/extract-math.xsl +1 -1
- package/assets/xsl/support/package-math.xsl +1 -1
- package/assets/xsl/support/webpack_static_imports.xml +19 -0
- package/assets/xsl/tests/README.md +19 -0
- package/assets/xsl/tests/null.xml +19 -0
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +1 -1
- package/assets/xsl/utilities/README.md +19 -0
- package/assets/xsl/utilities/author-report.xsl +1 -1
- package/assets/xsl/utilities/fix-deprecations.xsl +5 -5
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +1 -1
- package/assets/xsl/utilities/report-publisher-variables.xsl +5 -5
- package/assets/xsl/xml-to-json.xsl +4 -4
- package/assets/xsl-bundle.json +1 -1
- package/dist/banner.d.ts +51 -0
- package/dist/{cli-DF7XOWN7.js → cli-Bcn4t3B1.js} +387 -240
- package/dist/cli.js +2 -2
- package/dist/html-static.d.ts +20 -0
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.js +554 -407
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -25
- package/dist/renderer.d.ts +18 -1
- package/package.json +2 -1
- package/assets/xsl/pretext-smc.xsl +0 -492
|
@@ -1,12 +1,141 @@
|
|
|
1
|
-
import { readFile as
|
|
2
|
-
import * as
|
|
1
|
+
import { readFile as M, writeFile as W } from "node:fs/promises";
|
|
2
|
+
import * as v from "node:process";
|
|
3
3
|
import * as l from "node:path";
|
|
4
|
-
import { fileURLToPath as
|
|
5
|
-
import { fromXml as
|
|
6
|
-
import { toXml as
|
|
7
|
-
import { injectRevealBridge as
|
|
8
|
-
import { injectThemeBridge as
|
|
9
|
-
|
|
4
|
+
import { fileURLToPath as we } from "node:url";
|
|
5
|
+
import { fromXml as y } from "xast-util-from-xml";
|
|
6
|
+
import { toXml as S } from "xast-util-to-xml";
|
|
7
|
+
import { injectRevealBridge as be } from "./reveal.js";
|
|
8
|
+
import { injectThemeBridge as ve } from "./theme.js";
|
|
9
|
+
const ge = "ptxPreviewBannerDismissed", xe = "About live preview";
|
|
10
|
+
function H(e) {
|
|
11
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
12
|
+
}
|
|
13
|
+
function ye(e) {
|
|
14
|
+
return [
|
|
15
|
+
'<div id="ptx-preview-banner" class="ptx-preview-banner" role="note">',
|
|
16
|
+
` <span class="ptx-preview-banner-text">${H(e)}</span>`,
|
|
17
|
+
' <button type="button" class="ptx-preview-banner-dismiss" aria-label="Dismiss">×</button>',
|
|
18
|
+
"</div>",
|
|
19
|
+
`<button type="button" id="ptx-preview-banner-restore" class="ptx-preview-banner-restore" hidden>${H(xe)}</button>`
|
|
20
|
+
].join(`
|
|
21
|
+
`);
|
|
22
|
+
}
|
|
23
|
+
function Ee() {
|
|
24
|
+
return [
|
|
25
|
+
"<style>",
|
|
26
|
+
".ptx-preview-banner {",
|
|
27
|
+
" display: flex;",
|
|
28
|
+
" align-items: center;",
|
|
29
|
+
" gap: 0.75em;",
|
|
30
|
+
" padding: 0.5em 1em;",
|
|
31
|
+
" font-size: 0.9em;",
|
|
32
|
+
" background: #fff8e1;",
|
|
33
|
+
" color: #6b5300;",
|
|
34
|
+
" border-bottom: 1px solid #f0c36d;",
|
|
35
|
+
"}",
|
|
36
|
+
// The [hidden] content attribute only hides an element via the
|
|
37
|
+
// user-agent stylesheet's `[hidden] { display: none }` rule, and a
|
|
38
|
+
// normal-priority *author* rule always wins over a normal-priority UA
|
|
39
|
+
// rule regardless of selector specificity — so the unconditional
|
|
40
|
+
// `display: flex` above would otherwise keep the banner visible even
|
|
41
|
+
// after previewBannerScript sets `banner.hidden = true`.
|
|
42
|
+
".ptx-preview-banner[hidden] {",
|
|
43
|
+
" display: none;",
|
|
44
|
+
"}",
|
|
45
|
+
".ptx-preview-banner-text {",
|
|
46
|
+
" flex: 1 1 auto;",
|
|
47
|
+
"}",
|
|
48
|
+
".ptx-preview-banner-dismiss {",
|
|
49
|
+
" flex: 0 0 auto;",
|
|
50
|
+
" background: transparent;",
|
|
51
|
+
" border: none;",
|
|
52
|
+
" font-size: 1.2em;",
|
|
53
|
+
" line-height: 1;",
|
|
54
|
+
" cursor: pointer;",
|
|
55
|
+
" color: inherit;",
|
|
56
|
+
" padding: 0 0.25em;",
|
|
57
|
+
"}",
|
|
58
|
+
"html.dark-mode .ptx-preview-banner {",
|
|
59
|
+
" background: #3a2f00;",
|
|
60
|
+
" color: #f2d27a;",
|
|
61
|
+
" border-bottom-color: #6b5300;",
|
|
62
|
+
"}",
|
|
63
|
+
".ptx-preview-banner-restore {",
|
|
64
|
+
" position: fixed;",
|
|
65
|
+
" right: 0.5em;",
|
|
66
|
+
" bottom: 0.5em;",
|
|
67
|
+
" z-index: 1000;",
|
|
68
|
+
" background: transparent;",
|
|
69
|
+
" border: none;",
|
|
70
|
+
" padding: 0.15em 0.4em;",
|
|
71
|
+
" font-size: 0.75em;",
|
|
72
|
+
" color: inherit;",
|
|
73
|
+
" opacity: 0.45;",
|
|
74
|
+
" text-decoration: underline;",
|
|
75
|
+
" cursor: pointer;",
|
|
76
|
+
"}",
|
|
77
|
+
".ptx-preview-banner-restore:hover {",
|
|
78
|
+
" opacity: 0.85;",
|
|
79
|
+
"}",
|
|
80
|
+
"</style>"
|
|
81
|
+
].join(`
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
function Te() {
|
|
85
|
+
return [
|
|
86
|
+
"<script>",
|
|
87
|
+
"(function () {",
|
|
88
|
+
" var KEY = " + JSON.stringify(ge) + ";",
|
|
89
|
+
' var banner = document.getElementById("ptx-preview-banner");',
|
|
90
|
+
' var restore = document.getElementById("ptx-preview-banner-restore");',
|
|
91
|
+
" if (!banner || !restore) { return; }",
|
|
92
|
+
// localStorage can throw (disabled cookies/storage, sandboxed iframe);
|
|
93
|
+
// fall back to always showing the banner rather than crashing the page.
|
|
94
|
+
" function isDismissed() {",
|
|
95
|
+
" try { return window.localStorage.getItem(KEY) === '1'; }",
|
|
96
|
+
" catch (e) { return false; }",
|
|
97
|
+
" }",
|
|
98
|
+
" function setDismissed(value) {",
|
|
99
|
+
" try {",
|
|
100
|
+
" if (value) { window.localStorage.setItem(KEY, '1'); }",
|
|
101
|
+
" else { window.localStorage.removeItem(KEY); }",
|
|
102
|
+
" } catch (e) {}",
|
|
103
|
+
" }",
|
|
104
|
+
" function apply(dismissed) {",
|
|
105
|
+
" banner.hidden = dismissed;",
|
|
106
|
+
" restore.hidden = !dismissed;",
|
|
107
|
+
" }",
|
|
108
|
+
" apply(isDismissed());",
|
|
109
|
+
' var dismissBtn = banner.querySelector(".ptx-preview-banner-dismiss");',
|
|
110
|
+
" if (dismissBtn) {",
|
|
111
|
+
" dismissBtn.addEventListener('click', function () {",
|
|
112
|
+
" setDismissed(true);",
|
|
113
|
+
" apply(true);",
|
|
114
|
+
" });",
|
|
115
|
+
" }",
|
|
116
|
+
" restore.addEventListener('click', function () {",
|
|
117
|
+
" setDismissed(false);",
|
|
118
|
+
" apply(false);",
|
|
119
|
+
" });",
|
|
120
|
+
"})();",
|
|
121
|
+
"<\/script>"
|
|
122
|
+
].join(`
|
|
123
|
+
`);
|
|
124
|
+
}
|
|
125
|
+
const Se = "<!--ptx-preview-banner-->", $e = "<!--/ptx-preview-banner-->", ke = /\n?<!--ptx-preview-banner-->[\s\S]*?<!--\/ptx-preview-banner-->/;
|
|
126
|
+
function Pe(e, r) {
|
|
127
|
+
const t = ke.exec(e), n = t ? e.slice(0, t.index) + e.slice(t.index + t[0].length) : e;
|
|
128
|
+
if (!/<body[^>]*>/i.test(n))
|
|
129
|
+
return n;
|
|
130
|
+
const o = `
|
|
131
|
+
${Se}
|
|
132
|
+
${Ee()}
|
|
133
|
+
${ye(r.message)}
|
|
134
|
+
${Te()}
|
|
135
|
+
${$e}`;
|
|
136
|
+
return n.replace(/<body([^>]*)>/i, `<body$1>${o}`);
|
|
137
|
+
}
|
|
138
|
+
async function ee(e, r) {
|
|
10
139
|
const t = l.resolve(e), n = l.resolve(t, `.${l.posix.normalize(r)}`);
|
|
11
140
|
if (n !== t && !n.startsWith(t + l.sep)) {
|
|
12
141
|
console.error(
|
|
@@ -15,57 +144,64 @@ async function Q(e, r) {
|
|
|
15
144
|
return;
|
|
16
145
|
}
|
|
17
146
|
try {
|
|
18
|
-
return new Uint8Array(await
|
|
147
|
+
return new Uint8Array(await M(n));
|
|
19
148
|
} catch {
|
|
20
149
|
return;
|
|
21
150
|
}
|
|
22
151
|
}
|
|
23
|
-
async function
|
|
152
|
+
async function B(e) {
|
|
24
153
|
try {
|
|
25
|
-
return await
|
|
154
|
+
return await M(e, "utf8");
|
|
26
155
|
} catch {
|
|
27
156
|
return;
|
|
28
157
|
}
|
|
29
158
|
}
|
|
30
|
-
let
|
|
31
|
-
function
|
|
32
|
-
|
|
159
|
+
let te;
|
|
160
|
+
function kt(e) {
|
|
161
|
+
te = e;
|
|
33
162
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
163
|
+
function j() {
|
|
164
|
+
return te ?? process.env.PRETEXT_HTML_ASSETS ?? l.resolve(l.dirname(we(import.meta.url)), "..", "assets");
|
|
36
165
|
}
|
|
37
|
-
function
|
|
166
|
+
function Ie(e, r) {
|
|
38
167
|
return l.join(e, r);
|
|
39
168
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
169
|
+
const re = "2.46.0", De = "8.2.1", Re = [
|
|
170
|
+
"prefix-runtime.ed2cce180827a7ad.bundle.js",
|
|
171
|
+
"prefix-926.5c7038c8ef173faf.bundle.js",
|
|
172
|
+
"prefix-runestone.1f660864c47fc762.bundle.js"
|
|
173
|
+
], je = [
|
|
174
|
+
"prefix-926.229729d09512acc9.css",
|
|
175
|
+
"prefix-runestone.8086b62682b271d1.css"
|
|
176
|
+
], Le = "born-hidden-knowl", Ae = /<details\b([^>]*)>(\s*)(?:<summary\b([^>]*)>)?/g;
|
|
177
|
+
function Me(e) {
|
|
42
178
|
const r = /\bclass="([^"]*)"/.exec(e);
|
|
43
179
|
return r ? r[1].trim().split(/\s+/) : [];
|
|
44
180
|
}
|
|
45
|
-
function
|
|
181
|
+
function Be(e) {
|
|
46
182
|
return /(^|\s)open(\s|=|$)/.test(e);
|
|
47
183
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
184
|
+
function J(e) {
|
|
185
|
+
return Be(e) ? e : ` open${e}`;
|
|
50
186
|
}
|
|
51
|
-
function
|
|
187
|
+
function _e(e) {
|
|
52
188
|
return e.replace(
|
|
53
|
-
|
|
189
|
+
Ae,
|
|
54
190
|
(r, t, n, o) => {
|
|
55
|
-
if (!
|
|
191
|
+
if (!Me(t).includes(Le))
|
|
56
192
|
return r;
|
|
57
|
-
const s = `<details${
|
|
58
|
-
return o === void 0 ? `${s}${n}` : `${s}${n}<summary${
|
|
193
|
+
const s = `<details${J(t)}>`;
|
|
194
|
+
return o === void 0 ? `${s}${n}` : `${s}${n}<summary${J(o)}>`;
|
|
59
195
|
}
|
|
60
196
|
);
|
|
61
197
|
}
|
|
62
|
-
const
|
|
63
|
-
let L,
|
|
64
|
-
function
|
|
65
|
-
|
|
198
|
+
const _ = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Map();
|
|
199
|
+
let L, Ce = 0, oe = ee;
|
|
200
|
+
function Pt(e) {
|
|
201
|
+
oe = e;
|
|
66
202
|
}
|
|
67
|
-
function
|
|
68
|
-
const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, n =
|
|
203
|
+
function Oe(e, r) {
|
|
204
|
+
const t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, n = ne.get(t);
|
|
69
205
|
if (n !== void 0)
|
|
70
206
|
return Promise.resolve(new Response(n, { status: 200 }));
|
|
71
207
|
let o;
|
|
@@ -74,32 +210,32 @@ function Ee(e, r) {
|
|
|
74
210
|
} catch {
|
|
75
211
|
o = "";
|
|
76
212
|
}
|
|
77
|
-
const s =
|
|
78
|
-
return s !== void 0 ?
|
|
213
|
+
const s = _.get(o);
|
|
214
|
+
return s !== void 0 ? Ne(s, t) : L(e, r);
|
|
79
215
|
}
|
|
80
|
-
const
|
|
81
|
-
async function
|
|
82
|
-
const t = decodeURIComponent(new URL(r).pathname), n = await
|
|
216
|
+
const Xe = '<?xml version="1.0"?><pretext-preview-missing-file/>';
|
|
217
|
+
async function Ne(e, r) {
|
|
218
|
+
const t = decodeURIComponent(new URL(r).pathname), n = await oe(e, t);
|
|
83
219
|
if (n === void 0)
|
|
84
|
-
return new Response(
|
|
220
|
+
return new Response(Xe, { status: 200 });
|
|
85
221
|
const o = typeof n == "string" ? n : new Uint8Array(n);
|
|
86
222
|
return new Response(o, { status: 200 });
|
|
87
223
|
}
|
|
88
|
-
function
|
|
89
|
-
L || (L = globalThis.fetch, globalThis.fetch =
|
|
224
|
+
function se() {
|
|
225
|
+
L || (L = globalThis.fetch, globalThis.fetch = Oe);
|
|
90
226
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
const r = `mnt${
|
|
94
|
-
return
|
|
227
|
+
function ie(e) {
|
|
228
|
+
se();
|
|
229
|
+
const r = `mnt${++Ce}.ptx.invalid`;
|
|
230
|
+
return _.set(r, e), `http://${r}`;
|
|
95
231
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
232
|
+
function Fe(e) {
|
|
233
|
+
_.delete(new URL(e).host);
|
|
98
234
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
235
|
+
function Ue(e, r) {
|
|
236
|
+
se(), ne.set(e, r);
|
|
101
237
|
}
|
|
102
|
-
const
|
|
238
|
+
const A = `<?xml version="1.0" encoding="UTF-8"?>
|
|
103
239
|
<publication>
|
|
104
240
|
<source>
|
|
105
241
|
<directories external="../assets" generated="../generated-assets" />
|
|
@@ -108,31 +244,31 @@ const M = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
108
244
|
<platform portable="yes"/>
|
|
109
245
|
</html>
|
|
110
246
|
</publication>
|
|
111
|
-
`,
|
|
112
|
-
function
|
|
247
|
+
`, We = ["theme", "style", "shell"];
|
|
248
|
+
function b(e, r) {
|
|
113
249
|
for (const t of e.children)
|
|
114
250
|
if (t.type === "element" && t.name === r)
|
|
115
251
|
return t;
|
|
116
252
|
}
|
|
117
253
|
function g(e, r) {
|
|
118
|
-
let t =
|
|
254
|
+
let t = b(e, r);
|
|
119
255
|
return t || (t = { type: "element", name: r, attributes: {}, children: [] }, e.children.push(t)), t;
|
|
120
256
|
}
|
|
121
|
-
function
|
|
122
|
-
const t =
|
|
123
|
-
if (t &&
|
|
257
|
+
function He(e, r) {
|
|
258
|
+
const t = b(e, "css");
|
|
259
|
+
if (t && We.some((o) => t.attributes?.[o]))
|
|
124
260
|
return;
|
|
125
261
|
const n = t ?? g(e, "css");
|
|
126
262
|
n.attributes = { ...n.attributes, theme: r };
|
|
127
263
|
}
|
|
128
|
-
function
|
|
129
|
-
const t =
|
|
264
|
+
function Je(e, r) {
|
|
265
|
+
const t = b(e, "appearance");
|
|
130
266
|
if (t?.attributes?.theme)
|
|
131
267
|
return;
|
|
132
268
|
const n = t ?? g(e, "appearance");
|
|
133
269
|
n.attributes = { ...n.attributes, theme: r };
|
|
134
270
|
}
|
|
135
|
-
function
|
|
271
|
+
function Ke(e) {
|
|
136
272
|
const r = g(e, "resources");
|
|
137
273
|
r.attributes = {
|
|
138
274
|
...r.attributes,
|
|
@@ -140,30 +276,30 @@ function Re(e) {
|
|
|
140
276
|
math: "online"
|
|
141
277
|
};
|
|
142
278
|
}
|
|
143
|
-
function
|
|
279
|
+
function ze(e, r = {}) {
|
|
144
280
|
const t = r.cssTheme?.trim(), n = r.revealTheme?.trim(), o = r.target === "slides";
|
|
145
281
|
if (!e && !t && !o)
|
|
146
|
-
return
|
|
147
|
-
const s =
|
|
282
|
+
return A;
|
|
283
|
+
const s = y(e ?? A), a = b(s, "publication");
|
|
148
284
|
if (!a)
|
|
149
285
|
throw new Error(
|
|
150
286
|
"Invalid publication file: no root <publication> element found"
|
|
151
287
|
);
|
|
152
288
|
const i = g(a, "html"), u = g(i, "platform");
|
|
153
|
-
if (u.attributes = { ...u.attributes, portable: "yes" }, t &&
|
|
289
|
+
if (u.attributes = { ...u.attributes, portable: "yes" }, t && He(i, t), o) {
|
|
154
290
|
const c = g(a, "revealjs");
|
|
155
|
-
|
|
291
|
+
Ke(c), n && Je(c, n);
|
|
156
292
|
}
|
|
157
|
-
return
|
|
293
|
+
return S(s);
|
|
158
294
|
}
|
|
159
|
-
function
|
|
295
|
+
function K(e) {
|
|
160
296
|
if (!(e === void 0 || e === "" || e.startsWith("/")))
|
|
161
297
|
return e.endsWith("/") ? e : `${e}/`;
|
|
162
298
|
}
|
|
163
|
-
function
|
|
164
|
-
const r =
|
|
299
|
+
function Ye(e) {
|
|
300
|
+
const r = y(e ?? A), t = b(r, "publication"), n = t && b(t, "source"), o = n && b(n, "directories"), s = K(
|
|
165
301
|
o?.attributes?.external ?? void 0
|
|
166
|
-
), a =
|
|
302
|
+
), a = K(
|
|
167
303
|
o?.attributes?.generated ?? void 0
|
|
168
304
|
);
|
|
169
305
|
return {
|
|
@@ -172,59 +308,59 @@ function je(e) {
|
|
|
172
308
|
managed: s !== void 0 && a !== void 0
|
|
173
309
|
};
|
|
174
310
|
}
|
|
175
|
-
const
|
|
176
|
-
async function
|
|
177
|
-
return e.includes("include") ? (await
|
|
311
|
+
const ae = "http://www.w3.org/2001/XInclude", z = 64;
|
|
312
|
+
async function Ve(e, r, t) {
|
|
313
|
+
return e.includes("include") ? (await ce(e, r, t)).content : e;
|
|
178
314
|
}
|
|
179
|
-
async function
|
|
180
|
-
const n =
|
|
315
|
+
async function ce(e, r, t) {
|
|
316
|
+
const n = y(e), o = {
|
|
181
317
|
projectDir: l.resolve(t),
|
|
182
318
|
stack: [l.resolve(r)]
|
|
183
|
-
}, s = await
|
|
319
|
+
}, s = await x(
|
|
184
320
|
n,
|
|
185
321
|
l.dirname(l.resolve(r)),
|
|
186
322
|
{ "": "" },
|
|
187
323
|
o
|
|
188
324
|
);
|
|
189
|
-
return { tree: n, content: s ?
|
|
325
|
+
return { tree: n, content: s ? S(n) : e };
|
|
190
326
|
}
|
|
191
|
-
function
|
|
327
|
+
function Ge(e) {
|
|
192
328
|
return e.data?.ptxIncludedFile;
|
|
193
329
|
}
|
|
194
|
-
function
|
|
330
|
+
function qe(e, r) {
|
|
195
331
|
const t = e.data ?? (e.data = {});
|
|
196
332
|
t.ptxIncludedFile = r;
|
|
197
333
|
}
|
|
198
|
-
function
|
|
334
|
+
function $(e, r) {
|
|
199
335
|
let t = e;
|
|
200
336
|
for (const [n, o] of Object.entries(r.attributes))
|
|
201
337
|
(n === "xmlns" || n.startsWith("xmlns:")) && (t === e && (t = { ...e }), t[n === "xmlns" ? "" : n.slice(6)] = o ?? "");
|
|
202
338
|
return t;
|
|
203
339
|
}
|
|
204
|
-
function
|
|
340
|
+
function le(e, r) {
|
|
205
341
|
const t = e.name.indexOf(":"), n = t === -1 ? "" : e.name.slice(0, t);
|
|
206
|
-
return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && r[n] ===
|
|
342
|
+
return (t === -1 ? e.name : e.name.slice(t + 1)) === "include" && r[n] === ae;
|
|
207
343
|
}
|
|
208
|
-
async function
|
|
344
|
+
async function x(e, r, t, n) {
|
|
209
345
|
let o = !1;
|
|
210
346
|
for (let s = 0; s < e.children.length; s++) {
|
|
211
347
|
const a = e.children[s];
|
|
212
348
|
if (a.type !== "element")
|
|
213
349
|
continue;
|
|
214
|
-
const i =
|
|
215
|
-
if (
|
|
216
|
-
const u = await
|
|
350
|
+
const i = $(t, a);
|
|
351
|
+
if (le(a, i)) {
|
|
352
|
+
const u = await ue(
|
|
217
353
|
a,
|
|
218
354
|
r,
|
|
219
355
|
i,
|
|
220
356
|
n
|
|
221
357
|
);
|
|
222
358
|
e.children.splice(s, 1, ...u), s += u.length - 1, o = !0;
|
|
223
|
-
} else await
|
|
359
|
+
} else await x(a, r, i, n) && (o = !0);
|
|
224
360
|
}
|
|
225
361
|
return o;
|
|
226
362
|
}
|
|
227
|
-
async function
|
|
363
|
+
async function ue(e, r, t, n) {
|
|
228
364
|
const o = n.stack[n.stack.length - 1];
|
|
229
365
|
if (e.attributes.xpointer)
|
|
230
366
|
throw new Error(
|
|
@@ -247,44 +383,44 @@ async function ce(e, r, t, n) {
|
|
|
247
383
|
throw new Error(
|
|
248
384
|
`Circular xi:include: ${[...n.stack, i].join(" -> ")}`
|
|
249
385
|
);
|
|
250
|
-
if (n.stack.length >=
|
|
251
|
-
throw new Error(`xi:include nesting exceeds ${
|
|
252
|
-
const u = await
|
|
386
|
+
if (n.stack.length >= z)
|
|
387
|
+
throw new Error(`xi:include nesting exceeds ${z} levels`);
|
|
388
|
+
const u = await B(i);
|
|
253
389
|
if (u === void 0) {
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
return await
|
|
390
|
+
const p = Qe(e, t);
|
|
391
|
+
if (p)
|
|
392
|
+
return await x(p, r, t, n), p.children;
|
|
257
393
|
throw new Error(`xi:include target not found: ${s} (in ${o})`);
|
|
258
394
|
}
|
|
259
395
|
if (e.attributes.parse === "text")
|
|
260
396
|
return [{ type: "text", value: u }];
|
|
261
397
|
let c;
|
|
262
398
|
try {
|
|
263
|
-
c =
|
|
264
|
-
} catch (
|
|
399
|
+
c = y(u);
|
|
400
|
+
} catch (p) {
|
|
265
401
|
throw new Error(
|
|
266
|
-
`Could not parse xi:include target ${i} as XML: ${
|
|
402
|
+
`Could not parse xi:include target ${i} as XML: ${p instanceof Error ? p.message : p}. (Included files must be well-formed, with a single root element.)`
|
|
267
403
|
);
|
|
268
404
|
}
|
|
269
405
|
n.stack.push(i);
|
|
270
406
|
try {
|
|
271
|
-
await
|
|
407
|
+
await x(c, l.dirname(i), { "": "" }, n);
|
|
272
408
|
} finally {
|
|
273
409
|
n.stack.pop();
|
|
274
410
|
}
|
|
275
411
|
const f = c.children.filter(
|
|
276
|
-
(
|
|
412
|
+
(p) => p.type === "element"
|
|
277
413
|
);
|
|
278
|
-
for (const
|
|
279
|
-
|
|
414
|
+
for (const p of f)
|
|
415
|
+
qe(p, i);
|
|
280
416
|
return f;
|
|
281
417
|
}
|
|
282
|
-
function
|
|
418
|
+
function Y(e) {
|
|
283
419
|
return e.name === "docinfo";
|
|
284
420
|
}
|
|
285
|
-
async function
|
|
421
|
+
async function Ze(e, r, t) {
|
|
286
422
|
try {
|
|
287
|
-
const o =
|
|
423
|
+
const o = y(e).children.find(
|
|
288
424
|
(c) => c.type === "element"
|
|
289
425
|
);
|
|
290
426
|
if (!o)
|
|
@@ -292,24 +428,24 @@ async function Ue(e, r, t) {
|
|
|
292
428
|
const s = l.resolve(r), a = l.dirname(s), i = {
|
|
293
429
|
projectDir: l.resolve(t),
|
|
294
430
|
stack: [s]
|
|
295
|
-
}, u =
|
|
431
|
+
}, u = $({ "": "" }, o);
|
|
296
432
|
for (const c of o.children) {
|
|
297
433
|
if (c.type !== "element")
|
|
298
434
|
continue;
|
|
299
|
-
const f =
|
|
300
|
-
if (
|
|
301
|
-
return await
|
|
302
|
-
if (
|
|
303
|
-
const m = (await
|
|
435
|
+
const f = $(u, c);
|
|
436
|
+
if (Y(c))
|
|
437
|
+
return await x(c, a, f, i), S(c);
|
|
438
|
+
if (le(c, f)) {
|
|
439
|
+
const m = (await ue(
|
|
304
440
|
c,
|
|
305
441
|
a,
|
|
306
442
|
f,
|
|
307
443
|
i
|
|
308
444
|
)).find(
|
|
309
|
-
(
|
|
445
|
+
(h) => h.type === "element" && Y(h)
|
|
310
446
|
);
|
|
311
447
|
if (m)
|
|
312
|
-
return
|
|
448
|
+
return S(m);
|
|
313
449
|
continue;
|
|
314
450
|
}
|
|
315
451
|
break;
|
|
@@ -319,33 +455,33 @@ async function Ue(e, r, t) {
|
|
|
319
455
|
return;
|
|
320
456
|
}
|
|
321
457
|
}
|
|
322
|
-
function
|
|
458
|
+
function Qe(e, r) {
|
|
323
459
|
for (const t of e.children) {
|
|
324
460
|
if (t.type !== "element")
|
|
325
461
|
continue;
|
|
326
|
-
const n =
|
|
327
|
-
if ((o === -1 ? t.name : t.name.slice(o + 1)) === "fallback" && n[s] ===
|
|
462
|
+
const n = $(r, t), o = t.name.indexOf(":"), s = o === -1 ? "" : t.name.slice(0, o);
|
|
463
|
+
if ((o === -1 ? t.name : t.name.slice(o + 1)) === "fallback" && n[s] === ae)
|
|
328
464
|
return t;
|
|
329
465
|
}
|
|
330
466
|
}
|
|
331
|
-
function
|
|
467
|
+
function de(e) {
|
|
332
468
|
return typeof e == "object" && e !== null && e.type === "element";
|
|
333
469
|
}
|
|
334
|
-
function
|
|
470
|
+
function et(e) {
|
|
335
471
|
return /^(pf|xhtml):/.test(e.name);
|
|
336
472
|
}
|
|
337
|
-
function
|
|
338
|
-
const n = [], o = e.children.find(
|
|
473
|
+
function tt(e, r, t) {
|
|
474
|
+
const n = [], o = e.children.find(de);
|
|
339
475
|
if (o) {
|
|
340
476
|
const s = t?.parentId ?? "root";
|
|
341
|
-
|
|
477
|
+
fe(o, s, t?.position ?? 1, r, s, n);
|
|
342
478
|
}
|
|
343
479
|
return n;
|
|
344
480
|
}
|
|
345
|
-
function
|
|
346
|
-
const a =
|
|
481
|
+
function fe(e, r, t, n, o, s) {
|
|
482
|
+
const a = Ge(e) ?? n;
|
|
347
483
|
let i, u;
|
|
348
|
-
if (
|
|
484
|
+
if (et(e))
|
|
349
485
|
u = "root";
|
|
350
486
|
else {
|
|
351
487
|
const f = e.attributes.label ?? e.attributes["xml:id"];
|
|
@@ -360,7 +496,7 @@ function ue(e, r, t, n, o, s) {
|
|
|
360
496
|
}
|
|
361
497
|
let c = 0;
|
|
362
498
|
for (const f of e.children)
|
|
363
|
-
|
|
499
|
+
de(f) && (c += 1, fe(
|
|
364
500
|
f,
|
|
365
501
|
u,
|
|
366
502
|
c,
|
|
@@ -369,61 +505,67 @@ function ue(e, r, t, n, o, s) {
|
|
|
369
505
|
s
|
|
370
506
|
));
|
|
371
507
|
}
|
|
372
|
-
function
|
|
508
|
+
function It(e, r) {
|
|
373
509
|
let t;
|
|
374
510
|
for (const n of e)
|
|
375
511
|
n.line <= r && (t = n);
|
|
376
512
|
return t ?? e[0];
|
|
377
513
|
}
|
|
378
|
-
function
|
|
514
|
+
function rt(e) {
|
|
379
515
|
const r = e.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, " ");
|
|
380
516
|
return /<\s*slide(?:show)?[\s/>]/.test(r) ? "slides" : "html";
|
|
381
517
|
}
|
|
382
|
-
function
|
|
383
|
-
return
|
|
518
|
+
function nt() {
|
|
519
|
+
return Ie(j(), "xsl");
|
|
384
520
|
}
|
|
385
|
-
function
|
|
521
|
+
function ot() {
|
|
386
522
|
return "Suspending" in WebAssembly;
|
|
387
523
|
}
|
|
388
|
-
function
|
|
389
|
-
if (!
|
|
524
|
+
function st() {
|
|
525
|
+
if (!ot())
|
|
390
526
|
throw new Error(
|
|
391
527
|
"WebAssembly JSPI is not enabled. Run Node with --experimental-wasm-jspi (or use the pretext-html CLI, which re-launches itself with the flag)."
|
|
392
528
|
);
|
|
393
529
|
}
|
|
394
|
-
function
|
|
530
|
+
function I(e) {
|
|
395
531
|
return e.includes("'") ? e.includes('"') ? `concat(${e.split("'").map((t) => `'${t}'`).join(`, "'", `)})` : `"${e}"` : `'${e}'`;
|
|
396
532
|
}
|
|
397
|
-
function
|
|
533
|
+
function it(e) {
|
|
398
534
|
return e.replace(
|
|
399
535
|
/from '\.\/(https:\/\/[^']+)'/g,
|
|
400
536
|
(r, t) => `from '${t}'`
|
|
401
537
|
);
|
|
402
538
|
}
|
|
403
|
-
const
|
|
404
|
-
|
|
539
|
+
const at = `https://cdn.jsdelivr.net/gh/PreTeXtBook/html-static@${re}/dist/`, ct = {
|
|
540
|
+
"cli.version": re,
|
|
541
|
+
// Colon-delimited: pretext-runestone.xsl splits them with str:tokenize.
|
|
542
|
+
"rs-js": Re.join(":"),
|
|
543
|
+
"rs-css": je.join(":"),
|
|
544
|
+
"rs-version": De
|
|
545
|
+
};
|
|
546
|
+
function lt(e) {
|
|
405
547
|
return e.replace(
|
|
406
548
|
/(<link\b[^>]*\bhref=["'])_static\//gi,
|
|
407
|
-
`$1${
|
|
549
|
+
`$1${at}_static/`
|
|
408
550
|
);
|
|
409
551
|
}
|
|
410
|
-
function
|
|
552
|
+
function ut(e) {
|
|
411
553
|
return e.slice(0, 65536).replace(/<\?[\s\S]*?\?>/g, " ").replace(/<!--[\s\S]*?-->/g, " ").replace(/<!DOCTYPE[^>]*>/gi, " ").match(/<\s*([A-Za-z][\w:-]*)/)?.[1];
|
|
412
554
|
}
|
|
413
|
-
async function
|
|
414
|
-
const r = await
|
|
555
|
+
async function V(e) {
|
|
556
|
+
const r = await B(e);
|
|
415
557
|
if (r === void 0)
|
|
416
558
|
throw new Error(
|
|
417
559
|
`Could not read ${e}. (In the browser build only absolute URLs are readable — pass sourceContent instead of relying on sourcePath.)`
|
|
418
560
|
);
|
|
419
561
|
return r;
|
|
420
562
|
}
|
|
421
|
-
async function
|
|
422
|
-
const t = l.resolve(e), n = await
|
|
563
|
+
async function dt(e, r) {
|
|
564
|
+
const t = l.resolve(e), n = await B(t);
|
|
423
565
|
if (n !== void 0)
|
|
424
|
-
return
|
|
566
|
+
return Ze(n, t, r);
|
|
425
567
|
}
|
|
426
|
-
function
|
|
568
|
+
function ft(e, r, t, n) {
|
|
427
569
|
const o = e.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").replace(/<!DOCTYPE[^>]*>/i, ""), s = t === "slides" ? "slideshow" : r === "chapter" || r === "part" ? "book" : "article";
|
|
428
570
|
return `<pretext>
|
|
429
571
|
${n?.trim() ? `${n.trim()}
|
|
@@ -434,75 +576,75 @@ ${o}
|
|
|
434
576
|
</pretext>
|
|
435
577
|
`;
|
|
436
578
|
}
|
|
437
|
-
let
|
|
438
|
-
function
|
|
579
|
+
let pe = !1;
|
|
580
|
+
function pt(e) {
|
|
439
581
|
return e instanceof Error && /\bAborted\(/.test(e.message);
|
|
440
582
|
}
|
|
441
|
-
function
|
|
583
|
+
function mt(e) {
|
|
442
584
|
return e instanceof Error && /memory access|out of bounds/i.test(e.message);
|
|
443
585
|
}
|
|
444
|
-
function
|
|
445
|
-
if (
|
|
586
|
+
function ht() {
|
|
587
|
+
if (pe)
|
|
446
588
|
throw new Error(
|
|
447
589
|
"The WebAssembly renderer aborted earlier in this process and cannot be reused. Restart the process (or reload the page) to render again."
|
|
448
590
|
);
|
|
449
591
|
}
|
|
450
|
-
function
|
|
451
|
-
if (
|
|
452
|
-
throw
|
|
592
|
+
function G(e) {
|
|
593
|
+
if (pt(e))
|
|
594
|
+
throw pe = !0, new Error(
|
|
453
595
|
"The WebAssembly renderer aborted and cannot be reused. Restart the process (or reload the page) to render again.",
|
|
454
596
|
{ cause: e }
|
|
455
597
|
);
|
|
456
|
-
if (
|
|
598
|
+
if (mt(e))
|
|
457
599
|
throw new Error(
|
|
458
600
|
"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.",
|
|
459
601
|
{ cause: e }
|
|
460
602
|
);
|
|
461
603
|
}
|
|
462
|
-
let
|
|
463
|
-
async function
|
|
464
|
-
return
|
|
604
|
+
let D;
|
|
605
|
+
async function me() {
|
|
606
|
+
return D || (D = (async () => {
|
|
465
607
|
const [e, r] = await Promise.all([
|
|
466
608
|
import("@pretextbook/libxslt-wasm"),
|
|
467
609
|
import("@pretextbook/libxslt-wasm/exslt")
|
|
468
610
|
]);
|
|
469
611
|
return r.registerAll(), e;
|
|
470
|
-
})()),
|
|
612
|
+
})()), D;
|
|
471
613
|
}
|
|
472
|
-
const
|
|
614
|
+
const R = /* @__PURE__ */ new Map(), wt = {
|
|
473
615
|
html: "preview-html.xsl",
|
|
474
616
|
slides: "preview-revealjs.xsl"
|
|
475
617
|
};
|
|
476
|
-
async function
|
|
477
|
-
const t =
|
|
478
|
-
let o =
|
|
618
|
+
async function bt(e, r) {
|
|
619
|
+
const t = wt[r], n = `${r}\0${e}`;
|
|
620
|
+
let o = R.get(n);
|
|
479
621
|
return o || (o = (async () => {
|
|
480
|
-
const { XmlDocument: s, XsltStylesheet: a } = await
|
|
622
|
+
const { XmlDocument: s, XsltStylesheet: a } = await me(), i = ie(e), u = await ee(j(), `/${t}`);
|
|
481
623
|
if (u === void 0)
|
|
482
624
|
throw new Error(
|
|
483
|
-
`Could not read ${t} from ${
|
|
625
|
+
`Could not read ${t} from ${j()}. Check the assets location (PRETEXT_HTML_ASSETS under Node, setAssetsBase() in the browser).`
|
|
484
626
|
);
|
|
485
627
|
const c = new TextDecoder().decode(u), f = await s.fromString(c, {
|
|
486
628
|
url: `${i}/${t}`,
|
|
487
629
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
488
630
|
});
|
|
489
631
|
return a.fromXmlDocument(f);
|
|
490
|
-
})(),
|
|
632
|
+
})(), R.set(n, o), o.catch(() => R.delete(n))), o;
|
|
491
633
|
}
|
|
492
|
-
let
|
|
493
|
-
function
|
|
494
|
-
const r =
|
|
495
|
-
() =>
|
|
496
|
-
() =>
|
|
634
|
+
let q = Promise.resolve();
|
|
635
|
+
function vt(e) {
|
|
636
|
+
const r = q.then(
|
|
637
|
+
() => Z(e),
|
|
638
|
+
() => Z(e)
|
|
497
639
|
);
|
|
498
|
-
return
|
|
640
|
+
return q = r.catch(() => {
|
|
499
641
|
}), r;
|
|
500
642
|
}
|
|
501
|
-
async function
|
|
502
|
-
|
|
503
|
-
const { XmlDocument: r } = await
|
|
643
|
+
async function Z(e) {
|
|
644
|
+
st(), ht();
|
|
645
|
+
const { XmlDocument: r } = await me(), t = l.resolve(e.sourcePath), n = l.resolve(
|
|
504
646
|
e.projectDir ?? l.dirname(t)
|
|
505
|
-
), o = e.sourceContent ?? await
|
|
647
|
+
), o = e.sourceContent ?? await V(t), s = l.relative(n, t);
|
|
506
648
|
if (s.startsWith(".."))
|
|
507
649
|
throw new Error(
|
|
508
650
|
`sourcePath (${t}) must live inside projectDir (${n})`
|
|
@@ -510,92 +652,94 @@ async function q(e) {
|
|
|
510
652
|
const a = l.relative(
|
|
511
653
|
n,
|
|
512
654
|
l.resolve(e.mainSourcePath ?? t)
|
|
513
|
-
), i = a.startsWith("..") ? s : a, u =
|
|
655
|
+
), i = a.startsWith("..") ? s : a, u = ie(n);
|
|
514
656
|
try {
|
|
515
657
|
let c, f = `${u}/__pretext-preview-publication.xml`;
|
|
516
658
|
if (e.publicationPath) {
|
|
517
659
|
const d = l.resolve(e.publicationPath);
|
|
518
|
-
c = await
|
|
519
|
-
const
|
|
520
|
-
|
|
660
|
+
c = await V(d);
|
|
661
|
+
const w = l.relative(n, d);
|
|
662
|
+
w.startsWith("..") || (f = `${u}/${w.split(l.sep).join("/")}`);
|
|
521
663
|
}
|
|
522
|
-
let
|
|
664
|
+
let p, m;
|
|
523
665
|
if (e.sourceMap) {
|
|
524
|
-
const d = await
|
|
666
|
+
const d = await ce(
|
|
525
667
|
o,
|
|
526
668
|
t,
|
|
527
669
|
n
|
|
528
670
|
);
|
|
529
|
-
|
|
671
|
+
p = d.tree, m = d.content;
|
|
530
672
|
} else
|
|
531
|
-
m = await
|
|
673
|
+
m = await Ve(
|
|
532
674
|
o,
|
|
533
675
|
t,
|
|
534
676
|
n
|
|
535
677
|
);
|
|
536
|
-
const
|
|
678
|
+
const h = e.target ?? rt(m), he = await bt(e.xslDir ?? nt(), h), C = ze(c, {
|
|
537
679
|
cssTheme: e.cssTheme,
|
|
538
680
|
revealTheme: e.revealTheme,
|
|
539
|
-
target:
|
|
681
|
+
target: h
|
|
540
682
|
});
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
external: l.resolve(
|
|
544
|
-
generated: l.resolve(
|
|
545
|
-
} : void 0,
|
|
546
|
-
let
|
|
547
|
-
if (
|
|
683
|
+
Ue(f, C);
|
|
684
|
+
const E = Ye(C), O = l.dirname(l.resolve(n, i)), X = E.external !== void 0 && E.generated !== void 0 ? {
|
|
685
|
+
external: l.resolve(O, E.external),
|
|
686
|
+
generated: l.resolve(O, E.generated)
|
|
687
|
+
} : void 0, T = ut(m);
|
|
688
|
+
let N = { parentId: "root", position: 1 };
|
|
689
|
+
if (T !== "pretext" && T !== "mathbook")
|
|
548
690
|
if (e.fragment) {
|
|
549
|
-
const d = e.docinfo ?? (e.docinfoSourcePath ? await
|
|
550
|
-
m =
|
|
691
|
+
const d = e.docinfo ?? (e.docinfoSourcePath ? await dt(e.docinfoSourcePath, n) : void 0);
|
|
692
|
+
m = ft(
|
|
551
693
|
m,
|
|
552
|
-
|
|
553
|
-
|
|
694
|
+
T,
|
|
695
|
+
h,
|
|
554
696
|
d
|
|
555
|
-
),
|
|
697
|
+
), N = { parentId: d?.trim() ? "root-1-2" : "root-1-1", position: 2 };
|
|
556
698
|
} else
|
|
557
699
|
throw new Error(
|
|
558
|
-
`The document root is <${
|
|
700
|
+
`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.`
|
|
559
701
|
);
|
|
560
|
-
const
|
|
702
|
+
const F = p ? tt(p, t, N) : void 0, U = await r.fromString(m, {
|
|
561
703
|
url: `${u}/${i.split(l.sep).join("/")}`,
|
|
562
704
|
options: { noEnt: !0, dtdLoad: !0, huge: !0 }
|
|
563
|
-
}),
|
|
564
|
-
publisher:
|
|
705
|
+
}), k = {
|
|
706
|
+
publisher: I(f)
|
|
565
707
|
};
|
|
566
|
-
for (const [d,
|
|
567
|
-
|
|
568
|
-
|
|
708
|
+
for (const [d, w] of Object.entries(ct))
|
|
709
|
+
k[d] = I(w);
|
|
710
|
+
for (const [d, w] of Object.entries(e.stringParams ?? {}))
|
|
711
|
+
k[d] = I(w);
|
|
712
|
+
let P;
|
|
569
713
|
try {
|
|
570
|
-
|
|
714
|
+
P = await he.apply(U, k);
|
|
571
715
|
} catch (d) {
|
|
572
|
-
throw
|
|
716
|
+
throw G(d), new Error(
|
|
573
717
|
"PreTeXt XSLT transform failed; see the PTX:ERROR/PTX:FATAL messages on stderr for details.",
|
|
574
718
|
{ cause: d }
|
|
575
719
|
);
|
|
576
720
|
} finally {
|
|
577
|
-
|
|
721
|
+
U.delete();
|
|
578
722
|
}
|
|
579
723
|
try {
|
|
580
|
-
let d =
|
|
581
|
-
return (e.openKnowls ?? !0) && (d =
|
|
724
|
+
let d = it(P.toHtmlString());
|
|
725
|
+
return (e.openKnowls ?? !0) && (d = _e(d)), h === "slides" ? (d = lt(d), d = be(d, e.revealView ?? "scroll", {
|
|
582
726
|
zoom: e.revealZoom
|
|
583
|
-
})) : e.theme && (d =
|
|
727
|
+
})) : e.theme && (d = ve(d, e.theme)), e.previewBanner && (d = Pe(d, e.previewBanner)), {
|
|
584
728
|
html: d,
|
|
585
|
-
target:
|
|
586
|
-
...
|
|
587
|
-
...
|
|
729
|
+
target: h,
|
|
730
|
+
...F ? { sourceMap: F } : {},
|
|
731
|
+
...X ? { assetDirs: X } : {}
|
|
588
732
|
};
|
|
589
733
|
} catch (d) {
|
|
590
|
-
throw
|
|
734
|
+
throw G(d), d;
|
|
591
735
|
} finally {
|
|
592
|
-
|
|
736
|
+
P.delete();
|
|
593
737
|
}
|
|
594
738
|
} finally {
|
|
595
|
-
|
|
739
|
+
Fe(u);
|
|
596
740
|
}
|
|
597
741
|
}
|
|
598
|
-
const
|
|
742
|
+
const Q = `Usage: pretext-html <source.ptx> [options]
|
|
599
743
|
|
|
600
744
|
Render a PreTeXt document to a single standalone HTML page (portable build:
|
|
601
745
|
one page, css/js/MathJax from CDN). No PreTeXt installation required.
|
|
@@ -628,7 +772,7 @@ Options:
|
|
|
628
772
|
are previews of work in progress
|
|
629
773
|
-h, --help Show this help
|
|
630
774
|
`;
|
|
631
|
-
function
|
|
775
|
+
function gt(e) {
|
|
632
776
|
let r, t, n, o;
|
|
633
777
|
const s = {}, a = {};
|
|
634
778
|
for (let i = 0; i < e.length; i++) {
|
|
@@ -640,7 +784,7 @@ function ot(e) {
|
|
|
640
784
|
switch (u) {
|
|
641
785
|
case "-h":
|
|
642
786
|
case "--help":
|
|
643
|
-
|
|
787
|
+
v.stdout.write(Q), v.exit(0);
|
|
644
788
|
break;
|
|
645
789
|
case "-o":
|
|
646
790
|
case "--output":
|
|
@@ -674,10 +818,10 @@ function ot(e) {
|
|
|
674
818
|
o = c(), s.sourceMap = !0;
|
|
675
819
|
break;
|
|
676
820
|
case "--param": {
|
|
677
|
-
const f = c(),
|
|
678
|
-
if (
|
|
821
|
+
const f = c(), p = f.indexOf("=");
|
|
822
|
+
if (p === -1)
|
|
679
823
|
throw new Error(`--param expects name=value, got: ${f}`);
|
|
680
|
-
a[f.slice(0,
|
|
824
|
+
a[f.slice(0, p)] = f.slice(p + 1);
|
|
681
825
|
break;
|
|
682
826
|
}
|
|
683
827
|
default:
|
|
@@ -691,7 +835,7 @@ function ot(e) {
|
|
|
691
835
|
if (!r)
|
|
692
836
|
throw new Error(`No source file given.
|
|
693
837
|
|
|
694
|
-
` +
|
|
838
|
+
` + Q);
|
|
695
839
|
return Object.keys(a).length > 0 && (s.stringParams = a), {
|
|
696
840
|
options: { ...s, sourcePath: r },
|
|
697
841
|
output: t,
|
|
@@ -699,26 +843,29 @@ function ot(e) {
|
|
|
699
843
|
sourceMapPath: o
|
|
700
844
|
};
|
|
701
845
|
}
|
|
702
|
-
async function
|
|
703
|
-
const { options: r, output: t, docinfoPath: n, sourceMapPath: o } =
|
|
704
|
-
n && (r.docinfo = await
|
|
705
|
-
const s = Date.now(), { html: a, sourceMap: i } = await
|
|
706
|
-
|
|
707
|
-
`), o && i && (await
|
|
708
|
-
`)), t ? (await
|
|
709
|
-
`)) :
|
|
846
|
+
async function Dt(e) {
|
|
847
|
+
const { options: r, output: t, docinfoPath: n, sourceMapPath: o } = gt(e);
|
|
848
|
+
n && (r.docinfo = await M(n, "utf8"));
|
|
849
|
+
const s = Date.now(), { html: a, sourceMap: i } = await vt(r);
|
|
850
|
+
v.stderr.write(`pretext-html: rendered in ${Date.now() - s}ms
|
|
851
|
+
`), o && i && (await W(o, JSON.stringify(i, null, 2)), v.stderr.write(`pretext-html: wrote ${o}
|
|
852
|
+
`)), t ? (await W(t, a), v.stderr.write(`pretext-html: wrote ${t}
|
|
853
|
+
`)) : v.stdout.write(a);
|
|
710
854
|
}
|
|
711
855
|
export {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
856
|
+
ge as P,
|
|
857
|
+
rt as a,
|
|
858
|
+
ze as b,
|
|
859
|
+
ot as c,
|
|
860
|
+
nt as d,
|
|
861
|
+
Pt as e,
|
|
862
|
+
It as f,
|
|
863
|
+
gt as g,
|
|
864
|
+
Pe as i,
|
|
865
|
+
Dt as m,
|
|
866
|
+
_e as o,
|
|
867
|
+
Te as p,
|
|
868
|
+
vt as r,
|
|
869
|
+
kt as s,
|
|
870
|
+
I as x
|
|
724
871
|
};
|