@pretextbook/pretext-html 0.15.0 → 0.16.1

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 (52) hide show
  1. package/assets/upstream.json +2 -2
  2. package/assets/xsl/entities.ent +14 -1
  3. package/assets/xsl/latex/pretext-latex-texstyle.xsl +5 -2
  4. package/assets/xsl/localizations/README.md +1 -1
  5. package/assets/xsl/localizations/af-ZA.xml +5 -6
  6. package/assets/xsl/localizations/bg-BG.xml +5 -6
  7. package/assets/xsl/localizations/ca-ES.xml +5 -6
  8. package/assets/xsl/localizations/cs-CZ.xml +5 -6
  9. package/assets/xsl/localizations/de-DE.xml +108 -108
  10. package/assets/xsl/localizations/en-US.xml +18 -17
  11. package/assets/xsl/localizations/es-ES.xml +5 -6
  12. package/assets/xsl/localizations/fi-FI.xml +5 -6
  13. package/assets/xsl/localizations/fr-CA.xml +5 -6
  14. package/assets/xsl/localizations/fr-FR.xml +5 -6
  15. package/assets/xsl/localizations/hu-HU.xml +5 -6
  16. package/assets/xsl/localizations/it-IT.xml +7 -7
  17. package/assets/xsl/localizations/ku-CKB.xml +5 -6
  18. package/assets/xsl/localizations/nl-NL.xml +5 -6
  19. package/assets/xsl/localizations/pt-BR.xml +4 -5
  20. package/assets/xsl/localizations/pt-PT.xml +4 -5
  21. package/assets/xsl/localizations/zh-HANS.xml +5 -6
  22. package/assets/xsl/pretext-assembly.xsl +154 -29
  23. package/assets/xsl/pretext-beamer.xsl +112 -10
  24. package/assets/xsl/pretext-braille-preprint.xsl +22 -3
  25. package/assets/xsl/pretext-common.xsl +117 -42
  26. package/assets/xsl/pretext-epub.xsl +74 -87
  27. package/assets/xsl/pretext-fo.xsl +115 -41
  28. package/assets/xsl/pretext-html.xsl +333 -102
  29. package/assets/xsl/pretext-latex-classic.xsl +48 -35
  30. package/assets/xsl/pretext-latex-common.xsl +160 -98
  31. package/assets/xsl/pretext-latex.xsl +12 -10
  32. package/assets/xsl/pretext-markdown.xsl +5 -3
  33. package/assets/xsl/pretext-numbers.xsl +28 -2
  34. package/assets/xsl/pretext-revealjs.xsl +44 -2
  35. package/assets/xsl/pretext-runestone-static.xsl +27 -4
  36. package/assets/xsl/pretext-runestone.xsl +112 -0
  37. package/assets/xsl/pretext-text.xsl +21 -14
  38. package/assets/xsl/publisher-variables.xsl +187 -47
  39. package/assets/xsl/support/extract-math.xsl +22 -2
  40. package/assets/xsl/support/package-math.xsl +9 -8
  41. package/assets/xsl/utilities/report-publisher-variables.xsl +4 -0
  42. package/assets/xsl-bundle.json +1 -1
  43. package/dist/{cli-ox-z2TCZ.js → cli-DzlCZymu.js} +4 -4
  44. package/dist/cli.js +1 -1
  45. package/dist/html-static.d.ts +2 -2
  46. package/dist/index.browser.d.ts +2 -0
  47. package/dist/index.browser.js +858 -514
  48. package/dist/index.d.ts +2 -0
  49. package/dist/index.js +34 -29
  50. package/dist/live-patch.d.ts +100 -0
  51. package/dist/live-patch.js +346 -0
  52. package/package.json +9 -1
@@ -431,8 +431,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
431
431
  <!-- stylesheet older than the script that wrote it, and the mismatch -->
432
432
  <!-- would surface as substitutions quietly coming out wrong instead of -->
433
433
  <!-- as a statement of what is actually the matter. -->
434
+ <!-- The file is read only if this tree holds something the lookups below -->
435
+ <!-- will substitute, the same elements that open the file there. A -->
436
+ <!-- "setup" alone (such as "var" with "condition") is enough to name the -->
437
+ <!-- file, but has nothing to substitute and so the file is never made. -->
434
438
  <xsl:template match="/" mode="dynamic-substitution">
435
- <xsl:if test="($exercise-style = 'static') and not($b-extracting) and not($dynamic-substitutions-file = '')">
439
+ <xsl:if test="($exercise-style = 'static') and not($b-extracting) and not($dynamic-substitutions-file = '') and (.//fillin[@ansobj] or .//eval[@obj])">
436
440
  <xsl:variable name="recorded" select="document($dynamic-substitutions-file,$original)/*/@version"/>
437
441
  <!-- A missing @version is an older file, and is silent: the -->
438
442
  <!-- representation template already falls back for those. Only a -->
@@ -1159,35 +1163,36 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1159
1163
  <!-- $b-using-csl-styles: a consequence of opting in via publisher file -->
1160
1164
  <!-- $b-extracting-biblio: set here and overridden in the extraction stylesheet -->
1161
1165
 
1166
+ <!-- The generated file is only consulted in a conversion (extraction -->
1167
+ <!-- is making the file, not using it), with CSL styles in use, of a -->
1168
+ <!-- document that has references to replace. A stylesheet with no -->
1169
+ <!-- use for the file (the publisher variable report) overrides this. -->
1170
+ <xsl:variable name="b-consulting-csl-file" select="$b-using-csl-styles and not($b-extracting-biblio) and boolean($original//backmatter/references[not(@source)])"/>
1171
+
1162
1172
  <!-- two error conditions -->
1163
- <!-- 2025-08-13: this variable is always false -->
1173
+ <!-- The generated file is made on request, so is often absent. The -->
1174
+ <!-- xsltproc executable reads a missing file as an empty node-set, -->
1175
+ <!-- while lxml would halt, so the Python xsltproc() (in common.py) -->
1176
+ <!-- supplies a stand-in document for it instead. Either way, no -->
1177
+ <!-- "pi:csl-references" element is found. -->
1164
1178
  <xsl:variable name="missing-csl-file">
1165
1179
  <xsl:choose>
1166
1180
  <!-- can't be missing if we don't need it, and we -->
1167
1181
  <!-- don't induce panic by looking for it, when it -->
1168
1182
  <!-- isn't called for, and getting ominous warnings -->
1169
- <xsl:when test="not($b-using-csl-styles)">
1183
+ <xsl:when test="not($b-consulting-csl-file)">
1170
1184
  <xsl:text>no</xsl:text>
1171
1185
  </xsl:when>
1172
- <xsl:otherwise>
1186
+ <!-- since we build the file, condition on the size of -->
1187
+ <!-- this node-set: one (good) or none (bad, missing) -->
1188
+ <xsl:when test="count(document($csl-file, $original)/pi:csl-references) = 1">
1173
1189
  <xsl:text>no</xsl:text>
1174
- <!-- this is only a test, variable is local and not retained -->
1175
- <!-- <xsl:variable name="the-references" -->
1176
- <!-- select="document($csl-file, $original)/pi:csl-references"/> -->
1177
- <!-- since we build the file, condiition on the size of -->
1178
- <!-- this node-set: one (good) or none (bad, missing) -->
1179
- <!-- <xsl:choose> -->
1180
- <!-- file looks good -->
1181
- <!-- <xsl:when test="count($the-references) = 1"> -->
1182
- <!-- <xsl:text>no</xsl:text> -->
1183
- <!-- </xsl:when> -->
1184
- <!-- nothing came of document() -->
1185
- <!-- <xsl:otherwise> -->
1186
- <!-- <xsl:text>yes</xsl:text> -->
1187
- <!-- and we take the opportunity to say so, just once, and early on -->
1188
- <!-- <xsl:message>PTX:ERROR: your publisher file indicates the use of a Citation Stylesheet Language (CSL) specification for references, but we have not located your file of generated references and citations at "<xsl:value-of select="$csl-file"/>". We will fall back to default processing in order to proceed.</xsl:message> -->
1189
- <!-- </xsl:otherwise> -->
1190
- <!-- </xsl:choose> -->
1190
+ </xsl:when>
1191
+ <!-- nothing came of document() -->
1192
+ <xsl:otherwise>
1193
+ <xsl:text>yes</xsl:text>
1194
+ <!-- and we take the opportunity to say so, just once, and early on -->
1195
+ <xsl:message>PTX:FALLBACK: your publisher file indicates the use of a Citation Style Language (CSL) style for references ("<xsl:value-of select="$csl-style-file"/>"), perhaps by way of a journal, but we have not located your file of generated references and citations at "<xsl:value-of select="$csl-file"/>". Generate the "references" assets to create it. We will fall back to default processing in order to proceed.</xsl:message>
1191
1196
  </xsl:otherwise>
1192
1197
  </xsl:choose>
1193
1198
  </xsl:variable>
@@ -1202,7 +1207,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1202
1207
  <xsl:choose>
1203
1208
  <!-- we do not warning at the end of this template, -->
1204
1209
  <!-- just because the file itself does not exist -->
1205
- <xsl:when test="not($b-using-csl-styles) or $missing-csl-file">
1210
+ <xsl:when test="not($b-consulting-csl-file) or $b-missing-csl-file">
1206
1211
  <xsl:text>no</xsl:text>
1207
1212
  </xsl:when>
1208
1213
  <!-- now we are using CSL styles and we do have a file to interrogate -->
@@ -1221,7 +1226,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1221
1226
  <xsl:otherwise>
1222
1227
  <xsl:text>yes</xsl:text>
1223
1228
  <!-- and we take the opportunity to say so, just once, and early on -->
1224
- <xsl:message>PTX:WARNING: your publisher file indicates the use of one Citation Stylesheet Language (CSL) specification for references ("<xsl:value-of select="$csl-style-file"/>"), but your file of generated references and citations at "<xsl:value-of select="$csl-file"/>" was built using a different CSL style file ("<xsl:value-of select="$csl-style-file-for-generated"/>"). We will fall back to default processing in order to proceed.</xsl:message>
1229
+ <xsl:message>PTX:WARNING: your publisher file indicates the use of one Citation Style Language (CSL) specification for references ("<xsl:value-of select="$csl-style-file"/>"), but your file of generated references and citations at "<xsl:value-of select="$csl-file"/>" was built using a different CSL style file ("<xsl:value-of select="$csl-style-file-for-generated"/>"). We will fall back to default processing in order to proceed.</xsl:message>
1225
1230
  </xsl:otherwise>
1226
1231
  </xsl:choose>
1227
1232
  </xsl:otherwise>
@@ -1238,8 +1243,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1238
1243
  <xsl:template match="backmatter/references[not(@source)]" mode="assembly">
1239
1244
  <xsl:choose>
1240
1245
  <!-- duplicate for biblio extraction process or if using -->
1241
- <!-- default (simplistic) PreTeXt bibliography support -->
1242
- <xsl:when test="$b-extracting-biblio or not($b-using-csl-styles)">
1246
+ <!-- default (simplistic) PreTeXt bibliography support, -->
1247
+ <!-- or any other pass not consulting the generated file -->
1248
+ <xsl:when test="not($b-consulting-csl-file)">
1243
1249
  <xsl:copy>
1244
1250
  <xsl:apply-templates select="node()|@*" mode="assembly"/>
1245
1251
  </xsl:copy>
@@ -1332,7 +1338,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1332
1338
  <!-- Note: not using CSL styles immediately determines that -->
1333
1339
  <!-- this "xrref" is not a "biblio target" and a copy is -->
1334
1340
  <!-- made here, immediately as well -->
1335
- <xsl:when test="not($b-is-biblio-target) or $b-extracting-biblio">
1341
+ <!-- A missing or mismatched generated file is met the same -->
1342
+ <!-- way here as with the "references" division above: keep -->
1343
+ <!-- the author's "xref", so citations and bibliography both -->
1344
+ <!-- fall back to default processing, together -->
1345
+ <xsl:when test="not($b-is-biblio-target) or not($b-consulting-csl-file) or $b-missing-csl-file or $b-style-file-mismatch">
1336
1346
  <xsl:copy>
1337
1347
  <xsl:apply-templates select="node()|@*" mode="assembly"/>
1338
1348
  </xsl:copy>
@@ -1342,7 +1352,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1342
1352
  <xsl:variable name="the-xref-id">
1343
1353
  <xsl:value-of select="@pi:original-id"/>
1344
1354
  </xsl:variable>
1345
- <xsl:variable name="matched-citation" select="document('gen/references/csl-bibliography.xml', $original)/pi:csl-references/pi:csl-citation[@xml:id = $the-xref-id]"/>
1355
+ <!-- $csl-file is defined in the publisher-variables stylesheet -->
1356
+ <xsl:variable name="matched-citation" select="document($csl-file, $original)/pi:csl-references/pi:csl-citation[@xml:id = $the-xref-id]"/>
1346
1357
  <xsl:copy-of select="$matched-citation"/>
1347
1358
  <!-- WARN ON UNMATCHED -->
1348
1359
  </xsl:otherwise>
@@ -1379,10 +1390,37 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1379
1390
  <xsl:value-of select="parent::match/@order"/>
1380
1391
  </xsl:attribute>
1381
1392
  </xsl:if>
1382
- <xsl:apply-templates select="node()" mode="assembly"/>
1393
+ <xsl:apply-templates select="." mode="cardsort-card-assembly"/>
1394
+ </xsl:copy>
1395
+ </xsl:template>
1396
+
1397
+ <xsl:template match="cardsort/match/response" mode="assembly">
1398
+ <xsl:copy>
1399
+ <xsl:apply-templates select="@*" mode="assembly"/>
1400
+ <xsl:apply-templates select="." mode="cardsort-card-assembly"/>
1383
1401
  </xsl:copy>
1384
1402
  </xsl:template>
1385
1403
 
1404
+ <!-- Experimental, see "debug.advanced.feedback": a card may have a -->
1405
+ <!-- "statement" and a "feedback". Unless the experiment is on, -->
1406
+ <!-- the card is just the content of its "statement", and any -->
1407
+ <!-- "feedback" is dropped, so is never seen by any conversion. -->
1408
+ <xsl:template match="cardsort/match/premise|cardsort/match/response" mode="cardsort-card-assembly">
1409
+ <xsl:choose>
1410
+ <xsl:when test="not($b-debug-advanced-feedback) and statement">
1411
+ <xsl:apply-templates select="statement/node()" mode="assembly"/>
1412
+ </xsl:when>
1413
+ <xsl:otherwise>
1414
+ <xsl:apply-templates select="node()" mode="assembly"/>
1415
+ </xsl:otherwise>
1416
+ </xsl:choose>
1417
+ </xsl:template>
1418
+
1419
+ <!-- The deprecated "matches" form does not get this new feature -->
1420
+ <xsl:template match="matches/match/premise" mode="cardsort-card-assembly">
1421
+ <xsl:apply-templates select="node()" mode="assembly"/>
1422
+ </xsl:template>
1423
+
1386
1424
  <!-- WeBWorK @copy resolution -->
1387
1425
 
1388
1426
  <!-- A "webwork" with a @copy attribute is a lightweight reference -->
@@ -2726,6 +2764,57 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2726
2764
  </xsl:attribute>
2727
2765
  </xsl:template>
2728
2766
 
2767
+ <!-- 2026-09-22 A type of "exercise" is named as a publication file -->
2768
+ <!-- names it, as "exercise-inline" and so on, in a "rename" and in -->
2769
+ <!-- "list-of/@elements" alike. An older one-word name is upgraded -->
2770
+ <!-- here. "divisionexercise", which only "list-of" ever accepted, -->
2771
+ <!-- joins it, so that one type of "exercise" has one name. -->
2772
+ <xsl:template match="rename/@element" mode="repair">
2773
+ <xsl:attribute name="element">
2774
+ <xsl:call-template name="exercise-type-name">
2775
+ <xsl:with-param name="name" select="string(.)"/>
2776
+ </xsl:call-template>
2777
+ </xsl:attribute>
2778
+ </xsl:template>
2779
+
2780
+ <xsl:template match="list-of/@elements" mode="repair">
2781
+ <xsl:attribute name="elements">
2782
+ <xsl:for-each select="str:tokenize(., ', ')">
2783
+ <xsl:if test="position() != 1">
2784
+ <xsl:text> </xsl:text>
2785
+ </xsl:if>
2786
+ <xsl:call-template name="exercise-type-name">
2787
+ <xsl:with-param name="name" select="string(.)"/>
2788
+ </xsl:call-template>
2789
+ </xsl:for-each>
2790
+ </xsl:attribute>
2791
+ </xsl:template>
2792
+
2793
+ <!-- The current name of a type of "exercise", given whatever name an -->
2794
+ <!-- author wrote for it. Any other name, an ordinary element among -->
2795
+ <!-- them, passes through untouched. -->
2796
+ <xsl:template name="exercise-type-name">
2797
+ <xsl:param name="name"/>
2798
+
2799
+ <xsl:choose>
2800
+ <xsl:when test="$name = 'inlineexercise'">
2801
+ <xsl:text>exercise-inline</xsl:text>
2802
+ </xsl:when>
2803
+ <xsl:when test="($name = 'divisionalexercise') or ($name = 'divisionexercise')">
2804
+ <xsl:text>exercise-divisional</xsl:text>
2805
+ </xsl:when>
2806
+ <xsl:when test="$name = 'worksheetexercise'">
2807
+ <xsl:text>exercise-worksheet</xsl:text>
2808
+ </xsl:when>
2809
+ <xsl:when test="$name = 'readingquestion'">
2810
+ <xsl:text>exercise-reading</xsl:text>
2811
+ </xsl:when>
2812
+ <xsl:otherwise>
2813
+ <xsl:value-of select="$name"/>
2814
+ </xsl:otherwise>
2815
+ </xsl:choose>
2816
+ </xsl:template>
2817
+
2729
2818
  <!-- 2021-07-02 wrap notation/usage in "m" if not present -->
2730
2819
  <xsl:template match="notation/usage[not(m)]" mode="repair">
2731
2820
  <!-- duplicate "usage" w/ attributes, insert "m" as repair -->
@@ -4146,6 +4235,42 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4146
4235
  </xsl:copy>
4147
4236
  </xsl:template>
4148
4237
 
4238
+ <!-- A "slide" is numbered as a division is: its @pi:struct is the -->
4239
+ <!-- structure number of its container and its @pi:serial counts -->
4240
+ <!-- slides. The numbering level of divisions decides the form. -->
4241
+ <!-- At level 0 slides are counted through the whole slideshow and -->
4242
+ <!-- there is no structure number. At level 1, only possible with -->
4243
+ <!-- sections, slides are counted within their "section", and its -->
4244
+ <!-- number is the structure number. A slide gets no -->
4245
+ <!-- @pi:block-struct, so blocks within it are numbered by the -->
4246
+ <!-- enclosing division alone. -->
4247
+ <xsl:template match="slide" mode="augment">
4248
+ <xsl:param name="parent-struct"/>
4249
+ <xsl:param name="level"/>
4250
+
4251
+ <xsl:copy>
4252
+ <xsl:attribute name="pi:struct">
4253
+ <xsl:if test="$numbering-maxlevel > 0">
4254
+ <xsl:value-of select="$parent-struct"/>
4255
+ </xsl:if>
4256
+ </xsl:attribute>
4257
+ <xsl:attribute name="pi:serial">
4258
+ <xsl:choose>
4259
+ <xsl:when test="$numbering-maxlevel > 0">
4260
+ <xsl:number count="slide"/>
4261
+ </xsl:when>
4262
+ <xsl:otherwise>
4263
+ <xsl:number count="slide" level="any" from="slideshow"/>
4264
+ </xsl:otherwise>
4265
+ </xsl:choose>
4266
+ </xsl:attribute>
4267
+ <xsl:apply-templates select="node()|@*" mode="augment">
4268
+ <xsl:with-param name="parent-struct" select="$parent-struct"/>
4269
+ <xsl:with-param name="level" select="$level"/>
4270
+ </xsl:apply-templates>
4271
+ </xsl:copy>
4272
+ </xsl:template>
4273
+
4149
4274
  <!-- The top-level division (book, article, ...) is the root of the -->
4150
4275
  <!-- division tree, at level 0, which the catch-all does not record. -->
4151
4276
  <!-- A level-0 numbering scheme counts continuously from the root. -->
@@ -4393,7 +4518,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4393
4518
  <!-- ("-fn") are single counters; the block families share the "blocks" -->
4394
4519
  <!-- counter unless figure-likes, projects, inline exercises, or open -->
4395
4520
  <!-- problems are set "distinct", each then opening its own counter. -->
4396
- <xsl:template match="book|article|part|chapter|appendix|frontmatter|backmatter|preface|section|subsection|subsubsection|exercises|worksheet|handout|reading-questions|references|glossary|solutions" mode="serial-stamp">
4521
+ <xsl:template match="book|article|slideshow|part|chapter|appendix|frontmatter|backmatter|preface|section|subsection|subsubsection|exercises|worksheet|handout|reading-questions|references|glossary|solutions" mode="serial-stamp">
4397
4522
  <xsl:param name="eq-nodes"/>
4398
4523
  <xsl:param name="fn-nodes"/>
4399
4524
  <xsl:param name="blocks-nodes"/>
@@ -90,6 +90,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
90
90
  <xsl:call-template name="valign-letter">
91
91
  <xsl:with-param name="valign" select="$slides-valign-default"/>
92
92
  </xsl:call-template>
93
+ <xsl:call-template name="beamer-not-a-slide"/>
93
94
  <xsl:text>]&#xa;</xsl:text>
94
95
  <xsl:text>\frametitle{</xsl:text>
95
96
  <xsl:apply-templates select="." mode="type-name">
@@ -156,6 +157,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
156
157
  <xsl:call-template name="valign-letter">
157
158
  <xsl:with-param name="valign" select="$slides-valign-default"/>
158
159
  </xsl:call-template>
160
+ <xsl:call-template name="beamer-not-a-slide"/>
159
161
  <xsl:text>]&#xa;</xsl:text>
160
162
  <xsl:text>\titlepage&#xa;</xsl:text>
161
163
  <xsl:text>\end{frame}&#xa;&#xa;</xsl:text>
@@ -167,6 +169,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
167
169
  <xsl:call-template name="valign-letter">
168
170
  <xsl:with-param name="valign" select="$slides-valign-default"/>
169
171
  </xsl:call-template>
172
+ <xsl:call-template name="beamer-not-a-slide"/>
170
173
  <xsl:text>]&#xa;</xsl:text>
171
174
  <xsl:text>\frametitle{</xsl:text>
172
175
  <xsl:apply-templates select="." mode="type-name"/>
@@ -197,6 +200,16 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
197
200
  </xsl:choose>
198
201
  </xsl:template>
199
202
 
203
+ <!-- With PreTeXt's slide numbers, a frame that is not a "slide" -->
204
+ <!-- (title, contents, abstract, section title) does not advance -->
205
+ <!-- Beamer's count of frames, so that count, and the total a theme -->
206
+ <!-- may show or use for a progress bar, is a count of slides. -->
207
+ <xsl:template name="beamer-not-a-slide">
208
+ <xsl:if test="$b-beamer-slide-numbering">
209
+ <xsl:text>,noframenumbering</xsl:text>
210
+ </xsl:if>
211
+ </xsl:template>
212
+
200
213
  <!-- A "section" is a Beamer section (navigation, table of contents) -->
201
214
  <!-- with a section-title frame, as in the reveal.js conversion. -->
202
215
  <xsl:template match="slideshow/section">
@@ -207,6 +220,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
207
220
  <xsl:call-template name="valign-letter">
208
221
  <xsl:with-param name="valign" select="$slides-valign-default"/>
209
222
  </xsl:call-template>
223
+ <xsl:call-template name="beamer-not-a-slide"/>
210
224
  <xsl:text>]&#xa;</xsl:text>
211
225
  <xsl:text>\sectionpage&#xa;</xsl:text>
212
226
  <xsl:text>\end{frame}&#xa;&#xa;</xsl:text>
@@ -217,6 +231,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
217
231
  <!-- realized through the "listings" package (or other verbatim-like -->
218
232
  <!-- material) must be marked "fragile". -->
219
233
  <xsl:template match="slide">
234
+ <xsl:if test="$b-beamer-slide-numbering">
235
+ <xsl:text>\renewcommand{\ptxslidenumber}{</xsl:text>
236
+ <xsl:apply-templates select="." mode="number"/>
237
+ <xsl:text>}\ptxslidetrue&#xa;</xsl:text>
238
+ </xsl:if>
220
239
  <xsl:text>\begin{frame}[</xsl:text>
221
240
  <xsl:call-template name="valign-letter">
222
241
  <xsl:with-param name="valign">
@@ -231,7 +250,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
231
250
  <xsl:apply-templates select="." mode="title-full"/>
232
251
  <xsl:text>}&#xa;</xsl:text>
233
252
  <xsl:apply-templates/>
234
- <xsl:text>\end{frame}&#xa;&#xa;</xsl:text>
253
+ <xsl:text>\end{frame}&#xa;</xsl:text>
254
+ <xsl:if test="$b-beamer-slide-numbering">
255
+ <xsl:text>\ptxslidefalse&#xa;</xsl:text>
256
+ </xsl:if>
257
+ <xsl:text>&#xa;</xsl:text>
235
258
  </xsl:template>
236
259
 
237
260
  <!-- A "subslide" is material that appears, as one group, after an -->
@@ -367,8 +390,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
367
390
  </xsl:call-template>
368
391
  </xsl:template>
369
392
 
370
- <!-- Everything else theorem-ish, plus remarks and asides, is a -->
371
- <!-- generic Beamer "block" headed by its type-name and title -->
393
+ <!-- Everything else theorem-ish, plus remarks and asides, is a -->
394
+ <!-- generic Beamer "block" headed by its type-name and title, and -->
395
+ <!-- for a mathematical block the parenthesized attribution -->
372
396
  <xsl:template match="&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&ASIDE-LIKE;|&GOAL-LIKE;|assemblage">
373
397
  <xsl:text>\begin{block}{</xsl:text>
374
398
  <xsl:apply-templates select="." mode="type-name"/>
@@ -376,23 +400,40 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
376
400
  <xsl:text>: </xsl:text>
377
401
  <xsl:apply-templates select="." mode="title-full"/>
378
402
  </xsl:if>
403
+ <xsl:if test="creator or origins">
404
+ <xsl:text> (</xsl:text>
405
+ <xsl:apply-templates select="." mode="attribution-full"/>
406
+ <xsl:text>)</xsl:text>
407
+ </xsl:if>
379
408
  <xsl:text>}&#xa;</xsl:text>
380
409
  <xsl:apply-templates select="*[not(&PROOF-FILTER;)]"/>
381
410
  <xsl:text>\end{block}&#xa;</xsl:text>
382
411
  <xsl:apply-templates select="&PROOF-LIKE;"/>
383
412
  </xsl:template>
384
413
 
385
- <!-- The common core: the environment, an optional title in the -->
386
- <!-- optional argument, the guts, and any proof following outside -->
414
+ <!-- The common core: the environment, the optional argument, the -->
415
+ <!-- guts, and any proof following outside. Beamer sets the -->
416
+ <!-- optional argument in parentheses, so a title, the creator, and -->
417
+ <!-- the origins share that one group, separated by commas, as in -->
418
+ <!-- the classic LaTeX conversion. Braces protect the argument: a -->
419
+ <!-- citation such as [3] would otherwise end it at the first "]". -->
387
420
  <xsl:template name="beamer-environment">
388
421
  <xsl:param name="environment"/>
389
422
  <xsl:text>\begin{</xsl:text>
390
423
  <xsl:value-of select="$environment"/>
391
424
  <xsl:text>}</xsl:text>
392
- <xsl:if test="title">
393
- <xsl:text>[</xsl:text>
394
- <xsl:apply-templates select="." mode="title-full"/>
395
- <xsl:text>]</xsl:text>
425
+ <xsl:if test="title or creator or origins">
426
+ <xsl:text>[{</xsl:text>
427
+ <xsl:if test="title">
428
+ <xsl:apply-templates select="." mode="title-xref"/>
429
+ </xsl:if>
430
+ <xsl:if test="title and (creator or origins)">
431
+ <xsl:text>, </xsl:text>
432
+ </xsl:if>
433
+ <xsl:if test="creator or origins">
434
+ <xsl:apply-templates select="." mode="attribution-full"/>
435
+ </xsl:if>
436
+ <xsl:text>}]</xsl:text>
396
437
  </xsl:if>
397
438
  <xsl:text>&#xa;</xsl:text>
398
439
  <xsl:apply-templates select="*[not(&PROOF-FILTER;)]"/>
@@ -477,8 +518,41 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
477
518
  <!-- Beamer-specific treatment of \alert and no styling hooks) and -->
478
519
  <!-- the engine/font setup (fontenc/fontspec, where the regular -->
479
520
  <!-- "font-support" prescribes document fonts a theme should control). -->
521
+
522
+ <!-- The Beamer class names a slide's shape with the digits of the -->
523
+ <!-- aspect ratio run together, so "16:9" becomes "aspectratio=169". -->
524
+ <!-- The publisher expresses the ratio in its readable form, and the -->
525
+ <!-- options the publication file admits are exactly those the class -->
526
+ <!-- recognizes, so no value can reach here without a translation. -->
527
+ <xsl:template name="beamer-aspect-ratio-option">
528
+ <xsl:choose>
529
+ <xsl:when test="$beamer-aspect-ratio = '4:3'">
530
+ <xsl:text>43</xsl:text>
531
+ </xsl:when>
532
+ <xsl:when test="$beamer-aspect-ratio = '16:9'">
533
+ <xsl:text>169</xsl:text>
534
+ </xsl:when>
535
+ <xsl:when test="$beamer-aspect-ratio = '16:10'">
536
+ <xsl:text>1610</xsl:text>
537
+ </xsl:when>
538
+ <xsl:when test="$beamer-aspect-ratio = '14:9'">
539
+ <xsl:text>149</xsl:text>
540
+ </xsl:when>
541
+ <xsl:when test="$beamer-aspect-ratio = '5:4'">
542
+ <xsl:text>54</xsl:text>
543
+ </xsl:when>
544
+ <xsl:when test="$beamer-aspect-ratio = '3:2'">
545
+ <xsl:text>32</xsl:text>
546
+ </xsl:when>
547
+ </xsl:choose>
548
+ </xsl:template>
549
+
480
550
  <xsl:template name="beamer-preamble">
481
- <xsl:text>\documentclass[11pt, compress]{beamer}&#xa;</xsl:text>
551
+ <xsl:text>\documentclass[</xsl:text>
552
+ <xsl:value-of select="$beamer-font-size"/>
553
+ <xsl:text>, aspectratio=</xsl:text>
554
+ <xsl:call-template name="beamer-aspect-ratio-option"/>
555
+ <xsl:text>, compress]{beamer}&#xa;</xsl:text>
482
556
  <xsl:if test="$latex.preamble.early != ''">
483
557
  <xsl:text>%% Custom Preamble Entries, early (use latex.preamble.early)&#xa;</xsl:text>
484
558
  <xsl:value-of select="$latex.preamble.early" />
@@ -500,6 +574,34 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
500
574
  <xsl:text>\usefonttheme[onlymath]{serif}&#xa;</xsl:text>
501
575
  <xsl:text>%% quash navigation symbols&#xa;</xsl:text>
502
576
  <xsl:text>\setbeamertemplate{navigation symbols}{}&#xa;</xsl:text>
577
+ <!-- Every theme that shows a frame number, whether in a template -->
578
+ <!-- or directly, and every progress bar, gets it from the command -->
579
+ <!-- \insertframenumber. So it becomes PreTeXt's number of the -->
580
+ <!-- most recent slide, which is always a number, as a theme doing -->
581
+ <!-- arithmetic with it requires (so 0 before the first slide). -->
582
+ <!-- A theme displays the number through a template: "page number -->
583
+ <!-- in head/foot" for most (some leave it empty, others add a -->
584
+ <!-- total, which would announce how long a talk runs), "frame -->
585
+ <!-- numbering" for metropolis. Both show the number alone, and -->
586
+ <!-- only on a frame that is a slide, as the flag \ifptxslide says. -->
587
+ <!-- Without slide numbers, both templates are empty, so no theme -->
588
+ <!-- shows a number, just as a Reveal.js slideshow shows none. -->
589
+ <xsl:choose>
590
+ <xsl:when test="$b-beamer-slide-numbering">
591
+ <xsl:text>%% PreTeXt's slide numbers, wherever a theme shows a frame number,&#xa;</xsl:text>
592
+ <xsl:text>%% alone, and only on a frame that is a slide&#xa;</xsl:text>
593
+ <xsl:text>\newif\ifptxslide&#xa;</xsl:text>
594
+ <xsl:text>\newcommand{\ptxslidenumber}{0}&#xa;</xsl:text>
595
+ <xsl:text>\renewcommand{\insertframenumber}{\ptxslidenumber}&#xa;</xsl:text>
596
+ <xsl:text>\setbeamertemplate{page number in head/foot}{\ifptxslide\insertframenumber\fi}&#xa;</xsl:text>
597
+ <xsl:text>\setbeamertemplate{frame numbering}{\ifptxslide\insertframenumber\fi}&#xa;</xsl:text>
598
+ </xsl:when>
599
+ <xsl:otherwise>
600
+ <xsl:text>%% no slide numbers, whatever the theme&#xa;</xsl:text>
601
+ <xsl:text>\setbeamertemplate{page number in head/foot}{}&#xa;</xsl:text>
602
+ <xsl:text>\setbeamertemplate{frame numbering}{}&#xa;</xsl:text>
603
+ </xsl:otherwise>
604
+ </xsl:choose>
503
605
  <xsl:text>%% every "section" gets a section-title frame via \sectionpage&#xa;</xsl:text>
504
606
  <xsl:text>&#xa;%%%% Start PreTeXt generated preamble %%%%&#xa;&#xa;</xsl:text>
505
607
  <xsl:text>\usepackage{amsmath}&#xa;</xsl:text>
@@ -156,7 +156,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
156
156
  <!-- *are* present in "math-original" but that introduces a new -->
157
157
  <!-- element in-between "md" and "mrow", so matches on -->
158
158
  <!-- "md[mrow]" can be problematic here (and perhaps elsewhere). -->
159
- <xsl:template match="m|md" mode="meld-math">
159
+ <!-- Music notation ("n", "scaledeg", "timesignature", "chord") is -->
160
+ <!-- set as inline math, so it has a representation as an "m" does. -->
161
+ <xsl:template match="m|md|n|scaledeg|timesignature|chord" mode="meld-math">
160
162
  <!-- preserve author's element -->
161
163
  <xsl:copy>
162
164
  <!-- preserve attributes -->
@@ -1779,6 +1781,23 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1779
1781
  </xsl:choose>
1780
1782
  </xsl:template>
1781
1783
 
1784
+ <!-- Music notation ("n", "scaledeg", "timesignature", "chord") is -->
1785
+ <!-- LaTeX built by the -common templates and set as inline math, -->
1786
+ <!-- melded with a Nemeth representation just as an "m" is. It -->
1787
+ <!-- always has structure (an accidental, an octave, a chord's -->
1788
+ <!-- figures), so it is never one of the simple cases above, and it -->
1789
+ <!-- absorbs no clause-ending punctuation, so none is restored here. -->
1790
+ <xsl:template match="n|scaledeg|timesignature|chord">
1791
+ <xsl:variable name="raw-braille">
1792
+ <xsl:call-template name="brf-symbols-filter">
1793
+ <xsl:with-param name="text" select="math-nemeth"/>
1794
+ </xsl:call-template>
1795
+ </xsl:variable>
1796
+ <math>
1797
+ <xsl:value-of select="$raw-braille"/>
1798
+ </math>
1799
+ </xsl:template>
1800
+
1782
1801
  <xsl:template match="m[contains(math-nemeth, '&#xa;')]|md">
1783
1802
  <!-- Lines are trimmed, and possibly converted to BRF ASCII -->
1784
1803
  <!-- symbols ("early"), one at a time, below -->
@@ -2338,7 +2357,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2338
2357
  <!-- xref: xref-number and xref-link defined above -->
2339
2358
  <!-- today, timeofday: pure text in common -->
2340
2359
  <!-- ad, am, bc, ca, eg, etal, etc, ie, nb, pm, ps, vs, viz: Latin abbreviations, defined as text in common -->
2341
- <!-- title, subtitle, shorttitle, plaintitle, creator: killed in common as metadata -->
2360
+ <!-- title, subtitle, shorttitle, plaintitle, creator, origins: killed in common as metadata -->
2342
2361
  <!-- caption: killed in common as metadata -->
2343
2362
  <!-- cline: a simple template in common is active -->
2344
2363
  <!-- c: a simple template in common is active -->
@@ -2433,7 +2452,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2433
2452
  self::xref or
2434
2453
  self::today or self::timeofday or
2435
2454
  self::ad or self::am or self::bc or self::ca or self::eg or self::etal or self::etc or self::ie or self::nb or self::pm or self::ps or self::vs or self::viz or
2436
- self::title or self::subtitle or self::shorttitle or self::plaintitle or self::creator or
2455
+ self::title or self::subtitle or self::shorttitle or self::plaintitle or self::creator or self::origins or
2437
2456
  self::caption or
2438
2457
  self::cline or
2439
2458
  self::c or