@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.
Files changed (43) hide show
  1. package/README.md +20 -9
  2. package/assets/preview-html.xsl +8 -4
  3. package/assets/upstream.json +1 -1
  4. package/assets/xsl/README.md +25 -24
  5. package/assets/xsl/entities.ent +20 -0
  6. package/assets/xsl/extract-biblio-csl.xsl +1 -1
  7. package/assets/xsl/extract-pg.xsl +111 -297
  8. package/assets/xsl/extract-qrcode.xsl +11 -1
  9. package/assets/xsl/extract-sageplot.xsl +1 -1
  10. package/assets/xsl/latex/pretext-latex-texstyle.xsl +1 -2
  11. package/assets/xsl/localizations/README.md +24 -24
  12. package/assets/xsl/pretext-assembly.xsl +101 -11
  13. package/assets/xsl/pretext-beamer.xsl +43 -146
  14. package/assets/xsl/pretext-braille-preprint.xsl +457 -201
  15. package/assets/xsl/pretext-common.xsl +388 -423
  16. package/assets/xsl/pretext-epub.xsl +301 -72
  17. package/assets/xsl/pretext-fo.xsl +70 -86
  18. package/assets/xsl/pretext-html.xsl +331 -259
  19. package/assets/xsl/pretext-jupyter.xsl +534 -322
  20. package/assets/xsl/pretext-latex-classic.xsl +14 -15
  21. package/assets/xsl/pretext-latex-common.xsl +385 -2389
  22. package/assets/xsl/pretext-latex.xsl +1995 -5
  23. package/assets/xsl/pretext-markdown.xsl +919 -0
  24. package/assets/xsl/pretext-numbers.xsl +22 -4
  25. package/assets/xsl/pretext-revealjs.xsl +241 -33
  26. package/assets/xsl/pretext-runestone-fitb.xsl +20 -22
  27. package/assets/xsl/pretext-runestone.xsl +3 -3
  28. package/assets/xsl/pretext-sage-doctest.xsl +2 -2
  29. package/assets/xsl/pretext-text-utilities.xsl +69 -1
  30. package/assets/xsl/pretext-text.xsl +1077 -107
  31. package/assets/xsl/publisher-variables.xsl +396 -452
  32. package/assets/xsl/support/play-button/README.md +1 -3
  33. package/assets/xsl/tests/README.md +1 -1
  34. package/assets/xsl/utilities/README.md +6 -8
  35. package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
  36. package/assets/xsl-bundle.json +1 -1
  37. package/dist/{cli-CzoinNle.js → cli-Cp6C0sif.js} +220 -205
  38. package/dist/cli.js +1 -1
  39. package/dist/index.browser.js +351 -342
  40. package/dist/index.js +1 -1
  41. package/dist/publication.d.ts +9 -1
  42. package/dist/renderer.d.ts +20 -0
  43. package/package.json +1 -1
@@ -54,7 +54,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
54
54
  <!-- applying specializations below -->
55
55
  <xsl:import href="./extract-identity.xsl" />
56
56
 
57
- <xsl:output method="text" encoding="UTF-8"/>
57
+ <xsl:output method="xml" encoding="UTF-8"/>
58
58
 
59
59
  <!-- Avoid Catch-22: default assembly/pre-processor provides output -->
60
60
  <!-- for a conversion to a static format, but that format will -->
@@ -74,6 +74,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
74
74
  <xsl:variable name="chunk-level" select="$html-chunk-level"/>
75
75
  <xsl:variable name="file-extension" select="'.html'"/>
76
76
 
77
+ <!-- Wrap the ids below in a manifest of exactly the elements that -->
78
+ <!-- earn a QR code; the generator opens only these sidecar files. -->
79
+ <xsl:template match="*" mode="extraction-wrapper">
80
+ <pi:qrcodes>
81
+ <xsl:apply-imports/>
82
+ </pi:qrcodes>
83
+ </xsl:template>
84
+
77
85
  <xsl:template match="audio[@source|@href]|video[@source|@href|@youtube|@youtubeplaylist|@vimeo]|interactive" mode="extraction">
78
86
  <!-- Sidecar XML file with pre-computed URLs for use -->
79
87
  <!-- by pretext-assembly.xsl when building static -->
@@ -95,6 +103,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
95
103
  </pi:embed-iframe-url>
96
104
  </pi:qrcode-urls>
97
105
  </exsl:document>
106
+ <!-- record the id in the returned manifest (see the wrapper above) -->
107
+ <pi:qrcode id="{$the-id}"/>
98
108
  </xsl:template>
99
109
 
100
110
  </xsl:stylesheet>
@@ -88,7 +88,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
88
88
  <xsl:text>3d</xsl:text>
89
89
  </xsl:when>
90
90
  <xsl:otherwise>
91
- <xsl:message>PTX:ERROR: a "sageplot" has a @variant attribute ("<xsl:value-of select="@variant"/>") for "<xsl:value-of select="$filebase"/>" whose value is not "2d" nor "3d". The default ("2d") is being used, which could be incorrect</xsl:message>
91
+ <xsl:message>PTX:FALLBACK: a "sageplot" has a @variant attribute ("<xsl:value-of select="@variant"/>") for "<xsl:value-of select="$filebase"/>" whose value is not "2d" nor "3d". The default ("2d") is being used, which could be incorrect</xsl:message>
92
92
  <xsl:text>2d</xsl:text>
93
93
  </xsl:otherwise>
94
94
  </xsl:choose>
@@ -210,7 +210,6 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
210
210
  <xsl:call-template name="math-packages"/>
211
211
  <xsl:call-template name="pdfpages-package"/>
212
212
  <xsl:call-template name="semantic-macros"/>
213
- <xsl:call-template name="exercises-and-solutions"/>
214
213
  <xsl:call-template name="chapter-start-number"/>
215
214
  <xsl:call-template name="equation-numbering"/>
216
215
  <xsl:call-template name="image-tcolorbox"/>
@@ -624,7 +623,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
624
623
  </xsl:apply-templates>
625
624
  </xsl:when>
626
625
  <xsl:otherwise>
627
- <xsl:message>PTX:WARNING: The @authority attribute on a keyword element (in a texstyle file) is required and must be "author" or "msc". Found "@authority="<xsl:value-of select="@authority"/>". </xsl:message>
626
+ <xsl:message>PTX:ERROR: The @authority attribute on a keyword element (in a texstyle file) is required and must be "author" or "msc". Found "@authority="<xsl:value-of select="@authority"/>". </xsl:message>
628
627
  </xsl:otherwise>
629
628
  </xsl:choose>
630
629
  </xsl:template>
@@ -17,9 +17,10 @@ You should have received a copy of the GNU General Public License
17
17
  along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
18
18
  *********************************************************************-->
19
19
 
20
- # PreTeXt Localizations
20
+ PreTeXt Localizations
21
+ =====================
21
22
 
22
- Each file in this directory provides translations of various strings used in titles and headings (and other places) to a specific language. Filenames reflect the code for language (lowercase) and then the code for the region (uppercase). This is a requirement.
23
+ Each file in this directory provides translations of various strings used in titles and headings (and other places) to a specific language. Filenames reflect the code for language (lowercase) and then the code for the region (uppercase). This is a requirement.
23
24
 
24
25
  For each file of translations, the "language" attribute of the "locale" element used to reference the language code and the "string-id" of each "localization" element is the lookup key. Element content is the language-specific string. The English version ("en-US") is carefully documented, so additions of new languages do not necessarily require new documentation, though it could help other implementers. See `xsl/pretext-common.xsl` for the two routines which make use of this information, one is a named template and the other (largely) uses the name of an element as the string-id.
25
26
 
@@ -27,30 +28,29 @@ Some items peculiar to LaTeX are explained [here](http://www.tex.ac.uk/cgi-bin/t
27
28
 
28
29
  There is a [general overview of language tags](http://www.w3.org/International/articles/language-tags/) and the [Subtag Registry](http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
29
30
 
30
- Contibutions of new languages are always welcome and especially encouraged! Search on "Translation needed" to see where you can help. Use the en-US file as a template for a new language file, since it is always most complete. It is understood that certain English words and phrases have subtleties that can be very hard to capture in another language. Do your best to concoct a close approximation -- something should be better than nothing. And it might improve with additions from others later. We try to address some of this in the en-US file, so do be certain to look there for explanations of how these strings are employed. Comments about your own decisions, within the relevant language file, can be very helpful later.
31
+ Contibutions of new languages are always welcome and especially encouraged! Search on "Translation needed" to see where you can help. Use the en-US file as a template for a new language file, since it is always most complete. It is understood that certain English words and phrases have subtleties that can be very hard to capture in another language. Do your best to concoct a close approximation -- something should be better than nothing. And it might improve with additions from others later. We try to address some of this in the en-US file, so do be certain to look there for explanations of how these strings are employed. Comments about your own decisions, within the relevant language file, can be very helpful later.
31
32
 
32
- NEW LANGUAGES: for a new file to be effective, a single line needs to be added to the `xsl/localizations/localizations.xml` file. It should be obvious what to do by looking at the other lines of that file. If you create a new file, please include a "commented-out" line for any words you do not translate, and please use the **exact** style of commenting as elsewhere (one line per comment, indented). Including these, and using teh same style, greatly aids in maintenance and reliability.
33
+ NEW LANGUAGES: for a new file to be effective, a single line needs to be added to the `xsl/localizations/localizations.xml` file. It should be obvious what to do by looking at the other lines of that file. If you create a new file, please include a "commented-out" line for any words you do not translate, and please use the **exact** style of commenting as elsewhere (one line per comment, indented). Including these, and using teh same style, greatly aids in maintenance and reliability.
33
34
 
34
- Additions to incomplete files, or new files for additional languages, are very welcome and are a huge help in making PreTeXt useable for more authors. A GitHub pull request is preferable. If you do not know GitHub well, then emailing the entire language file (as an attachment) is very welcome and just as easy to deal with on our end. Please respect the order in the en-US file, it saves us time when we add new terms to each and every file. Thanks.
35
+ Additions to incomplete files, or new files for additional languages, are very welcome and are a huge help in making PreTeXt useable for more authors. A GitHub pull request is preferable. If you do not know GitHub well, then emailing the entire language file (as an attachment) is very welcome and just as easy to deal with on our end. Please respect the order in the en-US file, it saves us time when we add new terms to each and every file. Thanks.
35
36
 
36
- To test, or use: place `xml:lang="es-ES"`, or similar, as an attribute on your `<pretext>` element. `en-US` is the default if no `@xml:lang` attribute is given on the `pretext` element.
37
+ To test, or use: place `xml:lang="es-ES"`, or similar, as an attribute on your `<pretext>` element. `en-US` is the default if no `@xml:lang` attribute is given on the `pretext` element.
37
38
 
38
39
  Current (partially) implemented language codes and contributors
39
-
40
- - af-ZA, Afrikaans (South Africa), Dirk Basson
41
- - bg-BG, Bulgarian (Bulgaria), Boyko Bantchev
42
- - ca-ES, Catalan (Spain), Jordi Saludes
43
- - cs-CZ, Czech (Czechia), Jiří Lebl
44
- - de-DE, German (Germany), Karl-Dieter Crisman
45
- - es-ES, Spanish (Spain), Juan José Torrens
46
- - en-US, English (United States), Robert A. Beezer
47
- - fi-FI, Finnish (Finland), Lasse M. Manninen
48
- - fr-CA, French (Canada), Jean-Sébastien Turcotte
49
- - fr-FR, French (France), Thomas W. Judson, Julien Giol, Jean-Sébastien Turcotte
50
- - hu-HU, Hungarian (Hungary), Sándor Czirbusz
51
- - it-IT, Italian (Italy), Valerio Monti
52
- - ku-CKB, Rebin Muhammad, Kurdish (Central Kurdish)
53
- - nl-NL, Dutch (Netherlands), Gosia Wrzesinska
54
- - pt-BR, Portugese (Brazil), Igor Morgado, Vinicius Monego, Leon Silva
55
- - pt-PT, Portugese (Portugal), António Pereira
56
- - zh-HANS, Chinese Simplified (China), Hongqi Wang
40
+ * af-ZA, Afrikaans (South Africa), Dirk Basson
41
+ * bg-BG, Bulgarian (Bulgaria), Boyko Bantchev
42
+ * ca-ES, Catalan (Spain), Jordi Saludes
43
+ * cs-CZ, Czech (Czechia), Jiří Lebl
44
+ * de-DE, German (Germany), Karl-Dieter Crisman
45
+ * es-ES, Spanish (Spain), Juan José Torrens
46
+ * en-US, English (United States), Robert A. Beezer
47
+ * fi-FI, Finnish (Finland), Lasse M. Manninen
48
+ * fr-CA, French (Canada), Jean-Sébastien Turcotte
49
+ * fr-FR, French (France), Thomas W. Judson, Julien Giol, Jean-Sébastien Turcotte
50
+ * hu-HU, Hungarian (Hungary), Sándor Czirbusz
51
+ * it-IT, Italian (Italy), Valerio Monti
52
+ * ku-CKB, Rebin Muhammad, Kurdish (Central Kurdish)
53
+ * nl-NL, Dutch (Netherlands), Gosia Wrzesinska
54
+ * pt-BR, Portugese (Brazil), Igor Morgado, Vinicius Monego, Leon Silva
55
+ * pt-PT, Portugese (Portugal), António Pereira
56
+ * zh-HANS, Chinese Simplified (China), Hongqi Wang
@@ -519,6 +519,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
519
519
  <!-- Also, note that this tree is useful for certain tasks, like -->
520
520
  <!-- validation, or reporting values of publisher variables, without -->
521
521
  <!-- regard to the subsequent passes. -->
522
+ <!-- The version tree is the earliest assembly product a publisher -->
523
+ <!-- variable may consult (structure can differ by version). The -->
524
+ <!-- passes up to, and including, "version" must never consult a -->
525
+ <!-- variable defined from this tree — that is a circular reference, -->
526
+ <!-- detected only at runtime. The "crossing point" facts in -->
527
+ <!-- publisher-variables.xsl enumerate the consumers. -->
522
528
  <xsl:variable name="version-root" select="$version/pretext"/>
523
529
  <xsl:variable name="version-docinfo" select="$version-root/docinfo"/>
524
530
  <xsl:variable name="version-document-root" select="$version-root/*[not(self::docinfo)]"/>
@@ -872,7 +878,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
872
878
  <!-- This is an AWOL node, not empty content (which is allowed) -->
873
879
  <xsl:if test="not($the-lookup)">
874
880
  <xsl:text>[MISSING CUSTOM CONTENT HERE]</xsl:text>
875
- <xsl:message>PTX:WARNING: lookup for a "custom" element with @name set to "<xsl:value-of select="$the-ref"/>" has failed, while consulting the customization file "<xsl:value-of select="$customizations-file"/>". Output will contain "[MISSING CUSTOM CONTENT HERE]" instead</xsl:message>
881
+ <xsl:message>PTX:ERROR: lookup for a "custom" element with @name set to "<xsl:value-of select="$the-ref"/>" has failed, while consulting the customization file "<xsl:value-of select="$customizations-file"/>". Output will contain "[MISSING CUSTOM CONTENT HERE]" instead</xsl:message>
876
882
  <xsl:apply-templates select="$the-custom" mode="location-report"/>
877
883
  </xsl:if>
878
884
  <!-- Copying the contents of "custom" via the "version" templates -->
@@ -1070,11 +1076,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1070
1076
  <!-- Look at each "biblio" in the external file -->
1071
1077
  <xsl:for-each select="$biblios/pretext-biblios/biblio">
1072
1078
  <xsl:variable name="the-id" select="@xml:id"/>
1073
- <xsl:message>@xml:id of &lt;biblio&gt; in bibliography file: <xsl:value-of select="$the-id"/></xsl:message>
1079
+ <xsl:message>PTX:DEBUG: @xml:id of &lt;biblio&gt; in bibliography file: <xsl:value-of select="$the-id"/></xsl:message>
1074
1080
  <!-- Building duplicate, so look at $original for -->
1075
1081
  <!-- "xref" pointing to the current context "biblio" -->
1076
1082
  <xsl:if test="$original//xref[@ref = $the-id]">
1077
- <xsl:message> Located this &lt;biblio&gt; cited in original source</xsl:message>
1083
+ <xsl:message>PTX:DEBUG: Located this &lt;biblio&gt; cited in original source</xsl:message>
1078
1084
  <xsl:apply-templates select="." mode="assembly"/>
1079
1085
  </xsl:if>
1080
1086
  </xsl:for-each>
@@ -1613,6 +1619,78 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1613
1619
  </xsl:attribute>
1614
1620
  </xsl:template>
1615
1621
 
1622
+ <!-- Insert a default correct "test" for a FITB "exercise" or -->
1623
+ <!-- PROJECT-LIKE when an "evaluate" has no explicit correct -->
1624
+ <!-- "test": the corresponding "fillin" has a static @answer, -->
1625
+ <!-- so synthesize a "test" and let all downstream processing -->
1626
+ <!-- follow a single code path. Only @mode "string" and -->
1627
+ <!-- "number" are handled here; "math" uses separate logic. -->
1628
+ <xsl:template match="evaluation/evaluate[
1629
+ not(@all = 'yes') and
1630
+ not(test[@correct = 'yes']) and
1631
+ not(
1632
+ count(../../statement//fillin) > 1
1633
+ and
1634
+ ../evaluate[@all = 'yes']/test
1635
+ )
1636
+ ]" mode="exercise">
1637
+ <xsl:param name="division"/>
1638
+
1639
+ <!-- Identify this evaluate's position among its siblings and its name, -->
1640
+ <!-- to locate the corresponding fillin by name first, position second. -->
1641
+ <xsl:variable name="eval-position" select="count(preceding-sibling::evaluate) + 1"/>
1642
+ <xsl:variable name="eval-name" select="@name"/>
1643
+
1644
+ <!-- Navigate to the exercise/project/task parent of evaluation -->
1645
+ <xsl:variable name="exercise-parent" select="parent::evaluation/parent::*"/>
1646
+
1647
+ <!-- Find the corresponding fillin (name-based match takes priority) -->
1648
+ <xsl:variable name="match-fillin">
1649
+ <xsl:choose>
1650
+ <xsl:when test="$eval-name != '' and
1651
+ $exercise-parent/statement//fillin[@name = $eval-name]">
1652
+ <xsl:copy-of select="$exercise-parent/statement//fillin[@name = $eval-name]"/>
1653
+ </xsl:when>
1654
+ <xsl:otherwise>
1655
+ <xsl:copy-of select="($exercise-parent/statement//fillin)[$eval-position]"/>
1656
+ </xsl:otherwise>
1657
+ </xsl:choose>
1658
+ </xsl:variable>
1659
+ <xsl:variable name="fillin" select="exsl:node-set($match-fillin)/fillin"/>
1660
+
1661
+ <xsl:copy>
1662
+ <xsl:apply-templates select="@*" mode="exercise">
1663
+ <xsl:with-param name="division" select="$division"/>
1664
+ </xsl:apply-templates>
1665
+ <!-- Synthesize a correct test when the fillin has a static @answer -->
1666
+ <!-- and a recognized mode. Place it first so it takes precedence. -->
1667
+ <xsl:if test="$fillin/@answer and not($fillin/@ansobj)">
1668
+ <xsl:choose>
1669
+ <xsl:when test="$fillin/@mode = 'number'">
1670
+ <test correct="yes">
1671
+ <numcmp use-answer="yes"/>
1672
+ </test>
1673
+ </xsl:when>
1674
+ <xsl:when test="$fillin/@mode = 'string'">
1675
+ <test correct="yes">
1676
+ <strcmp use-answer="yes"/>
1677
+ </test>
1678
+ </xsl:when>
1679
+ <xsl:otherwise>
1680
+ <xsl:message>PTX:WARNING: fillin in "<xsl:value-of
1681
+ select="$exercise-parent/@visible-id"/>" has @answer but
1682
+ @mode is missing or not recognized (expected 'number' or
1683
+ 'string'). No default correct test synthesized.</xsl:message>
1684
+ </xsl:otherwise>
1685
+ </xsl:choose>
1686
+ </xsl:if>
1687
+ <!-- Copy existing children (non-correct tests, feedback, etc.) -->
1688
+ <xsl:apply-templates select="node()" mode="exercise">
1689
+ <xsl:with-param name="division" select="$division"/>
1690
+ </xsl:apply-templates>
1691
+ </xsl:copy>
1692
+ </xsl:template>
1693
+
1616
1694
  <!-- ##################################################### -->
1617
1695
  <!-- Dynamic Substitutions -->
1618
1696
  <!-- Cut out dynamic setup and evaluation for static mode. -->
@@ -3357,6 +3435,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3357
3435
  <!-- which have not been schema-compliant since circa 2017 -->
3358
3436
  <xsl:template match="sidebyside/*[&METADATA-FILTER;]" mode="repair"/>
3359
3437
 
3438
+ <!-- 2026-07-08 "title" deprecated on "introduction"/"conclusion" of a traditional division -->
3439
+
3440
+ <!-- The title is dropped, silently; conversions provide a localized -->
3441
+ <!-- heading whenever a heading is called for. Titles remain within -->
3442
+ <!-- specialized divisions, which are never structured, and so are -->
3443
+ <!-- never summary pages (the situation that demands the heading) -->
3444
+ <xsl:template match="introduction[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]/title|conclusion[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]/title" mode="repair"/>
3445
+
3360
3446
  <!-- ########## -->
3361
3447
  <!-- Enrichment -->
3362
3448
  <!-- ########## -->
@@ -4012,7 +4098,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4012
4098
  <xsl:param name="project-nodes"/>
4013
4099
  <xsl:param name="exercise-nodes"/>
4014
4100
  <xsl:param name="openproblem-nodes"/>
4015
- <xsl:variable name="b-terminal" select="not(part|chapter|appendix|section|subsection|subsubsection|preface)"/>
4101
+ <!-- terminal: holds content directly, so it has no child divisions of -->
4102
+ <!-- any kind. Specialized divisions ("worksheet", "handout", etc.) -->
4103
+ <!-- count here just like the traditional ones, else a division whose -->
4104
+ <!-- children are specialized divisions is wrongly deemed terminal and -->
4105
+ <!-- pools their blocks into one scope instead of one scope apiece. -->
4106
+ <xsl:variable name="b-terminal" select="not(part|chapter|appendix|section|subsection|subsubsection|preface|exercises|worksheet|handout|reading-questions|references|glossary|solutions)"/>
4016
4107
  <xsl:variable name="b-open-eq" select="not($eq-nodes) and ($b-terminal or (@level &gt;= $numbering-equations))"/>
4017
4108
  <xsl:variable name="b-open-fn" select="not($fn-nodes) and ($b-terminal or (@level &gt;= $numbering-footnotes))"/>
4018
4109
  <xsl:variable name="b-open-blocks" select="not($blocks-nodes) and ($b-terminal or (@level &gt;= $numbering-blocks))"/>
@@ -4683,20 +4774,19 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4683
4774
  <!-- Natural override for YouTube videos -->
4684
4775
  <!-- Better - standalone page, with "View on You Tube" -->
4685
4776
 
4686
- <!-- NB: ampersand is escaped for LaTeX use, be careful with switch to QR codes via Python! -->
4687
- <!-- POTENTIAL BUG: this should be un-LaTeX'ed for general use and then -->
4688
- <!-- sanitized on the receiving end in the LaTeX conversion, or maybe -->
4689
- <!-- the LaTeX conversion will do just fine if the right URL package is -->
4690
- <!-- used and the ampersand is handled correctly? -->
4777
+ <!-- NB: this is a genuine URL, with no escaping: consumers apply -->
4778
+ <!-- their own (the LaTeX conversion escapes the ampersand for its -->
4779
+ <!-- "\href", HTML-derived conversions use it as-is, and the QR code -->
4780
+ <!-- generator must encode exactly what a phone's camera should see). -->
4691
4781
 
4692
4782
  <xsl:template match="video[@youtube|@youtubeplaylist]" mode="static-url">
4693
4783
  <xsl:apply-templates select="." mode="youtube-view-url" />
4694
4784
  <xsl:if test="@start">
4695
- <xsl:text>\&amp;start=</xsl:text>
4785
+ <xsl:text>&amp;start=</xsl:text>
4696
4786
  <xsl:value-of select="@start" />
4697
4787
  </xsl:if>
4698
4788
  <xsl:if test="@end">
4699
- <xsl:text>\&amp;end=</xsl:text>
4789
+ <xsl:text>&amp;end=</xsl:text>
4700
4790
  <xsl:value-of select="@end" />
4701
4791
  </xsl:if>
4702
4792
  </xsl:template>
@@ -287,7 +287,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
287
287
  <xsl:template match="slide//ol/li|slide//ul/li">
288
288
  <xsl:text>\item{}</xsl:text>
289
289
  <xsl:if test="title">
290
- <xsl:text> \lititle{</xsl:text>
290
+ <xsl:text> \ptxlititle{</xsl:text>
291
291
  <xsl:apply-templates select="." mode="title-full"/>
292
292
  <xsl:text>}\par</xsl:text>
293
293
  </xsl:if>
@@ -434,12 +434,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
434
434
  <!-- Preamble -->
435
435
  <!-- ######## -->
436
436
 
437
- <!-- N.B. Portions of this preamble duplicate fragments of the LaTeX -->
438
- <!-- conversion's preamble, since the inherited content templates -->
439
- <!-- presume supporting macros and environments ("image", "sidebyside" -->
440
- <!-- and "sbspanel", "program", "console", "sageinput"/"sageoutput", -->
441
- <!-- tabular rules, semantic macros). Re-architecting the LaTeX -->
442
- <!-- preamble into shareable pieces would remove the duplication. -->
437
+ <!-- N.B. This preamble is assembled largely from the shared preamble -->
438
+ <!-- pieces of pretext-latex-common.xsl (tcolorbox setup, images, -->
439
+ <!-- tables, side-by-side, code, font hooks), so the environments the -->
440
+ <!-- inherited content templates emit are all defined. Two fragments -->
441
+ <!-- remain local duplicates: the semantic macros (a subset, with -->
442
+ <!-- Beamer-specific treatment of \alert and no styling hooks) and -->
443
+ <!-- the engine/font setup (fontenc/fontspec, where the regular -->
444
+ <!-- "font-support" prescribes document fonts a theme should control). -->
443
445
  <xsl:template name="beamer-preamble">
444
446
  <xsl:text>\documentclass[11pt, compress]{beamer}&#xa;</xsl:text>
445
447
  <xsl:if test="$latex.preamble.early != ''">
@@ -466,121 +468,38 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
466
468
  <xsl:text>%% Some aspects of the preamble are conditional,&#xa;</xsl:text>
467
469
  <xsl:text>%% the LaTeX engine is one such determinant&#xa;</xsl:text>
468
470
  <xsl:text>\usepackage{ifthen}&#xa;</xsl:text>
469
- <xsl:text>\newcommand{\tabularfont}{}&#xa;</xsl:text>
470
- <xsl:text>\usepackage[xparse, raster]{tcolorbox}&#xa;</xsl:text>
471
+ <!-- The style-writer font hooks that shared preamble pieces -->
472
+ <!-- presume; under Beamer the theme controls fonts, so the -->
473
+ <!-- no-op defaults are exactly right -->
474
+ <xsl:call-template name="automatic-font-control"/>
475
+ <xsl:text>%% Shared tcolorbox styles restore paragraph shape via \ptxsetparstyle;&#xa;</xsl:text>
476
+ <xsl:text>%% under Beamer the theme's paragraph shape should rule, so a no-op&#xa;</xsl:text>
477
+ <xsl:text>\newcommand{\ptxsetparstyle}{}&#xa;</xsl:text>
478
+ <!-- The shared tcolorbox setup: package, libraries, stock styles -->
479
+ <xsl:call-template name="tcolorbox-init"/>
480
+ <xsl:text>%% Boxes default to white backgrounds and frames, so tcolorbox&#xa;</xsl:text>
481
+ <xsl:text>%% content does not pick up colors from the Beamer theme&#xa;</xsl:text>
471
482
  <xsl:text>\tcbset{colback=white, colframe=white}&#xa;</xsl:text>
472
- <xsl:text>%% tcolorbox styles used by images and side-by-side panels&#xa;</xsl:text>
473
- <xsl:text>\tcbset{ bwminimalstyle/.style={size=minimal, boxrule=-0.3pt, frame empty,&#xa;</xsl:text>
474
- <xsl:text>colback=white, colbacktitle=white, coltitle=black, opacityfill=0.0} }&#xa;</xsl:text>
475
- <xsl:if test="$document-root//image">
476
- <xsl:text>%% "tcolorbox" environment for a single image, as in the LaTeX conversion&#xa;</xsl:text>
477
- <xsl:text>\tcbset{ imagestyle/.style={bwminimalstyle} }&#xa;</xsl:text>
478
- <xsl:text>\NewTColorBox{tcbimage}{mmm}{imagestyle,left skip=#1\linewidth,width=#2\linewidth}&#xa;</xsl:text>
479
- <xsl:text>\NewDocumentEnvironment{image}{mmmm}{\notblank{#4}{\leavevmode\nopagebreak\vspace{#4}}{}\begin{tcbimage}{#1}{#2}{#3}}{\end{tcbimage}%&#xa;}</xsl:text>
480
- <xsl:text>&#xa;</xsl:text>
481
- </xsl:if>
483
+ <!-- The shared "tcolorbox" environment for a single image -->
484
+ <xsl:call-template name="image-tcolorbox"/>
482
485
  <xsl:if test="$document-root//ol[@cols]|$document-root//ul[@cols]">
483
486
  <xsl:text>%% Multiple column lists&#xa;</xsl:text>
484
487
  <xsl:text>\usepackage{multicol}&#xa;</xsl:text>
485
488
  </xsl:if>
486
- <xsl:if test="$b-has-program or $b-has-console or $b-has-sage">
487
- <xsl:text>%% Program listing support: for listings, programs, consoles, and Sage code&#xa;</xsl:text>
488
- <xsl:text>\ifthenelse{\boolean{xetex} \or \boolean{luatex}}%&#xa;</xsl:text>
489
- <xsl:text> {\tcbuselibrary{listings}}%&#xa;</xsl:text>
490
- <xsl:text> {\tcbuselibrary{listingsutf8}}%&#xa;</xsl:text>
491
- <xsl:text>%% A null language, free of any formatting or style&#xa;</xsl:text>
492
- <xsl:text>\lstdefinelanguage{none}{identifierstyle=,commentstyle=,stringstyle=,keywordstyle=}&#xa;</xsl:text>
493
- <xsl:if test="$b-has-program">
494
- <xsl:text>%% Colors match a subset of Google prettify "Default" style&#xa;</xsl:text>
495
- <xsl:text>\definecolor{identifiers}{rgb}{0.375,0,0.375}&#xa;</xsl:text>
496
- <xsl:text>\definecolor{comments}{rgb}{0.5,0,0}&#xa;</xsl:text>
497
- <xsl:text>\definecolor{strings}{rgb}{0,0.5,0}&#xa;</xsl:text>
498
- <xsl:text>\definecolor{keywords}{rgb}{0,0,0.5}&#xa;</xsl:text>
499
- <xsl:text>\lstdefinestyle{programcodestyle}{identifierstyle=\color{identifiers},commentstyle=\color{comments},stringstyle=\color{strings},keywordstyle=\color{keywords}, breaklines=true, breakatwhitespace=true, columns=fixed, extendedchars=true, aboveskip=0pt, belowskip=0pt}&#xa;</xsl:text>
500
- <xsl:text>\lstdefinestyle{programcodenumberedstyle}{style=programcodestyle, numbers=left}&#xa;</xsl:text>
501
- <xsl:text>\tcbset{ programboxstyle/.style={left=3ex, right=0pt, top=0ex, bottom=0ex, middle=0pt, toptitle=0pt, bottomtitle=0pt, boxsep=0pt, &#xa;</xsl:text>
502
- <xsl:text>listing only, fontupper=\small\ttfamily,&#xa;</xsl:text>
503
- <xsl:text>colback=white, sharp corners, boxrule=-0.3pt, leftrule=0.5pt,&#xa;</xsl:text>
504
- <xsl:text>parbox=false,&#xa;</xsl:text>
505
- <xsl:text>} }&#xa;</xsl:text>
506
- <xsl:text>\tcbset{ programboxnumberedstyle/.style={programboxstyle, left=6ex} }&#xa;</xsl:text>
507
- <xsl:text>%% Arguments: language, left margin, width, right margin (latter ignored)&#xa;</xsl:text>
508
- <xsl:text>\newtcblisting{program}[4]{programboxstyle, left skip=#2\linewidth, width=#3\linewidth, listing options={language=#1, style=programcodestyle}}&#xa;</xsl:text>
509
- <xsl:text>\newtcblisting{programnumbered}[4]{programboxnumberedstyle, left skip=#2\linewidth, width=#3\linewidth, listing options={language=#1, style=programcodenumberedstyle}}&#xa;</xsl:text>
510
- <xsl:text>\newcommand{\programfragment}[2]{\lstinline[language=#1, style=programcodestyle, basicstyle=\ttfamily]#2}&#xa;</xsl:text>
511
- </xsl:if>
512
- <xsl:if test="$b-has-console">
513
- <xsl:text>%% Console session with prompt, input, output&#xa;</xsl:text>
514
- <xsl:text>\newcommand{\consoleinput}[1]{\textbf{#1}}&#xa;</xsl:text>
515
- <xsl:text>\lstdefinestyle{consolecodestyle}{language=none, escapeinside={(*}{*)}, identifierstyle=, commentstyle=, stringstyle=, keywordstyle=, breaklines=false, breakatwhitespace=false, columns=fixed, extendedchars=true, aboveskip=0pt, belowskip=0pt}&#xa;</xsl:text>
516
- <xsl:text>\tcbset{ consoleboxstyle/.style={left=0pt, right=0pt, top=0ex, bottom=0ex, middle=0pt, toptitle=0pt, bottomtitle=0pt, boxsep=0pt,&#xa;</xsl:text>
517
- <xsl:text>listing only, fontupper=\small\ttfamily,&#xa;</xsl:text>
518
- <xsl:text>colback=white, boxrule=-0.3pt,&#xa;</xsl:text>
519
- <xsl:text>parbox=false,&#xa;</xsl:text>
520
- <xsl:text>} }&#xa;</xsl:text>
521
- <xsl:text>%% Arguments: left margin, width, right margin (latter ignored)&#xa;</xsl:text>
522
- <xsl:text>\newtcblisting{console}[3]{consoleboxstyle, left skip=#1\linewidth, width=#2\linewidth, listing options={style=consolecodestyle}}&#xa;</xsl:text>
523
- </xsl:if>
524
- <xsl:if test="$b-has-sage">
525
- <xsl:text>%% The listings package as tcolorbox for Sage code&#xa;</xsl:text>
526
- <xsl:text>\definecolor{sageblue}{HTML}{</xsl:text><xsl:value-of select="$sage-input-background"/><xsl:text>}&#xa;</xsl:text>
527
- <xsl:text>\tcbset{ sagestyle/.style={left=0pt, right=0pt, top=0ex, bottom=0ex, middle=0pt, toptitle=0pt, bottomtitle=0pt,&#xa;</xsl:text>
528
- <xsl:text>boxsep=4pt, listing only, fontupper=\small\ttfamily,&#xa;</xsl:text>
529
- <xsl:text>parbox=false, &#xa;</xsl:text>
530
- <xsl:text>listing options={language=Python,breaklines=true,breakatwhitespace=true, extendedchars=true, aboveskip=0pt, belowskip=0pt}} }&#xa;</xsl:text>
531
- <xsl:text>\newtcblisting{sageinput}{sagestyle, colback=sageblue, sharp corners, boxrule=0.5pt, }&#xa;</xsl:text>
532
- <xsl:text>\newtcblisting{sageoutput}{sagestyle, colback=white, colframe=white, frame empty, before skip=0pt, after skip=0pt, }&#xa;</xsl:text>
533
- </xsl:if>
534
- </xsl:if>
535
- <xsl:if test="$document-root//sidebyside">
536
- <xsl:text>%% tcolorbox styles for sidebyside layout&#xa;</xsl:text>
537
- <xsl:text>\tcbset{ sbsstyle/.style={raster before skip=2.0ex, raster equal height=rows, raster force size=false} }&#xa;</xsl:text>
538
- <xsl:text>\tcbset{ sbspanelstyle/.style={bwminimalstyle} }&#xa;</xsl:text>
539
- <xsl:text>%% "xparse" environment for entire sidebyside&#xa;</xsl:text>
540
- <xsl:text>\NewDocumentEnvironment{sidebyside}{mmmm}&#xa;</xsl:text>
541
- <xsl:text> {\begin{tcbraster}&#xa;</xsl:text>
542
- <xsl:text> [sbsstyle,raster columns=#1,&#xa;</xsl:text>
543
- <xsl:text> raster left skip=#2\linewidth,raster right skip=#3\linewidth,raster column skip=#4\linewidth]}&#xa;</xsl:text>
544
- <xsl:text> {\end{tcbraster}}&#xa;</xsl:text>
545
- <xsl:text>%% "tcolorbox" environment for a panel of sidebyside&#xa;</xsl:text>
546
- <xsl:text>\NewTColorBox{sbspanel}{mO{top}}{sbspanelstyle,width=#1\linewidth,valign=#2}&#xa;</xsl:text>
547
- </xsl:if>
548
- <xsl:if test="$document-root//tabular">
549
- <xsl:text>%% For improved tables&#xa;</xsl:text>
550
- <xsl:text>\usepackage{array}&#xa;</xsl:text>
551
- <xsl:text>\setlength{\extrarowheight}{0.2ex}&#xa;</xsl:text>
552
- <xsl:text>%% Variable thickness horizontal rules, full and partial&#xa;</xsl:text>
553
- <xsl:text>\newcommand{\hrulethin} {\noalign{\hrule height 0.04em}}&#xa;</xsl:text>
554
- <xsl:text>\newcommand{\hrulemedium}{\noalign{\hrule height 0.07em}}&#xa;</xsl:text>
555
- <xsl:text>\newcommand{\hrulethick} {\noalign{\hrule height 0.11em}}&#xa;</xsl:text>
556
- <xsl:text>\let\oldsetlength\setlength&#xa;</xsl:text>
557
- <xsl:text>\newlength{\Oldarrayrulewidth}&#xa;</xsl:text>
558
- <xsl:text>\newcommand{\crulethin}[1]%&#xa;</xsl:text>
559
- <xsl:text>{\noalign{\global\oldsetlength{\Oldarrayrulewidth}{\arrayrulewidth}}%&#xa;</xsl:text>
560
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{0.04em}}\cline{#1}%&#xa;</xsl:text>
561
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{\Oldarrayrulewidth}}}%&#xa;</xsl:text>
562
- <xsl:text>\newcommand{\crulemedium}[1]%&#xa;</xsl:text>
563
- <xsl:text>{\noalign{\global\oldsetlength{\Oldarrayrulewidth}{\arrayrulewidth}}%&#xa;</xsl:text>
564
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{0.07em}}\cline{#1}%&#xa;</xsl:text>
565
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{\Oldarrayrulewidth}}}&#xa;</xsl:text>
566
- <xsl:text>\newcommand{\crulethick}[1]%&#xa;</xsl:text>
567
- <xsl:text>{\noalign{\global\oldsetlength{\Oldarrayrulewidth}{\arrayrulewidth}}%&#xa;</xsl:text>
568
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{0.11em}}\cline{#1}%&#xa;</xsl:text>
569
- <xsl:text>\noalign{\global\oldsetlength{\arrayrulewidth}{\Oldarrayrulewidth}}}&#xa;</xsl:text>
570
- <xsl:text>%% Single letter column specifiers defined via array package&#xa;</xsl:text>
571
- <xsl:text>\newcolumntype{A}{!{\vrule width 0.04em}}&#xa;</xsl:text>
572
- <xsl:text>\newcolumntype{B}{!{\vrule width 0.07em}}&#xa;</xsl:text>
573
- <xsl:text>\newcolumntype{C}{!{\vrule width 0.11em}}&#xa;</xsl:text>
574
- </xsl:if>
575
- <xsl:if test="$document-root//cell/line">
576
- <xsl:text>\newcommand{\tablecelllines}[3]%&#xa;</xsl:text>
577
- <xsl:text>{\begin{tabular}[#2]{@{}#1@{}}#3\end{tabular}}&#xa;</xsl:text>
578
- </xsl:if>
489
+ <!-- The shared support for programs, consoles, Sage code, and -->
490
+ <!-- verbatim-ish material ("pre", "cd", literate programming) -->
491
+ <xsl:call-template name="code-support"/>
492
+ <!-- The shared side-by-side environments; their styles employ -->
493
+ <!-- the \blocktitlefont and \ptxsetparstyle hooks defined above -->
494
+ <xsl:call-template name="sidebyside-environment"/>
495
+ <!-- The shared table support: rules, column types, and the -->
496
+ <!-- "tabularbox" that the inherited "tabular" templates rely on -->
497
+ <xsl:call-template name="tables"/>
579
498
  <xsl:text>\newcommand{\lt}{&lt;}&#xa;</xsl:text>
580
499
  <xsl:text>\newcommand{\gt}{&gt;}&#xa;</xsl:text>
581
500
  <xsl:text>\newcommand{\amp}{&amp;}&#xa;</xsl:text>
582
501
  <xsl:text>%% Begin: Semantic Macros&#xa;</xsl:text>
583
- <xsl:text>\newcommand{\mono}[1]{\texttt{#1}}&#xa;</xsl:text>
502
+ <xsl:text>\newcommand{\ptxmono}[1]{\texttt{#1}}&#xa;</xsl:text>
584
503
  <xsl:variable name="one-line-reps" select="
585
504
  ($document-root//abbr)[1]|
586
505
  ($document-root//acro)[1]|
@@ -589,13 +508,15 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
589
508
  <xsl:apply-templates select="." mode="tex-macro"/>
590
509
  </xsl:for-each>
591
510
  <xsl:if test="$document-root//alert">
592
- <xsl:text>\newcommand{\alert}[1]{\textbf{\textit{#1}}}&#xa;</xsl:text>
511
+ <!-- Beamer has its own theme-aware, overlay-capable \alert, -->
512
+ <!-- so the PreTeXt semantic macro is realized through it -->
513
+ <xsl:text>\newcommand{\ptxalert}[1]{\alert{#1}}&#xa;</xsl:text>
593
514
  </xsl:if>
594
515
  <xsl:if test="$document-root//term">
595
- <xsl:text>\newcommand{\terminology}[1]{\textbf{#1}}&#xa;</xsl:text>
516
+ <xsl:text>\newcommand{\ptxterminology}[1]{\textbf{#1}}&#xa;</xsl:text>
596
517
  </xsl:if>
597
518
  <xsl:if test="$document-root//pubtitle">
598
- <xsl:text>\newcommand{\pubtitle}[1]{\textsl{#1}}&#xa;</xsl:text>
519
+ <xsl:text>\newcommand{\ptxpubtitle}[1]{\textsl{#1}}&#xa;</xsl:text>
599
520
  </xsl:if>
600
521
  <xsl:if test="$document-root//fillin[not(parent::m or parent::me or parent::men or parent::mrow)]">
601
522
  <xsl:call-template name="fillin-text"/>
@@ -604,42 +525,18 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
604
525
  <xsl:call-template name="fillin-math"/>
605
526
  </xsl:if>
606
527
  <xsl:if test="$document-root//swungdash">
607
- <xsl:text>\newcommand{\swungdash}{\raisebox{-2.25ex}{\scalebox{2}{\~{}}}}&#xa;</xsl:text>
608
- </xsl:if>
609
- <xsl:if test="$document-root//quantity">
610
- <xsl:text>%% Used for units and number formatting&#xa;</xsl:text>
611
- <xsl:text>\usepackage[per-mode=fraction]{siunitx}&#xa;</xsl:text>
612
- <xsl:text>\sisetup{inter-unit-product=\cdot}&#xa;</xsl:text>
613
- <xsl:text>\ifxetex\sisetup{math-micro=\text{µ},text-micro=µ}\fi&#xa;</xsl:text>
614
- <xsl:text>\ifluatex\sisetup{math-micro=\text{µ},text-micro=µ}\fi&#xa;</xsl:text>
615
- <xsl:text>%% Common non-SI units&#xa;</xsl:text>
616
- <xsl:for-each select="document('pretext-units.xsl')//base[@siunitx]">
617
- <xsl:text>\DeclareSIUnit\</xsl:text>
618
- <xsl:value-of select="@full" />
619
- <xsl:text>{</xsl:text>
620
- <xsl:choose>
621
- <xsl:when test="@siunitx='none'">
622
- <xsl:value-of select="@short" />
623
- </xsl:when>
624
- <xsl:otherwise>
625
- <xsl:value-of select="@siunitx" />
626
- </xsl:otherwise>
627
- </xsl:choose>
628
- <xsl:text>}&#xa;</xsl:text>
629
- </xsl:for-each>
528
+ <xsl:text>\newcommand{\ptxswungdash}{\raisebox{-2.25ex}{\scalebox{2}{\~{}}}}&#xa;</xsl:text>
630
529
  </xsl:if>
530
+ <!-- The shared siunitx support for "quantity" -->
531
+ <xsl:call-template name="quantity-support"/>
631
532
  <xsl:if test="$document-root//case[@direction]">
632
533
  <xsl:text>%% Arrows for iff proofs, with trailing space&#xa;</xsl:text>
633
- <xsl:text>\newcommand{\forwardimplication}{($\Rightarrow$)}&#xa;</xsl:text>
634
- <xsl:text>\newcommand{\backwardimplication}{($\Leftarrow$)}&#xa;</xsl:text>
534
+ <xsl:text>\newcommand{\ptxforwardimplication}{($\Rightarrow$)}&#xa;</xsl:text>
535
+ <xsl:text>\newcommand{\ptxbackwardimplication}{($\Leftarrow$)}&#xa;</xsl:text>
635
536
  </xsl:if>
636
537
  <xsl:if test="$document-root//ol/li/title|$document-root//ul/li/title">
637
538
  <xsl:text>%% Style of a title on a list item, for ordered and unordered lists&#xa;</xsl:text>
638
- <xsl:text>\newcommand{\lititle}[1]{{\slshape#1}}&#xa;</xsl:text>
639
- </xsl:if>
640
- <xsl:if test="$document-root//xref">
641
- <xsl:text>%% Font for cross-reference numbers, a no-op on slides&#xa;</xsl:text>
642
- <xsl:text>\newcommand{\xreffont}{}&#xa;</xsl:text>
539
+ <xsl:text>\newcommand{\ptxlititle}[1]{{\slshape#1}}&#xa;</xsl:text>
643
540
  </xsl:if>
644
541
  <xsl:text>%% End: Semantic Macros&#xa;</xsl:text>
645
542
  <xsl:if test="$latex.preamble.late != ''">