@pretextbook/pretext-html 0.16.1 → 0.18.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 +163 -18
- package/assets/preview-html.xsl +81 -14
- package/assets/preview-revealjs.xsl +7 -2
- package/dist/assets.d.ts +9 -5
- package/dist/banner.d.ts +2 -2
- package/dist/cli-CKAOX3L6.js +1494 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.js +8 -3
- package/dist/index.browser.d.ts +10 -5
- package/dist/index.browser.js +1182 -856
- package/dist/index.d.ts +10 -4
- package/dist/index.js +49 -44
- package/dist/publication.d.ts +75 -21
- package/dist/renderer.d.ts +151 -23
- package/dist/skeleton.d.ts +68 -7
- package/dist/source-cache.d.ts +36 -0
- package/dist/sourcemap.d.ts +11 -1
- package/dist/subtree.d.ts +79 -0
- package/dist/target.d.ts +1 -1
- package/dist/xinclude.d.ts +40 -3
- package/package.json +1 -1
- package/dist/cli-DzlCZymu.js +0 -1145
package/README.md
CHANGED
|
@@ -10,11 +10,13 @@ CLI uses via lxml), so the HTML matches a real `pretext build`. It is a fork of
|
|
|
10
10
|
with a larger WASM stack so whole-book documents render without overflowing
|
|
11
11
|
(see [Forking libxslt-wasm](#forking-libxslt-wasm)).
|
|
12
12
|
|
|
13
|
-
The output is a single, standalone HTML page
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
The output is a single, standalone HTML page. The theme css/js and MathJax
|
|
14
|
+
load from public CDNs, the whole document is rendered as one page, and images
|
|
15
|
+
are linked rather than embedded, so the host serves them from wherever it
|
|
16
|
+
keeps them (see [Images and other assets](#images-and-other-assets)). This is
|
|
17
|
+
what powers the "Live Preview" in the PreTeXt-tools VS Code extension, and it
|
|
18
|
+
is published so other tools (e.g. pretext.plus) can render previews the same
|
|
19
|
+
way.
|
|
18
20
|
|
|
19
21
|
## Usage
|
|
20
22
|
|
|
@@ -66,9 +68,19 @@ const { html } = await renderHtml({
|
|
|
66
68
|
element has no HTML id of its own, and `findSourceMapEntry(entries, line)`
|
|
67
69
|
picks the element nearest a cursor line. (This powers the two-way sync in
|
|
68
70
|
the VS Code Instant Preview; the same map works for any embedder.)
|
|
69
|
-
- The user's publication file is respected, except
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
- The user's publication file is respected, except for four settings that
|
|
72
|
+
single-page in-memory output needs, which are always forced (see
|
|
73
|
+
`src/publication.ts`):
|
|
74
|
+
- `<html><resources host="cdn"/>`: css/js, theme and icon font from the CDN.
|
|
75
|
+
- `<common><chunking level="0"/>`: the whole document on one page.
|
|
76
|
+
- `<html><cross-references knowled="never"/>`: cross-references are links,
|
|
77
|
+
because the knowl files they would open are never written.
|
|
78
|
+
- `<html><platform portable="no"/>`: PreTeXt's _portable HTML_ mode is off,
|
|
79
|
+
even for a project that builds portable. Portable mode would do the first
|
|
80
|
+
three as well, and earlier releases relied on it, but it also inlines
|
|
81
|
+
every latex-image and PreFigure SVG into the page. Without it those are
|
|
82
|
+
linked like every other image. The search index stays embedded in the
|
|
83
|
+
page, as portable mode had it.
|
|
72
84
|
- `cssTheme: "denver"` supplies the PreTeXt HTML theme for projects that do not
|
|
73
85
|
choose one, by adding `<html><css theme="…"/></html>` to the publication file
|
|
74
86
|
used for the build (including the minimal one synthesized when you pass no
|
|
@@ -76,9 +88,9 @@ const { html } = await renderHtml({
|
|
|
76
88
|
that already names a theme — `@theme`, or the deprecated `@style`/`@shell` —
|
|
77
89
|
keeps it, so the preview goes on matching what `pretext build` produces. The
|
|
78
90
|
themes the bundled stylesheets know are `default-modern` (PreTeXt's own
|
|
79
|
-
default), `denver`, `tacoma`, `salem`, `greeley` and `boulder`;
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
default), `denver`, `tacoma`, `salem`, `greeley` and `boulder`; the preview
|
|
92
|
+
loads `theme-<name>.min.css` from the CDN, so an unrecognised name gives an
|
|
93
|
+
unstyled page. Not to be confused with `theme` below, which is the
|
|
82
94
|
light/dark mode _within_ whichever css theme is in force.
|
|
83
95
|
- The compiled stylesheet is cached per `xslDir` (~1s to compile, then
|
|
84
96
|
~100ms–1s per render depending on document size).
|
|
@@ -91,6 +103,136 @@ const { html } = await renderHtml({
|
|
|
91
103
|
alone. Pass `openKnowls: false` (`--no-open-knowls` on the CLI) for the
|
|
92
104
|
collapsed reading experience of a real `pretext build`.
|
|
93
105
|
|
|
106
|
+
### Images and other assets
|
|
107
|
+
|
|
108
|
+
Every image the page shows is an ordinary link under one of two fixed
|
|
109
|
+
prefixes, exactly as in a real build. Author-supplied files are under
|
|
110
|
+
`external/`, and everything `pretext generate` makes (latex-image, PreFigure,
|
|
111
|
+
sageplot, asymptote, …) is under `generated/`:
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<img src="external/kitten.png" />
|
|
115
|
+
<img src="generated/latex-image/diagram.svg" />
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A real build copies both directories next to its pages. A preview has no such
|
|
119
|
+
directory, so the host maps each URL to wherever it keeps the file:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import { renderHtml } from "@pretextbook/pretext-html";
|
|
123
|
+
import {
|
|
124
|
+
rewriteAssetUrls,
|
|
125
|
+
missingAssetPlaceholder,
|
|
126
|
+
} from "@pretextbook/pretext-html/assets"; // dependency-free subpath
|
|
127
|
+
|
|
128
|
+
const { html, assetDirs } = await renderHtml({ sourcePath: "source/main.ptx" });
|
|
129
|
+
|
|
130
|
+
const page = rewriteAssetUrls(html, (kind, relPath) => {
|
|
131
|
+
// kind is "external" or "generated"; relPath is e.g. "latex-image/diagram.svg"
|
|
132
|
+
const url = lookUp(kind, relPath); // a webview URI, a blob URL, a hosted URL…
|
|
133
|
+
return url ?? missingAssetPlaceholder(kind, relPath);
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- `assetDirs` gives the absolute directories behind the two prefixes, resolved
|
|
138
|
+
the way PreTeXt resolves them. `external` comes from the document's
|
|
139
|
+
`<docinfo><directories external="…"/>`, falling back to the publication
|
|
140
|
+
file's deprecated `source/directories/@external`; it is absent when neither
|
|
141
|
+
declares one, which PreTeXt reads as "no external assets". `generated` comes
|
|
142
|
+
from the publication file's `source/directories/@generated` and defaults to
|
|
143
|
+
`generated/` beside the main source file.
|
|
144
|
+
- A host without a filesystem (a browser editor) ignores `assetDirs` and
|
|
145
|
+
answers from its own store of uploaded or generated files. Nothing reads
|
|
146
|
+
image files during the render itself.
|
|
147
|
+
- Give a file a new URL when it changes, for instance with a version or
|
|
148
|
+
modification-time query. A page never fetches an `<img>` again while its
|
|
149
|
+
`src` is unchanged, and a live patch leaves an unchanged element alone, so a
|
|
150
|
+
regenerated image behind the same URL keeps showing the old picture. With a
|
|
151
|
+
new URL, a live patch updates just that `src` in place and only that image
|
|
152
|
+
reloads. Re-deliver the page when the files change (the VS Code preview
|
|
153
|
+
watches the asset directories), not only when the source does.
|
|
154
|
+
- `missingAssetPlaceholder` returns a data-URI SVG that names the missing file
|
|
155
|
+
and says what to do (`pretext generate latex-image`, or "check @source"),
|
|
156
|
+
which reads better than the browser's broken-image glyph. Return `undefined`
|
|
157
|
+
from the resolver instead to leave a URL as it is.
|
|
158
|
+
- Only `src` attributes are rewritten. An annotated PreFigure diagram (one with
|
|
159
|
+
`<annotations>`) is drawn by a script from `data-src`/`data-cml` attributes,
|
|
160
|
+
which are left alone.
|
|
161
|
+
- The CLI applies this itself when it writes a file (`--output`), linking each
|
|
162
|
+
asset relative to the output file. HTML written to stdout keeps PreTeXt's
|
|
163
|
+
own URLs.
|
|
164
|
+
|
|
165
|
+
### Previewing one division of a large document
|
|
166
|
+
|
|
167
|
+
A render costs what PreTeXt's assembly costs, and that tracks the number of
|
|
168
|
+
elements in the document: a few hundred milliseconds for a chapter, tens of
|
|
169
|
+
seconds for a whole book. A live preview of a large document therefore should
|
|
170
|
+
not render the whole document, and need not: the `subtree` option renders one
|
|
171
|
+
division of it, numbered and cross-referenced exactly as the whole document
|
|
172
|
+
would number it, by pruning the rest to a skeleton (see `src/skeleton.ts`).
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
const { html, size, subtree } = await renderHtml({
|
|
176
|
+
sourcePath: "source/main.ptx",
|
|
177
|
+
subtree: {
|
|
178
|
+
line: cursorLine, // the division around the author's cursor...
|
|
179
|
+
file: cursorFile, // ...in this file (defaults to sourcePath)
|
|
180
|
+
level: 2, // chunk level: sections of a book are pages of their own
|
|
181
|
+
wholeDocumentUpTo: 3000, // but a small document previews whole
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
- `line`/`file` select the innermost division containing a source line; `id`
|
|
187
|
+
selects by `xml:id` instead (an element inside a division selects that
|
|
188
|
+
division). The division need not carry an `xml:id` of its own — the one
|
|
189
|
+
PreTeXt would stamp on it is injected, so the page's HTML ids are unchanged.
|
|
190
|
+
- A division that contains divisions is previewed as a **summary page**: its
|
|
191
|
+
own content (introduction, conclusion, loose paragraphs) rendered in place,
|
|
192
|
+
then links to the divisions inside it, as the chapter page of a chunked
|
|
193
|
+
build summarizes its sections. Only leaf divisions render in full, so a
|
|
194
|
+
cursor at the top of a book shows the book's front matter and a table of
|
|
195
|
+
its chapters, never the book. The summary links are inert on a one-page
|
|
196
|
+
preview but carry `data-ptx-division` (and `data-ptx-id` for a link to an
|
|
197
|
+
element), so a host can make them re-render with `subtree: { id }`.
|
|
198
|
+
- `level` has PreTeXt's chunk-level meaning, for a host that wants whole
|
|
199
|
+
pages at some depth: the preview is the page that would hold the selection
|
|
200
|
+
in a build chunked at that level. A selection deeper than `level` previews
|
|
201
|
+
its ancestor at `level`, whole; one at `level` is shown whole; one shallower
|
|
202
|
+
is the summary page above. Omit it to treat every division as a page of its
|
|
203
|
+
own.
|
|
204
|
+
- `wholeDocumentUpTo` renders the whole document instead when it has no more
|
|
205
|
+
than that many elements — a small document previews whole as fast as any
|
|
206
|
+
division of it would.
|
|
207
|
+
- Every result carries `size` (`elements`, `bytes`, and the `files` the
|
|
208
|
+
document spans, to watch for changes), and `subtree` (`id`, `level`,
|
|
209
|
+
`collapsed`) when one division was emitted rather than the whole document.
|
|
210
|
+
`measureDocument(options)` reports the same `size` without rendering, for a
|
|
211
|
+
host deciding how much to preview before each render.
|
|
212
|
+
- With `fragment: true` and a context document, `subtree` narrows the preview
|
|
213
|
+
within the placed fragment — a cursor line in a chapter file previews the
|
|
214
|
+
section it is in.
|
|
215
|
+
|
|
216
|
+
What a division preview still has to do on every render is read and parse the
|
|
217
|
+
whole document, to prune it. Two options keep that cheap:
|
|
218
|
+
|
|
219
|
+
- `readSource(path)` (or `files`, a map from absolute path to content) supplies
|
|
220
|
+
the document's files from memory — the xi:include targets, the context
|
|
221
|
+
document, the publication file — for a host that already holds its project
|
|
222
|
+
in memory (a browser editor) or has unsaved buffers (an editor). A reader
|
|
223
|
+
that returns `undefined` for a path falls through to the platform's own read.
|
|
224
|
+
- A per-file parse cache, on by default, reuses the parse of every file whose
|
|
225
|
+
content has not changed since the last render. It is keyed by file, not by
|
|
226
|
+
the assembled document, so it does not matter how the project is split into
|
|
227
|
+
files: a keystroke re-parses the file being edited and nothing else. Pass a
|
|
228
|
+
`SourceCache` of your own as `cache` to scope it (and `invalidate()` it), or
|
|
229
|
+
`cache: false` to parse afresh each time.
|
|
230
|
+
|
|
231
|
+
On a synthetic 12-chapter book of 28,000 elements split into 157 files, a
|
|
232
|
+
section or subsection preview takes well under a second warm (0.3–0.8s
|
|
233
|
+
measured, most of it the division itself), and a chapter's summary page about
|
|
234
|
+
the same, against 20–40 seconds for the whole book.
|
|
235
|
+
|
|
94
236
|
### API (browser)
|
|
95
237
|
|
|
96
238
|
The same renderer runs in a browser — no server, no Python. Bundlers pick it up
|
|
@@ -117,9 +259,12 @@ filesystem:
|
|
|
117
259
|
|
|
118
260
|
- **`sourceContent` is required.** `sourcePath` still anchors relative
|
|
119
261
|
`xi:include`s and the output's URLs, but nothing is read from it.
|
|
120
|
-
- **`xi:include`s are not resolved from disk.**
|
|
121
|
-
|
|
122
|
-
|
|
262
|
+
- **`xi:include`s are not resolved from disk.** Supply the project's files
|
|
263
|
+
through `readSource` or `files` (see above) and they are resolved from
|
|
264
|
+
there, with the per-file parse cache working as it does under Node; or
|
|
265
|
+
pre-merge them and pass the merged document as `sourceContent`. An
|
|
266
|
+
unresolvable include uses its `<xi:fallback>` if it has one, and otherwise
|
|
267
|
+
throws.
|
|
123
268
|
- **`publicationPath` / `docinfoSourcePath` need absolute URLs**, since those
|
|
124
269
|
are the only readable locations. Prefer `docinfo` (a string) over
|
|
125
270
|
`docinfoSourcePath`.
|
|
@@ -409,7 +554,7 @@ through `stringParams` to link no Runestone code at all.
|
|
|
409
554
|
| ---------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
410
555
|
| No multi-file output (`exsl:document`) | Compiled with `FILESYSTEM=0` | Rebuild with `FILESYSTEM=1` (files land in MEMFS) |
|
|
411
556
|
| JSPI required (flagged on Node) | Loader fetches resources mid-transform via JSPI | Feature-detect with `isJspiAvailable()`; engines without it need a fallback |
|
|
412
|
-
| No generated images (latex-image, sageplot, …) | Produced by the Python toolchain, not XSLT | Out of scope; run `pretext generate` and the
|
|
557
|
+
| No generated images (latex-image, sageplot, …) | Produced by the Python toolchain, not XSLT | Out of scope; run `pretext generate` and the page links the files it made |
|
|
413
558
|
| `xi:include` with `xpointer` unsupported | JS resolver stands in for libxml2's | Rebuild adding `xmlXIncludeProcessFlags` to the JSPI export list |
|
|
414
559
|
| Renders run one at a time, never in parallel | Shared libxslt state; the transform suspends mid-run | Inherent; `renderHtml` queues concurrent calls for you |
|
|
415
560
|
|
|
@@ -436,9 +581,9 @@ later call for the lifetime of the process. Once that has happened, only a
|
|
|
436
581
|
restart (or a page reload) recovers; `renderHtml` detects the state and says so
|
|
437
582
|
rather than repeating the underlying assertion.
|
|
438
583
|
|
|
439
|
-
Missing generated assets
|
|
440
|
-
|
|
441
|
-
|
|
584
|
+
Missing generated assets cost the render nothing: the page links every image
|
|
585
|
+
whether or not the file exists, and deciding what to show for a missing one is
|
|
586
|
+
the host's (see [Images and other assets](#images-and-other-assets)).
|
|
442
587
|
|
|
443
588
|
## Forking libxslt-wasm
|
|
444
589
|
|
package/assets/preview-html.xsl
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
Regenerate with: npm run refresh-xsl -w @pretextbook/pretext-html
|
|
5
5
|
|
|
6
6
|
Wrapper around pretext-html.xsl for single-page in-memory HTML builds
|
|
7
|
-
(previews). The "file-wrap" template below is a
|
|
8
|
-
|
|
9
|
-
page is emitted on the main result tree
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
(previews). The "file-wrap" template below is a copy of the upstream
|
|
8
|
+
template with two changes: the <exsl:document> element is removed, so the
|
|
9
|
+
complete page is emitted on the main result tree, and the search index is
|
|
10
|
+
embedded in the page whether or not the build is portable. Intended to be
|
|
11
|
+
applied together with a publication file that forces CDN-hosted css/js
|
|
12
|
+
(<html><resources host="cdn"/>), chunk level 0 (one page), cross-references
|
|
13
|
+
as links rather than knowls, and portable mode off, so that latex-image and
|
|
14
|
+
PreFigure SVGs are linked rather than inlined. Remaining file writers are
|
|
15
|
+
stubbed at the end.
|
|
13
16
|
-->
|
|
14
17
|
<xsl:stylesheet
|
|
15
18
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
@@ -29,7 +32,9 @@
|
|
|
29
32
|
<xsl:import href="pretext-html.xsl"/>
|
|
30
33
|
<xsl:output method="html" encoding="UTF-8" doctype-system="about:legacy-compat"/>
|
|
31
34
|
|
|
32
|
-
<!-- Copied from pretext-html.xsl (mode="file-wrap"), exsl:document removed -->
|
|
35
|
+
<!-- Copied from pretext-html.xsl (mode="file-wrap"), exsl:document removed, -->
|
|
36
|
+
<!-- and the search index embedded in every build, not only portable ones. -->
|
|
37
|
+
<!-- See EMBEDDED_SEARCH_TEST in refresh-xsl.mjs. -->
|
|
33
38
|
<xsl:template match="*" mode="file-wrap">
|
|
34
39
|
<xsl:param name="content" />
|
|
35
40
|
<xsl:param name="title" select="''"/>
|
|
@@ -199,7 +204,7 @@
|
|
|
199
204
|
</div>
|
|
200
205
|
<xsl:copy-of select="$file-wrap-full-endbody-cache"/>
|
|
201
206
|
<!-- For portable builds we stash the lunr search here -->
|
|
202
|
-
<xsl:if test="$
|
|
207
|
+
<xsl:if test="$has-native-search">
|
|
203
208
|
<xsl:call-template name="embedded-search-construction"/>
|
|
204
209
|
</xsl:if>
|
|
205
210
|
<!-- optional body content that needs to be inserted after all content -->
|
|
@@ -211,8 +216,8 @@
|
|
|
211
216
|
</xsl:template>
|
|
212
217
|
|
|
213
218
|
<!-- Chunk at the subtree root's own level, so a fragment preview can name a -->
|
|
214
|
-
<!-- division of any depth as $subtree. Without this,
|
|
215
|
-
<!-- of 0 makes upstream abort on every division below the
|
|
219
|
+
<!-- division of any depth as $subtree. Without this, the preview's chunk -->
|
|
220
|
+
<!-- level of 0 makes upstream abort on every division below the root. -->
|
|
216
221
|
<!-- See SUBTREE_CHUNK_LEVEL_OVERRIDE in refresh-xsl.mjs. -->
|
|
217
222
|
<xsl:param name="subtree-level" select="''"/>
|
|
218
223
|
<xsl:variable name="chunk-level">
|
|
@@ -226,6 +231,62 @@
|
|
|
226
231
|
</xsl:choose>
|
|
227
232
|
</xsl:variable>
|
|
228
233
|
|
|
234
|
+
<!-- A subtree root one level above the chunk level is a summary page: its own -->
|
|
235
|
+
<!-- content, then links to the divisions inside it. Only that page is emitted; -->
|
|
236
|
+
<!-- the chunker is kept from also producing a page per child division. -->
|
|
237
|
+
<!-- See SUMMARY_PAGE_OVERRIDE in refresh-xsl.mjs. -->
|
|
238
|
+
<xsl:template match="*" mode="chunking">
|
|
239
|
+
<xsl:choose>
|
|
240
|
+
<xsl:when test="$b-subsetting and not(generate-id(.) = generate-id(id($subtree)))"/>
|
|
241
|
+
<xsl:otherwise>
|
|
242
|
+
<xsl:apply-imports/>
|
|
243
|
+
</xsl:otherwise>
|
|
244
|
+
</xsl:choose>
|
|
245
|
+
</xsl:template>
|
|
246
|
+
|
|
247
|
+
<xsl:template match="*" mode="intermediate">
|
|
248
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
249
|
+
<xsl:with-param name="content">
|
|
250
|
+
<xsl:apply-templates select="." mode="debug-location"/>
|
|
251
|
+
<section class="{local-name(.)}">
|
|
252
|
+
<xsl:apply-templates select="." mode="html-id-attribute"/>
|
|
253
|
+
<xsl:apply-templates select="." mode="section-heading">
|
|
254
|
+
<xsl:with-param name="heading-level" select="$chunk-heading-level"/>
|
|
255
|
+
</xsl:apply-templates>
|
|
256
|
+
<xsl:apply-templates select="." mode="author-byline"/>
|
|
257
|
+
<xsl:if test="self::frontmatter[not(titlepage)]">
|
|
258
|
+
<xsl:call-template name="frontmatter-title"/>
|
|
259
|
+
</xsl:if>
|
|
260
|
+
<!-- The division's own content, in place -->
|
|
261
|
+
<xsl:for-each select="*">
|
|
262
|
+
<xsl:variable name="structural">
|
|
263
|
+
<xsl:apply-templates select="." mode="is-structural"/>
|
|
264
|
+
</xsl:variable>
|
|
265
|
+
<xsl:if test="not($structural = 'true')">
|
|
266
|
+
<xsl:apply-templates select=".">
|
|
267
|
+
<xsl:with-param name="heading-level" select="$chunk-heading-level + 1"/>
|
|
268
|
+
</xsl:apply-templates>
|
|
269
|
+
</xsl:if>
|
|
270
|
+
</xsl:for-each>
|
|
271
|
+
<!-- Then the divisions inside it, as upstream's summary links -->
|
|
272
|
+
<nav class="summary-links">
|
|
273
|
+
<ul>
|
|
274
|
+
<xsl:for-each select="*">
|
|
275
|
+
<xsl:variable name="structural">
|
|
276
|
+
<xsl:apply-templates select="." mode="is-structural"/>
|
|
277
|
+
</xsl:variable>
|
|
278
|
+
<xsl:if test="$structural = 'true'">
|
|
279
|
+
<xsl:apply-templates select="." mode="summary-nav"/>
|
|
280
|
+
</xsl:if>
|
|
281
|
+
</xsl:for-each>
|
|
282
|
+
</ul>
|
|
283
|
+
</nav>
|
|
284
|
+
<xsl:apply-templates select="." mode="permalink"/>
|
|
285
|
+
</section>
|
|
286
|
+
</xsl:with-param>
|
|
287
|
+
</xsl:apply-templates>
|
|
288
|
+
</xsl:template>
|
|
289
|
+
|
|
229
290
|
<!-- Show the print-preview button on printouts, but inert: the page it would -->
|
|
230
291
|
<!-- reload with "?printpreview=<id>" does not exist for an in-memory render, -->
|
|
231
292
|
<!-- and a host that resolves that query against its own URL sends the reader -->
|
|
@@ -255,11 +316,17 @@
|
|
|
255
316
|
</div>
|
|
256
317
|
</xsl:template>
|
|
257
318
|
|
|
319
|
+
<!-- Skip the passes whose only product is a file the preview never writes: -->
|
|
320
|
+
<!-- knowl files for cross-references, and standalone pages for media. -->
|
|
321
|
+
<!-- See SKIPPED_WORK_STUBS in refresh-xsl.mjs. -->
|
|
322
|
+
<xsl:template match="*" mode="make-xref-knowls"/>
|
|
323
|
+
<xsl:template match="audio|video" mode="media-standalone-page"/>
|
|
324
|
+
|
|
258
325
|
<!-- Stub out the remaining file writers (every other template reachable -->
|
|
259
|
-
<!-- from pretext-html.xsl that contains exsl:document).
|
|
260
|
-
<!--
|
|
261
|
-
<!-- rest and act as a safety net if publication settings change.
|
|
262
|
-
<!-- exsl:document that does fire aborts the FILESYSTEM=0 WASM build.
|
|
326
|
+
<!-- from pretext-html.xsl that contains exsl:document). The preview's -->
|
|
327
|
+
<!-- publication settings keep some of these from being reached; the stubs -->
|
|
328
|
+
<!-- cover the rest and act as a safety net if publication settings change. -->
|
|
329
|
+
<!-- Any exsl:document that does fire aborts the FILESYSTEM=0 WASM build. -->
|
|
263
330
|
<xsl:template name="index-redirect-page"/>
|
|
264
331
|
<xsl:template match="*" mode="manufacture-knowl"/>
|
|
265
332
|
<xsl:template name="ol-marker-styles"/>
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
Intended to be applied together with a publication file that forces
|
|
13
13
|
<revealjs><resources host="cdn" math="online"/></revealjs>, since neither
|
|
14
|
-
locally hosted nor embedded reveal.js resources exist for an in-memory build
|
|
14
|
+
locally hosted nor embedded reveal.js resources exist for an in-memory build,
|
|
15
|
+
and <html><resources host="cdn"/> for PreTeXt's own css/js on the slides.
|
|
15
16
|
-->
|
|
16
17
|
<xsl:stylesheet
|
|
17
18
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
@@ -65,7 +66,11 @@
|
|
|
65
66
|
</xsl:for-each>
|
|
66
67
|
</xsl:template>
|
|
67
68
|
|
|
68
|
-
<!-- Same file-writer stubs as preview-html.xsl
|
|
69
|
+
<!-- Same skipped passes and file-writer stubs as preview-html.xsl (a video -->
|
|
70
|
+
<!-- on a slide renders through the same templates); see SKIPPED_WORK_STUBS -->
|
|
71
|
+
<!-- and FILE_WRITER_STUBS. -->
|
|
72
|
+
<xsl:template match="*" mode="make-xref-knowls"/>
|
|
73
|
+
<xsl:template match="audio|video" mode="media-standalone-page"/>
|
|
69
74
|
<xsl:template name="index-redirect-page"/>
|
|
70
75
|
<xsl:template match="*" mode="manufacture-knowl"/>
|
|
71
76
|
<xsl:template name="ol-marker-styles"/>
|
package/dist/assets.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Retargeting the asset URLs PreTeXt emits.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* — author-supplied images and media, sageplot, asymptote — is emitted as a
|
|
8
|
-
* *runtime* URL under one of two fixed prefixes:
|
|
4
|
+
* Every asset a preview shows — author-supplied images and media, and
|
|
5
|
+
* everything `pretext generate` makes (latex-image, PreFigure, sageplot,
|
|
6
|
+
* asymptote) — is emitted as a *runtime* URL under one of two fixed prefixes:
|
|
9
7
|
*
|
|
10
8
|
* <img src="external/kitten.png">
|
|
9
|
+
* <img src="generated/latex-image/diagram.svg">
|
|
11
10
|
* <img src="generated/sageplot/plot.svg">
|
|
12
11
|
*
|
|
12
|
+
* (A portable build would instead inline the latex-image and PreFigure SVGs,
|
|
13
|
+
* reading them during the transform. The preview no longer builds portable,
|
|
14
|
+
* so those images reach the host here like the rest, and nothing has to read
|
|
15
|
+
* image files while rendering. See publication.ts.)
|
|
16
|
+
*
|
|
13
17
|
* Those prefixes (`$external-directory` / `$generated-directory` in
|
|
14
18
|
* publisher-variables.xsl) name directories a real build populates by copying
|
|
15
19
|
* files next to the output HTML. The preview has no output directory, so the
|
package/dist/banner.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dismissible "this is a live preview" warning banner.
|
|
3
3
|
*
|
|
4
|
-
* The preview forces
|
|
5
|
-
* {@link
|
|
4
|
+
* The preview forces a few publication settings of its own (see
|
|
5
|
+
* {@link forcePreviewPublication}) and skips the asset-generation step
|
|
6
6
|
* entirely, so what an author sees while editing can genuinely differ from a
|
|
7
7
|
* real build — different chunking, no locally generated images, etc. The
|
|
8
8
|
* banner exists to say so, once, without nagging: it renders across the top
|