@pretextbook/pretext-html 0.3.0 → 0.5.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 (58) hide show
  1. package/README.md +106 -10
  2. package/assets/preview-html.xsl +8 -4
  3. package/assets/preview-revealjs.xsl +85 -0
  4. package/assets/upstream.json +1 -1
  5. package/assets/xsl/LICENSE-pretext +16 -0
  6. package/assets/xsl/README.md +25 -24
  7. package/assets/xsl/entities.ent +27 -0
  8. package/assets/xsl/extract-biblio-csl.xsl +6 -4
  9. package/assets/xsl/extract-dynamic.xsl +14 -12
  10. package/assets/xsl/extract-interactive.xsl +2 -2
  11. package/assets/xsl/extract-pg.xsl +123 -306
  12. package/assets/xsl/extract-qrcode.xsl +12 -2
  13. package/assets/xsl/extract-sageplot.xsl +1 -1
  14. package/assets/xsl/extract-trace.xsl +3 -3
  15. package/assets/xsl/extract-youtube.xsl +1 -1
  16. package/assets/xsl/latex/pretext-latex-texstyle.xsl +4 -5
  17. package/assets/xsl/localizations/README.md +24 -24
  18. package/assets/xsl/pretext-assembly.xsl +463 -368
  19. package/assets/xsl/pretext-beamer.xsl +43 -146
  20. package/assets/xsl/pretext-braille-preprint.xsl +458 -202
  21. package/assets/xsl/pretext-common.xsl +486 -510
  22. package/assets/xsl/pretext-epub.xsl +318 -78
  23. package/assets/xsl/pretext-fo.xsl +80 -96
  24. package/assets/xsl/pretext-html.xsl +413 -318
  25. package/assets/xsl/pretext-jupyter.xsl +534 -322
  26. package/assets/xsl/pretext-latex-classic.xsl +14 -15
  27. package/assets/xsl/pretext-latex-common.xsl +393 -2397
  28. package/assets/xsl/pretext-latex.xsl +1995 -5
  29. package/assets/xsl/pretext-markdown.xsl +919 -0
  30. package/assets/xsl/pretext-numbers.xsl +57 -39
  31. package/assets/xsl/pretext-revealjs.xsl +241 -33
  32. package/assets/xsl/pretext-runestone-fitb.xsl +34 -35
  33. package/assets/xsl/pretext-runestone-static.xsl +17 -17
  34. package/assets/xsl/pretext-runestone.xsl +36 -34
  35. package/assets/xsl/pretext-sage-doctest.xsl +2 -2
  36. package/assets/xsl/pretext-text-utilities.xsl +69 -1
  37. package/assets/xsl/pretext-text.xsl +1077 -107
  38. package/assets/xsl/pretext-view-source.xsl +5 -3
  39. package/assets/xsl/pretext-ww-problem-sets.xsl +6 -1
  40. package/assets/xsl/publisher-variables.xsl +397 -477
  41. package/assets/xsl/support/play-button/README.md +1 -3
  42. package/assets/xsl/tests/README.md +1 -1
  43. package/assets/xsl/utilities/README.md +6 -8
  44. package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
  45. package/assets/xsl-bundle.json +1 -1
  46. package/dist/cli-DZsyZERX.js +694 -0
  47. package/dist/cli.js +1 -1
  48. package/dist/index.browser.d.ts +5 -0
  49. package/dist/index.browser.js +499 -344
  50. package/dist/index.d.ts +5 -0
  51. package/dist/index.js +23 -18
  52. package/dist/publication.d.ts +26 -12
  53. package/dist/renderer.d.ts +68 -0
  54. package/dist/reveal.d.ts +77 -0
  55. package/dist/reveal.js +110 -0
  56. package/dist/target.d.ts +34 -0
  57. package/package.json +12 -1
  58. package/dist/cli-CzoinNle.js +0 -639
@@ -49,22 +49,22 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
49
49
  <!-- ######################## -->
50
50
 
51
51
  <!-- Given a block element, produce its structure number prefix -->
52
- <!-- by reading the pre-computed @block-struct from the nearest -->
52
+ <!-- by reading the pre-computed @pi:block-struct from the nearest -->
53
53
  <!-- ancestor division, then truncating or padding to the configured -->
54
- <!-- number of levels. The @block-struct chain already excludes -->
54
+ <!-- number of levels. The @pi:block-struct chain already excludes -->
55
55
  <!-- parts (they are squelched in assembly), so when parts are -->
56
56
  <!-- present the caller's $levels (which counts from "part" depth) -->
57
57
  <!-- must be reduced by one to match the shorter chain. -->
58
58
  <xsl:template name="block-structure-number">
59
59
  <xsl:param name="levels"/>
60
60
  <xsl:variable name="raw-struct"
61
- select="ancestor::*[@block-struct][1]/@block-struct"/>
62
- <!-- The @block-struct chain already excludes parts, so when -->
63
- <!-- parts are present the $levels count (which includes the -->
64
- <!-- part depth) must be reduced by one. But only for -->
65
- <!-- blocks actually inside a part or backmatter — blocks -->
66
- <!-- in frontmatter have no part ancestor and should use -->
67
- <!-- $levels unmodified. -->
61
+ select="ancestor::*[@pi:block-struct][1]/@pi:block-struct"/>
62
+ <!-- The @pi:block-struct chain already excludes parts, so when -->
63
+ <!-- parts are present the $levels count (which includes the -->
64
+ <!-- part depth) must be reduced by one. But only for -->
65
+ <!-- blocks actually inside a part or backmatter — blocks -->
66
+ <!-- in frontmatter have no part ancestor and should use -->
67
+ <!-- $levels unmodified. -->
68
68
  <xsl:variable name="effective-levels">
69
69
  <xsl:choose>
70
70
  <xsl:when test="not($parts = 'absent') and ancestor::*[self::part or self::backmatter]">
@@ -150,12 +150,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
150
150
  <xsl:variable name="old-level">
151
151
  <xsl:apply-templates select="." mode="level"/>
152
152
  </xsl:variable>
153
- <xsl:if test="not($old-level = @level)">
153
+ <xsl:if test="not($old-level = @pi:level)">
154
154
  <xsl:message>PTX:BUG: development bug, new level does not match old level for "<xsl:value-of select="local-name(.)"/>"</xsl:message>
155
155
  <xsl:apply-templates select="." mode="location-report" />
156
156
  </xsl:if>
157
157
  <!-- actual value here, above is debugging -->
158
- <xsl:value-of select="@level"/>
158
+ <xsl:value-of select="@pi:level"/>
159
159
  </xsl:template>
160
160
 
161
161
  <xsl:template match="*" mode="new-level">
@@ -217,12 +217,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
217
217
  <xsl:template match="backmatter/references" mode="serial-number" />
218
218
  <xsl:template match="backmatter/glossary" mode="serial-number" />
219
219
 
220
- <!-- Serial number of a block: read the @serial that the assembly -->
221
- <!-- "serial-stamp" pass stamped. That pass decides, from the -->
222
- <!-- publication "@distinct" switches, whether a group shares the -->
223
- <!-- overall blocks counter or runs on its own distinct counter. -->
220
+ <!-- Serial number of a block: read the @pi:serial that the assembly -->
221
+ <!-- "serial-stamp" pass stamped. That pass decides, from the -->
222
+ <!-- publication "@distinct" switches, whether a group shares the -->
223
+ <!-- overall blocks counter or runs on its own distinct counter. -->
224
224
  <xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&FIGURE-LIKE;|&OPENPROBLEM-LIKE;|exercise" mode="serial-number">
225
- <xsl:value-of select="@serial"/>
225
+ <xsl:value-of select="@pi:serial"/>
226
226
  </xsl:template>
227
227
 
228
228
  <!-- Proofs may be numbered (for cross-reference knowls) -->
@@ -231,12 +231,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
231
231
  </xsl:template>
232
232
 
233
233
 
234
- <!-- Serial Numbers: Equations -->
235
- <!-- The assembly equation-serial pass stamps @serial on every numbered -->
236
- <!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
237
- <!-- behaviour live in the assembly pass. -->
234
+ <!-- Serial Numbers: Equations -->
235
+ <!-- The assembly equation-serial pass stamps @pi:serial on every numbered -->
236
+ <!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
237
+ <!-- behaviour live in the assembly pass. -->
238
238
  <xsl:template match="mrow[@pi:numbered = 'yes']" mode="serial-number">
239
- <xsl:value-of select="@serial"/>
239
+ <xsl:value-of select="@pi:serial"/>
240
240
  </xsl:template>
241
241
 
242
242
  <!-- An authored bare "md" may carry an @xml:id, and so may be cross-referenced. -->
@@ -323,12 +323,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
323
323
  </xsl:choose>
324
324
  </xsl:template>
325
325
 
326
- <!-- Serial Numbers: Footnotes -->
327
- <!-- We determine the appropriate subtree to count within -->
328
- <!-- given the document root and the configured depth -->
329
- <!-- @serial is stamped on every fn during assembly; here we read it back. -->
326
+ <!-- Serial Numbers: Footnotes -->
327
+ <!-- We determine the appropriate subtree to count within -->
328
+ <!-- given the document root and the configured depth -->
329
+ <!-- @pi:serial is stamped on every fn during assembly; here we read it back. -->
330
330
  <xsl:template match="fn" mode="serial-number">
331
- <xsl:value-of select="@serial"/>
331
+ <xsl:value-of select="@pi:serial"/>
332
332
  </xsl:template>
333
333
 
334
334
  <!-- Serial Numbers: Subfigures, Subtables, Sublisting-->
@@ -363,7 +363,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
363
363
  <!-- First, the number of a list item within its own ordered list. This -->
364
364
  <!-- trades on the PTX format codes being identical to the XSLT codes. -->
365
365
  <xsl:template match="ol/li" mode="item-number">
366
- <xsl:variable name="code" select="../@format-code" />
366
+ <xsl:variable name="code" select="../@pi:format-code" />
367
367
  <xsl:number format="{$code}" />
368
368
  </xsl:template>
369
369
 
@@ -389,7 +389,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
389
389
  <!-- group as its serial number. -->
390
390
  <xsl:template match="exercisegroup" mode="serial-number">
391
391
  <xsl:apply-templates select="exercise[1]" mode="serial-number" />
392
- <xsl:call-template name="ndash-character"/>
392
+ <xsl:call-template name="character">
393
+ <xsl:with-param name="name" select="'ndash'"/>
394
+ </xsl:call-template>
393
395
  <xsl:apply-templates select="exercise[last()]" mode="serial-number" />
394
396
  </xsl:template>
395
397
 
@@ -450,7 +452,23 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
450
452
  <!-- Lists live in paragraphs, exercises, objectives, so -->
451
453
  <!-- should be referenced as part of some enclosing element. -->
452
454
  <!-- "mathbook" helps some tree-climbing routines halt -->
453
- <xsl:template match="mathbook|pretext|introduction|conclusion|frontmatter|backmatter|sidebyside|sbsgroup|ol|ul|dl|statement" mode="serial-number" />
455
+ <xsl:template match="mathbook|pretext|frontmatter|backmatter|sidebyside|sbsgroup|ol|ul|dl|statement" mode="serial-number" />
456
+
457
+ <!-- An "introduction" or "conclusion" of a structured division (a -->
458
+ <!-- "division companion") occurs at most once per division, and so -->
459
+ <!-- takes its number from the parent, exactly as GOAL-LIKE does. -->
460
+ <!-- The number is never displayed where born; it only serves to -->
461
+ <!-- identify the target of a cross-reference. Every other flavor -->
462
+ <!-- (in blocks, tasks, exercise groups, ...) has no number at all. -->
463
+ <xsl:template match="introduction|conclusion" mode="serial-number"/>
464
+
465
+ <xsl:template match="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]" mode="serial-number">
466
+ <xsl:apply-templates select="parent::*" mode="serial-number"/>
467
+ </xsl:template>
468
+
469
+ <xsl:template match="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]" mode="structure-number">
470
+ <xsl:apply-templates select="parent::*" mode="structure-number"/>
471
+ </xsl:template>
454
472
 
455
473
  <!-- Poems go by their titles, not numbers -->
456
474
  <xsl:template match="poem" mode="serial-number" />
@@ -507,10 +525,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
507
525
  <xsl:number count="stage" from="static" />
508
526
  </xsl:template>
509
527
 
510
- <!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @serial, -->
511
- <!-- alongside the other block families above. Their structure number -->
512
- <!-- follows the figure/project pattern: the open-problem level when they -->
513
- <!-- run on a distinct counter, otherwise the shared "blocks" level. -->
528
+ <!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @pi:serial, -->
529
+ <!-- alongside the other block families above. Their structure number -->
530
+ <!-- follows the figure/project pattern: the open-problem level when they -->
531
+ <!-- run on a distinct counter, otherwise the shared "blocks" level. -->
514
532
  <xsl:template match="&OPENPROBLEM-LIKE;" mode="structure-number">
515
533
  <xsl:variable name="openproblem-levels">
516
534
  <xsl:choose>
@@ -541,7 +559,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
541
559
  <!-- Should not drop in here. Ever. -->
542
560
  <xsl:template match="*" mode="serial-number">
543
561
  <xsl:text>[NUM]</xsl:text>
544
- <xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a serial number, search output for "[NUM]"</xsl:message>
562
+ <xsl:message>PTX:BUG: An object (<xsl:value-of select="local-name(.)" />) lacks a serial number, search output for "[NUM]"</xsl:message>
545
563
  <xsl:apply-templates select="." mode="location-report" />
546
564
  </xsl:template>
547
565
 
@@ -565,7 +583,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
565
583
  <!-- NB: this is number of the *container* of the division, -->
566
584
  <!-- a serial number for the division itself will be appended -->
567
585
  <xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="structure-number">
568
- <xsl:value-of select="@struct"/>
586
+ <xsl:value-of select="@pi:struct"/>
569
587
  </xsl:template>
570
588
 
571
589
  <!-- Structure Numbers: Specialized Divisions -->
@@ -580,7 +598,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
580
598
  </xsl:variable>
581
599
  <xsl:choose>
582
600
  <xsl:when test="$is-numbered = 'true'">
583
- <xsl:value-of select="@struct"/>
601
+ <xsl:value-of select="@pi:struct"/>
584
602
  </xsl:when>
585
603
  <xsl:otherwise>
586
604
  <xsl:apply-templates select="parent::*" mode="structure-number" />
@@ -784,7 +802,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
784
802
  <!-- Should not drop in here. Ever. -->
785
803
  <xsl:template match="*" mode="structure-number">
786
804
  <xsl:text>[STRUCT]</xsl:text>
787
- <xsl:message>PTX:ERROR: An object (<xsl:value-of select="local-name(.)" />) lacks a structure number, search output for "[STRUCT]"</xsl:message>
805
+ <xsl:message>PTX:BUG: An object (<xsl:value-of select="local-name(.)" />) lacks a structure number, search output for "[STRUCT]"</xsl:message>
788
806
  <xsl:apply-templates select="." mode="location-report" />
789
807
  </xsl:template>
790
808
 
@@ -845,7 +863,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
845
863
  <xsl:choose>
846
864
  <xsl:when test="$relative-level > $numbering-maxlevel" />
847
865
  <xsl:otherwise>
848
- <xsl:value-of select="@serial"/>
866
+ <xsl:value-of select="@pi:serial"/>
849
867
  </xsl:otherwise>
850
868
  </xsl:choose>
851
869
  </xsl:template>
@@ -863,7 +881,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
863
881
  <xsl:choose>
864
882
  <xsl:when test="$relative-level > $numbering-maxlevel" />
865
883
  <xsl:otherwise>
866
- <xsl:value-of select="@serial"/>
884
+ <xsl:value-of select="@pi:serial"/>
867
885
  </xsl:otherwise>
868
886
  </xsl:choose>
869
887
  </xsl:when>
@@ -31,10 +31,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
31
31
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
32
32
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
33
33
  xmlns:pi="http://pretextbook.org/2020/pretext/internal"
34
+ xmlns:svg="http://www.w3.org/2000/svg"
35
+ xmlns:pf="https://prefigure.org"
34
36
  xmlns:exsl="http://exslt.org/common"
35
37
  xmlns:date="http://exslt.org/dates-and-times"
36
38
  xmlns:str="http://exslt.org/strings"
37
39
  extension-element-prefixes="exsl date str"
40
+ exclude-result-prefixes="svg pf"
38
41
  >
39
42
 
40
43
  <!-- Necessary to get some HTML constructions, -->
@@ -52,6 +55,17 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
52
55
  <!-- HTML conversion (preferably avoid using this). -->
53
56
  <xsl:variable name="b-reveal-build" select="true()" />
54
57
 
58
+ <!-- Embedded mathematics: files of per-equation SVG and speech -->
59
+ <!-- representations, keyed by id, manufactured at build time by -->
60
+ <!-- the "mathjax_latex()" routine and passed in here as string -->
61
+ <!-- parameters. Both are empty for online mathematics (the -->
62
+ <!-- default), and then the derived variables are empty node-sets, -->
63
+ <!-- never consulted. -->
64
+ <xsl:param name="mathfile" select="''"/>
65
+ <xsl:param name="speechfile" select="''"/>
66
+ <xsl:variable name="math-repr" select="document($mathfile)/pi:math-representations"/>
67
+ <xsl:variable name="speech-repr" select="document($speechfile)/pi:math-representations"/>
68
+
55
69
  <!-- Reveal.js output is one monolithic page, so heading levels are -->
56
70
  <!-- threaded, not chunked. The slideshow title (h1) and subtitle -->
57
71
  <!-- (h2) are fixed. A "section" is always level 2 (sections never -->
@@ -129,18 +143,34 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
129
143
  <xsl:apply-templates select="." mode="sagecell" />
130
144
  <xsl:call-template name="syntax-highlight"/>
131
145
 
132
- <!-- load reveal.js resources; w/ v 4.1.2 -->
133
- <!-- these seem to be *always* minified -->
146
+ <!-- load reveal.js resources; w/ v 6.x -->
147
+ <!-- paths are relative to the distribution's "dist" -->
148
+ <!-- directory, whose layout a "local" resource host -->
149
+ <!-- must reproduce -->
134
150
  <link href="{$reveal-root}/reset.css" rel="stylesheet"></link>
135
151
  <link href="{$reveal-root}/reveal.css" rel="stylesheet"></link>
136
152
  <link href="{$reveal-root}/theme/{$reveal-theme}.css" rel="stylesheet"></link>
137
153
  <script src="{$reveal-root}/reveal.js"></script>
138
- <script src="{$reveal-root}/plugin/math/math.js"></script>
154
+ <!-- embedded mathematics needs no typesetting, so no math plugin -->
155
+ <xsl:if test="not($b-reveal-embedded-math)">
156
+ <script src="{$reveal-root}/plugin/math.js"></script>
157
+ </xsl:if>
139
158
 
140
159
  <link href="_static/pretext/css/pretext-reveal.css" rel="stylesheet"></link>
141
160
  <style>
161
+ <xsl:if test="$b-reveal-embedded-math">
162
+ <!-- layout for build-time SVG images of mathematics; the -->
163
+ <!-- class names are those of the EPUB conversion, which -->
164
+ <!-- pioneered this device -->
165
+ <xsl:text>span.mjpage { display: inline; }&#xa;</xsl:text>
166
+ <xsl:text>span.mjpage__block { display: block; text-align: center; margin: 0.5em 0; }&#xa;</xsl:text>
167
+ </xsl:if>
142
168
  </style>
143
- <xsl:call-template name="diagcess-header"/>
169
+ <!-- no diagcess machinery with embedded mathematics: an -->
170
+ <!-- annotated PreFigure diagram is then a static image -->
171
+ <xsl:if test="not($b-reveal-embedded-math)">
172
+ <xsl:call-template name="diagcess-header"/>
173
+ </xsl:if>
144
174
 
145
175
  <!-- custom-css, if specified, should be last -->
146
176
  <xsl:if test="not($reveal-custom-css = '')">
@@ -157,15 +187,22 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
157
187
 
158
188
  <body>
159
189
  <div class="reveal ptx-content">
160
- <!-- For mathematics/MathJax, must be located -->
161
- <!-- within div.reveal to be effective -->
162
- <xsl:apply-templates select="." mode="latex-macros"/>
190
+ <!-- For mathematics/MathJax, must be located -->
191
+ <!-- within div.reveal to be effective. With -->
192
+ <!-- embedded mathematics the macros are baked -->
193
+ <!-- into the SVG images at build time, so the -->
194
+ <!-- hidden macro division would be inert. -->
195
+ <xsl:if test="not($b-reveal-embedded-math)">
196
+ <xsl:apply-templates select="." mode="latex-macros"/>
197
+ </xsl:if>
163
198
  <div class="slides">
164
199
  <xsl:apply-templates select="frontmatter"/>
165
200
  <xsl:apply-templates select="section|slide"/>
166
201
  </div>
167
202
  </div>
168
- <xsl:call-template name="diagcess-footer"/>
203
+ <xsl:if test="not($b-reveal-embedded-math)">
204
+ <xsl:call-template name="diagcess-footer"/>
205
+ </xsl:if>
169
206
  </body>
170
207
 
171
208
  <script>
@@ -206,27 +243,41 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
206
243
  <xsl:text> transition: 'fade',&#xa;</xsl:text>
207
244
  <xsl:text> width: "100%",&#xa;</xsl:text>
208
245
  <xsl:text> height: "100%",&#xa;</xsl:text>
209
- <xsl:text> margin: "0.025",&#xa;</xsl:text>
210
- <!-- Explicitly enable AMS-style inline \(...\), -->
211
- <!-- and explicitly disable TeX-style inline $...$ -->
212
- <!-- The main HTML conversion does not do anything -->
213
- <!-- special for display math, so we disable any such -->
214
- <!-- markup, since we use environments exclusively. -->
215
- <!-- N.B. default HTML adds a "zero-width" space into -->
216
- <!-- a \( authored in a non-math context. -->
217
- <!-- N.B. This may need to be changed for MathJax 3 -->
218
-
219
- <!-- Suggested by https://revealjs.com/math/, 2021-09-19 -->
220
- <xsl:text> math: {&#xa;</xsl:text>
221
- <xsl:text> mathjax: 'https://cdn.jsdelivr.net/gh/mathjax/mathjax@2.7.8/MathJax.js',&#xa;</xsl:text>
222
- <xsl:text> config: 'TeX-AMS_HTML-full',&#xa;</xsl:text>
223
- <xsl:text> // other options are passed into MathJax.Hub.Config()&#xa;</xsl:text>
224
- <xsl:text> tex2jax: {&#xa;</xsl:text>
225
- <xsl:text> inlineMath: [['\\(','\\)']],&#xa;</xsl:text>
226
- <xsl:text> displayMath: [],&#xa;</xsl:text>
227
- <xsl:text> }&#xa;</xsl:text>
228
- <xsl:text> },&#xa;</xsl:text>
229
- <xsl:text> plugins: [ RevealMath ]&#xa;</xsl:text>
246
+ <!-- "margin" must be a JavaScript number. The PDF export -->
247
+ <!-- computes its page size as (slide dimension)*(1 + margin); -->
248
+ <!-- a quoted value concatenates instead of adding, producing -->
249
+ <!-- pages ten times too large, and a print dialog then -->
250
+ <!-- shrinks each slide to a small fraction of the paper. -->
251
+ <xsl:text> margin: 0.025,&#xa;</xsl:text>
252
+ <xsl:choose>
253
+ <!-- Embedded mathematics is finished SVG images: -->
254
+ <!-- no math plugin, no typesetting configuration -->
255
+ <xsl:when test="$b-reveal-embedded-math">
256
+ <xsl:text> plugins: []&#xa;</xsl:text>
257
+ </xsl:when>
258
+ <!-- Explicitly enable AMS-style inline \(...\), -->
259
+ <!-- and explicitly disable TeX-style inline $...$ -->
260
+ <!-- The main HTML conversion does not do anything -->
261
+ <!-- special for display math, so we disable any such -->
262
+ <!-- markup, since we use environments exclusively. -->
263
+ <!-- N.B. default HTML adds a "zero-width" space into -->
264
+ <!-- a \( authored in a non-math context. -->
265
+ <!-- The MathJax version matches the main HTML -->
266
+ <!-- conversion; the "mathjax4" adapter of the math -->
267
+ <!-- plugin loads it from the URL given and passes -->
268
+ <!-- the "tex" object into the MathJax configuration. -->
269
+ <!-- Suggested by https://revealjs.com/math/, 2026-07-22 -->
270
+ <xsl:otherwise>
271
+ <xsl:text> mathjax4: {&#xa;</xsl:text>
272
+ <xsl:text> mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js',&#xa;</xsl:text>
273
+ <xsl:text> tex: {&#xa;</xsl:text>
274
+ <xsl:text> inlineMath: [['\\(','\\)']],&#xa;</xsl:text>
275
+ <xsl:text> displayMath: [],&#xa;</xsl:text>
276
+ <xsl:text> }&#xa;</xsl:text>
277
+ <xsl:text> },&#xa;</xsl:text>
278
+ <xsl:text> plugins: [ RevealMath.MathJax4 ]&#xa;</xsl:text>
279
+ </xsl:otherwise>
280
+ </xsl:choose>
230
281
  <xsl:text>});&#xa;</xsl:text>
231
282
  </script>
232
283
  </html>
@@ -416,8 +467,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
416
467
  </xsl:template>
417
468
 
418
469
  <!-- Side-By-Side -->
419
- <!-- Built by implementing two abstract -->
420
- <!-- templates from the -common templates -->
470
+ <!-- Same container-declared composition as HTML and LaTeX, -->
471
+ <!-- realized here with CSS table display: margins are declared on -->
472
+ <!-- the wrapper div, and each panel div carries its width and -->
473
+ <!-- vertical alignment. Built by implementing the two abstract -->
474
+ <!-- templates ("panel-panel", "compose-panels") of the -common -->
475
+ <!-- machinery. -->
421
476
 
422
477
  <!-- Overall wrapper of a sidebyside -->
423
478
  <xsl:template match="sidebyside" mode="compose-panels">
@@ -511,12 +566,165 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
511
566
  <xsl:with-param name="warning">Conversion to reveal.js presentations/slideshows is experimental&#xa;Requests for additional specific constructions welcome&#xa;Additional PreTeXt elements are subject to change</xsl:with-param>
512
567
  </xsl:call-template>
513
568
  <xsl:if test="not($theme = '')">
514
- <xsl:message >PTX:WARNING: the temporary "theme" stringparam is deprecated and is being ignored by the conversion to a Reveal.js slideshow. Please switch to using a publisher file to set this option, see documentation in The Guide. The default theme is "simple".</xsl:message>
569
+ <xsl:message >PTX:DEPRECATE: the temporary "theme" stringparam is deprecated and is being ignored by the conversion to a Reveal.js slideshow. Please switch to using a publisher file to set this option, see documentation in The Guide. The default theme is "simple".</xsl:message>
515
570
  <xsl:text>simple</xsl:text>
516
571
  </xsl:if>
517
572
  <xsl:if test="not($local = '')">
518
- <xsl:message >PTX:WARNING: the temporary "local" stringparam is deprecated and is being ignored. Please switch to using a publisher file to set this option, see documentation in The Guide. The default behavior is to get resources from a CDN.</xsl:message>
573
+ <xsl:message >PTX:DEPRECATE: the temporary "local" stringparam is deprecated and is being ignored. Please switch to using a publisher file to set this option, see documentation in The Guide. The default behavior is to get resources from a CDN.</xsl:message>
519
574
  </xsl:if>
520
575
  </xsl:template>
521
576
 
577
+ <!-- #################### -->
578
+ <!-- Embedded Mathematics -->
579
+ <!-- #################### -->
580
+
581
+ <!-- Online mathematics (the default) is authored LaTeX passed -->
582
+ <!-- through, inherited from the HTML conversion, for the math -->
583
+ <!-- plugin and MathJax to typeset in the browser. Embedded -->
584
+ <!-- mathematics substitutes an SVG image and a speech string, -->
585
+ <!-- both manufactured at build time, so the slideshow performs no -->
586
+ <!-- typesetting at all: the same device as the EPUB conversion, -->
587
+ <!-- whose templates these mirror. Every "md" has "mrow" children -->
588
+ <!-- once the assembly repairs an authored one-line "md", so the -->
589
+ <!-- match covers all mathematics. Slides never link to an -->
590
+ <!-- equation (a cross-reference renders as its text), so no HTML -->
591
+ <!-- id is placed, unlike EPUB. -->
592
+ <xsl:template match="m|md[mrow]">
593
+ <xsl:choose>
594
+ <xsl:when test="$b-reveal-embedded-math">
595
+ <!-- NB: math-representation file writes with "unique-id" -->
596
+ <xsl:variable name="id">
597
+ <xsl:apply-templates select="." mode="unique-id"/>
598
+ </xsl:variable>
599
+ <xsl:variable name="math" select="$math-repr/pi:math[@id = $id]"/>
600
+ <xsl:variable name="speech" select="$speech-repr/pi:math[@id = $id]"/>
601
+ <span>
602
+ <xsl:attribute name="class">
603
+ <xsl:choose>
604
+ <xsl:when test="$math/@context = 'inline'">
605
+ <xsl:text>mjpage</xsl:text>
606
+ </xsl:when>
607
+ <xsl:when test="$math/@context = 'displaymath'">
608
+ <xsl:text>mjpage mjpage__block</xsl:text>
609
+ </xsl:when>
610
+ </xsl:choose>
611
+ </xsl:attribute>
612
+ <xsl:apply-templates select="$math/div[@class = 'svg']/svg:svg" mode="svg-edit">
613
+ <xsl:with-param name="speech" select="$speech"/>
614
+ <xsl:with-param name="base-id" select="$id"/>
615
+ </xsl:apply-templates>
616
+ </span>
617
+ </xsl:when>
618
+ <!-- online: the usual LaTeX-within-delimiters construction -->
619
+ <xsl:otherwise>
620
+ <xsl:apply-imports/>
621
+ </xsl:otherwise>
622
+ </xsl:choose>
623
+ </xsl:template>
624
+
625
+ <!-- An annotated PreFigure diagram is normally embedded for the -->
626
+ <!-- diagcess library: an interactive, keyboard-driven exploration -->
627
+ <!-- for a screen reader. With embedded mathematics the slideshow -->
628
+ <!-- has already traded such interactivity for fixed alternatives, -->
629
+ <!-- so the diagram becomes a static image (its plain SVG), and the -->
630
+ <!-- diagcess machinery is omitted entirely. -->
631
+ <xsl:template match="image[pf:prefigure[pf:diagram/pf:annotations]]" mode="image-inclusion">
632
+ <xsl:choose>
633
+ <xsl:when test="$b-reveal-embedded-math">
634
+ <xsl:variable name="base-pathname">
635
+ <xsl:value-of select="$generated-directory"/>
636
+ <xsl:if test="$b-managed-directories">
637
+ <xsl:text>prefigure/</xsl:text>
638
+ </xsl:if>
639
+ <xsl:apply-templates select="pf:prefigure" mode="image-source-basename"/>
640
+ </xsl:variable>
641
+ <xsl:apply-templates select="." mode="svg-png-wrapper">
642
+ <xsl:with-param name="image-filename" select="concat($base-pathname, '.svg')"/>
643
+ </xsl:apply-templates>
644
+ <!-- possibly annotate with archive links -->
645
+ <xsl:apply-templates select="." mode="archive">
646
+ <xsl:with-param name="base-pathname" select="$base-pathname"/>
647
+ </xsl:apply-templates>
648
+ <!-- possibly give a long description -->
649
+ <xsl:apply-templates select="." mode="description"/>
650
+ </xsl:when>
651
+ <!-- online: the diagcess embedding, inherited -->
652
+ <xsl:otherwise>
653
+ <xsl:apply-imports/>
654
+ </xsl:otherwise>
655
+ </xsl:choose>
656
+ </xsl:template>
657
+
658
+ <!-- MathJax mints an HTML id from an equation's \tag for its own -->
659
+ <!-- \eqref linking, which PreTeXt never uses; a tag used twice -->
660
+ <!-- (symbols as tags invite this) would duplicate the id, so they -->
661
+ <!-- are dropped -->
662
+ <xsl:template match="@id[starts-with(., 'mjx-eqn')]" mode="svg-edit"/>
663
+
664
+ <!-- Identity for the SVG stream-edit -->
665
+ <xsl:template match="node()|@*" mode="svg-edit">
666
+ <xsl:copy>
667
+ <xsl:apply-templates select="node()|@*" mode="svg-edit"/>
668
+ </xsl:copy>
669
+ </xsl:template>
670
+
671
+ <!-- We enrich the main "svg" element with a speech string. -->
672
+ <!-- 1. Since this is the "entry template" for this mode, -->
673
+ <!-- this is the only place we accept the "speech" param. -->
674
+ <!-- 2. MathJax seems to use SVGs inside of SVGs for placing -->
675
+ <!-- numbers/tags of numbered equations, so we only enrich -->
676
+ <!-- "top-level" SVG - that is the point of the filter. -->
677
+ <!-- 3. The id of the math element will be used as the base -->
678
+ <!-- of (unique) ids necessary to point to the speech. -->
679
+ <!-- Pattern 11 at: -->
680
+ <!-- https://www.deque.com/blog/creating-accessible-svgs/ -->
681
+ <!-- 4. Seems -->
682
+ <!-- "title" + @aria-labelledby -->
683
+ <!-- "desc" + @aria-describedby -->
684
+ <!-- cover all the bases. It is suggested that the two -->
685
+ <!-- elements alone would be recognized by screen readers. -->
686
+ <xsl:template match="svg:svg[not(ancestor::svg:svg)]" mode="svg-edit">
687
+ <xsl:param name="speech"/>
688
+ <xsl:param name="base-id"/>
689
+
690
+ <!-- manufacture id values for consistency, uniqueness -->
691
+ <xsl:variable name="title-id">
692
+ <xsl:value-of select="$base-id"/>
693
+ <xsl:text>-title</xsl:text>
694
+ </xsl:variable>
695
+ <xsl:variable name="desc-id">
696
+ <xsl:value-of select="$base-id"/>
697
+ <xsl:text>-desc</xsl:text>
698
+ </xsl:variable>
699
+
700
+ <xsl:copy>
701
+ <!-- attributes first -->
702
+ <xsl:apply-templates select="@*" mode="svg-edit"/>
703
+ <xsl:attribute name="role">
704
+ <xsl:text>img</xsl:text>
705
+ </xsl:attribute>
706
+ <xsl:attribute name="aria-labelledby">
707
+ <xsl:value-of select="$title-id"/>
708
+ </xsl:attribute>
709
+ <xsl:attribute name="aria-describedby">
710
+ <xsl:value-of select="$desc-id"/>
711
+ </xsl:attribute>
712
+ <!-- now additional metadata, of sorts -->
713
+ <xsl:element name="title" namespace="http://www.w3.org/2000/svg">
714
+ <xsl:attribute name="id">
715
+ <xsl:value-of select="$title-id"/>
716
+ </xsl:attribute>
717
+ <xsl:text>Math Expression</xsl:text>
718
+ </xsl:element>
719
+ <xsl:element name="desc" namespace="http://www.w3.org/2000/svg">
720
+ <xsl:attribute name="id">
721
+ <xsl:value-of select="$desc-id"/>
722
+ </xsl:attribute>
723
+ <xsl:value-of select="$speech"/>
724
+ </xsl:element>
725
+ <!-- and all the rest of the nodes -->
726
+ <xsl:apply-templates select="node()" mode="svg-edit"/>
727
+ </xsl:copy>
728
+ </xsl:template>
729
+
522
730
  </xsl:stylesheet>