@pretextbook/pretext-html 0.3.0 → 0.4.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 +20 -9
- package/assets/preview-html.xsl +8 -4
- package/assets/upstream.json +1 -1
- package/assets/xsl/README.md +25 -24
- package/assets/xsl/entities.ent +20 -0
- package/assets/xsl/extract-biblio-csl.xsl +1 -1
- package/assets/xsl/extract-pg.xsl +111 -297
- package/assets/xsl/extract-qrcode.xsl +11 -1
- package/assets/xsl/extract-sageplot.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +1 -2
- package/assets/xsl/localizations/README.md +24 -24
- package/assets/xsl/pretext-assembly.xsl +101 -11
- package/assets/xsl/pretext-beamer.xsl +43 -146
- package/assets/xsl/pretext-braille-preprint.xsl +457 -201
- package/assets/xsl/pretext-common.xsl +388 -423
- package/assets/xsl/pretext-epub.xsl +301 -72
- package/assets/xsl/pretext-fo.xsl +70 -86
- package/assets/xsl/pretext-html.xsl +331 -259
- package/assets/xsl/pretext-jupyter.xsl +534 -322
- package/assets/xsl/pretext-latex-classic.xsl +14 -15
- package/assets/xsl/pretext-latex-common.xsl +385 -2389
- package/assets/xsl/pretext-latex.xsl +1995 -5
- package/assets/xsl/pretext-markdown.xsl +919 -0
- package/assets/xsl/pretext-numbers.xsl +22 -4
- package/assets/xsl/pretext-revealjs.xsl +241 -33
- package/assets/xsl/pretext-runestone-fitb.xsl +20 -22
- package/assets/xsl/pretext-runestone.xsl +3 -3
- package/assets/xsl/pretext-sage-doctest.xsl +2 -2
- package/assets/xsl/pretext-text-utilities.xsl +69 -1
- package/assets/xsl/pretext-text.xsl +1077 -107
- package/assets/xsl/publisher-variables.xsl +396 -452
- package/assets/xsl/support/play-button/README.md +1 -3
- package/assets/xsl/tests/README.md +1 -1
- package/assets/xsl/utilities/README.md +6 -8
- package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
- package/assets/xsl-bundle.json +1 -1
- package/dist/{cli-CzoinNle.js → cli-Cp6C0sif.js} +220 -205
- package/dist/cli.js +1 -1
- package/dist/index.browser.js +351 -342
- package/dist/index.js +1 -1
- package/dist/publication.d.ts +9 -1
- package/dist/renderer.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,17 @@ const { html } = await renderHtml({
|
|
|
69
69
|
- The user's publication file is respected, except
|
|
70
70
|
`<html><platform portable="yes"/></html>` is always forced — that is what
|
|
71
71
|
makes single-page in-memory output possible.
|
|
72
|
+
- `cssTheme: "denver"` supplies the PreTeXt HTML theme for projects that do not
|
|
73
|
+
choose one, by adding `<html><css theme="…"/></html>` to the publication file
|
|
74
|
+
used for the build (including the minimal one synthesized when you pass no
|
|
75
|
+
`publicationPath`). It is a default, never an override: a publication file
|
|
76
|
+
that already names a theme — `@theme`, or the deprecated `@style`/`@shell` —
|
|
77
|
+
keeps it, so the preview goes on matching what `pretext build` produces. The
|
|
78
|
+
themes the bundled stylesheets know are `default-modern` (PreTeXt's own
|
|
79
|
+
default), `denver`, `tacoma`, `salem`, `greeley` and `boulder`; a portable
|
|
80
|
+
build loads `theme-<name>.min.css` from the CDN, so an unrecognised name
|
|
81
|
+
gives an unstyled page. Not to be confused with `theme` below, which is the
|
|
82
|
+
light/dark mode _within_ whichever css theme is in force.
|
|
72
83
|
- The compiled stylesheet is cached per `xslDir` (~1s to compile, then
|
|
73
84
|
~100ms–1s per render depending on document size).
|
|
74
85
|
- `theme: "dark" | "light" | "system"` makes the preview follow the embedding
|
|
@@ -213,13 +224,13 @@ the message helper.
|
|
|
213
224
|
|
|
214
225
|
## Limitations (current WASM build)
|
|
215
226
|
|
|
216
|
-
| Limitation | Cause
|
|
217
|
-
| ---------------------------------------------- |
|
|
218
|
-
| No multi-file output (`exsl:document`) | Compiled with `FILESYSTEM=0`
|
|
219
|
-
| JSPI required (flagged on Node) | Loader fetches resources mid-transform via JSPI
|
|
220
|
-
| No generated images (latex-image, sageplot, …) | Produced by the Python toolchain, not XSLT
|
|
221
|
-
| `xi:include` with `xpointer` unsupported | JS resolver stands in for libxml2's
|
|
222
|
-
| Renders run one at a time, never in parallel | Shared libxslt state; the transform suspends mid-run | Inherent; `renderHtml` queues concurrent calls for you
|
|
227
|
+
| Limitation | Cause | Fix |
|
|
228
|
+
| ---------------------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
229
|
+
| No multi-file output (`exsl:document`) | Compiled with `FILESYSTEM=0` | Rebuild with `FILESYSTEM=1` (files land in MEMFS) |
|
|
230
|
+
| JSPI required (flagged on Node) | Loader fetches resources mid-transform via JSPI | Feature-detect with `isJspiAvailable()`; engines without it need a fallback |
|
|
231
|
+
| No generated images (latex-image, sageplot, …) | Produced by the Python toolchain, not XSLT | Out of scope; run `pretext generate` and the preview will pick the files up |
|
|
232
|
+
| `xi:include` with `xpointer` unsupported | JS resolver stands in for libxml2's | Rebuild adding `xmlXIncludeProcessFlags` to the JSPI export list |
|
|
233
|
+
| Renders run one at a time, never in parallel | Shared libxslt state; the transform suspends mid-run | Inherent; `renderHtml` queues concurrent calls for you |
|
|
223
234
|
|
|
224
235
|
The whole-book stack overflow ("memory access out of bounds") that the stock
|
|
225
236
|
`libxslt-wasm` build hit on large documents is **fixed** in the
|
|
@@ -228,7 +239,7 @@ The whole-book stack overflow ("memory access out of bounds") that the stock
|
|
|
228
239
|
### Concurrency
|
|
229
240
|
|
|
230
241
|
A render is not reentrant. It drives a single cached compiled stylesheet
|
|
231
|
-
through a patched `globalThis.fetch` and shared mount tables, and it
|
|
242
|
+
through a patched `globalThis.fetch` and shared mount tables, and it _suspends_
|
|
232
243
|
mid-transform to fetch stylesheets — which is precisely the window in which
|
|
233
244
|
another render would get to run. Overlapping renders interleave inside libxslt
|
|
234
245
|
and corrupt it.
|
|
@@ -239,7 +250,7 @@ render that rejects does not stall the queue.
|
|
|
239
250
|
|
|
240
251
|
This matters mainly if you drive the internals yourself. If you do, serialize
|
|
241
252
|
your own calls — the corruption is not self-describing: it surfaces as an
|
|
242
|
-
out-of-bounds memory fault, and afterwards the WASM instance aborts on
|
|
253
|
+
out-of-bounds memory fault, and afterwards the WASM instance aborts on _every_
|
|
243
254
|
later call for the lifetime of the process. Once that has happened, only a
|
|
244
255
|
restart (or a page reload) recovers; `renderHtml` detects the state and says so
|
|
245
256
|
rather than repeating the underlying assertion.
|
package/assets/preview-html.xsl
CHANGED
|
@@ -111,11 +111,15 @@
|
|
|
111
111
|
<!-- this *must* be first for maximum utility -->
|
|
112
112
|
<xsl:call-template name="skip-to-content-link" />
|
|
113
113
|
<!-- HTML5 body/header will be a "banner" landmark automatically -->
|
|
114
|
-
<header id="ptx-masthead" class="ptx-masthead">
|
|
114
|
+
<header id="ptx-masthead" class="ptx-masthead" role="banner">
|
|
115
115
|
<div class="ptx-banner">
|
|
116
116
|
<xsl:call-template name="brand-logo" />
|
|
117
117
|
<div class="title-container">
|
|
118
|
-
<
|
|
118
|
+
<xsl:variable name="banner-heading-element-type">
|
|
119
|
+
<xsl:apply-templates select="." mode="banner-heading-element-type"/>
|
|
120
|
+
</xsl:variable>
|
|
121
|
+
<xsl:element name="{$banner-heading-element-type}">
|
|
122
|
+
<xsl:attribute name="class">heading ptx-banner-heading</xsl:attribute>
|
|
119
123
|
<xsl:variable name="root-filename">
|
|
120
124
|
<xsl:apply-templates select="$document-root" mode="containing-filename" />
|
|
121
125
|
</xsl:variable>
|
|
@@ -133,7 +137,7 @@
|
|
|
133
137
|
</span>
|
|
134
138
|
</xsl:if>
|
|
135
139
|
</a>
|
|
136
|
-
</
|
|
140
|
+
</xsl:element>
|
|
137
141
|
<!-- Serial list of authors/editors -->
|
|
138
142
|
<xsl:if test="$b-html-banner-byline">
|
|
139
143
|
<p class="byline">
|
|
@@ -142,7 +146,7 @@
|
|
|
142
146
|
</p>
|
|
143
147
|
</xsl:if>
|
|
144
148
|
</div> <!-- title-container -->
|
|
145
|
-
</div>
|
|
149
|
+
</div> <!-- banner -->
|
|
146
150
|
</header> <!-- masthead -->
|
|
147
151
|
<xsl:apply-templates select="." mode="primary-navigation"/>
|
|
148
152
|
<xsl:apply-templates select="." mode="latex-macros"/>
|
package/assets/upstream.json
CHANGED
package/assets/xsl/README.md
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
eXtensible Stylesheet Language (XSL) Stylesheets
|
|
2
|
+
================================================
|
|
2
3
|
|
|
3
4
|
XSL stylesheets are the primary vehicle for converting PreTeXt XML
|
|
4
|
-
source into various output formats.
|
|
5
|
-
simply called "conversions."
|
|
6
|
-
conversions, the list is not exhaustive.
|
|
5
|
+
source into various output formats. As such, they are sometimes
|
|
6
|
+
simply called "conversions." Here we list **some** of the available
|
|
7
|
+
conversions, the list is not exhaustive. See _The PreTeXt Guide_
|
|
7
8
|
for detailed documentation of use, in chapters of the part
|
|
8
9
|
titled _Publisher's Guide_.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
* `pretext-latex.xsl` - conversion to LaTeX, which can then
|
|
12
|
+
be converted to PDF, in print or electronic flavors.
|
|
13
|
+
* `pretext-html.xsl` - conversion to HTML for online use.
|
|
14
|
+
* `pretext-epub.xsl` - conversion to EPUB, which
|
|
15
|
+
requires significant additional processing. So this stylesheet
|
|
16
|
+
is not meant to be applied in isolation. See the `pretext/pretext`
|
|
17
|
+
Python script for an option to initiate the processing pipeline.
|
|
18
|
+
* `pretext-jupyter.xsl` - conversion to Jupyter notebooks.
|
|
19
|
+
* `pretext-revealjs.xsl` - conversion of slideshows to HTML.
|
|
20
|
+
* `pretext-beamer.xsl` - conversion of slideshows to PDF.
|
|
21
|
+
* `pretext-braille.xsl` - conversion to a precursor for braille output, which
|
|
22
|
+
requires significant further processing. So this stylesheet
|
|
23
|
+
is not meant to be applied in isolation. See the `pretext/pretext`
|
|
24
|
+
Python script for an option to initiate the processing pipeline.
|
|
25
|
+
* `pretext-common.xsl` - base templates, and not useful in isolation.
|
|
26
|
+
* `pretext-assembly.xsl` - pre-processing stylesheet, which creates an
|
|
27
|
+
enhanced version of source. Applied in a controlled way by other stylesheets.
|
|
28
|
+
See the `utilities\pretext-enhanced-source.xsl` stylesheet for a demonstration.
|
|
29
|
+
* `extract-*.xsl` - used to isolate particular parts of a PreTeXt
|
|
30
|
+
document, typically for subsequent processing by a script.
|
|
30
31
|
|
|
31
32
|
(Updated: 2020-06-12)
|
package/assets/xsl/entities.ent
CHANGED
|
@@ -37,6 +37,14 @@
|
|
|
37
37
|
|
|
38
38
|
<!ENTITY SPECIALIZED-DIVISION "exercises|worksheet|handout|reading-questions|references|glossary|solutions">
|
|
39
39
|
|
|
40
|
+
<!-- "Division companions" are the non-structural companions of a -->
|
|
41
|
+
<!-- structured traditional division: they may earn their own page -->
|
|
42
|
+
<!-- (and links) when their parent is realized as a summary page in -->
|
|
43
|
+
<!-- a chunked conversion (HTML and derivatives). The schema only -->
|
|
44
|
+
<!-- allows these four elements, division-flavored, in the parents -->
|
|
45
|
+
<!-- listed. The filter form presumes context has qualified parents. -->
|
|
46
|
+
<!ENTITY DIVISION-COMPANION "introduction[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]|conclusion[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]|objectives[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]|outcomes[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]">
|
|
47
|
+
|
|
40
48
|
<!-- for filtering nodes, eg *[&STRUCTURAL-FILTER;], *[not(&STRUCTURAL-FILTER;)] -->
|
|
41
49
|
<!ENTITY STRUCTURAL-FILTER "self::book or self::article or self::slideshow or self::letter or self::memo or self::frontmatter or self::part or self::chapter or self::appendix or self::index or self::preface or self::acknowledgement or self::biography or self::foreword or self::dedication or self::colophon or self::section or self::subsection or self::subsubsection or self::slide or self::exercises or self::worksheet or self::handout or self::reading-questions or self::solutions or self::references or self::glossary or self::backmatter">
|
|
42
50
|
|
|
@@ -44,6 +52,8 @@
|
|
|
44
52
|
|
|
45
53
|
<!ENTITY SPECIALIZED-DIVISION-FILTER "self::exercises or self::worksheet or self::handout or self::reading-questions or self::references or self::glossary or self::solutions">
|
|
46
54
|
|
|
55
|
+
<!ENTITY DIVISION-COMPANION-FILTER "self::introduction or self::conclusion or self::objectives or self::outcomes">
|
|
56
|
+
|
|
47
57
|
<!-- NB: (2019-06-12) Only the two metadata "filters" seem to -->
|
|
48
58
|
<!-- be in use, so only those are being maintained. grep'ing on -->
|
|
49
59
|
<!-- METADATA v. METADATA-FILTER, and applying "wc" makes this evident. -->
|
|
@@ -139,6 +149,16 @@
|
|
|
139
149
|
<!ENTITY FUNDAMENTAL-BLOCK-FILTER "(&DEFINITION-FILTER;) or (&THEOREM-FILTER;) or (&AXIOM-FILTER;) or (&REMARK-FILTER;) or (&COMPUTATION-FILTER;) or (&EXAMPLE-FILTER;)">
|
|
140
150
|
<!ENTITY TOP-FIGURE-FILTER "(&FIGURE-FILTER;) and not(parent::sidebyside/parent::figure or parent::sidebyside/parent::sbsgroup/parent::figure)">
|
|
141
151
|
|
|
152
|
+
<!-- Panels of a "sidebyside", and content of a "stack" panel. The -->
|
|
153
|
+
<!-- lists mirror the schema, plus grandfathered items the code still -->
|
|
154
|
+
<!-- tolerates: "audio", "video", "interactive" (precluded -->
|
|
155
|
+
<!-- 2026-07-22, may someday be removed). An "exercise" panel -->
|
|
156
|
+
<!-- (worksheet or handout only) and a "slate" panel (within an -->
|
|
157
|
+
<!-- "interactive" only) are policed by the validation-plus -->
|
|
158
|
+
<!-- stylesheet. -->
|
|
159
|
+
<!ENTITY SBSPANEL "p|pre|ol|ul|dl|program|console|poem|audio|video|interactive|slate|exercise|image|figure|table|listing|list|tabular|stack">
|
|
160
|
+
<!ENTITY STACKABLE "tabular|image|p|pre|ol|ul|dl|audio|video|interactive|slate|program|console">
|
|
161
|
+
|
|
142
162
|
<!-- appendages of examples, exercises, tasks -->
|
|
143
163
|
<!ENTITY SOLUTION-LIKE "hint|answer|solution">
|
|
144
164
|
<!ENTITY SOLUTION-FILTER "self::hint or self::answer or self::solution">
|
|
@@ -100,7 +100,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
100
100
|
<!-- TODO: perhaps report content also, as a better assist, or the self/parent/ancestor biblio id -->
|
|
101
101
|
<!-- TODO: refine to include un-implemented bits of "citeproc-py" (e/g static-ordering) -->
|
|
102
102
|
<xsl:template match="*" mode="biblio-to-json">
|
|
103
|
-
<xsl:message>BUG: PreTeXt "biblio" markup using a "<xsl:value-of select="local-name()"/>" element is not implemented</xsl:message>
|
|
103
|
+
<xsl:message>PTX:BUG: PreTeXt "biblio" markup using a "<xsl:value-of select="local-name()"/>" element is not implemented</xsl:message>
|
|
104
104
|
</xsl:template>
|
|
105
105
|
|
|
106
106
|
<!-- Gross JSON array structure, duplicate an ID for the division -->
|