@pretextbook/pretext-html 0.6.0 → 0.8.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 (98) hide show
  1. package/README.md +31 -2
  2. package/assets/upstream.json +1 -1
  3. package/assets/xsl/LICENSE-pretext +1 -1
  4. package/assets/xsl/README.md +19 -0
  5. package/assets/xsl/entities.ent +15 -4
  6. package/assets/xsl/extract-asymptote.xsl +5 -5
  7. package/assets/xsl/extract-biblio-csl.xsl +1 -1
  8. package/assets/xsl/extract-datafile.xsl +1 -1
  9. package/assets/xsl/extract-dynamic.xsl +1 -1
  10. package/assets/xsl/extract-identity.xsl +5 -5
  11. package/assets/xsl/extract-interactive.xsl +1 -1
  12. package/assets/xsl/extract-latex-image.xsl +5 -5
  13. package/assets/xsl/extract-mermaid.xsl +1 -1
  14. package/assets/xsl/extract-mom.xsl +5 -5
  15. package/assets/xsl/extract-pg.xsl +1 -1
  16. package/assets/xsl/extract-prefigure.xsl +5 -5
  17. package/assets/xsl/extract-qrcode.xsl +1 -1
  18. package/assets/xsl/extract-runestone-page-template.xsl +1 -1
  19. package/assets/xsl/extract-sageplot.xsl +5 -5
  20. package/assets/xsl/extract-stack.xsl +1 -1
  21. package/assets/xsl/extract-trace.xsl +1 -1
  22. package/assets/xsl/extract-youtube.xsl +5 -5
  23. package/assets/xsl/latex/pretext-latex-AIM.xsl +1 -1
  24. package/assets/xsl/latex/pretext-latex-chaos.xsl +1 -1
  25. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +1 -1
  26. package/assets/xsl/latex/pretext-latex-guide.xsl +1 -1
  27. package/assets/xsl/localizations/README.md +1 -1
  28. package/assets/xsl/localizations/af-ZA.xml +1 -1
  29. package/assets/xsl/localizations/bg-BG.xml +1 -1
  30. package/assets/xsl/localizations/ca-ES.xml +1 -1
  31. package/assets/xsl/localizations/cs-CZ.xml +1 -1
  32. package/assets/xsl/localizations/de-DE.xml +1 -1
  33. package/assets/xsl/localizations/en-US.xml +1 -1
  34. package/assets/xsl/localizations/es-ES.xml +1 -1
  35. package/assets/xsl/localizations/fi-FI.xml +1 -1
  36. package/assets/xsl/localizations/fr-CA.xml +1 -1
  37. package/assets/xsl/localizations/fr-FR.xml +1 -1
  38. package/assets/xsl/localizations/hu-HU.xml +1 -1
  39. package/assets/xsl/localizations/it-IT.xml +1 -1
  40. package/assets/xsl/localizations/ku-CKB.xml +1 -1
  41. package/assets/xsl/localizations/localizations.xml +1 -1
  42. package/assets/xsl/localizations/nl-NL.xml +1 -1
  43. package/assets/xsl/localizations/pt-BR.xml +1 -1
  44. package/assets/xsl/localizations/pt-PT.xml +1 -1
  45. package/assets/xsl/localizations/zh-HANS.xml +1 -1
  46. package/assets/xsl/pretext-assembly.xsl +66 -7
  47. package/assets/xsl/pretext-basic-html.xsl +5 -5
  48. package/assets/xsl/pretext-braille-preprint.xsl +5 -5
  49. package/assets/xsl/pretext-common.xsl +123 -32
  50. package/assets/xsl/pretext-dynamic.xsl +1 -1
  51. package/assets/xsl/pretext-epub.xsl +94 -85
  52. package/assets/xsl/pretext-fo.xsl +18 -20
  53. package/assets/xsl/pretext-html.xsl +260 -74
  54. package/assets/xsl/pretext-json-manifest.xsl +1 -1
  55. package/assets/xsl/pretext-jupyter.xsl +5 -5
  56. package/assets/xsl/pretext-latex-classic.xsl +1 -1
  57. package/assets/xsl/pretext-latex-common.xsl +35 -22
  58. package/assets/xsl/pretext-latex.xsl +3 -3
  59. package/assets/xsl/pretext-litprog.xsl +9 -2
  60. package/assets/xsl/pretext-markdown.xsl +1 -1
  61. package/assets/xsl/pretext-numbers.xsl +1 -1
  62. package/assets/xsl/pretext-revealjs.xsl +1 -3
  63. package/assets/xsl/pretext-runestone-fitb.xsl +18 -0
  64. package/assets/xsl/pretext-runestone-static.xsl +13 -1
  65. package/assets/xsl/pretext-runestone.xsl +39 -27
  66. package/assets/xsl/pretext-sage-doctest.xsl +18 -0
  67. package/assets/xsl/pretext-solution-manual-latex.xsl +4 -4
  68. package/assets/xsl/pretext-text-utilities.xsl +1 -1
  69. package/assets/xsl/pretext-text.xsl +5 -5
  70. package/assets/xsl/pretext-units.xsl +5 -5
  71. package/assets/xsl/pretext-view-source.xsl +1 -1
  72. package/assets/xsl/pretext-ww-problem-sets.xsl +15 -12
  73. package/assets/xsl/publisher-variables.xsl +160 -133
  74. package/assets/xsl/support/README.md +19 -0
  75. package/assets/xsl/support/extract-math.xsl +1 -1
  76. package/assets/xsl/support/package-math.xsl +1 -1
  77. package/assets/xsl/support/webpack_static_imports.xml +19 -0
  78. package/assets/xsl/tests/README.md +19 -0
  79. package/assets/xsl/tests/null.xml +19 -0
  80. package/assets/xsl/tests/pretext-text-utilities-test.xsl +1 -1
  81. package/assets/xsl/utilities/README.md +19 -0
  82. package/assets/xsl/utilities/author-report.xsl +1 -1
  83. package/assets/xsl/utilities/fix-deprecations.xsl +5 -5
  84. package/assets/xsl/utilities/pretext-enhanced-source.xsl +1 -1
  85. package/assets/xsl/utilities/report-publisher-variables.xsl +5 -5
  86. package/assets/xsl/xml-to-json.xsl +4 -4
  87. package/assets/xsl-bundle.json +1 -1
  88. package/dist/banner.d.ts +51 -0
  89. package/dist/{cli-DF7XOWN7.js → cli-Bcn4t3B1.js} +387 -240
  90. package/dist/cli.js +2 -2
  91. package/dist/html-static.d.ts +20 -0
  92. package/dist/index.browser.d.ts +2 -0
  93. package/dist/index.browser.js +554 -407
  94. package/dist/index.d.ts +2 -0
  95. package/dist/index.js +28 -25
  96. package/dist/renderer.d.ts +18 -1
  97. package/package.json +2 -1
  98. package/assets/xsl/pretext-smc.xsl +0 -492
@@ -78,29 +78,20 @@
78
78
  </xsl:variable>
79
79
  <xsl:variable name="mock-UUID">mock-123456789-0-987654321</xsl:variable>
80
80
 
81
- <!-- We hard-code the chunking level. Level 2 is the -->
82
- <!-- default for books, which we presume throughout. -->
83
- <!-- Specialized divisions, to the spine, assume this. -->
84
- <!-- NB: this override is only defined for a "book", -->
85
- <!-- so when there is support for "article" it will -->
86
- <!-- need new definitions. -->
87
- <xsl:variable name="chunk-level">
88
- <xsl:choose>
89
- <xsl:when test="$root/book/part">3</xsl:when>
90
- <xsl:when test="$root/book">2</xsl:when>
91
- <!-- break "article" into "section" -->
92
- <xsl:when test="$root/article/section">1</xsl:when>
93
- <!-- otherwise, no real divisions -->
94
- <xsl:when test="$root/article">0</xsl:when>
95
- </xsl:choose>
96
- </xsl:variable>
97
-
98
- <!-- Force level 2 as the top level heading for chunks -->
99
- <!-- by overrideing this template than calling the original -->
81
+ <!-- The level a document's structure implies, with no publisher -->
82
+ <!-- choice consulted: a reader is served by files that are neither -->
83
+ <!-- so large that a reading system labors over one nor so numerous -->
84
+ <!-- that it labors over the set. See "chunking-level-warnings". -->
85
+ <xsl:variable name="chunk-level" select="$chunk-level-default"/>
86
+
87
+ <!-- Force level 2 as the top level heading for chunks -->
88
+ <!-- by overriding this variable rather than the original. -->
100
89
  <xsl:variable name="chunk-heading-level" select="2"/>
101
90
 
102
- <!-- We disable the ToC level to avoid any conflicts with chunk level -->
103
- <xsl:variable name="toc-level" select="number(0)" />
91
+ <!-- The navigation document lists every file of the spine, so its -->
92
+ <!-- depth is the chunking level and there is nothing left for a -->
93
+ <!-- table of contents level to say. See "chunking-level-warnings". -->
94
+ <xsl:variable name="toc-level" select="number(0)"/>
104
95
 
105
96
  <!-- XHTML files as output -->
106
97
  <xsl:variable name="file-extension" select="'.xhtml'" />
@@ -188,7 +179,10 @@
188
179
  <!-- template in the entry template here, so these pages are not built (good). -->
189
180
  <!-- But we do get little buttons to elect a printable version. We have to kill -->
190
181
  <!-- those buttons, since EPUB wants to go looking for the printable-version files. -->
191
- <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"/>
192
186
 
193
187
 
194
188
  <!-- ############## -->
@@ -213,12 +207,25 @@
213
207
  <xsl:apply-templates select="$original" mode="parameter-deprecation-warnings"/>
214
208
  <!-- Following should use $root or $document-root as defined -->
215
209
  <!-- by the "assembly" template. Checked 2020-07-16. -->
210
+ <xsl:call-template name="chunking-level-warnings"/>
216
211
  <xsl:call-template name="setup" />
217
212
  <xsl:apply-templates select="$root"/>
218
213
  <xsl:call-template name="package-document" />
219
214
  <xsl:call-template name="packaging-info"/>
220
215
  </xsl:template>
221
216
 
217
+ <!-- Two publisher choices under "common" do not reach this -->
218
+ <!-- conversion, and an author who set one deserves to hear so -->
219
+ <!-- rather than wonder why the output never changed. -->
220
+ <xsl:template name="chunking-level-warnings">
221
+ <xsl:if test="$chunk-level-entered != ''">
222
+ <xsl:message>PTX:FALLBACK: the publisher file common/chunking/@level entry is being ignored for the conversion to EPUB, which always divides a document at the default level for its structure. The choice matters little here: a reading system presents the files as one continuous reading order, and the level only governs how large the files are. The default keeps them at a size reading systems handle well.</xsl:message>
223
+ </xsl:if>
224
+ <xsl:if test="$publication/common/tableofcontents/@level">
225
+ <xsl:message>PTX:FALLBACK: the publisher file common/tableofcontents/@level entry is being ignored for the conversion to EPUB, whose navigation lists every file of the document, leaving a reading system to provide its own control over how much of that to show at once.</xsl:message>
226
+ </xsl:if>
227
+ </xsl:template>
228
+
222
229
  <!-- First, create the cover page and table of contents files, which are -->
223
230
  <!-- necessary for every EPUB, even when the source has no "frontmatter" -->
224
231
  <!-- We process structural nodes via chunking routine in xsl/mathbook-common.xsl -->
@@ -901,46 +908,11 @@
901
908
  <nav epub:type="toc" id="toc">
902
909
  <h2>Table of Contents</h2>
903
910
  <ol>
904
- <!-- top-level divisions, for a book -->
905
- <xsl:for-each select="$document-root/chapter[$b-is-book]|$document-root/section[$b-is-article]">
906
- <li>
907
- <xsl:element name="a">
908
- <xsl:attribute name="href">
909
- <xsl:apply-templates select="." mode="containing-filename" />
910
- </xsl:attribute>
911
- <xsl:apply-templates select="." mode="title-simple" />
912
- </xsl:element>
913
- <xsl:apply-templates select="." mode="nav-companions"/>
914
- </li>
915
- </xsl:for-each>
916
- <!-- following divisions identical for book v. article -->
917
- <xsl:if test="$document-root/backmatter/appendix|$document-root/backmatter/solutions">
918
- <li class="no-marker">
919
- <span>Appendices</span>
920
- <ol type="A">
921
- <xsl:for-each select="$document-root/backmatter/appendix|$document-root/backmatter/solutions">
922
- <li>
923
- <xsl:element name="a">
924
- <xsl:attribute name="href">
925
- <xsl:apply-templates select="." mode="containing-filename" />
926
- </xsl:attribute>
927
- <xsl:apply-templates select="." mode="title-simple" />
928
- </xsl:element>
929
- </li>
930
- </xsl:for-each>
931
- </ol>
932
- </li>
933
- </xsl:if>
934
- <xsl:for-each select="$document-root/backmatter/references|$document-root/backmatter/index">
935
- <li class="no-marker">
936
- <xsl:element name="a">
937
- <xsl:attribute name="href">
938
- <xsl:apply-templates select="." mode="containing-filename" />
939
- </xsl:attribute>
940
- <xsl:apply-templates select="." mode="title-simple" />
941
- </xsl:element>
942
- </li>
943
- </xsl:for-each>
911
+ <!-- The whole document, so the navigation mirrors the spine: -->
912
+ <!-- every file of the reading order earns an entry, nested by -->
913
+ <!-- the divisions that contain it. A reading system offers no -->
914
+ <!-- other way in, so anything omitted here is unreachable. -->
915
+ <xsl:apply-templates select="$document-root" mode="nav-entry"/>
944
916
  </ol>
945
917
  </nav>
946
918
  </body>
@@ -948,31 +920,68 @@
948
920
  </exsl:document>
949
921
  </xsl:template>
950
922
 
951
- <!-- Division companions of a division, nested in the nav -->
952
- <!-- document, exactly when they are files of the spine -->
953
- <xsl:template match="*" mode="nav-companions">
954
- <xsl:variable name="companion-files">
955
- <xsl:for-each select="introduction|conclusion|objectives|outcomes">
956
- <xsl:apply-templates select="." mode="is-chunk"/>
957
- </xsl:for-each>
923
+ <!-- One "li" of the navigation document per file of the spine. -->
924
+ <!-- The test is "is-epub-page", the very template the manifest -->
925
+ <!-- and the spine consult, so the four cannot disagree. A -->
926
+ <!-- division that is not a file of its own ("book" and -->
927
+ <!-- "backmatter") contributes no entry, and its children rise -->
928
+ <!-- to take its place rather than becoming unreachable. -->
929
+ <xsl:template match="&STRUCTURAL;" mode="nav-entry">
930
+ <xsl:variable name="is-page">
931
+ <xsl:apply-templates select="." mode="is-epub-page"/>
932
+ </xsl:variable>
933
+ <xsl:choose>
934
+ <xsl:when test="$is-page = 'true'">
935
+ <li>
936
+ <xsl:element name="a">
937
+ <xsl:attribute name="href">
938
+ <xsl:apply-templates select="." mode="containing-filename"/>
939
+ </xsl:attribute>
940
+ <xsl:apply-templates select="." mode="title-simple"/>
941
+ </xsl:element>
942
+ <xsl:call-template name="nav-subentries"/>
943
+ </li>
944
+ </xsl:when>
945
+ <xsl:otherwise>
946
+ <xsl:apply-templates select="*" mode="nav-entry"/>
947
+ </xsl:otherwise>
948
+ </xsl:choose>
949
+ </xsl:template>
950
+
951
+ <!-- A division companion is a file exactly when it is a chunk, -->
952
+ <!-- the same test the manifest makes. It has no children that -->
953
+ <!-- could ever be files, so there is no recursion. -->
954
+ <xsl:template match="&DIVISION-COMPANION;" mode="nav-entry">
955
+ <xsl:variable name="chunk">
956
+ <xsl:apply-templates select="." mode="is-chunk"/>
958
957
  </xsl:variable>
959
- <xsl:if test="contains($companion-files, 'true')">
958
+ <xsl:if test="$chunk = 'true'">
959
+ <li class="no-marker">
960
+ <xsl:element name="a">
961
+ <xsl:attribute name="href">
962
+ <xsl:apply-templates select="." mode="containing-filename"/>
963
+ </xsl:attribute>
964
+ <xsl:apply-templates select="." mode="division-companion-text"/>
965
+ </xsl:element>
966
+ </li>
967
+ </xsl:if>
968
+ </xsl:template>
969
+
970
+ <!-- Everything else is not a division, so it is not a file, so -->
971
+ <!-- it earns no entry. Without this the default template rule -->
972
+ <!-- would spill the text of paragraphs into the navigation. -->
973
+ <xsl:template match="*" mode="nav-entry"/>
974
+
975
+ <!-- The nested list of a division's own entries, built first so -->
976
+ <!-- that a division whose children are all inlined contributes -->
977
+ <!-- no empty "ol", which is invalid in a navigation document. -->
978
+ <xsl:template name="nav-subentries">
979
+ <xsl:variable name="subentries">
980
+ <xsl:apply-templates select="*" mode="nav-entry"/>
981
+ </xsl:variable>
982
+ <xsl:if test="exsl:node-set($subentries)/*">
960
983
  <ol>
961
- <xsl:for-each select="introduction|conclusion|objectives|outcomes">
962
- <xsl:variable name="chunk">
963
- <xsl:apply-templates select="." mode="is-chunk"/>
964
- </xsl:variable>
965
- <xsl:if test="$chunk = 'true'">
966
- <li class="no-marker">
967
- <xsl:element name="a">
968
- <xsl:attribute name="href">
969
- <xsl:apply-templates select="." mode="containing-filename" />
970
- </xsl:attribute>
971
- <xsl:apply-templates select="." mode="division-companion-text" />
972
- </xsl:element>
973
- </li>
974
- </xsl:if>
975
- </xsl:for-each>
984
+ <xsl:copy-of select="$subentries"/>
976
985
  </ol>
977
986
  </xsl:if>
978
987
  </xsl:template>
@@ -1,7 +1,7 @@
1
1
  <?xml version='1.0'?>
2
2
 
3
3
  <!--********************************************************************
4
- Copyright 2026 Robert A. Beezer
4
+ Copyright (C) 2026 Robert A. Beezer
5
5
 
6
6
  This file is part of PreTeXt.
7
7
 
@@ -2205,25 +2205,23 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2205
2205
  <!-- "sageplot" has no useful print representation yet.) -->
2206
2206
  <xsl:template match="image[latex-image]|image[sageplot]|image[asymptote]|image[pf:prefigure]|image[mermaid]" mode="image-filename">
2207
2207
  <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>
2208
+ <xsl:choose>
2209
+ <xsl:when test="latex-image">
2210
+ <xsl:text>latex-image/</xsl:text>
2211
+ </xsl:when>
2212
+ <xsl:when test="sageplot">
2213
+ <xsl:text>sageplot/</xsl:text>
2214
+ </xsl:when>
2215
+ <xsl:when test="asymptote">
2216
+ <xsl:text>asymptote/</xsl:text>
2217
+ </xsl:when>
2218
+ <xsl:when test="pf:prefigure">
2219
+ <xsl:text>prefigure/</xsl:text>
2220
+ </xsl:when>
2221
+ <xsl:when test="mermaid">
2222
+ <xsl:text>mermaid/</xsl:text>
2223
+ </xsl:when>
2224
+ </xsl:choose>
2227
2225
  <xsl:apply-templates select="latex-image|sageplot|asymptote|pf:prefigure|mermaid" mode="image-source-basename"/>
2228
2226
  <xsl:choose>
2229
2227
  <xsl:when test="pf:prefigure">