@pretextbook/pretext-html 0.4.0 → 0.5.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 (42) hide show
  1. package/README.md +86 -1
  2. package/assets/preview-revealjs.xsl +85 -0
  3. package/assets/upstream.json +1 -1
  4. package/assets/xsl/LICENSE-pretext +16 -0
  5. package/assets/xsl/entities.ent +7 -0
  6. package/assets/xsl/extract-biblio-csl.xsl +5 -3
  7. package/assets/xsl/extract-dynamic.xsl +14 -12
  8. package/assets/xsl/extract-interactive.xsl +2 -2
  9. package/assets/xsl/extract-pg.xsl +12 -9
  10. package/assets/xsl/extract-qrcode.xsl +1 -1
  11. package/assets/xsl/extract-trace.xsl +3 -3
  12. package/assets/xsl/extract-youtube.xsl +1 -1
  13. package/assets/xsl/latex/pretext-latex-texstyle.xsl +3 -3
  14. package/assets/xsl/pretext-assembly.xsl +362 -357
  15. package/assets/xsl/pretext-braille-preprint.xsl +1 -1
  16. package/assets/xsl/pretext-common.xsl +101 -90
  17. package/assets/xsl/pretext-epub.xsl +17 -6
  18. package/assets/xsl/pretext-fo.xsl +10 -10
  19. package/assets/xsl/pretext-html.xsl +83 -60
  20. package/assets/xsl/pretext-latex-common.xsl +8 -8
  21. package/assets/xsl/pretext-numbers.xsl +35 -35
  22. package/assets/xsl/pretext-revealjs.xsl +1 -1
  23. package/assets/xsl/pretext-runestone-fitb.xsl +14 -13
  24. package/assets/xsl/pretext-runestone-static.xsl +17 -17
  25. package/assets/xsl/pretext-runestone.xsl +33 -31
  26. package/assets/xsl/pretext-view-source.xsl +5 -3
  27. package/assets/xsl/pretext-ww-problem-sets.xsl +6 -1
  28. package/assets/xsl/publisher-variables.xsl +23 -47
  29. package/assets/xsl-bundle.json +1 -1
  30. package/dist/cli-DZsyZERX.js +694 -0
  31. package/dist/cli.js +1 -1
  32. package/dist/index.browser.d.ts +5 -0
  33. package/dist/index.browser.js +402 -256
  34. package/dist/index.d.ts +5 -0
  35. package/dist/index.js +23 -18
  36. package/dist/publication.d.ts +25 -19
  37. package/dist/renderer.d.ts +48 -0
  38. package/dist/reveal.d.ts +77 -0
  39. package/dist/reveal.js +110 -0
  40. package/dist/target.d.ts +34 -0
  41. package/package.json +12 -1
  42. package/dist/cli-Cp6C0sif.js +0 -654
@@ -49,22 +49,22 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
49
49
  <!-- ######################## -->
50
50
 
51
51
  <!-- Given a block element, produce its structure number prefix -->
52
- <!-- by reading the pre-computed @block-struct from the nearest -->
52
+ <!-- by reading the pre-computed @pi:block-struct from the nearest -->
53
53
  <!-- ancestor division, then truncating or padding to the configured -->
54
- <!-- number of levels. The @block-struct chain already excludes -->
54
+ <!-- number of levels. The @pi:block-struct chain already excludes -->
55
55
  <!-- parts (they are squelched in assembly), so when parts are -->
56
56
  <!-- present the caller's $levels (which counts from "part" depth) -->
57
57
  <!-- must be reduced by one to match the shorter chain. -->
58
58
  <xsl:template name="block-structure-number">
59
59
  <xsl:param name="levels"/>
60
60
  <xsl:variable name="raw-struct"
61
- select="ancestor::*[@block-struct][1]/@block-struct"/>
62
- <!-- The @block-struct chain already excludes parts, so when -->
63
- <!-- parts are present the $levels count (which includes the -->
64
- <!-- part depth) must be reduced by one. But only for -->
65
- <!-- blocks actually inside a part or backmatter — blocks -->
66
- <!-- in frontmatter have no part ancestor and should use -->
67
- <!-- $levels unmodified. -->
61
+ select="ancestor::*[@pi:block-struct][1]/@pi:block-struct"/>
62
+ <!-- The @pi:block-struct chain already excludes parts, so when -->
63
+ <!-- parts are present the $levels count (which includes the -->
64
+ <!-- part depth) must be reduced by one. But only for -->
65
+ <!-- blocks actually inside a part or backmatter — blocks -->
66
+ <!-- in frontmatter have no part ancestor and should use -->
67
+ <!-- $levels unmodified. -->
68
68
  <xsl:variable name="effective-levels">
69
69
  <xsl:choose>
70
70
  <xsl:when test="not($parts = 'absent') and ancestor::*[self::part or self::backmatter]">
@@ -150,12 +150,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
150
150
  <xsl:variable name="old-level">
151
151
  <xsl:apply-templates select="." mode="level"/>
152
152
  </xsl:variable>
153
- <xsl:if test="not($old-level = @level)">
153
+ <xsl:if test="not($old-level = @pi:level)">
154
154
  <xsl:message>PTX:BUG: development bug, new level does not match old level for "<xsl:value-of select="local-name(.)"/>"</xsl:message>
155
155
  <xsl:apply-templates select="." mode="location-report" />
156
156
  </xsl:if>
157
157
  <!-- actual value here, above is debugging -->
158
- <xsl:value-of select="@level"/>
158
+ <xsl:value-of select="@pi:level"/>
159
159
  </xsl:template>
160
160
 
161
161
  <xsl:template match="*" mode="new-level">
@@ -217,12 +217,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
217
217
  <xsl:template match="backmatter/references" mode="serial-number" />
218
218
  <xsl:template match="backmatter/glossary" mode="serial-number" />
219
219
 
220
- <!-- Serial number of a block: read the @serial that the assembly -->
221
- <!-- "serial-stamp" pass stamped. That pass decides, from the -->
222
- <!-- publication "@distinct" switches, whether a group shares the -->
223
- <!-- overall blocks counter or runs on its own distinct counter. -->
220
+ <!-- Serial number of a block: read the @pi:serial that the assembly -->
221
+ <!-- "serial-stamp" pass stamped. That pass decides, from the -->
222
+ <!-- publication "@distinct" switches, whether a group shares the -->
223
+ <!-- overall blocks counter or runs on its own distinct counter. -->
224
224
  <xsl:template match="&DEFINITION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&REMARK-LIKE;|&COMPUTATION-LIKE;|&EXAMPLE-LIKE;|&PROJECT-LIKE;|&FIGURE-LIKE;|&OPENPROBLEM-LIKE;|exercise" mode="serial-number">
225
- <xsl:value-of select="@serial"/>
225
+ <xsl:value-of select="@pi:serial"/>
226
226
  </xsl:template>
227
227
 
228
228
  <!-- Proofs may be numbered (for cross-reference knowls) -->
@@ -231,12 +231,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
231
231
  </xsl:template>
232
232
 
233
233
 
234
- <!-- Serial Numbers: Equations -->
235
- <!-- The assembly equation-serial pass stamps @serial on every numbered -->
236
- <!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
237
- <!-- behaviour live in the assembly pass. -->
234
+ <!-- Serial Numbers: Equations -->
235
+ <!-- The assembly equation-serial pass stamps @pi:serial on every numbered -->
236
+ <!-- <mrow>; here we just read it back. Scope rules and pad/truncate -->
237
+ <!-- behaviour live in the assembly pass. -->
238
238
  <xsl:template match="mrow[@pi:numbered = 'yes']" mode="serial-number">
239
- <xsl:value-of select="@serial"/>
239
+ <xsl:value-of select="@pi:serial"/>
240
240
  </xsl:template>
241
241
 
242
242
  <!-- An authored bare "md" may carry an @xml:id, and so may be cross-referenced. -->
@@ -323,12 +323,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
323
323
  </xsl:choose>
324
324
  </xsl:template>
325
325
 
326
- <!-- Serial Numbers: Footnotes -->
327
- <!-- We determine the appropriate subtree to count within -->
328
- <!-- given the document root and the configured depth -->
329
- <!-- @serial is stamped on every fn during assembly; here we read it back. -->
326
+ <!-- Serial Numbers: Footnotes -->
327
+ <!-- We determine the appropriate subtree to count within -->
328
+ <!-- given the document root and the configured depth -->
329
+ <!-- @pi:serial is stamped on every fn during assembly; here we read it back. -->
330
330
  <xsl:template match="fn" mode="serial-number">
331
- <xsl:value-of select="@serial"/>
331
+ <xsl:value-of select="@pi:serial"/>
332
332
  </xsl:template>
333
333
 
334
334
  <!-- Serial Numbers: Subfigures, Subtables, Sublisting-->
@@ -363,7 +363,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
363
363
  <!-- First, the number of a list item within its own ordered list. This -->
364
364
  <!-- trades on the PTX format codes being identical to the XSLT codes. -->
365
365
  <xsl:template match="ol/li" mode="item-number">
366
- <xsl:variable name="code" select="../@format-code" />
366
+ <xsl:variable name="code" select="../@pi:format-code" />
367
367
  <xsl:number format="{$code}" />
368
368
  </xsl:template>
369
369
 
@@ -525,10 +525,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
525
525
  <xsl:number count="stage" from="static" />
526
526
  </xsl:template>
527
527
 
528
- <!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @serial, -->
529
- <!-- alongside the other block families above. Their structure number -->
530
- <!-- follows the figure/project pattern: the open-problem level when they -->
531
- <!-- run on a distinct counter, otherwise the shared "blocks" level. -->
528
+ <!-- OPENPROBLEM-LIKE are blocks: their serial number is read from @pi:serial, -->
529
+ <!-- alongside the other block families above. Their structure number -->
530
+ <!-- follows the figure/project pattern: the open-problem level when they -->
531
+ <!-- run on a distinct counter, otherwise the shared "blocks" level. -->
532
532
  <xsl:template match="&OPENPROBLEM-LIKE;" mode="structure-number">
533
533
  <xsl:variable name="openproblem-levels">
534
534
  <xsl:choose>
@@ -583,7 +583,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
583
583
  <!-- NB: this is number of the *container* of the division, -->
584
584
  <!-- a serial number for the division itself will be appended -->
585
585
  <xsl:template match="part|chapter|appendix|section|subsection|subsubsection|backmatter/solutions" mode="structure-number">
586
- <xsl:value-of select="@struct"/>
586
+ <xsl:value-of select="@pi:struct"/>
587
587
  </xsl:template>
588
588
 
589
589
  <!-- Structure Numbers: Specialized Divisions -->
@@ -598,7 +598,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
598
598
  </xsl:variable>
599
599
  <xsl:choose>
600
600
  <xsl:when test="$is-numbered = 'true'">
601
- <xsl:value-of select="@struct"/>
601
+ <xsl:value-of select="@pi:struct"/>
602
602
  </xsl:when>
603
603
  <xsl:otherwise>
604
604
  <xsl:apply-templates select="parent::*" mode="structure-number" />
@@ -863,7 +863,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
863
863
  <xsl:choose>
864
864
  <xsl:when test="$relative-level > $numbering-maxlevel" />
865
865
  <xsl:otherwise>
866
- <xsl:value-of select="@serial"/>
866
+ <xsl:value-of select="@pi:serial"/>
867
867
  </xsl:otherwise>
868
868
  </xsl:choose>
869
869
  </xsl:template>
@@ -881,7 +881,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
881
881
  <xsl:choose>
882
882
  <xsl:when test="$relative-level > $numbering-maxlevel" />
883
883
  <xsl:otherwise>
884
- <xsl:value-of select="@serial"/>
884
+ <xsl:value-of select="@pi:serial"/>
885
885
  </xsl:otherwise>
886
886
  </xsl:choose>
887
887
  </xsl:when>
@@ -592,7 +592,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
592
592
  <xsl:template match="m|md[mrow]">
593
593
  <xsl:choose>
594
594
  <xsl:when test="$b-reveal-embedded-math">
595
- <!-- NB: math-representation file writes with "visible-id" -->
595
+ <!-- NB: math-representation file writes with "unique-id" -->
596
596
  <xsl:variable name="id">
597
597
  <xsl:apply-templates select="." mode="unique-id"/>
598
598
  </xsl:variable>
@@ -5,10 +5,11 @@
5
5
  <xsl:stylesheet
6
6
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
7
7
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
8
+ xmlns:pi="http://pretextbook.org/2020/pretext/internal"
8
9
  xmlns:exsl="http://exslt.org/common"
9
10
  xmlns:date="http://exslt.org/dates-and-times"
10
11
  xmlns:str="http://exslt.org/strings"
11
- extension-element-prefixes="exsl date str"
12
+ extension-element-prefixes="pi exsl date str"
12
13
  >
13
14
 
14
15
  <xsl:variable name="b-include-postContent" select="true()"/>
@@ -18,12 +19,12 @@
18
19
  <!-- ==================================================== -->
19
20
 
20
21
  <!-- Convert fillin tag to an input element on the page -->
21
- <xsl:template match="exercise[@exercise-interactive='fillin']//fillin
22
- | project[@exercise-interactive='fillin']//fillin
23
- | activity[@exercise-interactive='fillin']//fillin
24
- | exploration[@exercise-interactive='fillin']//fillin
25
- | investigation[@exercise-interactive='fillin']//fillin
26
- | task[@exercise-interactive='fillin']//fillin">
22
+ <xsl:template match="exercise[@pi:exercise-interactive='fillin']//fillin
23
+ | project[@pi:exercise-interactive='fillin']//fillin
24
+ | activity[@pi:exercise-interactive='fillin']//fillin
25
+ | exploration[@pi:exercise-interactive='fillin']//fillin
26
+ | investigation[@pi:exercise-interactive='fillin']//fillin
27
+ | task[@pi:exercise-interactive='fillin']//fillin">
27
28
  <xsl:param name="b-human-readable" />
28
29
  <xsl:variable name="parent-id">
29
30
  <xsl:apply-templates select="ancestor::exercise" mode="html-id" />
@@ -61,12 +62,12 @@
61
62
  <!-- The HTML will contain this JSON and Runestone extracts it -->
62
63
  <!-- and inserts it into the HTML page via JS. -->
63
64
  <!-- ========================================================= -->
64
- <xsl:template match="exercise[@exercise-interactive='fillin']
65
- | project[@exercise-interactive='fillin']
66
- | activity[@exercise-interactive='fillin']
67
- | exploration[@exercise-interactive='fillin']
68
- | investigation[@exercise-interactive='fillin']
69
- | task[@exercise-interactive='fillin']" mode="runestone-to-interactive">
65
+ <xsl:template match="exercise[@pi:exercise-interactive='fillin']
66
+ | project[@pi:exercise-interactive='fillin']
67
+ | activity[@pi:exercise-interactive='fillin']
68
+ | exploration[@pi:exercise-interactive='fillin']
69
+ | investigation[@pi:exercise-interactive='fillin']
70
+ | task[@pi:exercise-interactive='fillin']" mode="runestone-to-interactive">
70
71
  <xsl:variable name="b-is-dynamic" select="boolean(./setup)"/>
71
72
  <div class="ptx-runestone-container">
72
73
  <div class="runestone">
@@ -47,11 +47,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
47
47
  <!-- before these templates are applied, so these should just -->
48
48
  <!-- produce the "body" of the exercise. -->
49
49
 
50
- <!-- The application of the "runestone-to-static" template is -->
51
- <!-- controlled by a surrounding "match" that limits elements -->
52
- <!-- to "exercise", PROJECT-LIKE, and soon "task". So the -->
53
- <!-- matches here are fine with a *[@exercise-interactive='foo'], -->
54
- <!-- as a convenience. -->
50
+ <!-- The application of the "runestone-to-static" template is -->
51
+ <!-- controlled by a surrounding "match" that limits elements -->
52
+ <!-- to "exercise", PROJECT-LIKE, and soon "task". So the -->
53
+ <!-- matches here are fine with a *[@pi:exercise-interactive='foo'], -->
54
+ <!-- as a convenience. -->
55
55
 
56
56
  <!-- These get-programming-language templates duplicate logic from pretext-common -->
57
57
  <!-- as the contents of that file are not available yet. -->
@@ -66,7 +66,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
66
66
  </xsl:choose>
67
67
  </xsl:template>
68
68
 
69
- <xsl:template match="*[@exercise-interactive = 'parson' or @exercise-interactive = 'parson-horizontal']" mode="get-programming-language">
69
+ <xsl:template match="*[@pi:exercise-interactive = 'parson' or @pi:exercise-interactive = 'parson-horizontal']" mode="get-programming-language">
70
70
  <xsl:choose>
71
71
  <xsl:when test="@language">
72
72
  <xsl:value-of select="@language" />
@@ -83,7 +83,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
83
83
 
84
84
  <!-- True/False -->
85
85
 
86
- <xsl:template match="*[@exercise-interactive = 'truefalse']" mode="runestone-to-static">
86
+ <xsl:template match="*[@pi:exercise-interactive = 'truefalse']" mode="runestone-to-static">
87
87
  <!-- metadata (idx, title) -->
88
88
  <xsl:copy-of select="statement/preceding-sibling::*"/>
89
89
  <!-- prompt, followed by ordered list of choices -->
@@ -149,7 +149,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
149
149
  </solution>
150
150
  </xsl:template>
151
151
 
152
- <xsl:template match="*[@exercise-interactive = 'multiplechoice']" mode="runestone-to-static">
152
+ <xsl:template match="*[@pi:exercise-interactive = 'multiplechoice']" mode="runestone-to-static">
153
153
  <!-- metadata (idx, title) -->
154
154
  <xsl:copy-of select="statement/preceding-sibling::*"/>
155
155
  <!-- prompt, followed by ordered list of choices -->
@@ -215,7 +215,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
215
215
  </solution>
216
216
  </xsl:template>
217
217
 
218
- <xsl:template match="*[@exercise-interactive = 'parson']" mode="runestone-to-static">
218
+ <xsl:template match="*[@pi:exercise-interactive = 'parson']" mode="runestone-to-static">
219
219
  <!-- determine these options before context switches -->
220
220
  <xsl:variable name="language">
221
221
  <!-- we just need the "raw" programming language, not active-language translation -->
@@ -532,7 +532,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
532
532
 
533
533
  <!-- Parson (Horizontal) -->
534
534
 
535
- <xsl:template match="*[@exercise-interactive = 'parson-horizontal']" mode="runestone-to-static">
535
+ <xsl:template match="*[@pi:exercise-interactive = 'parson-horizontal']" mode="runestone-to-static">
536
536
  <xsl:attribute name="language">
537
537
  <xsl:apply-templates select="." mode="active-language"/>
538
538
  </xsl:attribute>
@@ -610,7 +610,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
610
610
 
611
611
  <!-- Note how this template accomodates both types of problems -->
612
612
  <!-- by using match/select and modal template names effectively. -->
613
- <xsl:template match="*[@exercise-interactive = 'cardsort']|*[@exercise-interactive = 'matching']" mode="runestone-to-static">
613
+ <xsl:template match="*[@pi:exercise-interactive = 'cardsort']|*[@pi:exercise-interactive = 'matching']" mode="runestone-to-static">
614
614
  <!-- metadata (idx, title) -->
615
615
  <xsl:copy-of select="statement/preceding-sibling::*"/>
616
616
  <!-- Statement -->
@@ -826,7 +826,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
826
826
 
827
827
  <!-- Clickable Area -->
828
828
 
829
- <xsl:template match="*[@exercise-interactive = 'clickablearea']" mode="runestone-to-static">
829
+ <xsl:template match="*[@pi:exercise-interactive = 'clickablearea']" mode="runestone-to-static">
830
830
  <!-- metadata (idx, title) -->
831
831
  <xsl:copy-of select="statement/preceding-sibling::*"/>
832
832
  <!-- Statement -->
@@ -989,7 +989,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
989
989
 
990
990
  <!-- Select -->
991
991
 
992
- <xsl:template match="*[@exercise-interactive = 'select']" mode="runestone-to-static">
992
+ <xsl:template match="*[@pi:exercise-interactive = 'select']" mode="runestone-to-static">
993
993
  <!-- metadata (idx, title) -->
994
994
  <xsl:copy-of select="select/preceding-sibling::*"/>
995
995
 
@@ -1101,7 +1101,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1101
1101
 
1102
1102
  <!-- Fill-In the Blanks (Basic) -->
1103
1103
 
1104
- <xsl:template match="*[@exercise-interactive = 'fillin-basic']" mode="runestone-to-static">
1104
+ <xsl:template match="*[@pi:exercise-interactive = 'fillin-basic']" mode="runestone-to-static">
1105
1105
  <!-- metadata (idx, title) -->
1106
1106
  <xsl:copy-of select="statement/preceding-sibling::*"/>
1107
1107
  <!-- reproduce statement identically, but replace var w/ fillin -->
@@ -1212,7 +1212,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1212
1212
 
1213
1213
  <!-- Fill-In the Blanks (Complete) -->
1214
1214
 
1215
- <xsl:template match="*[@exercise-interactive = 'fillin']" mode="runestone-to-static">
1215
+ <xsl:template match="*[@pi:exercise-interactive = 'fillin']" mode="runestone-to-static">
1216
1216
  <!-- metadata (idx, title) -->
1217
1217
  <xsl:copy-of select="statement/preceding-sibling::*"/>
1218
1218
  <!-- reproduce statement identically, but replace var w/ fillin -->
@@ -1268,7 +1268,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1268
1268
  <!-- Short Answer -->
1269
1269
 
1270
1270
  <!-- Authored with a "response" element, we effectively drop it here -->
1271
- <xsl:template match="*[@exercise-interactive = 'shortanswer']" mode="runestone-to-static">
1271
+ <xsl:template match="*[@pi:exercise-interactive = 'shortanswer']" mode="runestone-to-static">
1272
1272
  <!-- metadata (idx, title) -->
1273
1273
  <xsl:copy-of select="statement/preceding-sibling::*"/>
1274
1274
  <!-- reproduce usual components -->
@@ -1345,7 +1345,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1345
1345
 
1346
1346
  <!-- Active Code -->
1347
1347
 
1348
- <xsl:template match="*[@exercise-interactive = 'coding']" mode="runestone-to-static">
1348
+ <xsl:template match="*[@pi:exercise-interactive = 'coding']" mode="runestone-to-static">
1349
1349
  <!-- metadata (idx, title) -->
1350
1350
  <xsl:copy-of select="statement/preceding-sibling::*"/>
1351
1351
  <statement>
@@ -751,7 +751,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
751
751
  <!-- efficient but has proven to be a popular spot for bugs. -->
752
752
  <xsl:template match="exercise|&PROJECT-LIKE;|task" mode="runestone-manifest">
753
753
  <xsl:variable name="manifestable-interactives-fenced">|truefalse|multiplechoice|parson|parson-horizontal|cardsort|matching|clickablearea|select|fillin-basic|fillin|coding|dual|shortanswer|webwork|</xsl:variable>
754
- <xsl:if test="contains($manifestable-interactives-fenced, concat('|', @exercise-interactive, '|'))">
754
+ <xsl:if test="contains($manifestable-interactives-fenced, concat('|', @pi:exercise-interactive, '|'))">
755
755
  <question>
756
756
  <!-- A divisional exercise ("exercises/../exercise") is not really -->
757
757
  <!-- a reading activity in the Runestone model, so we flag these -->
@@ -762,8 +762,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
762
762
  <!-- value to "yes" and never bother to say "no". The only -->
763
763
  <!-- consumer is the import into the Runestone database, so any -->
764
764
  <!-- change needs only coordinate there. -->
765
- <xsl:if test="(@exercise-customization = 'divisional') or
766
- (self::task and ancestor::exercise[@exercise-customization = 'divisional'])">
765
+ <xsl:if test="(@pi:exercise-customization = 'divisional') or
766
+ (self::task and ancestor::exercise[@pi:exercise-customization = 'divisional'])">
767
767
  <xsl:attribute name="optional">
768
768
  <xsl:text>yes</xsl:text>
769
769
  </xsl:attribute>
@@ -779,7 +779,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
779
779
  <xsl:apply-templates select="." mode="eg-introduction"/>
780
780
  <xsl:choose>
781
781
  <!-- with "webwork" guts, the HTML is exceptional -->
782
- <xsl:when test="@exercise-interactive = 'webwork'">
782
+ <xsl:when test="@pi:exercise-interactive = 'webwork'">
783
783
  <xsl:apply-templates select="." mode="webwork-core">
784
784
  <xsl:with-param name="b-original" select="true()"/>
785
785
  <xsl:with-param name="heading-level" select="3"/>
@@ -814,13 +814,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
814
814
  </htmlsrc>
815
815
  </question>
816
816
  </xsl:if>
817
- <!-- The match for this template will include "exercise" and &PROJECT-LIKE -->
818
- <!-- that are just containers for a bunch of "task". In other words, they -->
819
- <!-- will not be marked with the "@exercise-interactive" attribute. So the -->
820
- <!-- "xsl:if" above will fail. And right here is a dead-end. We need to -->
821
- <!-- recurse into "task" for the possibility they are marked with -->
822
- <!-- "@exercise-interactive" so they can potentially get placed properly in -->
823
- <!-- the manifest. -->
817
+ <!-- The match for this template will include "exercise" and &PROJECT-LIKE -->
818
+ <!-- that are just containers for a bunch of "task". In other words, they -->
819
+ <!-- will not be marked with the "@pi:exercise-interactive" attribute. So the -->
820
+ <!-- "xsl:if" above will fail. And right here is a dead-end. We need to -->
821
+ <!-- recurse into "task" for the possibility they are marked with -->
822
+ <!-- "@pi:exercise-interactive" so they can potentially get placed properly in -->
823
+ <!-- the manifest. -->
824
824
  <xsl:apply-templates select="task" mode="runestone-manifest"/>
825
825
  </xsl:template>
826
826
 
@@ -987,15 +987,15 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
987
987
  <!-- "regular" PreTeXt statement together with some additional -->
988
988
  <!-- interactive material to make a hybrid "statement" -->
989
989
 
990
- <!-- The application of the "runestone-to-interactive" template is -->
991
- <!-- controlled by a surrounding "match" that limits elements -->
992
- <!-- to "exercise", PROJECT-LIKE, and soon "task". So the -->
993
- <!-- matches here are fine with a *[@exercise-interactive='foo'], -->
994
- <!-- as a convenience. -->
990
+ <!-- The application of the "runestone-to-interactive" template is -->
991
+ <!-- controlled by a surrounding "match" that limits elements -->
992
+ <!-- to "exercise", PROJECT-LIKE, and soon "task". So the -->
993
+ <!-- matches here are fine with a *[@pi:exercise-interactive='foo'], -->
994
+ <!-- as a convenience. -->
995
995
 
996
996
  <!-- True/False -->
997
997
 
998
- <xsl:template match="*[@exercise-interactive = 'truefalse']" mode="runestone-to-interactive">
998
+ <xsl:template match="*[@pi:exercise-interactive = 'truefalse']" mode="runestone-to-interactive">
999
999
  <div class="ptx-runestone-container">
1000
1000
  <div class="runestone multiplechoice_section">
1001
1001
  <!-- ul can have multiple answer attribute -->
@@ -1051,7 +1051,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1051
1051
 
1052
1052
  <!-- Multiple Choice -->
1053
1053
 
1054
- <xsl:template match="*[@exercise-interactive = 'multiplechoice']" mode="runestone-to-interactive">
1054
+ <xsl:template match="*[@pi:exercise-interactive = 'multiplechoice']" mode="runestone-to-interactive">
1055
1055
  <div class="ptx-runestone-container">
1056
1056
  <div class="runestone multiplechoice_section">
1057
1057
  <!-- overall statement, not per-choice -->
@@ -1126,7 +1126,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1126
1126
 
1127
1127
  <!-- Parsons Problem -->
1128
1128
 
1129
- <xsl:template match="*[@exercise-interactive = 'parson']" mode="runestone-to-interactive">
1129
+ <xsl:template match="*[@pi:exercise-interactive = 'parson']" mode="runestone-to-interactive">
1130
1130
  <!-- active-language only used if runnable but needed multiple places -->
1131
1131
  <xsl:variable name="active-language">
1132
1132
  <xsl:apply-templates select="." mode="active-language"/>
@@ -1392,7 +1392,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1392
1392
 
1393
1393
  <!-- Parsons Problem (Horizontal)-->
1394
1394
 
1395
- <xsl:template match="*[@exercise-interactive = 'parson-horizontal']" mode="runestone-to-interactive">
1395
+ <xsl:template match="*[@pi:exercise-interactive = 'parson-horizontal']" mode="runestone-to-interactive">
1396
1396
  <!-- determine these options before context switches -->
1397
1397
  <xsl:variable name="active-language">
1398
1398
  <xsl:apply-templates select="." mode="active-language"/>
@@ -1617,7 +1617,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1617
1617
 
1618
1618
  <!-- Carsort Problem -->
1619
1619
 
1620
- <xsl:template match="*[@exercise-interactive = 'cardsort']" mode="runestone-to-interactive">
1620
+ <xsl:template match="*[@pi:exercise-interactive = 'cardsort']" mode="runestone-to-interactive">
1621
1621
  <div class="ptx-runestone-container">
1622
1622
  <div class="runestone cardsort_section">
1623
1623
  <ul data-component="dragndrop" data-question_label="" style="visibility: hidden;">
@@ -1683,7 +1683,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1683
1683
 
1684
1684
  <!-- Matching Problem -->
1685
1685
 
1686
- <xsl:template match="*[@exercise-interactive = 'matching']" mode="runestone-to-interactive">
1686
+ <xsl:template match="*[@pi:exercise-interactive = 'matching']" mode="runestone-to-interactive">
1687
1687
  <div class="ptx-runestone-container">
1688
1688
  <div data-component="matching" class="runestone">
1689
1689
  <xsl:apply-templates select="." mode="runestone-id-attribute"/>
@@ -1786,7 +1786,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1786
1786
 
1787
1787
  <!-- Clickable Area Problem -->
1788
1788
 
1789
- <xsl:template match="*[@exercise-interactive = 'clickablearea']" mode="runestone-to-interactive">
1789
+ <xsl:template match="*[@pi:exercise-interactive = 'clickablearea']" mode="runestone-to-interactive">
1790
1790
  <div class="ptx-runestone-container">
1791
1791
  <div class="runestone clickablearea_section">
1792
1792
  <div data-component="clickablearea" data-question_label="" style="visibility: hidden;">
@@ -1864,7 +1864,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1864
1864
  <!-- * Question List - several equivalent problems, -->
1865
1865
  <!-- reader is assigned just one (good for exams) -->
1866
1866
  <!-- * A/B Experiment - two choices, experiment managed by Runestone -->
1867
- <xsl:template match="*[@exercise-interactive = 'select']" mode="runestone-to-interactive">
1867
+ <xsl:template match="*[@pi:exercise-interactive = 'select']" mode="runestone-to-interactive">
1868
1868
  <!-- identify the type of "select" -->
1869
1869
  <!-- duplicated in "pretext-runestone-static.xsl" -->
1870
1870
  <xsl:variable name="select-variant">
@@ -1946,7 +1946,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
1946
1946
  <!-- Fill-in-the-Blanks problem -->
1947
1947
 
1948
1948
  <!-- Runestone structure -->
1949
- <xsl:template match="*[@exercise-interactive = 'fillin-basic']" mode="runestone-to-interactive">
1949
+ <xsl:template match="*[@pi:exercise-interactive = 'fillin-basic']" mode="runestone-to-interactive">
1950
1950
  <div class="ptx-runestone-container">
1951
1951
  <div class="runestone fillintheblank_section">
1952
1952
  <!-- dropped "visibility: hidden" on next div -->
@@ -2093,7 +2093,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2093
2093
 
2094
2094
  <!-- Coding exercise -->
2095
2095
 
2096
- <xsl:template match="*[@exercise-interactive = 'coding']" mode="runestone-to-interactive">
2096
+ <xsl:template match="*[@pi:exercise-interactive = 'coding']" mode="runestone-to-interactive">
2097
2097
  <!-- We don't have a 'coding' attribute value -->
2098
2098
  <!-- unless one of the two tests below is true -->
2099
2099
  <xsl:choose>
@@ -2114,7 +2114,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2114
2114
  <!-- Dual Form exercise (dynamic/static)-->
2115
2115
 
2116
2116
  <!-- 2025-11-11: Runestone HTML is speculative -->
2117
- <xsl:template match="*[@exercise-interactive = 'dual']" mode="runestone-to-interactive">
2117
+ <xsl:template match="*[@pi:exercise-interactive = 'dual']" mode="runestone-to-interactive">
2118
2118
  <div class="ptx-runestone-container">
2119
2119
  <div class="runestone dualquestion_section">
2120
2120
  <div data-component="dual">
@@ -2135,7 +2135,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2135
2135
  <!-- interactive, see "static" v. "dynamic" publisher variables. -->
2136
2136
  <!-- NB - not currently applying to short-form with no "statement" -->
2137
2137
  <!-- NB: match is recycled in manifest formation -->
2138
- <xsl:template match="*[@exercise-interactive = 'shortanswer']" mode="runestone-to-interactive">
2138
+ <xsl:template match="*[@pi:exercise-interactive = 'shortanswer']" mode="runestone-to-interactive">
2139
2139
  <xsl:choose>
2140
2140
  <xsl:when test="$b-host-runestone or ($short-answer-responses = 'always')">
2141
2141
  <!-- when "response" has attributes, perhaps they get interpreted here -->
@@ -2870,7 +2870,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
2870
2870
  <!-- Runestone Components play nicely with this device, along with more -->
2871
2871
  <!-- boring exercises. -->
2872
2872
 
2873
- <xsl:template match="exercise[task and not(@exercise-customization = 'worksheet')]|&PROJECT-LIKE;" mode="tabbed-tasks">
2873
+ <xsl:template match="exercise[task and not(@pi:exercise-customization = 'worksheet')]|&PROJECT-LIKE;" mode="tabbed-tasks">
2874
2874
  <xsl:param name="heading-level"/>
2875
2875
  <div class="ptx-runestone-container">
2876
2876
  <div>
@@ -3037,7 +3037,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3037
3037
  <!-- frequently point to other Runestone components in the database. -->
3038
3038
  <!-- * Authors point in their source with @xml:id -->
3039
3039
  <!-- values in a space- or comma- separated list -->
3040
- <!-- * We locate the targets in the orginal source -->
3040
+ <!-- * We locate the targets in the assembled tree, where a -->
3041
+ <!-- database id (a @label) exists even when only an @xml:id -->
3042
+ <!-- was authored (a backward-compatibility promotion) -->
3041
3043
  <!-- * Compute the Runestone database id -->
3042
3044
  <!-- * Return a list (varying separator) to use in Runestone HTML. -->
3043
3045
  <xsl:template name="runestone-targets">
@@ -3053,7 +3055,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
3053
3055
  <xsl:value-of select="."/>
3054
3056
  </xsl:variable>
3055
3057
  <!-- context shift so id() functions properly -->
3056
- <xsl:for-each select="$original">
3058
+ <xsl:for-each select="$root">
3057
3059
  <xsl:variable name="target" select="id($the-id)"/>
3058
3060
  <xsl:if test="not($target)">
3059
3061
  <xsl:message>PTX:ERROR: an @xml:id value "<xsl:value-of select="$the-id"/>" was used to specify a runestone component but no item with that id exists.</xsl:message>
@@ -33,8 +33,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
33
33
  <!-- xmlns="http://www.w3.org/1999/xhtml" -->
34
34
  <xsl:stylesheet
35
35
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
36
+ xmlns:pi="http://pretextbook.org/2020/pretext/internal"
36
37
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
37
38
  xmlns:exsl="http://exslt.org/common"
39
+ exclude-result-prefixes="pi"
38
40
  extension-element-prefixes="exsl"
39
41
  >
40
42
 
@@ -66,7 +68,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
66
68
  <!-- their source. So at the last minute, while creating text versions -->
67
69
  <!-- of source material, we kill it. Any similar leakage could be -->
68
70
  <!-- handled the same way. -->
69
- <xsl:template match="@original-id" mode="xml-to-string"/>
71
+ <xsl:template match="@pi:original-id" mode="xml-to-string"/>
70
72
 
71
73
 
72
74
  <!-- N.B.: the -assembly stylesheet first construct a "version" which -->
@@ -92,11 +94,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
92
94
  <xsl:if test="$b-view-source and not($b-banned)">
93
95
  <!-- Part 1: Serialize the source -->
94
96
  <!-- Save off the id of the element being annotated -->
95
- <xsl:variable name="the-element-id" select="@original-id"/>
97
+ <xsl:variable name="the-element-id" select="@pi:original-id"/>
96
98
  <!-- Locate the element with the same id, but in a very early -->
97
99
  <!-- pass of the assembly stylesheet, so with as little (no?) -->
98
100
  <!-- extraneous manufactured markup as possible. -->
99
- <xsl:variable name="original-element" select="$original-labeled//*[@original-id = $the-element-id]"/>
101
+ <xsl:variable name="original-element" select="$original-labeled//*[@pi:original-id = $the-element-id]"/>
100
102
  <!-- Just for convenience, capture highly sanitized text -->
101
103
  <!-- version of the XML source within a variable. -->
102
104
  <!-- -->
@@ -155,6 +155,11 @@
155
155
  </xsl:template>
156
156
 
157
157
  <!-- For copied problems move to the problem that was copied -->
158
+ <!-- NB: this @copied-from is a plain attribute, not a "pi" -->
159
+ <!-- namespace stamp: it arrives via the representations -->
160
+ <!-- file, an interchange format written by the Python -->
161
+ <!-- routines, and is promoted onto "webwork" elements when -->
162
+ <!-- the representations merge into the tree. -->
158
163
  <xsl:template match="webwork[@copied-from]" mode="relative-filename">
159
164
  <xsl:variable name="copied-from" select="@copied-from"/>
160
165
  <xsl:apply-templates select="$document-root//webwork[@xml:id=$copied-from]" mode="relative-filename"/>
@@ -370,7 +375,7 @@
370
375
  </xsl:text><xsl:choose><xsl:when test="$document-root//frontmatter/colophon/website"><xsl:text>
371
376
  TEXT(MODES(
372
377
  TeX =>"\noindent This assignment contains exercises from </xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text> of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>.",
373
- HTML=>"This assignment contains exercises from ".htmlLink(qq!</xsl:text><xsl:apply-templates select="$document-root//frontmatter/colophon/website/url/@href" /><xsl:text>/</xsl:text><xsl:apply-templates select="." mode="visible-id" /><xsl:text>.html!,"</xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text>")." of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>."
378
+ HTML=>"This assignment contains exercises from ".htmlLink(qq!</xsl:text><xsl:apply-templates select="$document-root//frontmatter/colophon/website/url/@href" /><xsl:text>/</xsl:text><xsl:apply-templates select="." mode="unique-id" /><xsl:text>.html!,"</xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text>")." of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>."
374
379
  ));
375
380
  </xsl:text></xsl:when><xsl:otherwise><xsl:text>
376
381
  TEXT("This assignment contains exercises from </xsl:text><xsl:apply-templates select="." mode="type-name" /><xsl:text> </xsl:text><xsl:apply-templates select="." mode="number" /><xsl:text> of </xsl:text><xsl:apply-templates select="$document-root" mode="title-simple" /><xsl:text>.");