@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
@@ -2230,8 +2230,9 @@ Book (with parts), "section" at level 3
2230
2230
  <!-- of its own, since there is no enclosing "figure" -->
2231
2231
  <!-- -->
2232
2232
  <!-- "subnumber" - a panel of a side-by-side, which in turn is a -->
2233
- <!-- child/descendant of a "figure" (a "sbsgroup" may intervene). -->
2234
- <!-- This triggers a block number foor the exterior "figure" and -->
2233
+ <!-- child/descendant of a "figure" (a "sbsgroup" may intervene), -->
2234
+ <!-- or a "figure" in a "stack" that is the content of a "figure". -->
2235
+ <!-- This triggers a block number for the exterior "figure" and -->
2235
2236
  <!-- a subnumber for the interior FIGURE-LIKE. -->
2236
2237
  <!-- -->
2237
2238
  <!-- (These code comments are referenced in the LaTeX conversion.) -->
@@ -2242,6 +2243,9 @@ Book (with parts), "section" at level 3
2242
2243
  <xsl:when test="parent::sidebyside and ancestor::figure">
2243
2244
  <xsl:text>subnumber</xsl:text>
2244
2245
  </xsl:when>
2246
+ <xsl:when test="self::figure and parent::stack/parent::figure">
2247
+ <xsl:text>subnumber</xsl:text>
2248
+ </xsl:when>
2245
2249
  <xsl:when test="parent::sidebyside">
2246
2250
  <xsl:text>panel</xsl:text>
2247
2251
  </xsl:when>
@@ -2522,16 +2526,17 @@ Book (with parts), "section" at level 3
2522
2526
  <!-- the localization routines. -->
2523
2527
 
2524
2528
 
2525
- <!-- With modal templates below, the default template does nothing -->
2526
- <!-- We include the "creator" element of a theorem/axiom as metadata -->
2527
- <!-- NB: since these elements get killed on-sight, when we actually -->
2528
- <!-- want to process them we need to use a "select" attribute -->
2529
- <!-- similar to title/*|title/text() or title/node(). -->
2529
+ <!-- With modal templates below, the default template does nothing -->
2530
+ <!-- The "creator" and "origins" of a mathematical block are metadata -->
2531
+ <!-- NB: since these elements get killed on-sight, when we actually -->
2532
+ <!-- want to process them we need to use a "select" attribute -->
2533
+ <!-- similar to title/*|title/text() or title/node(). -->
2530
2534
  <xsl:template match="title" />
2531
2535
  <xsl:template match="subtitle" />
2532
2536
  <xsl:template match="shorttitle"/>
2533
2537
  <xsl:template match="plaintitle"/>
2534
2538
  <xsl:template match="creator" />
2539
+ <xsl:template match="origins"/>
2535
2540
 
2536
2541
  <!-- Some items have default titles that make sense -->
2537
2542
  <!-- Typically these are one-off subdivisions (eg preface), -->
@@ -2742,6 +2747,10 @@ Book (with parts), "section" at level 3
2742
2747
  <xsl:when test="plaintitle">
2743
2748
  <xsl:apply-templates select="plaintitle/text()"/>
2744
2749
  </xsl:when>
2750
+ <!-- only the lines, not the whitespace between them -->
2751
+ <xsl:when test="title/line">
2752
+ <xsl:apply-templates select="title/line" mode="plain-title-edit"/>
2753
+ </xsl:when>
2745
2754
  <xsl:when test="title">
2746
2755
  <xsl:apply-templates select="title/node()[not(self::fn)]" mode="plain-title-edit"/>
2747
2756
  </xsl:when>
@@ -2756,8 +2765,24 @@ Book (with parts), "section" at level 3
2756
2765
 
2757
2766
  <!-- Plain subtitle: used for HTML <meta> tags -->
2758
2767
  <xsl:template match="*" mode="subtitle-plain">
2759
- <xsl:if test="subtitle">
2760
- <xsl:apply-templates select="subtitle/node()[not(self::fn)]" mode="plain-title-edit"/>
2768
+ <xsl:choose>
2769
+ <!-- only the lines, not the whitespace between them -->
2770
+ <xsl:when test="subtitle/line">
2771
+ <xsl:apply-templates select="subtitle/line" mode="plain-title-edit"/>
2772
+ </xsl:when>
2773
+ <xsl:when test="subtitle">
2774
+ <xsl:apply-templates select="subtitle/node()[not(self::fn)]" mode="plain-title-edit"/>
2775
+ </xsl:when>
2776
+ </xsl:choose>
2777
+ </xsl:template>
2778
+
2779
+ <!-- The lines of a structured title (or subtitle) run together -->
2780
+ <!-- in a plain version, separated by a space, as they are in -->
2781
+ <!-- the "title-simple" template -->
2782
+ <xsl:template match="title/line|subtitle/line" mode="plain-title-edit">
2783
+ <xsl:apply-templates select="node()[not(self::fn)]" mode="plain-title-edit"/>
2784
+ <xsl:if test="following-sibling::line">
2785
+ <xsl:text> </xsl:text>
2761
2786
  </xsl:if>
2762
2787
  </xsl:template>
2763
2788
 
@@ -2822,7 +2847,7 @@ Book (with parts), "section" at level 3
2822
2847
  <!-- pieces simply so it is more readable. -->
2823
2848
  <!-- -->
2824
2849
  <!-- Blocks -->
2825
- <xsl:template match="&THEOREM-LIKE;|&PROOF-LIKE;|&AXIOM-LIKE;|&DEFINITION-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&ASIDE-LIKE;|exercise|assemblage" mode="title-wants-punctuation">
2850
+ <xsl:template match="&THEOREM-LIKE;|&PROOF-LIKE;|&AXIOM-LIKE;|&DEFINITION-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&OPENPROBLEM-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&ASIDE-LIKE;|exercise|assemblage" mode="title-wants-punctuation">
2826
2851
  <xsl:value-of select="true()"/>
2827
2852
  </xsl:template>
2828
2853
  <!-- Miscellaneous -->
@@ -2841,11 +2866,36 @@ Book (with parts), "section" at level 3
2841
2866
  <xsl:value-of select="false()"/>
2842
2867
  </xsl:template>
2843
2868
 
2844
- <xsl:template match="&THEOREM-LIKE;|&AXIOM-LIKE;" mode="creator-full">
2869
+ <!-- The attribution of a mathematical block: the "creator" (a name, -->
2870
+ <!-- as short text) and the "origins" (cross-references, typically to -->
2871
+ <!-- bibliography entries). Each conversion places the whole group -->
2872
+ <!-- after the title, in parentheses, so the pieces here carry only -->
2873
+ <!-- the commas between them. -->
2874
+ <xsl:template match="&THEOREM-LIKE;|&AXIOM-LIKE;|&DEFINITION-LIKE;|&OPENPROBLEM-LIKE;" mode="creator-full">
2845
2875
  <!-- select="creator" would just get it killed -->
2846
2876
  <xsl:apply-templates select="creator/*|creator/text()" />
2847
2877
  </xsl:template>
2848
2878
 
2879
+ <!-- The schema allows only "xref" inside "origins", so each one is -->
2880
+ <!-- a live cross-reference; commas separate them, with no -->
2881
+ <!-- conjunction before the last -->
2882
+ <xsl:template match="&THEOREM-LIKE;|&AXIOM-LIKE;|&DEFINITION-LIKE;|&OPENPROBLEM-LIKE;" mode="origins-full">
2883
+ <xsl:for-each select="origins/xref">
2884
+ <xsl:if test="preceding-sibling::xref">
2885
+ <xsl:text>, </xsl:text>
2886
+ </xsl:if>
2887
+ <xsl:apply-templates select="."/>
2888
+ </xsl:for-each>
2889
+ </xsl:template>
2890
+
2891
+ <xsl:template match="&THEOREM-LIKE;|&AXIOM-LIKE;|&DEFINITION-LIKE;|&OPENPROBLEM-LIKE;" mode="attribution-full">
2892
+ <xsl:apply-templates select="." mode="creator-full"/>
2893
+ <xsl:if test="creator and origins">
2894
+ <xsl:text>, </xsl:text>
2895
+ </xsl:if>
2896
+ <xsl:apply-templates select="." mode="origins-full"/>
2897
+ </xsl:template>
2898
+
2849
2899
  <!-- Structured titles -->
2850
2900
 
2851
2901
  <!-- Each "line", except the last, gets a separator -->
@@ -2904,13 +2954,17 @@ Book (with parts), "section" at level 3
2904
2954
  <!-- -->
2905
2955
  <!-- 1. in a figure (itself not in a sidebyside) where it -->
2906
2956
  <!-- can have a width specification on itself -->
2907
- <!-- 2. in a sidebyside directly, or a figure in a sidebyside. -->
2957
+ <!-- 2. as a panel of a sidebyside, or in a figure that is a panel. -->
2908
2958
  <!-- These widths come from the layout, and are converter dependent -->
2959
+ <!-- 3. more deeply within a sidebyside, such as in an "exercise" -->
2960
+ <!-- panel or in a list item. The layout does not size it, so it -->
2961
+ <!-- is handled as in case 1, relative to the available width -->
2962
+ <!-- where it sits. -->
2909
2963
  <!-- -->
2910
- <!-- Entirely similar for jsxgraph, audio and video but we do -->
2911
- <!-- not consult default *image* width in docinfo -->
2964
+ <!-- Entirely similar for jsxgraph, audio, video, interactive and slate, -->
2965
+ <!-- but we do not consult default *image* width in docinfo -->
2912
2966
 
2913
- <xsl:template match="image[not(ancestor::sidebyside)]|audio[not(ancestor::sidebyside)]|video[not(ancestor::sidebyside)]|jsxgraph[not(ancestor::sidebyside)]|interactive[not(ancestor::sidebyside)]|slate[not(ancestor::sidebyside)]" mode="get-width-percentage">
2967
+ <xsl:template match="image[not(&SBS-LAYOUT-FILTER;)]|audio[not(&SBS-LAYOUT-FILTER;)]|video[not(&SBS-LAYOUT-FILTER;)]|jsxgraph[not(&SBS-LAYOUT-FILTER;)]|interactive[not(&SBS-LAYOUT-FILTER;)]|slate[not(&SBS-LAYOUT-FILTER;)]" mode="get-width-percentage">
2914
2968
  <!-- find it first -->
2915
2969
  <xsl:variable name="raw-width">
2916
2970
  <xsl:choose>
@@ -2948,11 +3002,13 @@ Book (with parts), "section" at level 3
2948
3002
  </xsl:choose>
2949
3003
  </xsl:template>
2950
3004
 
2951
- <!-- Any way that an image gets placed in a sidebyside -->
2952
- <!-- panel it should have a relative size filling that -->
2953
- <!-- panel, so this is easy, just 100% all the time -->
2954
- <!-- Exception: asymptote WebGL needs actual pixels -->
2955
- <xsl:template match="image[ancestor::sidebyside]" mode="get-width-percentage">
3005
+ <!-- An image that is a panel of a sidebyside, or that is -->
3006
+ <!-- the content of a figure panel, has a relative size -->
3007
+ <!-- filling that panel, so this is easy, just 100% all the -->
3008
+ <!-- time. An image more deeply within a sidebyside is -->
3009
+ <!-- handled above. -->
3010
+ <!-- Exception: asymptote WebGL needs actual pixels -->
3011
+ <xsl:template match="image[&SBS-LAYOUT-FILTER;]" mode="get-width-percentage">
2956
3012
  <xsl:text>100%</xsl:text>
2957
3013
  </xsl:template>
2958
3014
 
@@ -2968,8 +3024,8 @@ Book (with parts), "section" at level 3
2968
3024
  <!-- of the sidebyside, a naked object, or a figure holding the object -->
2969
3025
  <!-- Widths from sidebyside layouts have been error-checked as input -->
2970
3026
 
2971
- <!-- occurs in a figure, not contained in a sidebyside -->
2972
- <xsl:template match="audio[ancestor::sidebyside]|video[ancestor::sidebyside]|jsxgraph[ancestor::sidebyside]|interactive[ancestor::sidebyside]|slate[ancestor::sidebyside]|image[asymptote and ancestor::sidebyside]|image[sageplot and ancestor::sidebyside]" mode="get-width-percentage">
3027
+ <!-- a panel of a sidebyside, or the content of a stack or figure panel -->
3028
+ <xsl:template match="audio[&SBS-LAYOUT-FILTER;]|video[&SBS-LAYOUT-FILTER;]|jsxgraph[&SBS-LAYOUT-FILTER;]|interactive[&SBS-LAYOUT-FILTER;]|slate[&SBS-LAYOUT-FILTER;]|image[asymptote and (&SBS-LAYOUT-FILTER;)]|image[sageplot and (&SBS-LAYOUT-FILTER;)]" mode="get-width-percentage">
2973
3029
  <!-- in a side-by-side, get layout, locate in layout -->
2974
3030
  <!-- and get width. The layout-parameters template -->
2975
3031
  <!-- will analyze an enclosing sbsgroup -->
@@ -3257,26 +3313,27 @@ Book (with parts), "section" at level 3
3257
3313
  <!-- First, a "divisional" "exercise" in an "exercises", -->
3258
3314
  <!-- with perhaps intervening groups, like an "exercisegroup" -->
3259
3315
  <xsl:template match="exercises//exercise" mode="string-id">
3260
- <xsl:text>divisionalexercise</xsl:text>
3316
+ <xsl:text>exercise-divisional</xsl:text>
3261
3317
  </xsl:template>
3262
3318
 
3263
3319
  <!-- Second, an "exercise" placed within a "worksheet"-->
3264
3320
  <xsl:template match="worksheet//exercise" mode="string-id">
3265
- <xsl:text>worksheetexercise</xsl:text>
3321
+ <xsl:text>exercise-worksheet</xsl:text>
3266
3322
  </xsl:template>
3267
3323
 
3268
3324
  <!-- Third, an "exercise" placed within a "reading-questions"-->
3269
3325
  <xsl:template match="reading-questions//exercise" mode="string-id">
3270
- <xsl:text>readingquestion</xsl:text>
3326
+ <xsl:text>exercise-reading</xsl:text>
3271
3327
  </xsl:template>
3272
3328
 
3273
3329
  <!-- Finally, an inline exercise has a division (several possible) -->
3274
3330
  <!-- as a parent. We just drop in here last if other matches do not -->
3275
3331
  <!-- succeed, but could improve with a filter or list of specific matches -->
3276
- <!-- This matches the LaTeX environment of the same name, so -->
3277
- <!-- template to create an "inlineexercise" environment runs smoothly -->
3332
+ <!-- The LaTeX conversions name their environment for an inline exercise -->
3333
+ <!-- "inlineexercise", written there as a literal: an environment name is -->
3334
+ <!-- not a string-id, and a hyphen does not belong in one. -->
3278
3335
  <xsl:template match="exercise" mode="string-id">
3279
- <xsl:text>inlineexercise</xsl:text>
3336
+ <xsl:text>exercise-inline</xsl:text>
3280
3337
  </xsl:template>
3281
3338
 
3282
3339
  <!-- "solutions" divisions are "Solutions 5.6" in the -->
@@ -4222,7 +4279,7 @@ Book (with parts), "section" at level 3
4222
4279
  </xsl:when>
4223
4280
  <!-- not placed on image, or figure/image, -->
4224
4281
  <!-- but a document-wide default margins exists -->
4225
- <xsl:when test="self::image and not(ancestor::sidebyside) and $docinfo/defaults/images/@margins">
4282
+ <xsl:when test="self::image and not(&SBS-LAYOUT-FILTER;) and $docinfo/defaults/images/@margins">
4226
4283
  <xsl:value-of select="normalize-space($docinfo/defaults/images/@margins)" />
4227
4284
  </xsl:when>
4228
4285
  <!-- default if not specified -->
@@ -4263,7 +4320,7 @@ Book (with parts), "section" at level 3
4263
4320
  </xsl:when>
4264
4321
  <!-- not placed on image, or figure/image, -->
4265
4322
  <!-- but a document-wide default width exists -->
4266
- <xsl:when test="self::image and not(ancestor::sidebyside) and $docinfo/defaults/images/@width">
4323
+ <xsl:when test="self::image and not(&SBS-LAYOUT-FILTER;) and $docinfo/defaults/images/@width">
4267
4324
  <xsl:value-of select="$docinfo/defaults/images/@width" />
4268
4325
  </xsl:when>
4269
4326
  <!-- default setting if not specified, and not global -->
@@ -7140,19 +7197,22 @@ Book (with parts), "section" at level 3
7140
7197
  <!-- categorized by their ancestors. So we recognize certain strings -->
7141
7198
  <!-- as "pseudo-elements". We do this once and then pass them along. -->
7142
7199
  <!-- -->
7143
- <!-- * inlineexercise -->
7144
- <!-- * divisionexercise -->
7145
- <!-- * worksheetexercise -->
7146
- <!-- * readingquestion -->
7200
+ <!-- * exercise-inline -->
7201
+ <!-- * exercise-divisional -->
7202
+ <!-- * exercise-worksheet -->
7203
+ <!-- * exercise-reading -->
7147
7204
  <!-- -->
7148
- <!-- Equality of strings (e.g. 'inlineexercise') and the node-set ($elements)-->
7149
- <!-- is true when the *string-value* of *one* node in the set is identical -->
7150
- <!-- NB: if this gets out-of-hand, it should be passed as a structure -->
7151
- <xsl:variable name="b-inline-exercises" select="'inlineexercise' = $elements"/>
7152
- <xsl:variable name="b-division-exercises" select="'divisionexercise' = $elements"/>
7153
- <xsl:variable name="b-worksheet-exercises" select="'worksheetexercise' = $elements"/>
7154
- <xsl:variable name="b-reading-questions" select="'readingquestion' = $elements"/>
7155
- <!-- display subdivision headings with empty contents? -->
7205
+ <!-- These are the names a publication file uses, and the names an -->
7206
+ <!-- author writes in a "rename", so a type of "exercise" has one name. -->
7207
+ <!-- -->
7208
+ <!-- Equality of strings (e.g. 'exercise-inline') and the node-set -->
7209
+ <!-- ($elements) is true when the *string-value* of *one* node in the -->
7210
+ <!-- set is identical. NB: if this gets out-of-hand, pass a structure -->
7211
+ <xsl:variable name="b-inline-exercises" select="'exercise-inline' = $elements"/>
7212
+ <xsl:variable name="b-division-exercises" select="'exercise-divisional' = $elements"/>
7213
+ <xsl:variable name="b-worksheet-exercises" select="'exercise-worksheet' = $elements"/>
7214
+ <xsl:variable name="b-reading-questions" select="'exercise-reading' = $elements"/>
7215
+ <!-- display subdivision headings with empty contents? -->
7156
7216
  <xsl:variable name="entered-empty">
7157
7217
  <xsl:choose>
7158
7218
  <xsl:when test="not(@empty)">
@@ -11975,6 +12035,21 @@ http://andrewmccarthy.ie/2014/11/06/swung-dash-in-latex/
11975
12035
  <xsl:with-param name="message" select="'an &quot;sbsgroup&quot; now requires at least two &quot;sidebyside&quot;. A group of one behaves exactly like the &quot;sidebyside&quot; alone, so use the &quot;sidebyside&quot; by itself, with the layout attributes moved onto it'"/>
11976
12036
  </xsl:call-template>
11977
12037
  <!-- -->
12038
+ <!-- 2026-09-22 a type of "exercise" is named as in a publication file -->
12039
+ <xsl:call-template name="deprecation-message">
12040
+ <xsl:with-param name="occurrences" select="&quot;$docinfo/rename[(@element = 'inlineexercise') or (@element = 'divisionalexercise') or (@element = 'worksheetexercise') or (@element = 'readingquestion')]&quot;" />
12041
+ <xsl:with-param name="date-string" select="'2026-09-22'" />
12042
+ <xsl:with-param name="message" select="'a &quot;rename&quot; now names a type of &quot;exercise&quot; the way a publication file does: &quot;exercise-inline&quot;, &quot;exercise-divisional&quot;, &quot;exercise-worksheet&quot;, or &quot;exercise-reading&quot;. The one-word names are deprecated, and will continue to be honored'"/>
12043
+ </xsl:call-template>
12044
+ <!-- -->
12045
+ <!-- 2026-09-22 a type of "exercise" is named as in a publication file -->
12046
+ <xsl:call-template name="deprecation-message">
12047
+ <xsl:with-param name="occurrences" select="&quot;$document-root//list-of[contains(@elements, 'inlineexercise') or contains(@elements, 'divisionexercise') or contains(@elements, 'divisionalexercise') or contains(@elements, 'worksheetexercise') or contains(@elements, 'readingquestion')]&quot;" />
12048
+ <xsl:with-param name="date-string" select="'2026-09-22'" />
12049
+ <xsl:with-param name="message" select="'the &quot;elements&quot; attribute of a &quot;list-of&quot; now names a type of &quot;exercise&quot; the way a publication file does: &quot;exercise-inline&quot;, &quot;exercise-divisional&quot;, &quot;exercise-worksheet&quot;, or &quot;exercise-reading&quot;. The one-word names are deprecated, and will continue to be honored'"/>
12050
+ </xsl:call-template>
12051
+ <!-- -->
12052
+ <!-- End of the chronological sequence: a new entry goes just above. -->
11978
12053
  </xsl:template>
11979
12054
 
11980
12055
  <!-- Miscellaneous -->
@@ -142,6 +142,21 @@
142
142
  <!-- but a a boolean sure helps -->
143
143
  <xsl:variable name="b-kindle" select="$math.format = 'kindle'"/>
144
144
 
145
+ <!-- A file holding mathematics must say so in the "properties" of -->
146
+ <!-- its manifest "item", and which property depends only on the -->
147
+ <!-- format of the mathematics. Mathematics as speech is text, so -->
148
+ <!-- it has no property, and the value is empty. -->
149
+ <xsl:variable name="manifest-math-property">
150
+ <xsl:choose>
151
+ <xsl:when test="$math.format = 'mml' or $math.format = 'kindle'">
152
+ <xsl:text>mathml</xsl:text>
153
+ </xsl:when>
154
+ <xsl:when test="$math.format = 'svg'">
155
+ <xsl:text>svg</xsl:text>
156
+ </xsl:when>
157
+ </xsl:choose>
158
+ </xsl:variable>
159
+
145
160
  <!-- If there are footnotes, we'll build and package a "endnotes.xhtml" file -->
146
161
  <xsl:variable name="b-has-endnotes" select="boolean($document-root//fn|$document-root//aside|$document-root//biographical|$document-root//historical)"/>
147
162
 
@@ -394,10 +409,12 @@
394
409
  <xsl:apply-templates select="personname"/>
395
410
  </xsl:element>
396
411
  </xsl:for-each>
397
- <!-- Required in EPUB 3.0.1 spec -->
398
- <!-- TODO: title-types can refine this -->
412
+ <!-- Required in EPUB 3.0.1 spec -->
413
+ <!-- TODO: title-types can refine this -->
414
+ <!-- Text only, so any mathematics is its LaTeX source -->
415
+ <!-- (or the author supplies a "plaintitle" instead) -->
399
416
  <xsl:element name="dc:title">
400
- <xsl:apply-templates select="$document-root" mode="title-full" />
417
+ <xsl:apply-templates select="$document-root" mode="title-plain"/>
401
418
  </xsl:element>
402
419
  <!-- Required in EPUB 3.0.1 spec -->
403
420
  <!-- Repeatable and more complicated, see spec -->
@@ -454,7 +471,20 @@
454
471
  <item id="css-epub" href="{$css-dir}/epub.css" media-type="text/css"/>
455
472
  </xsl:otherwise>
456
473
  </xsl:choose>
457
- <item id="cover-page" href="{$xhtml-dir}/cover-page.xhtml" media-type="application/xhtml+xml"/>
474
+ <!-- Absent an authored image, the cover page shows the -->
475
+ <!-- document's title, which may hold mathematics -->
476
+ <item id="cover-page" href="{$xhtml-dir}/cover-page.xhtml" media-type="application/xhtml+xml">
477
+ <xsl:variable name="has-math">
478
+ <xsl:call-template name="file-has-math">
479
+ <xsl:with-param name="filename" select="'cover-page.xhtml'"/>
480
+ </xsl:call-template>
481
+ </xsl:variable>
482
+ <xsl:if test="$has-math = 'true'">
483
+ <xsl:attribute name="properties">
484
+ <xsl:value-of select="$manifest-math-property"/>
485
+ </xsl:attribute>
486
+ </xsl:if>
487
+ </item>
458
488
  <item id="table-contents"
459
489
  href="{$xhtml-dir}/table-contents.xhtml"
460
490
  media-type="application/xhtml+xml">
@@ -462,27 +492,17 @@
462
492
  <!-- predict which division titles the table of contents -->
463
493
  <!-- displays, read it and see if any mathematics landed -->
464
494
  <!-- there, exactly as "manifest-item" does per chunk -->
465
- <xsl:variable name="toc-contents" select="document(concat($tmpdir, '/', $content-dir, '/', $xhtml-dir, '/table-contents.xhtml'))"/>
495
+ <xsl:variable name="has-math">
496
+ <xsl:call-template name="file-has-math">
497
+ <xsl:with-param name="filename" select="'table-contents.xhtml'"/>
498
+ </xsl:call-template>
499
+ </xsl:variable>
466
500
  <xsl:attribute name="properties">
467
- <xsl:choose>
468
- <xsl:when test="$toc-contents//svg:svg | $toc-contents//math:math">
469
- <xsl:choose>
470
- <xsl:when test="$math.format = 'mml' or
471
- $math.format = 'kindle'">
472
- <xsl:text>nav mathml</xsl:text>
473
- </xsl:when>
474
- <xsl:when test="$math.format = 'svg'">
475
- <xsl:text>nav svg</xsl:text>
476
- </xsl:when>
477
- <xsl:otherwise>
478
- <xsl:text>nav</xsl:text>
479
- </xsl:otherwise>
480
- </xsl:choose>
481
- </xsl:when>
482
- <xsl:otherwise>
483
- <xsl:text>nav</xsl:text>
484
- </xsl:otherwise>
485
- </xsl:choose>
501
+ <xsl:text>nav</xsl:text>
502
+ <xsl:if test="($has-math = 'true') and not($manifest-math-property = '')">
503
+ <xsl:text> </xsl:text>
504
+ <xsl:value-of select="$manifest-math-property"/>
505
+ </xsl:if>
486
506
  </xsl:attribute>
487
507
  </item>
488
508
  <item id="cover-image" href="{$xhtml-dir}/{$epub-cover-dest}" properties="cover-image">
@@ -516,17 +536,12 @@
516
536
  <xsl:if test="$b-has-endnotes">
517
537
  <item id="endnotes" href="{$xhtml-dir}/{$endnote-file}"
518
538
  media-type="application/xhtml+xml">
519
- <xsl:if test="$b-endnotes-have-math">
539
+ <!-- The test examines the source, not the file, so it -->
540
+ <!-- also holds for mathematics as speech, which is -->
541
+ <!-- text and has no property to declare -->
542
+ <xsl:if test="$b-endnotes-have-math and not($manifest-math-property = '')">
520
543
  <xsl:attribute name="properties">
521
- <xsl:choose>
522
- <xsl:when test="$math.format = 'mml' or
523
- $math.format = 'kindle'">
524
- <xsl:text>mathml</xsl:text>
525
- </xsl:when>
526
- <xsl:when test="$math.format = 'svg'">
527
- <xsl:text>svg</xsl:text>
528
- </xsl:when>
529
- </xsl:choose>
544
+ <xsl:value-of select="$manifest-math-property"/>
530
545
  </xsl:attribute>
531
546
  </xsl:if>
532
547
  </item>
@@ -610,6 +625,17 @@
610
625
  </xsl:if>
611
626
  </xsl:template>
612
627
 
628
+ <!-- Whether a file of the container holds mathematics, as "true" -->
629
+ <!-- or "false". There are simply too many edge cases to decide -->
630
+ <!-- this from the structure of the source, so read the XHTML file, -->
631
+ <!-- already written, and look for an "svg" or a "math" element. -->
632
+ <!-- (Processing with page2svg makes it appear SVG images exist.) -->
633
+ <xsl:template name="file-has-math">
634
+ <xsl:param name="filename"/>
635
+ <xsl:variable name="contents" select="document(concat($tmpdir, '/', $content-dir, '/', $xhtml-dir, '/', $filename))"/>
636
+ <xsl:value-of select="boolean($contents//svg:svg | $contents//math:math)"/>
637
+ </xsl:template>
638
+
613
639
  <!-- One manifest "item" element for the context node's file -->
614
640
  <xsl:template name="manifest-item">
615
641
  <!-- Annotate manifest entries -->
@@ -620,49 +646,17 @@
620
646
  <xsl:element name="item" xmlns="http://www.idpf.org/2007/opf">
621
647
  <xsl:apply-templates select="." mode="html-id-attribute"/>
622
648
  <!-- properties are iff, so validator complains if extra -->
623
- <!-- condition on math presence for svg/mathml property -->
624
- <!-- TODO: use a parameter switch for output style -->
625
649
  <!-- Study: https://github.com/w3c/epubcheck/issues/420 -->
626
- <!-- Processing with page2svg makes it appear SVG images exist -->
627
- <!-- Set properties="svg" or properties="mathml" when a -->
628
- <!-- file contains math in one of thse formats. -->
629
- <!-- There are simply too many edge cases to do this -->
630
- <!-- based on document structure alone, so read the actual -->
631
- <!-- XHTML files we've already written and look for svg -->
632
- <!-- or math tags in them. -->
633
650
  <xsl:variable name="has-math">
634
- <xsl:variable name="contents-filename">
635
- <xsl:value-of select="$tmpdir" />
636
- <xsl:text>/</xsl:text>
637
- <xsl:value-of select="$content-dir" />
638
- <xsl:text>/</xsl:text>
639
- <xsl:value-of select="$xhtml-dir" />
640
- <xsl:text>/</xsl:text>
641
- <xsl:apply-templates select="."
642
- mode="containing-filename"/>
643
- </xsl:variable>
644
- <xsl:variable name="filedata"
645
- select="document($contents-filename)"/>
646
- <xsl:choose>
647
- <xsl:when test="$filedata//svg:svg|$filedata//math:math">
648
- <xsl:text>true</xsl:text>
649
- </xsl:when>
650
- <xsl:otherwise>
651
- <xsl:text>false</xsl:text>
652
- </xsl:otherwise>
653
- </xsl:choose>
651
+ <xsl:call-template name="file-has-math">
652
+ <xsl:with-param name="filename">
653
+ <xsl:apply-templates select="." mode="containing-filename"/>
654
+ </xsl:with-param>
655
+ </xsl:call-template>
654
656
  </xsl:variable>
655
- <xsl:variable name="b-has-math" select="$has-math = 'true'" />
656
- <xsl:if test="$b-has-math">
657
+ <xsl:if test="$has-math = 'true'">
657
658
  <xsl:attribute name="properties">
658
- <xsl:choose>
659
- <xsl:when test="$math.format = 'mml' or $math.format = 'kindle'">
660
- <xsl:text>mathml</xsl:text>
661
- </xsl:when>
662
- <xsl:when test="$math.format = 'svg'">
663
- <xsl:text>svg</xsl:text>
664
- </xsl:when>
665
- </xsl:choose>
659
+ <xsl:value-of select="$manifest-math-property"/>
666
660
  </xsl:attribute>
667
661
  </xsl:if>
668
662
  <!-- TODO: coordinate with manifest/script on xhtml extension -->
@@ -769,16 +763,6 @@
769
763
  </xsl:choose>
770
764
  </xsl:attribute>
771
765
  </cover>
772
- <!-- These may be used in automated creation of a cover image -->
773
- <title>
774
- <xsl:apply-templates select="$document-root" mode="title-simple"/>
775
- </title>
776
- <subtitle>
777
- <xsl:apply-templates select="$document-root" mode="subtitle"/>
778
- </subtitle>
779
- <author>
780
- <xsl:apply-templates select="$bibinfo/author" mode="name-list"/>
781
- </author>
782
766
  <!-- Decide what to do with preview images, etc. -->
783
767
  <images>
784
768
  <xsl:for-each select="$document-root//image">
@@ -856,11 +840,12 @@
856
840
  <exsl:document href="{$content-dir}/{$xhtml-dir}/cover-page.xhtml" method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="no">
857
841
  <html>
858
842
  <xsl:call-template name="html-theme-attributes"/>
859
- <!-- head element should not be empty -->
843
+ <!-- head element should not be empty -->
844
+ <!-- and a "title" in the "head" is text only -->
860
845
  <head>
861
846
  <meta charset="utf-8"/>
862
847
  <title>
863
- <xsl:apply-templates select="$document-root" mode="title-full"/>
848
+ <xsl:apply-templates select="$document-root" mode="title-plain"/>
864
849
  </title>
865
850
  <xsl:if test="not($b-authored-cover)">
866
851
  <xsl:call-template name="epub-kindle-css"/>
@@ -1574,8 +1559,10 @@
1574
1559
  <!-- Math -->
1575
1560
  <!-- #### -->
1576
1561
 
1577
- <!-- Pluck SVGs from the file full of them, with matching IDs -->
1578
- <xsl:template match="m|md[mrow]">
1562
+ <!-- Pluck SVGs from the file full of them, with matching IDs. -->
1563
+ <!-- Music notation ("n", "scaledeg", "timesignature", "chord") -->
1564
+ <!-- is set as inline math, so it has a representation as well. -->
1565
+ <xsl:template match="m|md[mrow]|n|scaledeg|timesignature|chord">
1579
1566
  <!-- NB: math-representation file writes with "unique-id" -->
1580
1567
  <xsl:variable name="id">
1581
1568
  <xsl:apply-templates select="." mode="unique-id"/>