@pretextbook/pretext-html 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +31 -2
  2. package/assets/preview-html.xsl +16 -0
  3. package/assets/upstream.json +1 -1
  4. package/assets/xsl/README.md +25 -24
  5. package/assets/xsl/entities.ent +11 -0
  6. package/assets/xsl/extract-dynamic.xsl +54 -3
  7. package/assets/xsl/extract-gdscript.xsl +61 -0
  8. package/assets/xsl/extract-sageplot.xsl +3 -0
  9. package/assets/xsl/localizations/README.md +24 -24
  10. package/assets/xsl/localizations/it-IT.xml +37 -41
  11. package/assets/xsl/pretext-assembly.xsl +190 -30
  12. package/assets/xsl/pretext-beamer.xsl +57 -12
  13. package/assets/xsl/pretext-common.xsl +175 -30
  14. package/assets/xsl/pretext-epub.xsl +4 -6
  15. package/assets/xsl/pretext-fo.xsl +127 -67
  16. package/assets/xsl/pretext-html.xsl +350 -94
  17. package/assets/xsl/pretext-jupyter.xsl +1 -0
  18. package/assets/xsl/pretext-latex-classic.xsl +2 -2
  19. package/assets/xsl/pretext-latex-common.xsl +296 -151
  20. package/assets/xsl/pretext-latex.xsl +16 -6
  21. package/assets/xsl/pretext-numbers.xsl +10 -0
  22. package/assets/xsl/pretext-revealjs.xsl +69 -4
  23. package/assets/xsl/pretext-runestone-fitb.xsl +179 -84
  24. package/assets/xsl/pretext-runestone-static.xsl +72 -20
  25. package/assets/xsl/pretext-runestone.xsl +32 -25
  26. package/assets/xsl/pretext-text-utilities.xsl +7 -0
  27. package/assets/xsl/pretext-text.xsl +17 -0
  28. package/assets/xsl/publisher-variables.xsl +109 -111
  29. package/assets/xsl/support/play-button/README.md +1 -3
  30. package/assets/xsl/tests/README.md +1 -1
  31. package/assets/xsl/utilities/README.md +6 -8
  32. package/assets/xsl-bundle.json +1 -1
  33. package/dist/cli-BUrNZxov.js +1098 -0
  34. package/dist/cli.js +1 -1
  35. package/dist/html-static.d.ts +20 -0
  36. package/dist/index.browser.js +598 -374
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.js +35 -30
  39. package/dist/renderer.d.ts +40 -1
  40. package/dist/skeleton.d.ts +41 -0
  41. package/dist/xrefs.d.ts +54 -0
  42. package/package.json +2 -1
  43. package/dist/cli-D0m0Ha1j.js +0 -856
@@ -81,6 +81,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
81
81
  <!-- provisional cross-references show in red -->
82
82
  <xsl:param name="author.tools" select="''" />
83
83
 
84
+ <!-- The Godot engine version used for GDScript. Read both by the -->
85
+ <!-- conversion to Runestone, for the Web Assembly shell, and by the -->
86
+ <!-- "pck" extraction, which runs as a separate command. A default -->
87
+ <!-- in each would let the two silently disagree. -->
88
+ <xsl:param name="godot.version" select="'4.6.3'"/>
89
+
84
90
  <!-- ######### -->
85
91
  <!-- Variables -->
86
92
  <!-- ######### -->
@@ -2828,7 +2834,7 @@ Book (with parts), "section" at level 3
2828
2834
  <xsl:value-of select="true()"/>
2829
2835
  </xsl:template>
2830
2836
  <!-- Introductions and Conclusions -->
2831
- <xsl:template match="article/introduction|chapter/introduction|section/introduction|subsection/introduction|appendix/introduction|exercises/introduction|solutions/introduction|worksheet/introduction|handout/introduction|reading-questions/introduction|glossary/introduction|references/introduction|article/conclusion|chapter/conclusion|section/conclusion|subsection/conclusion|appendix/conclusion|exercises/conclusion|solutions/conclusion|worksheet/conclusion|handout/conclusion|reading-questions/conclusion|glossary/conclusion|references/conclusion" mode="title-wants-punctuation">
2837
+ <xsl:template match="article/introduction|chapter/introduction|section/introduction|subsection/introduction|appendix/introduction|exercises/introduction|solutions/introduction|worksheet/introduction|handout/introduction|reading-questions/introduction|article/conclusion|chapter/conclusion|section/conclusion|subsection/conclusion|appendix/conclusion|exercises/conclusion|solutions/conclusion|worksheet/conclusion|handout/conclusion|reading-questions/conclusion" mode="title-wants-punctuation">
2832
2838
  <xsl:value-of select="true()"/>
2833
2839
  </xsl:template>
2834
2840
  <xsl:template match="*" mode="title-wants-punctuation">
@@ -3201,7 +3207,7 @@ Book (with parts), "section" at level 3
3201
3207
  <xsl:text>[</xsl:text>
3202
3208
  <xsl:value-of select="$str-id" />
3203
3209
  <xsl:text>]</xsl:text>
3204
- <xsl:message>PTX:BUG: could not translate string with id "<xsl:value-of select="$str-id"/>" into language for code "<xsl:value-of select="$lang"/>"</xsl:message>
3210
+ <xsl:message>PTX:WARNING: could not translate string with id "<xsl:value-of select="$str-id"/>" into language for code "<xsl:value-of select="$lang"/>"</xsl:message>
3205
3211
  </xsl:otherwise>
3206
3212
  </xsl:choose>
3207
3213
  </xsl:template>
@@ -3217,6 +3223,19 @@ Book (with parts), "section" at level 3
3217
3223
  </xsl:apply-templates>
3218
3224
  </xsl:template>
3219
3225
 
3226
+ <!-- A bare appendix letter beside a title is ambiguous ("A Trip -->
3227
+ <!-- Abroad"), so wherever the letter and title compose on one line -->
3228
+ <!-- a period follows the letter: "A. Trip Abroad". A "solutions" -->
3229
+ <!-- division in the back matter shares the letter sequence (see -->
3230
+ <!-- "division-serial-number" in the assembly), so it is treated -->
3231
+ <!-- identically. Only the top-level letter: subdivision numbers -->
3232
+ <!-- ("A.2") are already unambiguous. Styling refinements are -->
3233
+ <!-- anticipated. -->
3234
+ <xsl:template match="*" mode="division-number-separator"/>
3235
+ <xsl:template match="appendix|backmatter/solutions" mode="division-number-separator">
3236
+ <xsl:text>.</xsl:text>
3237
+ </xsl:template>
3238
+
3220
3239
  <!-- Most PreTeXt elements have names, and their localizations, indexed -->
3221
3240
  <!-- by a "string-id" that is simply their local name. However, others -->
3222
3241
  <!-- ("exercise" is archetypical) have names that vary according to their -->
@@ -3819,7 +3838,7 @@ Book (with parts), "section" at level 3
3819
3838
  <xsl:text>has been encountered without a @label attribute. For reasons of backward-compatibility &#xa;</xsl:text>
3820
3839
  <xsl:text>we have used the value of an @xml:id. This may not be what you want, and as of 2024-02-15 &#xa;</xsl:text>
3821
3840
  <xsl:text>is no longer best practice. You can copy the @xml:id value exactly into a new @label &#xa;</xsl:text>
3822
- <xsl:text>attribute and this warning will stop AND your project's entries in any Runestone database &#xa;</xsl:text>
3841
+ <xsl:text>attribute and this message will stop AND your project's entries in any Runestone database &#xa;</xsl:text>
3823
3842
  <xsl:text>will be preserved and function exactly as before.&#xa;</xsl:text>
3824
3843
  <xsl:text>[You may get more than one message about this instance.]&#xa;</xsl:text>
3825
3844
  </xsl:message>
@@ -5601,6 +5620,22 @@ Book (with parts), "section" at level 3
5601
5620
  <!-- the element from this template would be useful. -->
5602
5621
  <xsl:template match="*" mode="dry-run"/>
5603
5622
 
5623
+ <!-- A PROJECT-LIKE which is *not* already inside a printout, but which -->
5624
+ <!-- requests workspace, is a printout in its own right: it is meant to be -->
5625
+ <!-- worked on paper, so each conversion gives it the treatment it gives -->
5626
+ <!-- a worksheet. In HTML that is a print preview icon, page margins, and -->
5627
+ <!-- workspace divs the preview javascript expands to fill pages; in -->
5628
+ <!-- LaTeX it is a page of its own, with the worksheet margins. Inside a -->
5629
+ <!-- worksheet or handout there is nothing to do, since the enclosing -->
5630
+ <!-- printout already provides all of this. -->
5631
+ <xsl:template match="*" mode="is-standalone-printout">
5632
+ <xsl:value-of select="false()"/>
5633
+ </xsl:template>
5634
+
5635
+ <xsl:template match="&PROJECT-LIKE;" mode="is-standalone-printout">
5636
+ <xsl:value-of select="boolean(not(ancestor::worksheet|ancestor::handout) and (@workspace|.//@workspace))"/>
5637
+ </xsl:template>
5638
+
5604
5639
  <!-- This template is called for items in a printout that can have a -->
5605
5640
  <!-- workspace specified. It is important that this sometimes returns -->
5606
5641
  <!-- an empty string, since that is a signal to not construct some -->
@@ -5613,7 +5648,7 @@ Book (with parts), "section" at level 3
5613
5648
  <!-- NB: a blank workspace is used as a signal in "divisionexercise" -->
5614
5649
  <!-- in LaTeX conversion, via parameter #3 of the environment -->
5615
5650
 
5616
- <xsl:if test="(ancestor::worksheet or ancestor::handout) and not(child::task)">
5651
+ <xsl:if test="(ancestor::worksheet or ancestor::handout or ancestor-or-self::*[&PROJECT-FILTER;]) and not(child::task)">
5617
5652
  <!-- First element with @workspace, confined to the printout -->
5618
5653
  <!-- Could be empty node-set, which will be empty string later -->
5619
5654
  <xsl:variable name="raw-workspace">
@@ -6417,7 +6452,8 @@ Book (with parts), "section" at level 3
6417
6452
  <!-- Printout Margins -->
6418
6453
  <!-- ################ -->
6419
6454
 
6420
- <xsl:template match="&PRINTOUT;" mode="printout-margin">
6455
+ <!-- PROJECT-LIKE is here for standalone printout previews. -->
6456
+ <xsl:template match="&PRINTOUT;|&PROJECT-LIKE;" mode="printout-margin">
6421
6457
  <xsl:param name="author-side"/>
6422
6458
  <xsl:param name="publisher-side"/>
6423
6459
  <xsl:choose>
@@ -6467,7 +6503,7 @@ Book (with parts), "section" at level 3
6467
6503
  <xsl:if test="@primary='no' or @secondary='yes'">
6468
6504
  <xsl:text>Secondary </xsl:text>
6469
6505
  </xsl:if>
6470
- <xsl:value-of select="."/>
6506
+ <xsl:value-of select="normalize-space(.)"/>
6471
6507
  <xsl:choose>
6472
6508
  <xsl:when test="following-sibling::keyword[1][@primary='no' or @secondary='yes']">
6473
6509
  <xsl:text>; </xsl:text>
@@ -7370,6 +7406,8 @@ Book (with parts), "section" at level 3
7370
7406
  <language name="basic" active="" listings="Basic" prism="basic"/>
7371
7407
  <language name="c" active="c" listings="C" prism="c"/>
7372
7408
  <language name="cpp" active="cpp" listings="C++" prism="cpp"/>
7409
+ <!-- using Python as a closest match for now in listings. -->
7410
+ <language name="gdscript" active="gdscript" listings="Python" prism="gdscript"/>
7373
7411
  <language name="go" active="" listings="C" prism="go"/>
7374
7412
  <language name="java" active="java" listings="Java" prism="java"/>
7375
7413
  <language name="javascript" active="javascript" listings="" prism="javascript"/>
@@ -7444,6 +7482,35 @@ Book (with parts), "section" at level 3
7444
7482
  </xsl:if>
7445
7483
  </xsl:variable>
7446
7484
 
7485
+ <!-- The content of a "slide" of a "slideshow" may be placed at -->
7486
+ <!-- the top, middle, or bottom of the slide. A document-wide -->
7487
+ <!-- default comes from "docinfo/defaults/slides/@valign"; absent -->
7488
+ <!-- an expressed preference, content is placed at the top. -->
7489
+ <xsl:variable name="slides-valign-default">
7490
+ <xsl:choose>
7491
+ <xsl:when test="$docinfo/defaults/slides/@valign">
7492
+ <xsl:value-of select="$docinfo/defaults/slides/@valign"/>
7493
+ </xsl:when>
7494
+ <xsl:otherwise>
7495
+ <xsl:text>top</xsl:text>
7496
+ </xsl:otherwise>
7497
+ </xsl:choose>
7498
+ </xsl:variable>
7499
+
7500
+ <!-- A "slide" may override the document-wide default with its -->
7501
+ <!-- own "@valign"; the conversions consult this modal template -->
7502
+ <!-- for the effective vertical alignment of a slide's content. -->
7503
+ <xsl:template match="slide" mode="valign">
7504
+ <xsl:choose>
7505
+ <xsl:when test="@valign">
7506
+ <xsl:value-of select="@valign"/>
7507
+ </xsl:when>
7508
+ <xsl:otherwise>
7509
+ <xsl:value-of select="$slides-valign-default"/>
7510
+ </xsl:otherwise>
7511
+ </xsl:choose>
7512
+ </xsl:template>
7513
+
7447
7514
  <!-- Determine programming language to use. First choice is @language -->
7448
7515
  <!-- on current element. If that is not available, check docinfo default. -->
7449
7516
  <!-- "exercise" might be a Runestone interactive (programming) exercise. -->
@@ -9001,18 +9068,32 @@ Book (with parts), "section" at level 3
9001
9068
  <!-- content override of type-prefix -->
9002
9069
  <xsl:when test="$b-has-content">
9003
9070
  <xsl:copy-of select="$custom-text" />
9004
- <xsl:apply-templates select="." mode="xref-text-separator"/>
9005
- <xsl:apply-templates select="$target" mode="xref-number">
9006
- <xsl:with-param name="xref" select="." />
9007
- </xsl:apply-templates>
9071
+ <xsl:variable name="the-number">
9072
+ <xsl:apply-templates select="$target" mode="xref-number">
9073
+ <xsl:with-param name="xref" select="." />
9074
+ </xsl:apply-templates>
9075
+ </xsl:variable>
9076
+ <!-- an unnumbered target ("paragraphs", squelched -->
9077
+ <!-- numbering) contributes no separator, either -->
9078
+ <xsl:if test="not($the-number = '')">
9079
+ <xsl:apply-templates select="." mode="xref-text-separator"/>
9080
+ </xsl:if>
9081
+ <xsl:copy-of select="$the-number"/>
9008
9082
  </xsl:when>
9009
9083
  <!-- usual, default case -->
9010
9084
  <xsl:otherwise>
9011
9085
  <xsl:apply-templates select="$target" mode="type-name" />
9012
- <xsl:apply-templates select="." mode="xref-text-separator"/>
9013
- <xsl:apply-templates select="$target" mode="xref-number">
9014
- <xsl:with-param name="xref" select="." />
9015
- </xsl:apply-templates>
9086
+ <xsl:variable name="the-number">
9087
+ <xsl:apply-templates select="$target" mode="xref-number">
9088
+ <xsl:with-param name="xref" select="." />
9089
+ </xsl:apply-templates>
9090
+ </xsl:variable>
9091
+ <!-- an unnumbered target ("paragraphs", squelched -->
9092
+ <!-- numbering) contributes no separator, either -->
9093
+ <xsl:if test="not($the-number = '')">
9094
+ <xsl:apply-templates select="." mode="xref-text-separator"/>
9095
+ </xsl:if>
9096
+ <xsl:copy-of select="$the-number"/>
9016
9097
  </xsl:otherwise>
9017
9098
  </xsl:choose>
9018
9099
  </xsl:when>
@@ -9021,14 +9102,50 @@ Book (with parts), "section" at level 3
9021
9102
  <!-- content override of type-prefix -->
9022
9103
  <xsl:when test="$b-has-content">
9023
9104
  <xsl:copy-of select="$custom-text" />
9024
- <xsl:apply-templates select="." mode="xref-text-separator"/>
9025
- <xsl:apply-templates select="$target" mode="serial-number" />
9105
+ <xsl:variable name="the-number">
9106
+ <xsl:apply-templates select="$target" mode="serial-number" />
9107
+ </xsl:variable>
9108
+ <!-- an unnumbered target ("paragraphs", squelched -->
9109
+ <!-- numbering) contributes no separator, either -->
9110
+ <xsl:if test="not($the-number = '')">
9111
+ <xsl:apply-templates select="." mode="xref-text-separator"/>
9112
+ </xsl:if>
9113
+ <!-- a task's local serial reads as its rendered -->
9114
+ <!-- label: "Task (a)", not "Task a" -->
9115
+ <xsl:choose>
9116
+ <xsl:when test="$target/self::task">
9117
+ <xsl:text>(</xsl:text>
9118
+ <xsl:copy-of select="$the-number"/>
9119
+ <xsl:text>)</xsl:text>
9120
+ </xsl:when>
9121
+ <xsl:otherwise>
9122
+ <xsl:copy-of select="$the-number"/>
9123
+ </xsl:otherwise>
9124
+ </xsl:choose>
9026
9125
  </xsl:when>
9027
9126
  <!-- usual, default case -->
9028
9127
  <xsl:otherwise>
9029
9128
  <xsl:apply-templates select="$target" mode="type-name" />
9030
- <xsl:apply-templates select="." mode="xref-text-separator"/>
9031
- <xsl:apply-templates select="$target" mode="serial-number" />
9129
+ <xsl:variable name="the-number">
9130
+ <xsl:apply-templates select="$target" mode="serial-number" />
9131
+ </xsl:variable>
9132
+ <!-- an unnumbered target ("paragraphs", squelched -->
9133
+ <!-- numbering) contributes no separator, either -->
9134
+ <xsl:if test="not($the-number = '')">
9135
+ <xsl:apply-templates select="." mode="xref-text-separator"/>
9136
+ </xsl:if>
9137
+ <!-- a task's local serial reads as its rendered -->
9138
+ <!-- label: "Task (a)", not "Task a" -->
9139
+ <xsl:choose>
9140
+ <xsl:when test="$target/self::task">
9141
+ <xsl:text>(</xsl:text>
9142
+ <xsl:copy-of select="$the-number"/>
9143
+ <xsl:text>)</xsl:text>
9144
+ </xsl:when>
9145
+ <xsl:otherwise>
9146
+ <xsl:copy-of select="$the-number"/>
9147
+ </xsl:otherwise>
9148
+ </xsl:choose>
9032
9149
  </xsl:otherwise>
9033
9150
  </xsl:choose>
9034
9151
  </xsl:when>
@@ -9043,19 +9160,26 @@ Book (with parts), "section" at level 3
9043
9160
  <xsl:apply-templates select="$target" mode="type-name" />
9044
9161
  </xsl:otherwise>
9045
9162
  </xsl:choose>
9046
- <xsl:apply-templates select="." mode="xref-text-separator"/>
9047
9163
  <!-- only difference in behavior is global/local number -->
9048
- <xsl:choose>
9049
- <xsl:when test="$text-style = 'type-global-title'">
9050
- <xsl:apply-templates select="$target" mode="xref-number">
9051
- <xsl:with-param name="xref" select="." />
9052
- </xsl:apply-templates>
9053
- </xsl:when>
9054
- <xsl:when test="$text-style = 'type-local-title'">
9055
- <xsl:apply-templates select="$target" mode="serial-number"/>
9056
- </xsl:when>
9057
- <xsl:otherwise/>
9058
- </xsl:choose>
9164
+ <xsl:variable name="the-number">
9165
+ <xsl:choose>
9166
+ <xsl:when test="$text-style = 'type-global-title'">
9167
+ <xsl:apply-templates select="$target" mode="xref-number">
9168
+ <xsl:with-param name="xref" select="." />
9169
+ </xsl:apply-templates>
9170
+ </xsl:when>
9171
+ <xsl:when test="$text-style = 'type-local-title'">
9172
+ <xsl:apply-templates select="$target" mode="serial-number"/>
9173
+ </xsl:when>
9174
+ <xsl:otherwise/>
9175
+ </xsl:choose>
9176
+ </xsl:variable>
9177
+ <!-- an unnumbered target ("paragraphs", squelched -->
9178
+ <!-- numbering) contributes no separator, either -->
9179
+ <xsl:if test="not($the-number = '')">
9180
+ <xsl:apply-templates select="." mode="xref-text-separator"/>
9181
+ </xsl:if>
9182
+ <xsl:copy-of select="$the-number"/>
9059
9183
  <xsl:variable name="the-title">
9060
9184
  <xsl:apply-templates select="$target" mode="title-xref"/>
9061
9185
  </xsl:variable>
@@ -11885,6 +12009,27 @@ http://andrewmccarthy.ie/2014/11/06/swung-dash-in-latex/
11885
12009
  <xsl:with-param name="message" select="'the document-wide style of cross-reference text is now a &quot;text&quot; attribute on an &quot;xrefs&quot; element within &quot;docinfo/defaults&quot;, replacing the &quot;cross-references&quot; element. We will honor your intent, but please convert to the new form.'"/>
11886
12010
  </xsl:call-template>
11887
12011
  <!-- -->
12012
+ <!-- 2026-07-31 a footnote within a "tabular" cell becomes a "tn" table note -->
12013
+ <xsl:call-template name="deprecation-message">
12014
+ <xsl:with-param name="occurrences" select="&quot;$document-root//tabular//fn&quot;" />
12015
+ <xsl:with-param name="date-string" select="'2026-07-31'" />
12016
+ <xsl:with-param name="message" select="'a footnote (&quot;fn&quot;) within a &quot;tabular&quot; cell is now a table note, the &quot;tn&quot; element, lettered and placed at the bottom of the table. We will honor your intent, but please convert to &quot;tn&quot;. Note that a table note is not part of the numbering of true footnotes, and is not a target for a cross-reference.'"/>
12017
+ </xsl:call-template>
12018
+ <!-- -->
12019
+ <!-- 2026-08-06 references "introduction" is now a "headnote" -->
12020
+ <xsl:call-template name="deprecation-message">
12021
+ <xsl:with-param name="occurrences" select="&quot;$document-root//references/introduction&quot;" />
12022
+ <xsl:with-param name="date-string" select="'2026-08-06'" />
12023
+ <xsl:with-param name="message" select="'a &quot;references&quot; &quot;introduction&quot; is now a &quot;headnote&quot;. We will attempt to fix your source, but a &quot;title&quot; on such an &quot;introduction&quot; is discarded entirely: its text will not appear in any output. Please convert to a &quot;headnote&quot; yourself'"/>
12024
+ </xsl:call-template>
12025
+ <!-- -->
12026
+ <!-- 2026-08-06 references "conclusion" is obsolete -->
12027
+ <xsl:call-template name="deprecation-message">
12028
+ <xsl:with-param name="occurrences" select="&quot;$document-root//references/conclusion&quot;" />
12029
+ <xsl:with-param name="date-string" select="'2026-08-06'" />
12030
+ <xsl:with-param name="message" select="'a &quot;references&quot; division no longer has a &quot;conclusion&quot;. The element is discarded entirely: its content will not appear in any output. Please relocate the content, perhaps following the &quot;references&quot;'"/>
12031
+ </xsl:call-template>
12032
+ <!-- -->
11888
12033
  </xsl:template>
11889
12034
 
11890
12035
  <!-- Miscellaneous -->
@@ -179,7 +179,10 @@
179
179
  <!-- template in the entry template here, so these pages are not built (good). -->
180
180
  <!-- But we do get little buttons to elect a printable version. We have to kill -->
181
181
  <!-- those buttons, since EPUB wants to go looking for the printable-version files. -->
182
- <xsl:template match="&PRINTOUT;" mode="standalone-printout-links"/>
182
+ <!-- PROJECT-LIKE is here for the same reason: a project with workspace -->
183
+ <!-- outside a printout earns a print preview button in HTML, which is -->
184
+ <!-- meaningless in EPUB. -->
185
+ <xsl:template match="&PRINTOUT;|&PROJECT-LIKE;" mode="standalone-printout-links"/>
183
186
 
184
187
 
185
188
  <!-- ############## -->
@@ -1400,11 +1403,6 @@
1400
1403
  </xsl:template>
1401
1404
 
1402
1405
  <!-- Footnotes -->
1403
- <!-- First disable the "footnote" popping routine used to -->
1404
- <!-- move the content out of HTML structures where it is -->
1405
- <!-- not welcome (e.g a "p" inside a "p"). -->
1406
- <xsl:template match="*" mode="pop-footnote-text"/>
1407
-
1408
1406
  <!-- Drop a marker as a superscript -->
1409
1407
  <xsl:template match="fn">
1410
1408
  <xsl:variable name="hid">
@@ -430,6 +430,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
430
430
  </xsl:variable>
431
431
  <xsl:if test="not($the-number = '')">
432
432
  <xsl:value-of select="$the-number"/>
433
+ <xsl:apply-templates select="." mode="division-number-separator"/>
433
434
  <xsl:text> </xsl:text>
434
435
  </xsl:if>
435
436
  <xsl:variable name="the-title">
@@ -498,11 +499,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
498
499
  </xsl:template>
499
500
 
500
501
  <xsl:template match="affiliation">
501
- <xsl:apply-templates select="department|institution|location"/>
502
+ <xsl:apply-templates select="position|department|institution|location"/>
502
503
  </xsl:template>
503
504
 
504
505
  <!-- each is a line, or authored "line"s, of the address block -->
505
- <xsl:template match="department|institution|location">
506
+ <xsl:template match="position|department|institution|location">
506
507
  <xsl:choose>
507
508
  <xsl:when test="line">
508
509
  <xsl:apply-templates select="line"/>
@@ -731,6 +732,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
731
732
  <xsl:apply-templates select="." mode="link-id-attribute"/>
732
733
  <xsl:if test="not($the-number = '')">
733
734
  <xsl:value-of select="$the-number"/>
735
+ <xsl:apply-templates select="." mode="division-number-separator"/>
734
736
  <xsl:text> </xsl:text>
735
737
  </xsl:if>
736
738
  <xsl:apply-templates select="." mode="title-full"/>
@@ -1431,24 +1433,32 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1431
1433
  <xsl:apply-templates select="." mode="exercise-heading"/>
1432
1434
  <xsl:text> </xsl:text>
1433
1435
  </xsl:variable>
1436
+ <!-- The component switches must pass as genuine booleans: a -->
1437
+ <!-- with-param carrying *content* is a result tree fragment, -->
1438
+ <!-- and any fragment, even one whose text is "false", is true -->
1439
+ <!-- in the boolean tests downstream. So: compute the strings, -->
1440
+ <!-- pass comparisons. -->
1441
+ <xsl:variable name="has-hint">
1442
+ <xsl:apply-templates select="." mode="b-main-text-component">
1443
+ <xsl:with-param name="component" select="'hint'"/>
1444
+ </xsl:apply-templates>
1445
+ </xsl:variable>
1446
+ <xsl:variable name="has-answer">
1447
+ <xsl:apply-templates select="." mode="b-main-text-component">
1448
+ <xsl:with-param name="component" select="'answer'"/>
1449
+ </xsl:apply-templates>
1450
+ </xsl:variable>
1451
+ <xsl:variable name="has-solution">
1452
+ <xsl:apply-templates select="." mode="b-main-text-component">
1453
+ <xsl:with-param name="component" select="'solution'"/>
1454
+ </xsl:apply-templates>
1455
+ </xsl:variable>
1434
1456
  <xsl:apply-templates select="." mode="exercise-components">
1435
1457
  <xsl:with-param name="b-original" select="true()"/>
1436
1458
  <xsl:with-param name="b-has-statement" select="true()"/>
1437
- <xsl:with-param name="b-has-hint">
1438
- <xsl:apply-templates select="." mode="b-main-text-component">
1439
- <xsl:with-param name="component" select="'hint'"/>
1440
- </xsl:apply-templates>
1441
- </xsl:with-param>
1442
- <xsl:with-param name="b-has-answer">
1443
- <xsl:apply-templates select="." mode="b-main-text-component">
1444
- <xsl:with-param name="component" select="'answer'"/>
1445
- </xsl:apply-templates>
1446
- </xsl:with-param>
1447
- <xsl:with-param name="b-has-solution">
1448
- <xsl:apply-templates select="." mode="b-main-text-component">
1449
- <xsl:with-param name="component" select="'solution'"/>
1450
- </xsl:apply-templates>
1451
- </xsl:with-param>
1459
+ <xsl:with-param name="b-has-hint" select="$has-hint = 'true'"/>
1460
+ <xsl:with-param name="b-has-answer" select="$has-answer = 'true'"/>
1461
+ <xsl:with-param name="b-has-solution" select="$has-solution = 'true'"/>
1452
1462
  <xsl:with-param name="run-in-heading" select="$heading"/>
1453
1463
  </xsl:apply-templates>
1454
1464
  <!-- writing space below, in a printout, when requested -->
@@ -2205,25 +2215,23 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2205
2215
  <!-- "sageplot" has no useful print representation yet.) -->
2206
2216
  <xsl:template match="image[latex-image]|image[sageplot]|image[asymptote]|image[pf:prefigure]|image[mermaid]" mode="image-filename">
2207
2217
  <xsl:value-of select="$generated-directory"/>
2208
- <xsl:if test="$b-managed-directories">
2209
- <xsl:choose>
2210
- <xsl:when test="latex-image">
2211
- <xsl:text>latex-image/</xsl:text>
2212
- </xsl:when>
2213
- <xsl:when test="sageplot">
2214
- <xsl:text>sageplot/</xsl:text>
2215
- </xsl:when>
2216
- <xsl:when test="asymptote">
2217
- <xsl:text>asymptote/</xsl:text>
2218
- </xsl:when>
2219
- <xsl:when test="pf:prefigure">
2220
- <xsl:text>prefigure/</xsl:text>
2221
- </xsl:when>
2222
- <xsl:when test="mermaid">
2223
- <xsl:text>mermaid/</xsl:text>
2224
- </xsl:when>
2225
- </xsl:choose>
2226
- </xsl:if>
2218
+ <xsl:choose>
2219
+ <xsl:when test="latex-image">
2220
+ <xsl:text>latex-image/</xsl:text>
2221
+ </xsl:when>
2222
+ <xsl:when test="sageplot">
2223
+ <xsl:text>sageplot/</xsl:text>
2224
+ </xsl:when>
2225
+ <xsl:when test="asymptote">
2226
+ <xsl:text>asymptote/</xsl:text>
2227
+ </xsl:when>
2228
+ <xsl:when test="pf:prefigure">
2229
+ <xsl:text>prefigure/</xsl:text>
2230
+ </xsl:when>
2231
+ <xsl:when test="mermaid">
2232
+ <xsl:text>mermaid/</xsl:text>
2233
+ </xsl:when>
2234
+ </xsl:choose>
2227
2235
  <xsl:apply-templates select="latex-image|sageplot|asymptote|pf:prefigure|mermaid" mode="image-source-basename"/>
2228
2236
  <xsl:choose>
2229
2237
  <xsl:when test="pf:prefigure">
@@ -2348,6 +2356,19 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2348
2356
  <xsl:apply-templates select="row[not(@header = 'yes') and not(@header = 'vertical')]"/>
2349
2357
  </fo:table-body>
2350
2358
  </fo:table>
2359
+ <!-- Table notes ("tn") collect just below the table, lettered in -->
2360
+ <!-- reading order, which is document order of the marks (Notes -->
2361
+ <!-- to tables: CMoS 18th ed., 3.77-3.81; specific notes at -->
2362
+ <!-- 3.80). Disjoint from true footnote numbering. -->
2363
+ <xsl:for-each select=".//tn">
2364
+ <fo:block font-size="80%" text-align="{$text-alignment}" text-align-last="start" space-before="0.25em">
2365
+ <fo:inline baseline-shift="35%" font-size="70%" font-style="italic">
2366
+ <xsl:apply-templates select="." mode="number"/>
2367
+ </fo:inline>
2368
+ <xsl:text> </xsl:text>
2369
+ <xsl:apply-templates/>
2370
+ </fo:block>
2371
+ </xsl:for-each>
2351
2372
  </xsl:template>
2352
2373
 
2353
2374
  <!-- An estimated width, in points, for each of a tabular's columns, -->
@@ -2457,6 +2478,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2457
2478
 
2458
2479
  <xsl:template match="fn" mode="width-text"/>
2459
2480
 
2481
+ <!-- A table note's text sets below the table, so a cell is only -->
2482
+ <!-- as wide as its mark: one superscript letter, roughly one -->
2483
+ <!-- character. -->
2484
+ <xsl:template match="tn" mode="width-text">
2485
+ <xsl:text>a</xsl:text>
2486
+ </xsl:template>
2487
+
2460
2488
  <!-- A cross-reference's displayed text is generated, never in -->
2461
2489
  <!-- the source, so render it via the shared "xref-text" (driven -->
2462
2490
  <!-- by the resolved text style) rather than measure an empty -->
@@ -3181,42 +3209,65 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3181
3209
  <!-- Figures and Caption -->
3182
3210
  <!-- ################### -->
3183
3211
 
3184
- <!-- The FIGURE-LIKE blocks (a captioned "figure"; and "table", -->
3185
- <!-- "listing", "list", each titled) wrap their contents and -->
3186
- <!-- finish with a caption: a body-aligned paragraph led by a -->
3187
- <!-- bold run-in heading (the type name and number), so a long -->
3188
- <!-- caption sets as ordinary prose, not centered ragged lines. -->
3189
- <!-- All share one counter. The "caption" element is consumed -->
3190
- <!-- here, so it is killed in the default mode, with the rest -->
3191
- <!-- of the metadata. -->
3212
+ <!-- The FIGURE-LIKE blocks: a "figure" wraps its contents and -->
3213
+ <!-- finishes with its caption below, while the titled blocks -->
3214
+ <!-- ("table", "listing", "list") lead with their title above, -->
3215
+ <!-- as the other conversions do. Either way the heading is a -->
3216
+ <!-- body-aligned paragraph led by a bold run-in (the type name -->
3217
+ <!-- and number), so a long caption or title sets as ordinary -->
3218
+ <!-- prose, not centered ragged lines. All share one counter. -->
3219
+ <!-- The "caption" element is consumed here, so it is killed in -->
3220
+ <!-- the default mode, with the rest of the metadata. -->
3192
3221
  <xsl:template match="&FIGURE-LIKE;">
3193
3222
  <xsl:apply-templates select="." mode="forced-pagebreak"/>
3194
3223
  <fo:block space-before="1em" space-after="1em">
3195
3224
  <xsl:apply-templates select="." mode="link-id-attribute"/>
3225
+ <xsl:if test="not(self::figure)">
3226
+ <xsl:apply-templates select="." mode="figure-like-heading"/>
3227
+ </xsl:if>
3196
3228
  <xsl:apply-templates select="*"/>
3197
- <fo:block text-align="{$text-alignment}" space-before="0.5em" keep-with-previous.within-page="always">
3198
- <fo:inline font-weight="bold">
3199
- <xsl:apply-templates select="." mode="type-name"/>
3200
- <xsl:variable name="the-number">
3201
- <xsl:apply-templates select="." mode="number"/>
3202
- </xsl:variable>
3203
- <xsl:if test="not($the-number = '')">
3204
- <xsl:text> </xsl:text>
3205
- <xsl:value-of select="$the-number"/>
3206
- </xsl:if>
3207
- <xsl:text>.</xsl:text>
3208
- </fo:inline>
3209
- <xsl:text> </xsl:text>
3210
- <xsl:choose>
3211
- <xsl:when test="self::figure">
3212
- <xsl:apply-templates select="caption/node()"/>
3213
- </xsl:when>
3214
- <!-- "table", "listing", "list" are titled -->
3215
- <xsl:otherwise>
3216
- <xsl:apply-templates select="." mode="title-full"/>
3217
- </xsl:otherwise>
3218
- </xsl:choose>
3219
- </fo:block>
3229
+ <xsl:if test="self::figure">
3230
+ <xsl:apply-templates select="." mode="figure-like-heading"/>
3231
+ </xsl:if>
3232
+ </fo:block>
3233
+ </xsl:template>
3234
+
3235
+ <!-- The caption of a "figure" (set below, held to its content), or -->
3236
+ <!-- the title of a "table"/"listing"/"list" (set above, held to -->
3237
+ <!-- its content). -->
3238
+ <xsl:template match="&FIGURE-LIKE;" mode="figure-like-heading">
3239
+ <fo:block text-align="{$text-alignment}">
3240
+ <xsl:choose>
3241
+ <xsl:when test="self::figure">
3242
+ <xsl:attribute name="space-before">0.5em</xsl:attribute>
3243
+ <xsl:attribute name="keep-with-previous.within-page">always</xsl:attribute>
3244
+ </xsl:when>
3245
+ <xsl:otherwise>
3246
+ <xsl:attribute name="space-after">0.5em</xsl:attribute>
3247
+ <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
3248
+ </xsl:otherwise>
3249
+ </xsl:choose>
3250
+ <fo:inline font-weight="bold">
3251
+ <xsl:apply-templates select="." mode="type-name"/>
3252
+ <xsl:variable name="the-number">
3253
+ <xsl:apply-templates select="." mode="number"/>
3254
+ </xsl:variable>
3255
+ <xsl:if test="not($the-number = '')">
3256
+ <xsl:text> </xsl:text>
3257
+ <xsl:value-of select="$the-number"/>
3258
+ </xsl:if>
3259
+ <xsl:text>.</xsl:text>
3260
+ </fo:inline>
3261
+ <xsl:text> </xsl:text>
3262
+ <xsl:choose>
3263
+ <xsl:when test="self::figure">
3264
+ <xsl:apply-templates select="caption/node()"/>
3265
+ </xsl:when>
3266
+ <!-- "table", "listing", "list" are titled -->
3267
+ <xsl:otherwise>
3268
+ <xsl:apply-templates select="." mode="title-full"/>
3269
+ </xsl:otherwise>
3270
+ </xsl:choose>
3220
3271
  </fo:block>
3221
3272
  </xsl:template>
3222
3273
 
@@ -3626,6 +3677,15 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3626
3677
  <!-- text, and the body, marked again, collected at the bottom of -->
3627
3678
  <!-- the page above the separator rule defined in the entry -->
3628
3679
  <!-- template. The footnote number is the serial machinery's. -->
3680
+ <!-- A table note ("tn") drops only its superscript letter mark at -->
3681
+ <!-- the cell location; the note text collects below the table, in -->
3682
+ <!-- the "tabular" template. No footnote machinery is involved. -->
3683
+ <xsl:template match="tabular//tn">
3684
+ <fo:inline baseline-shift="35%" font-size="70%" font-style="italic">
3685
+ <xsl:apply-templates select="." mode="number"/>
3686
+ </fo:inline>
3687
+ </xsl:template>
3688
+
3629
3689
  <xsl:template match="fn">
3630
3690
  <xsl:variable name="the-mark">
3631
3691
  <xsl:apply-templates select="." mode="serial-number"/>