@pretextbook/pretext-html 0.7.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.
@@ -1156,7 +1156,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1156
1156
  <!-- while a trailing slash will be reliably added if -->
1157
1157
  <!-- (a) not present in publisher file specification -->
1158
1158
  <!-- (b) the path is not empty -->
1159
- <!-- The external directory is a fact of the source (a different -->
1159
+ <!-- The external directory is a property of the source (a different -->
1160
1160
  <!-- directory of files is a different document), so its declaration -->
1161
1161
  <!-- is "directories/@external" within "docinfo" (2026-07-30). The -->
1162
1162
  <!-- publication file "source/directories/@external" is deprecated but -->
@@ -1165,6 +1165,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1165
1165
  <!-- directory variables and the tree behind $docinfo does not exist -->
1166
1166
  <!-- yet at that point (referencing it is a circular definition). -->
1167
1167
  <xsl:variable name="external-directory-source">
1168
+ <!-- an empty declaration is an error, not an election -->
1169
+ <xsl:if test="$version-docinfo/directories/@external = ''">
1170
+ <xsl:message terminate="yes">PTX:FATAL: the value of "directories/@external" within "docinfo" must be nonempty</xsl:message>
1171
+ </xsl:if>
1172
+ <xsl:if test="$publication/source/directories/@external = ''">
1173
+ <xsl:message terminate="yes">PTX:FATAL: the value of source/directories/@external in the publisher file must be nonempty</xsl:message>
1174
+ </xsl:if>
1168
1175
  <xsl:variable name="raw-input">
1169
1176
  <xsl:choose>
1170
1177
  <xsl:when test="$version-docinfo/directories/@external">
@@ -1174,7 +1181,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1174
1181
  <xsl:value-of select="$version-docinfo/directories/@external"/>
1175
1182
  </xsl:when>
1176
1183
  <xsl:when test="$publication/source/directories/@external">
1177
- <xsl:message>PTX:DEPRECATE: (2026-07-30) the external directory is a fact of the source, and is now declared with a "directories/@external" attribute within "docinfo". The publication file entry "source/directories/@external" is honored meanwhile, but please relocate it.</xsl:message>
1184
+ <xsl:message>PTX:DEPRECATE: (2026-07-30) the external directory is a property of your source, and is now declared with a "directories/@external" attribute within "docinfo". The publication file entry "source/directories/@external" is honored meanwhile, but please relocate it.</xsl:message>
1178
1185
  <xsl:value-of select="$publication/source/directories/@external"/>
1179
1186
  </xsl:when>
1180
1187
  <xsl:otherwise/>
@@ -1200,104 +1207,50 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1200
1207
  </xsl:choose>
1201
1208
  </xsl:variable>
1202
1209
 
1203
- <!-- Historically this was given by the "images" directory as a default, -->
1204
- <!-- and it seems almost every author just ran with this. -->
1210
+ <!-- The generated directory is machine-owned, so it is defaultable: -->
1211
+ <!-- an undeclared location is the directory "generated", beside the -->
1212
+ <!-- source. (Historically an unmanaged scheme fell back to the -->
1213
+ <!-- "images" directory; managed directories are now the only scheme.)-->
1205
1214
  <xsl:variable name="generated-directory-source">
1206
- <xsl:variable name="raw-input" select="$publication/source/directories/@generated"/>
1207
- <xsl:choose>
1208
- <xsl:when test="$b-managed-directories">
1209
- <xsl:choose>
1210
- <xsl:when test="substring($raw-input, 1, 1) = '/'">
1211
- <xsl:message>PTX:FALLBACK: a generated-image directory (source/directories/@generated in the publisher file) must be a relative path and not begin with "/" as in "<xsl:value-of select="$raw-input"/>". Proceeding with the default, which is an empty string, and may lead to unexpected results.</xsl:message>
1212
- <xsl:text/>
1213
- </xsl:when>
1214
- <!-- trailing path separator is good -->
1215
- <xsl:when test="substring($raw-input, string-length($raw-input), 1) = '/'">
1216
- <xsl:value-of select="$raw-input"/>
1217
- </xsl:when>
1218
- <!-- if there is substance, we need to add a trailing slash -->
1219
- <xsl:when test="string-length($raw-input) > 0">
1220
- <xsl:value-of select="concat($raw-input, '/')"/>
1221
- </xsl:when>
1222
- <!-- specification must be empty, so we leave it that way -->
1223
- <xsl:otherwise/>
1224
- </xsl:choose>
1225
- </xsl:when>
1226
- <!-- Should issue a deprecation warning (elsewhere) for this. -->
1227
- <!-- directory.images *is* defined elsewhere in this stylesheet, -->
1228
- <!-- and defaults to "images", but does not have a slash, which -->
1229
- <!-- is presumed for the $generated-directory variable -->
1230
- <xsl:otherwise>
1231
- <xsl:value-of select="concat($directory.images, '/')"/>
1232
- </xsl:otherwise>
1233
- </xsl:choose>
1234
- </xsl:variable>
1235
-
1236
- <!-- For backward-compatibility, we want to know if the collection of -->
1237
- <!-- generated images is structured by their production method (newer) -->
1238
- <!-- or not (older, historical). So we create a boolean based on the -->
1239
- <!-- presence of the publisher file specification. -->
1240
- <xsl:variable name="managed-directories">
1241
- <xsl:if test="$version-docinfo/directories/@external = ''">
1242
- <xsl:message terminate="yes">PTX:FATAL: the value of "directories/@external" within "docinfo" must be nonempty</xsl:message>
1243
- </xsl:if>
1244
- <xsl:if test="$publication/source/directories/@external = ''">
1245
- <xsl:message terminate="yes">PTX:FATAL: the value of source/directories/@external in the publisher file must be nonempty</xsl:message>
1246
- </xsl:if>
1247
1215
  <xsl:if test="$publication/source/directories/@generated = ''">
1248
1216
  <xsl:message terminate="yes">PTX:FATAL: the value of source/directories/@generated in the publisher file must be nonempty</xsl:message>
1249
1217
  </xsl:if>
1250
- <!-- The external directory may be declared in "docinfo" (preferred) -->
1251
- <!-- or the publication file (deprecated, honored); the generated -->
1252
- <!-- directory is a publication file entry. Management requires an -->
1253
- <!-- external declaration, from either home, together with the -->
1254
- <!-- generated declaration. -->
1255
- <xsl:variable name="b-has-external" select="boolean($version-docinfo/directories/@external) or boolean($publication/source/directories/@external)"/>
1218
+ <xsl:variable name="raw-input">
1219
+ <xsl:choose>
1220
+ <xsl:when test="$publication/source/directories/@generated">
1221
+ <xsl:value-of select="$publication/source/directories/@generated"/>
1222
+ </xsl:when>
1223
+ <xsl:otherwise>
1224
+ <xsl:text>generated</xsl:text>
1225
+ </xsl:otherwise>
1226
+ </xsl:choose>
1227
+ </xsl:variable>
1256
1228
  <xsl:choose>
1257
- <xsl:when test="$b-has-external and $publication/source/directories/@generated">
1258
- <xsl:text>yes</xsl:text>
1229
+ <xsl:when test="substring($raw-input, 1, 1) = '/'">
1230
+ <xsl:message>PTX:FALLBACK: a generated-image directory (source/directories/@generated in the publisher file) must be a relative path and not begin with "/" as in "<xsl:value-of select="$raw-input"/>". Proceeding with the default, which is an empty string, and may lead to unexpected results.</xsl:message>
1231
+ <xsl:text/>
1259
1232
  </xsl:when>
1260
- <xsl:when test="not($b-has-external) and not($publication/source/directories/@generated)">
1261
- <xsl:text>no</xsl:text>
1233
+ <!-- trailing path separator is good -->
1234
+ <xsl:when test="substring($raw-input, string-length($raw-input), 1) = '/'">
1235
+ <xsl:value-of select="$raw-input"/>
1262
1236
  </xsl:when>
1237
+ <!-- add the trailing slash -->
1263
1238
  <xsl:otherwise>
1264
- <xsl:message>PTX:FALLBACK: an external directory ("directories/@external" within "docinfo", or the deprecated publication file form) and a generated directory (source/directories/@generated in the publication file) must be specified together; only one was found. Proceeding as if neither was specified.</xsl:message>
1265
- <xsl:text>no</xsl:text>
1239
+ <xsl:value-of select="concat($raw-input, '/')"/>
1266
1240
  </xsl:otherwise>
1267
1241
  </xsl:choose>
1268
1242
  </xsl:variable>
1269
- <xsl:variable name="b-managed-directories" select="$managed-directories = 'yes'"/>
1270
1243
 
1271
- <!-- Destination directory is hard-coded here and used in -->
1272
- <!-- various conversions under the managed directories scheme. -->
1273
- <xsl:variable name="external-directory">
1274
- <xsl:choose>
1275
- <xsl:when test="$b-managed-directories">
1276
- <xsl:text>external/</xsl:text>
1277
- </xsl:when>
1278
- <!-- backwards-compatiblity, there never was any sort of -->
1279
- <!-- naming/copying scheme for externally produced content -->
1280
- <xsl:otherwise/>
1281
- </xsl:choose>
1282
- </xsl:variable>
1244
+ <!-- Managed directories are the only scheme (2026-08-02). The two -->
1245
+ <!-- directions are independent facts: an undeclared external means -->
1246
+ <!-- the project has no external assets, and the machine-owned -->
1247
+ <!-- generated directory is defaultable. -->
1283
1248
 
1284
- <!-- There was once a scheme of sorts for managing the directory -->
1285
- <!-- where generated images landed and were found. So we need -->
1286
- <!-- to preserve that logic for backward-compatibility. -->
1287
- <xsl:variable name="generated-directory">
1288
- <xsl:choose>
1289
- <xsl:when test="$b-managed-directories">
1290
- <xsl:value-of select="'generated/'"/>
1291
- </xsl:when>
1292
- <!-- Should issue a deprecation warning (elsewhere) for this. -->
1293
- <!-- directory.images *is* defined elsewhere in this stylesheet, -->
1294
- <!-- and defaults to "images", but does not have a slash, which -->
1295
- <!-- is presumed for the $generated-directory variable -->
1296
- <xsl:otherwise>
1297
- <xsl:value-of select="concat($directory.images, '/')"/>
1298
- </xsl:otherwise>
1299
- </xsl:choose>
1300
- </xsl:variable>
1249
+
1250
+ <!-- The destination directories within any output are hard-coded -->
1251
+ <!-- here, and used in the various conversions. -->
1252
+ <xsl:variable name="external-directory" select="'external/'"/>
1253
+ <xsl:variable name="generated-directory" select="'generated/'"/>
1301
1254
 
1302
1255
 
1303
1256
  <!-- This is a directory that may need to be copied to a -->
@@ -1436,22 +1389,17 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1436
1389
  <!-- variable since it will not be used, and it is silent. -->
1437
1390
  <xsl:if test="$original//webwork[node() or @*]">
1438
1391
  <xsl:choose>
1439
- <!-- Note: $generated-directory-source is never empty? -->
1440
- <!-- Defaults to the very old "directory.images"? -->
1441
- <!-- So testing for the publication file entry is better. -->
1442
- <xsl:when test="$publication/source/directories/@generated">
1443
- <xsl:value-of select="str:replace(concat($generated-directory-source, 'webwork/'), '&#x20;', '%20')"/>
1444
- </xsl:when>
1445
- <xsl:when test="$publication/source/@webwork-problems">
1392
+ <!-- the deprecated location is honored only when no -->
1393
+ <!-- generated directory is declared -->
1394
+ <xsl:when test="$publication/source/@webwork-problems and not($publication/source/directories/@generated)">
1446
1395
  <xsl:value-of select="str:replace($publication/source/@webwork-problems, '&#x20;', '%20')"/>
1447
1396
  <xsl:message>PTX:DEPRECATE: the publication file entry source/@webwork-problems is</xsl:message>
1448
1397
  <xsl:message> deprecated, please move to using managed directories</xsl:message>
1449
1398
  </xsl:when>
1450
- <!-- no specification, so empty string for filename -->
1451
- <!-- this will be noted where it is employed -->
1452
- <!-- no specification, so empty string for directory -->
1453
- <!-- this will be noted where it is employed -->
1454
- <xsl:otherwise/>
1399
+ <!-- the generated directory, declared or defaulted -->
1400
+ <xsl:otherwise>
1401
+ <xsl:value-of select="str:replace(concat($generated-directory-source, 'webwork/'), '&#x20;', '%20')"/>
1402
+ </xsl:otherwise>
1455
1403
  </xsl:choose>
1456
1404
  </xsl:if>
1457
1405
  </xsl:variable>
@@ -1463,15 +1411,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1463
1411
  <xsl:variable name="dynamic-substitutions-file">
1464
1412
  <!-- Only relevant if there are dynamic exercises present. -->
1465
1413
  <xsl:if test="$original//exercise//setup">
1466
- <xsl:choose>
1467
- <!-- Look in the publication file for the generated directory -->
1468
- <xsl:when test="$publication/source/directories/@generated">
1469
- <xsl:value-of select="str:replace(concat($generated-directory-source, 'dynamic_subs/dynamic_substitutions.xml'), '&#x20;', '%20')"/>
1470
- </xsl:when>
1471
- <!-- no specification, so empty string for filename -->
1472
- <!-- this will be noted where it is employed -->
1473
- <xsl:otherwise/>
1474
- </xsl:choose>
1414
+ <!-- the generated directory, declared or defaulted -->
1415
+ <xsl:value-of select="str:replace(concat($generated-directory-source, 'dynamic_subs/dynamic_substitutions.xml'), '&#x20;', '%20')"/>
1475
1416
  </xsl:if>
1476
1417
  </xsl:variable>
1477
1418
 
@@ -2824,6 +2765,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2824
2765
  </xsl:variable>
2825
2766
  <xsl:variable name="b-has-embed-button" select="$embed-button = 'yes'"/>
2826
2767
 
2768
+ <!-- -->
2769
+ <!-- HTML Read-aloud control -->
2770
+ <!-- -->
2771
+
2772
+ <xsl:variable name="read-aloud">
2773
+ <xsl:apply-templates select="$publisher-attribute-options/html/pi:pub-attribute[@name='read-aloud']" mode="set-pubfile-variable"/>
2774
+ </xsl:variable>
2775
+ <xsl:variable name="b-read-aloud" select="not($read-aloud = 'no')"/>
2827
2776
 
2828
2777
  <!-- -->
2829
2778
  <!-- HTML Banner options -->
@@ -3548,6 +3497,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3548
3497
  </common>
3549
3498
  <html>
3550
3499
  <pi:pub-attribute name="short-answer-responses" default="graded" options="always"/>
3500
+ <pi:pub-attribute name="read-aloud" default="yes" options="no"/>
3551
3501
  <pi:pub-attribute name="favicon" default="none" options="simple"/>
3552
3502
  <pi:pub-attribute name="embed-button" default="no" options="yes"/>
3553
3503
  <pi:pub-attribute name="design-width" freeform="yes"/>
@@ -3946,9 +3896,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3946
3896
  <!-- silently moved here, which should make no real difference -->
3947
3897
  <xsl:param name="directory.knowls" select="''" />
3948
3898
 
3949
- <!-- Deprecated 2020-11-23 in favor of publisher file -->
3950
- <!-- specification, but will still be respected -->
3951
- <xsl:param name="directory.images" select="'images'" />
3899
+ <!-- Deprecated 2020-11-23 in favor of publisher file -->
3900
+ <!-- specification; as of 2026-08-02 managed -->
3901
+ <!-- directories are the only scheme, so this is dead: -->
3902
+ <!-- it survives only to power a deprecation warning. -->
3903
+ <xsl:param name="directory.images" select="''" />
3952
3904
 
3953
3905
  <!-- 2021-01-03 chunk.level to publisher file -->
3954
3906
  <xsl:param name="chunk.level" select="''" />
@@ -4739,6 +4691,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
4739
4691
  <xsl:with-param name="incorrect-use" select="($html.annotation != '')" />
4740
4692
  </xsl:call-template>
4741
4693
  <!-- -->
4694
+ <!-- 2026-08-02 managed directories are the only scheme -->
4695
+ <xsl:call-template name="parameter-deprecation-message">
4696
+ <xsl:with-param name="date-string" select="'2026-08-02'" />
4697
+ <xsl:with-param name="message" select="'the directory.images parameter is now ignored: managed directories are the only scheme. Generated assets live in the directory given by source/directories/@generated in the publication file (default: &quot;generated&quot;, beside the source), and external assets in the directory given by &quot;directories/@external&quot; within &quot;docinfo&quot;.'" />
4698
+ <xsl:with-param name="incorrect-use" select="($directory.images != '')" />
4699
+ </xsl:call-template>
4700
+ <!-- -->
4742
4701
  </xsl:template>
4743
4702
 
4744
4703
  </xsl:stylesheet>
@@ -1,6 +1,5 @@
1
1
  Generic Video Preview Image
2
-
3
- ```
2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
3
 
5
4
  2023-02-07: This image was previously provided for LaTeX output as a macro that resolves to a TikZ version. See removed code and comments below. In HTML we use an SVG we have mildly edited. Search the HTML conversion for a template with name "generic-preview-svg".
6
5
 
@@ -43,4 +42,3 @@ The purpose of the PNG image is to be the static version created via the pre-pro
43
42
  (64.0200,47.9100) -- (38.2800,61.4100) -- cycle;
44
43
  \end{tikzpicture}
45
44
  }
46
- ```
@@ -40,4 +40,4 @@ Refer to the existing tests in `pretext-text-utilities-test.xsl` for examples of
40
40
  ## Files
41
41
 
42
42
  - `pretext-text-utilities-test.xsl`: Contains tests for the text utilities templates.
43
- - `null.xml`: A minimal XML file used as input for the tests.
43
+ - `null.xml`: A minimal XML file used as input for the tests.
@@ -21,30 +21,28 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
21
21
 
22
22
  ## Source-to-Source conversions
23
23
 
24
- For utility programs here which rewrite your source, be **sure** to use version control (collect and review changes on a branch, stash and drop undesirable outcomes), or have backups handy. The effects are not reversible. Stylesheets will output to standard output, so you can redirect their output, or you can use something like the `-o` flag on the `xsltproc` command-line invocation. Experiment first.
24
+ For utility programs here which rewrite your source, be **sure** to use version control (collect and review changes on a branch, stash and drop undesirable outcomes), or have backups handy. The effects are not reversible. Stylesheets will output to standard output, so you can redirect their output, or you can use something like the `-o` flag on the `xsltproc` command-line invocation. Experiment first.
25
25
 
26
26
  ### `fix-deprecations.xsl`
27
+ This will convert any obsolete element names or constructions to their replacements. As deprecations are added, you may run it anew, and only the new changes will be applied. Despite the name, it does make some minor changes. Empty tags will get a single space prior to the closing backslash.
27
28
 
28
- This will convert any obsolete element names or constructions to their replacements. As deprecations are added, you may run it anew, and only the new changes will be applied. Despite the name, it does make some minor changes. Empty tags will get a single space prior to the closing backslash.
29
-
30
- Be sure to read all the details in the Author's Guide before using this on your source. Here is an absolute minimal example.
31
-
29
+ Be sure to read all the details in the Author's Guide before using this on your source. Here is an absolute minimal example.
32
30
  ```
33
31
  $ xsltproc /path/to/xsl/utilities/fix-deprecations.xsl -stringparam fix all /path/to/examples/sample-errors-and-warnings.xml > new-sample.xml
34
32
 
35
33
  $ diff /path/to/examples/sample-errors-and-warnings.xml new-sample.xml
36
34
  ```
37
-
38
35
  (Updated: 2017-07-04)
39
36
 
37
+
40
38
  ## Author Report
41
39
 
42
- `author-report.xsl` is a very simple stylesheet which will produce a text version of items in your source that could benefit from your attention. This is different than validating your PreTeXt source against the schema, but is part of using automated tools to ensure healthy source material.
40
+ `author-report.xsl` is a very simple stylesheet which will produce a text version of items in your source that could benefit from your attention. This is different than validating your PreTeXt source against the schema, but is part of using automated tools to ensure healthy source material.
43
41
 
44
42
  (Updated: 2018-12-09)
45
43
 
46
44
  ## Intermediate Enhanced Source
47
45
 
48
- `pretext-enhanced-source.xsl` is mainly meant for development use. It outputs an XML file, which is not necessarily valid PreTeXt, at a key stage of the processing. It gives you a look under the hood (or bonnet). So generally not useful (or necessary) for authors.
46
+ `pretext-enhanced-source.xsl` is mainly meant for development use. It outputs an XML file, which is not necessarily valid PreTeXt, at a key stage of the processing. It gives you a look under the hood (or bonnet). So generally not useful (or necessary) for authors.
49
47
 
50
48
  (Updated: 2020-02-25)