@pretextbook/pretext-html 0.8.0 → 0.9.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.
Files changed (36) hide show
  1. package/assets/preview-html.xsl +16 -0
  2. package/assets/upstream.json +1 -1
  3. package/assets/xsl/extract-dynamic.xsl +54 -3
  4. package/assets/xsl/extract-gdscript.xsl +61 -0
  5. package/assets/xsl/extract-sageplot.xsl +3 -0
  6. package/assets/xsl/localizations/it-IT.xml +37 -41
  7. package/assets/xsl/pretext-assembly.xsl +188 -24
  8. package/assets/xsl/pretext-beamer.xsl +57 -12
  9. package/assets/xsl/pretext-common.xsl +156 -28
  10. package/assets/xsl/pretext-epub.xsl +0 -5
  11. package/assets/xsl/pretext-fo.xsl +110 -48
  12. package/assets/xsl/pretext-html.xsl +147 -54
  13. package/assets/xsl/pretext-jupyter.xsl +1 -0
  14. package/assets/xsl/pretext-latex-classic.xsl +2 -2
  15. package/assets/xsl/pretext-latex-common.xsl +268 -134
  16. package/assets/xsl/pretext-latex.xsl +16 -6
  17. package/assets/xsl/pretext-numbers.xsl +10 -0
  18. package/assets/xsl/pretext-revealjs.xsl +68 -1
  19. package/assets/xsl/pretext-runestone-fitb.xsl +179 -84
  20. package/assets/xsl/pretext-runestone-static.xsl +72 -20
  21. package/assets/xsl/pretext-runestone.xsl +27 -4
  22. package/assets/xsl/pretext-text-utilities.xsl +7 -0
  23. package/assets/xsl/pretext-text.xsl +17 -0
  24. package/assets/xsl/publisher-variables.xsl +39 -0
  25. package/assets/xsl-bundle.json +1 -1
  26. package/dist/cli-BUrNZxov.js +1098 -0
  27. package/dist/cli.js +1 -1
  28. package/dist/html-static.d.ts +2 -2
  29. package/dist/index.browser.js +595 -386
  30. package/dist/index.d.ts +4 -0
  31. package/dist/index.js +35 -30
  32. package/dist/renderer.d.ts +35 -0
  33. package/dist/skeleton.d.ts +41 -0
  34. package/dist/xrefs.d.ts +54 -0
  35. package/package.json +1 -1
  36. package/dist/cli-Bcn4t3B1.js +0 -871
@@ -210,6 +210,22 @@
210
210
 
211
211
  </xsl:template>
212
212
 
213
+ <!-- Chunk at the subtree root's own level, so a fragment preview can name a -->
214
+ <!-- division of any depth as $subtree. Without this, portable's chunk level -->
215
+ <!-- of 0 makes upstream abort on every division below the document root. -->
216
+ <!-- See SUBTREE_CHUNK_LEVEL_OVERRIDE in refresh-xsl.mjs. -->
217
+ <xsl:param name="subtree-level" select="''"/>
218
+ <xsl:variable name="chunk-level">
219
+ <xsl:choose>
220
+ <xsl:when test="$subtree != '' and $subtree-level != ''">
221
+ <xsl:value-of select="number($subtree-level)"/>
222
+ </xsl:when>
223
+ <xsl:otherwise>
224
+ <xsl:value-of select="$html-chunk-level"/>
225
+ </xsl:otherwise>
226
+ </xsl:choose>
227
+ </xsl:variable>
228
+
213
229
  <!-- Show the print-preview button on printouts, but inert: the page it would -->
214
230
  <!-- reload with "?printpreview=<id>" does not exist for an in-memory render, -->
215
231
  <!-- and a host that resolves that query against its own URL sends the reader -->
@@ -3,5 +3,5 @@
3
3
  "repository": "PreTeXtBook/pretext",
4
4
  "ref": "master"
5
5
  },
6
- "refreshed": "2026-08-03T22:54:01.900Z"
6
+ "refreshed": "2026-08-12T16:43:55.215Z"
7
7
  }
@@ -79,9 +79,24 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
79
79
  <!-- static seed. Results are HTML files -->
80
80
  <!-- (despite this stylesheet having text output). -->
81
81
  <xsl:template match="*" mode="extraction-wrapper">
82
- <xsl:text>[ { "exercise_id": null }</xsl:text>
82
+ <xsl:text>{&#xa;</xsl:text>
83
+ <!-- Remote libraries the publisher has approved for execution -->
84
+ <!-- during a static build. See "remote-library-allowlist" in -->
85
+ <!-- publisher-variables.xsl for why this gate exists. An empty -->
86
+ <!-- list means no exercise may import a library by @url. -->
87
+ <xsl:text>"allowed_remote": [</xsl:text>
88
+ <xsl:for-each select="$remote-library-allowlist">
89
+ <xsl:if test="position() > 1">
90
+ <xsl:text>, </xsl:text>
91
+ </xsl:if>
92
+ <xsl:call-template name="escape-quote-string">
93
+ <xsl:with-param name="text" select="@url"/>
94
+ </xsl:call-template>
95
+ </xsl:for-each>
96
+ <xsl:text>],&#xa;</xsl:text>
97
+ <xsl:text>"exercises": [ { "exercise_id": null }</xsl:text>
83
98
  <xsl:apply-templates select="." mode="extraction"/>
84
- <xsl:text>]</xsl:text>
99
+ <xsl:text>]&#xa;}</xsl:text>
85
100
  </xsl:template>
86
101
 
87
102
  <xsl:template match="exercise[@pi:exercise-interactive='fillin' and setup]
@@ -103,6 +118,34 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
103
118
  <!-- exercises, so it would miss unlabeled exercises and tasks. -->
104
119
  <xsl:apply-templates select="." mode="assembly-id" />
105
120
  <xsl:text>",&#xa;</xsl:text>
121
+ <!-- The @assembly-id above is what the substitution pass reads -->
122
+ <!-- back, but it means nothing to an author. Carry the -->
123
+ <!-- @unique-id alongside it purely so that a failure during -->
124
+ <!-- evaluation can name the exercise the way the author sees it. -->
125
+ <xsl:text> "exercise_unique_id": "</xsl:text>
126
+ <xsl:apply-templates select="." mode="unique-id" />
127
+ <xsl:text>",&#xa;</xsl:text>
128
+ <!-- Packages and libraries this exercise's setup depends on. -->
129
+ <!-- This mirrors the "dyn_imports" array of the HTML version, -->
130
+ <!-- including its leading "BTM", which the substitution script -->
131
+ <!-- matches as a literal and resolves to the npm package, just -->
132
+ <!-- as the Runestone component does. Keeping the two arrays -->
133
+ <!-- identical means an exercise that loads in a browser loads -->
134
+ <!-- the same way under Node. -->
135
+ <xsl:text> "exercise_imports": [</xsl:text>
136
+ <xsl:text>"BTM"</xsl:text>
137
+ <xsl:for-each select="setup/jsimports/jslibrary">
138
+ <xsl:variable name="import-path">
139
+ <xsl:apply-templates select="." mode="js-import-path"/>
140
+ </xsl:variable>
141
+ <xsl:if test="string-length($import-path) > 0">
142
+ <xsl:text>, </xsl:text>
143
+ <xsl:call-template name="escape-quote-string">
144
+ <xsl:with-param name="text" select="$import-path"/>
145
+ </xsl:call-template>
146
+ </xsl:if>
147
+ </xsl:for-each>
148
+ <xsl:text>],&#xa;</xsl:text>
106
149
  <xsl:text> "exercise_setup": </xsl:text>
107
150
  <xsl:call-template name="dynamic-setup" />
108
151
  <xsl:text>,&#xa;</xsl:text>
@@ -116,8 +159,16 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
116
159
  </xsl:otherwise>
117
160
  </xsl:choose>
118
161
  <xsl:text>",&#xa;</xsl:text>
162
+ <!-- Everything the static version needs a value for. Each entry -->
163
+ <!-- is the @obj (or @ansobj) verbatim, which is a Javascript -->
164
+ <!-- *expression*, not merely a variable name: the HTML version -->
165
+ <!-- drops the same string into a template as [%= ... %] , so -->
166
+ <!-- "_config.date" and the like have to evaluate, not be looked -->
167
+ <!-- up. The substitution script evaluates each one in the scope -->
168
+ <!-- left behind by the setup. Duplicates are harmless; they -->
169
+ <!-- collapse to one entry there. -->
119
170
  <xsl:text> "exercise_evals": [</xsl:text>
120
- <xsl:for-each select="(statement|solution)//eval[@obj]|evaluation//feedback//eval[@obj]|statement//fillin[@ansobj]">
171
+ <xsl:for-each select="(statement|solution)//eval[@obj]|evaluation//test[@correct='yes']/feedback//eval[@obj]|statement//fillin[@ansobj]">
121
172
  <xsl:if test="position() > 1">
122
173
  <xsl:text>, </xsl:text>
123
174
  </xsl:if>
@@ -0,0 +1,61 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2026 Robert A. Beezer
5
+
6
+ This file is part of PreTeXt.
7
+
8
+ PreTeXt is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 2 or version 3 of the
11
+ License (at your option).
12
+
13
+ PreTeXt is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
20
+ *********************************************************************-->
21
+
22
+ <!-- This stylesheet locates "program[@pck]" elements and prepares -->
23
+ <!-- a file necessary to zip a "pck" for each activecode with -->
24
+ <!-- GDScript. -->
25
+
26
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
27
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
28
+ xmlns:exsl="http://exslt.org/common"
29
+ xmlns:str="http://exslt.org/strings"
30
+ extension-element-prefixes="exsl"
31
+ >
32
+
33
+ <!-- Get internal ID's for filenames, etc -->
34
+ <!-- Standard conversion groundwork -->
35
+ <xsl:import href="./publisher-variables.xsl"/>
36
+ <xsl:import href="./pretext-assembly.xsl"/>
37
+ <xsl:import href="./pretext-common.xsl"/>
38
+
39
+ <!-- Get a "subtree" xml:id value -->
40
+ <!-- Then walk the XML source tree -->
41
+ <!-- applying specializations below -->
42
+ <xsl:import href="./extract-identity.xsl" />
43
+ <xsl:output method="text" encoding="UTF-8"/>
44
+
45
+ <!-- PreTeXt override: force dynamic exercise processing so that the -->
46
+ <!-- "unique-id" template computes identifiers matching the interactive -->
47
+ <!-- web target rather than a static print target. -->
48
+ <xsl:variable name="exercise-style" select="'dynamic'"/>
49
+
50
+ <!-- Unique id, pck, scene name, and version as a comma-separated quadruple per line -->
51
+ <xsl:template match="program[@pck and @interactive='activecode']" mode="extraction">
52
+ <xsl:apply-templates select="." mode="unique-id" />
53
+ <xsl:text>,</xsl:text>
54
+ <xsl:value-of select="@pck" />
55
+ <xsl:text>,</xsl:text>
56
+ <xsl:value-of select="@scene" />
57
+ <xsl:text>,</xsl:text>
58
+ <xsl:value-of select="$godot.version" />
59
+ <xsl:text>&#xa;</xsl:text> <!-- newline -->
60
+ </xsl:template>
61
+ </xsl:stylesheet>
@@ -122,9 +122,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
122
122
  </xsl:call-template>
123
123
  </xsl:variable>
124
124
  <!-- NB: 2D PNG is not preferable, but needed for EPUB sent to Kindle -->
125
+ <!-- NB: 2D EPS serves journals requiring it; Sage's matplotlib -->
126
+ <!-- machinery saves any 2D plot by the requested file extension -->
125
127
  <xsl:variable name="b-legal-combination" select="($variant = '2d' and $sageplot.fileformat = 'pdf')
126
128
  or ($variant = '2d' and $sageplot.fileformat = 'svg')
127
129
  or ($variant = '2d' and $sageplot.fileformat = 'png')
130
+ or ($variant = '2d' and $sageplot.fileformat = 'eps')
128
131
  or ($variant = '3d' and $sageplot.fileformat = 'png')
129
132
  or ($variant = '3d' and $sageplot.fileformat = 'html')"/>
130
133
  <!-- Only certain combinations are supported and only certain -->
@@ -59,10 +59,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
59
59
  <localization string-id='displaymath'>Matematica in display</localization>
60
60
  <!-- Types of documents, mostly for informational messages -->
61
61
  <localization string-id='volume'>Volume</localization>
62
- <localization string-id='book'>libro</localization>
62
+ <localization string-id='book'>Libro</localization>
63
63
  <localization string-id='article'>Articolo</localization>
64
64
  <localization string-id='letter'>Lettera</localization>
65
- <!-- <localization string-id='slideshow'>Slideshow</localization> -->
65
+ <localization string-id='slideshow'>Sequenza di diapositive</localization>
66
66
  <localization string-id='memo'>Memo</localization>
67
67
  <localization string-id='presentation'>Presentazione</localization>
68
68
  <!-- Parts of a document -->
@@ -79,7 +79,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
79
79
  <localization string-id='conclusion'>Conclusione</localization>
80
80
  <localization string-id='exercises'>Esercizi</localization>
81
81
  <localization string-id='worksheet'>Scheda didattica</localization>
82
- <!-- <localization string-id='handout'>Handout</localization> -->
82
+ <localization string-id='handout'>Dispensa</localization>
83
83
  <localization string-id='reading-questions'>Domande di comprensione del testo</localization>
84
84
  <localization string-id='solutions'>Soluzioni</localization>
85
85
  <localization string-id='glossary'>Glossario</localization>
@@ -88,7 +88,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
88
88
  <localization string-id='paragraphs'>Capoversi</localization>
89
89
  <localization string-id='subparagraph'>Sottocapoverso</localization>
90
90
  <!-- Adjustments to titles of divisions -->
91
- <!-- <localization string-id='group'>Group</localization> -->
91
+ <localization string-id='group'>Gruppo</localization>
92
92
  <!-- Components of the narrative -->
93
93
  <!-- REMARK-LIKE blocks -->
94
94
  <localization string-id='remark'>Osservazione</localization>
@@ -170,11 +170,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
170
170
  <localization string-id='video'>Video</localization>
171
171
  <localization string-id='program'>Programma</localization>
172
172
  <!-- Runestone Exercises -->
173
- <!-- <localization string-id='true'>True</localization> -->
174
- <!-- <localization string-id='false'>False</localization> -->
175
- <!-- <localization string-id='or'>Or</localization> -->
176
- <!-- <localization string-id='either'>Either</localization> -->
177
- <!-- <localization string-id='uncategorized'>Uncategorized</localization> -->
173
+ <localization string-id='true'>Vero</localization>
174
+ <localization string-id='false'>Falso</localization>
175
+ <localization string-id='or'>O</localization>
176
+ <localization string-id='either'>O</localization>
177
+ <localization string-id='uncategorized'>Senza categoria</localization>
178
178
  <!-- <localization string-id='query'>Query</localization> -->
179
179
  <localization string-id='program-activecode'>ActiveCode</localization>
180
180
  <!-- <localization string-id='scratch-activecode'>Scratch ActiveCode</localization> -->
@@ -204,7 +204,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
204
204
  <localization string-id='feedback'>Feedback</localization>
205
205
  <localization string-id='authored'>Redatto in PreTeXt</localization>
206
206
  <!-- Search Results display/dialog -->
207
- <!-- <localization string-id='search-book'>Search Book</localization> -->
207
+ <localization string-id='search-book'>Cerca nel libro</localization>
208
208
  <localization string-id='search-results-heading'>Risultati</localization>
209
209
  <localization string-id='no-search-results'>Nessun risultato</localization>
210
210
  <!-- Parts of memos and letters -->
@@ -225,18 +225,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
225
225
  <localization string-id='permalink'>permalink</localization>
226
226
  <localization string-id='incontext'>Nel Contesto</localization>
227
227
  <!-- <localization string-id='standalone'>Standalone</localization> -->
228
- <!-- <localization string-id='embed'>Embed</localization> -->
229
- <!-- <localization string-id='embed-this-page'>Embed this page</localization> -->
230
- <!-- <localization string-id='copy'>Copy</localization> -->
231
- <!-- <localization string-id='profile'>Profile</localization> -->
232
- <!-- Following is in ENGLISH and should be translated. Due to its -->
233
- <!-- ubiquitous nature we have not left it undefined. See the -->
234
- <!-- "en-US" file for a more complete explanation of its use. -->
235
- <!-- Please remove this entire comment when translated. Thanks. -->
236
- <localization string-id='permalink-tooltip'>Copy heading and permalink for</localization>
237
- <!-- <localization string-id='calculator'>Calculator</localization> -->
228
+ <localization string-id='embed'>Immergi</localization>
229
+ <localization string-id='embed-this-page'>Immergi questa pagina</localization>
230
+ <localization string-id='copy'>Copia</localization>
231
+ <localization string-id='profile'>Profilo</localization>
232
+ <localization string-id='permalink-tooltip'>Copia descrizione e permalink per</localization>
233
+ <localization string-id='calculator'>Calcolatore</localization>
238
234
  <localization string-id='evaluate'>Calcola</localization>
239
- <!-- <localization string-id='code'>Code</localization> -->
235
+ <localization string-id='code'>Codice</localization>
240
236
  <localization string-id='instructions'>Istruzioni</localization>
241
237
  <localization string-id='correct'>Giusto</localization>
242
238
  <localization string-id='incorrect'>Sbagliato</localization>
@@ -249,28 +245,28 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
249
245
  <localization string-id='reset'>Azzera</localization>
250
246
  <localization string-id='array'>tabella</localization>
251
247
  <localization string-id="papersize">Formato carta</localization>
252
- <!-- <localization string-id="printing-options">Additional printing options</localization> -->
253
- <!-- <localization string-id="hide-hints">Hide hints</localization> -->
254
- <!-- <localization string-id="hide-answers">Hide answers</localization> -->
255
- <!-- <localization string-id="hide-solutions">Hide solutions</localization> -->
256
- <!-- <localization string-id="print-header">Print headers</localization> -->
257
- <!-- <localization string-id="print-footer">Print footers</localization> -->
258
- <!-- <localization string-id="first-page">First page</localization> -->
259
- <!-- <localization string-id="running">Running</localization> -->
260
- <!-- <localization string-id="highlight-workspace">Highlight workspace</localization> -->
248
+ <localization string-id="printing-options">Opzioni di stampa addizionali</localization>
249
+ <localization string-id="hide-hints">Nascondi suggerimenti</localization>
250
+ <localization string-id="hide-answers">Nascondi risposte</localization>
251
+ <localization string-id="hide-solutions">Nascondi soluzioni</localization>
252
+ <localization string-id="print-header">Stampa intestazioni</localization>
253
+ <localization string-id="print-footer">Stampa piè di pagina</localization>
254
+ <localization string-id="first-page">Prima pagina</localization>
255
+ <localization string-id="running">Successive</localization>
256
+ <localization string-id="highlight-workspace">Evidenzia spazio di lavoro</localization>
261
257
  <localization string-id='print'>Stampa</localization>
262
258
  <localization string-id='print-preview'>Anteprima di stampa</localization>
263
259
  <localization string-id='close'>Chiudi</localization>
264
- <!-- <localization string-id='open-new-tab'>Open in new tab</localization> -->
260
+ <localization string-id='open-new-tab'>Apri in nuova scheda</localization>
265
261
  <!-- Readability menu items, HTML only, utilized by Javascript -->
266
- <!-- <localization string-id='readability-settings'>Readability settings</localization> -->
267
- <!-- <localization string-id='readability-line-height'>Line height</localization> -->
268
- <!-- <localization string-id='readability-content-font-size'>Content font size</localization> -->
269
- <!-- <localization string-id='readability-theme'>Theme</localization> -->
270
- <!-- <localization string-id='readability-theme-system'>System</localization> -->
271
- <!-- <localization string-id='readability-theme-light'>Light</localization> -->
272
- <!-- <localization string-id='readability-theme-dark'>Dark</localization> -->
273
- <!-- <localization string-id='readability-assistive-technologies'>Assistive technologies</localization> -->
274
- <!-- <localization string-id='readability-expose-permalinks'>Expose permalinks</localization> -->
275
- <!-- <localization string-id='reset-all'>Reset All</localization> -->
262
+ <localization string-id='readability-settings'>Impostazioni di leggibilità</localization>
263
+ <localization string-id='readability-line-height'>Interlinea</localization>
264
+ <localization string-id='readability-content-font-size'>Dimensione dei caratteri del contenuto</localization>
265
+ <localization string-id='readability-theme'>Tema</localization>
266
+ <localization string-id='readability-theme-system'>Sistema</localization>
267
+ <localization string-id='readability-theme-light'>Chiaro</localization>
268
+ <localization string-id='readability-theme-dark'>Scuro</localization>
269
+ <localization string-id='readability-assistive-technologies'>Tecnologie assistive</localization>
270
+ <localization string-id='readability-expose-permalinks'>Mostra i permalink</localization>
271
+ <localization string-id='reset-all'>Ripristina tutte</localization>
276
272
  </locale>