@pretextbook/pretext-html 0.4.0 → 0.6.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 (44) hide show
  1. package/README.md +92 -1
  2. package/assets/preview-html.xsl +14 -0
  3. package/assets/preview-revealjs.xsl +85 -0
  4. package/assets/upstream.json +1 -1
  5. package/assets/xsl/LICENSE-pretext +16 -0
  6. package/assets/xsl/entities.ent +7 -0
  7. package/assets/xsl/extract-biblio-csl.xsl +5 -3
  8. package/assets/xsl/extract-dynamic.xsl +14 -12
  9. package/assets/xsl/extract-interactive.xsl +2 -2
  10. package/assets/xsl/extract-pg.xsl +12 -9
  11. package/assets/xsl/extract-qrcode.xsl +1 -1
  12. package/assets/xsl/extract-trace.xsl +3 -3
  13. package/assets/xsl/extract-youtube.xsl +1 -1
  14. package/assets/xsl/latex/pretext-latex-texstyle.xsl +3 -3
  15. package/assets/xsl/pretext-assembly.xsl +362 -357
  16. package/assets/xsl/pretext-braille-preprint.xsl +1 -1
  17. package/assets/xsl/pretext-common.xsl +101 -90
  18. package/assets/xsl/pretext-epub.xsl +17 -6
  19. package/assets/xsl/pretext-fo.xsl +10 -10
  20. package/assets/xsl/pretext-html.xsl +83 -60
  21. package/assets/xsl/pretext-latex-common.xsl +8 -8
  22. package/assets/xsl/pretext-numbers.xsl +35 -35
  23. package/assets/xsl/pretext-revealjs.xsl +1 -1
  24. package/assets/xsl/pretext-runestone-fitb.xsl +14 -13
  25. package/assets/xsl/pretext-runestone-static.xsl +17 -17
  26. package/assets/xsl/pretext-runestone.xsl +33 -31
  27. package/assets/xsl/pretext-view-source.xsl +5 -3
  28. package/assets/xsl/pretext-ww-problem-sets.xsl +6 -1
  29. package/assets/xsl/publisher-variables.xsl +23 -47
  30. package/assets/xsl-bundle.json +1 -1
  31. package/dist/cli-DF7XOWN7.js +724 -0
  32. package/dist/cli.js +1 -1
  33. package/dist/index.browser.d.ts +6 -0
  34. package/dist/index.browser.js +501 -332
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.js +25 -19
  37. package/dist/knowls.d.ts +43 -0
  38. package/dist/publication.d.ts +25 -19
  39. package/dist/renderer.d.ts +61 -0
  40. package/dist/reveal.d.ts +77 -0
  41. package/dist/reveal.js +110 -0
  42. package/dist/target.d.ts +34 -0
  43. package/package.json +12 -1
  44. package/dist/cli-Cp6C0sif.js +0 -654
package/README.md CHANGED
@@ -84,6 +84,12 @@ const { html } = await renderHtml({
84
84
  ~100ms–1s per render depending on document size).
85
85
  - `theme: "dark" | "light" | "system"` makes the preview follow the embedding
86
86
  app's light/dark theme (see [Theme control](#theme-control)).
87
+ - Born-hidden knowls — solutions, hints, answers, and any block the publication
88
+ file elects to hide — are rendered **expanded**, because these pages are
89
+ previews: an author editing a solution would otherwise watch it collapse on
90
+ every re-render. Other `<details>` (footnotes, image descriptions) are left
91
+ alone. Pass `openKnowls: false` (`--no-open-knowls` on the CLI) for the
92
+ collapsed reading experience of a real `pretext build`.
87
93
 
88
94
  ### API (browser)
89
95
 
@@ -172,6 +178,87 @@ its native `localStorage`/`prefers-color-scheme` behaviour. The
172
178
  `isPreviewTheme`) with no dependency on the renderer, so a host can import just
173
179
  the message helper.
174
180
 
181
+ ### Slideshows (reveal.js)
182
+
183
+ A document whose top-level element is `<slideshow>` is rendered as a
184
+ [reveal.js](https://revealjs.com) deck instead, through PreTeXt's own
185
+ `pretext-revealjs.xsl`. Detection is automatic — there is nothing to turn on —
186
+ and `RenderResult.target` reports which conversion ran.
187
+
188
+ ```js
189
+ import { renderHtml } from "@pretextbook/pretext-html";
190
+ // dependency-free subpath, like ./theme:
191
+ import { injectRevealBridge } from "@pretextbook/pretext-html/reveal";
192
+
193
+ const { html, target } = await renderHtml({
194
+ sourcePath: "source/slides.ptx",
195
+ revealView: "scroll", // the default: whole deck as one scrolling page
196
+ revealTheme: "black", // fallback only; the project's own theme wins
197
+ revealZoom: 1, // content size vs. presented size (scroll view)
198
+ });
199
+ target; // "slides"
200
+
201
+ // Switch to the ordinary presentation later — no re-render, just re-inject:
202
+ const presenting = injectRevealBridge(html, "slides");
203
+ ```
204
+
205
+ Two things are forced on a slideshow render, overriding the publication file,
206
+ because the alternatives cannot work without the Python toolchain:
207
+ `revealjs/resources/@host` becomes `cdn` (a `local` host points at a `dist/`
208
+ tree that was never copied anywhere; `embedded` expects a post-processing step
209
+ that never runs), and `@math` becomes `online` (embedded mathematics is
210
+ prebuilt SVG passed in through the `mathfile` parameter, and without it a deck
211
+ renders with its mathematics silently missing). Everything else — theme,
212
+ navigation mode, controls — stays as the project authored it.
213
+
214
+ The scroll view is tuned for reading a deck rather than presenting it. It lays
215
+ slides out at reveal's nominal **960×700** and scales them to fit, stacks them
216
+ with `scrollLayout: "compact"` and an outline around each, and shows every
217
+ `@pause`/`<subslide>` fragment at once so scrolling is not interrupted. Switch
218
+ to `revealView: "slides"` to see the pauses step through as they will when
219
+ presented.
220
+
221
+ Showing the pauses at once takes more than `fragments: false`, which is worth
222
+ knowing if you ever touch this: the scroll view counts its scroll steps with
223
+ `querySelectorAll('.fragment')` and never consults that setting, so the config
224
+ alone makes fragments _visible_ while reveal still adds a scroll step — and a
225
+ full `scrollTriggerHeight` of padding — for each one. Compact layout compounds
226
+ it, because a page with any scroll trigger reverts to a full-viewport height.
227
+ A slide with two pauses ends up roughly three screens tall. The injected script
228
+ therefore removes the `fragment` class outright before `initialize` runs.
229
+
230
+ The nominal size is worth understanding, because it is the one override that
231
+ changes how a deck _looks_: PreTeXt publishes `width: "100%", height: "100%"`,
232
+ and reveal resolves a percentage against the presentation element — so the
233
+ slide becomes exactly as large as whatever is showing it, the computed scale is
234
+ always 1, and no downscaling ever happens. Full screen that is fine; in an
235
+ editor pane it means text sized for a 960px slide is drawn at full size into a
236
+ fraction of that width. Giving reveal a real deck size to scale from restores
237
+ the proportions a full-screen presentation will have.
238
+
239
+ `revealZoom` then works _in slide units_, dividing that nominal size rather than
240
+ shrinking the slide on screen — `0.5` gives a 1920×1400 slide. This is the only
241
+ arrangement that behaves like zooming out on a web page. Reveal lays content out
242
+ in slide units and scales the whole slide to fit, so a smaller _box_ fits
243
+ exactly the same content and clips exactly the same overflow; a larger box
244
+ leaves the slide the same size on screen (reveal simply scales it down further)
245
+ while fixed-pixel text occupies proportionally less of it. Since reveal clips
246
+ whatever runs past the bottom of a slide, with no way to scroll to it, zooming
247
+ out is the only way to read content that does not fit — which is also why the
248
+ default is `1`, where the deck, overflow included, looks exactly as it will when
249
+ presented.
250
+
251
+ Two further notes:
252
+
253
+ - **`RenderOptions.theme` does nothing for a deck.** reveal.js pages load none
254
+ of the PreTeXt javascript behind light/dark mode, so there is no
255
+ `setDarkMode` to drive. Pick a light or dark **reveal** theme with
256
+ `revealTheme` instead.
257
+ - **Views are baked in at render time.** reveal reads `view` once, when it
258
+ initializes, so `injectRevealBridge` returns a new page rather than talking
259
+ to a live deck — deliver it as a fresh document (`webview.html = …`, not an
260
+ in-place rewrite) for the change to take.
261
+
175
262
  ## Requirements
176
263
 
177
264
  - **Node ≥ 24** launched with **`--experimental-wasm-jspi`** (WebAssembly
@@ -202,7 +289,11 @@ the message helper.
202
289
  other file-writing templates are stubbed. The wrapper is **generated** by
203
290
  `scripts/refresh-xsl.mjs`, which also audits every `exsl:document` site
204
291
  reachable from `pretext-html.xsl` and fails if upstream adds a writer we
205
- don't cover.
292
+ don't cover. `assets/preview-revealjs.xsl` is the slideshow counterpart and
293
+ is far thinner: `pretext-revealjs.xsl` already emits one monolithic page, so
294
+ there is no template to copy — it only stubs the same file writers (a slide
295
+ holding an `<interactive>` really does reach one) and stamps `@id` onto
296
+ slides, via `apply-imports` so no upstream markup is duplicated.
206
297
  3. **Virtual-host fetch shim** — the WASM build has no filesystem
207
298
  (`FILESYSTEM=0`); every resource load (stylesheet imports, `document()`
208
299
  calls, the publication file) goes through the global `fetch`. We mount
@@ -210,6 +210,20 @@
210
210
 
211
211
  </xsl:template>
212
212
 
213
+ <!-- Show the print-preview button on printouts, but inert: the page it would -->
214
+ <!-- reload with "?printpreview=<id>" does not exist for an in-memory render, -->
215
+ <!-- and a host that resolves that query against its own URL sends the reader -->
216
+ <!-- somewhere unrelated. See PRINTOUT_LINK_OVERRIDE in refresh-xsl.mjs. -->
217
+ <xsl:template match="*" mode="standalone-printout-links">
218
+ <div class="print-links">
219
+ <a class="print-link" style="opacity:0.45;cursor:default" aria-disabled="true" title="Print preview is not available in the live preview">
220
+ <xsl:call-template name="insert-symbol">
221
+ <xsl:with-param name="name" select="'print'"/>
222
+ </xsl:call-template>
223
+ </a>
224
+ </div>
225
+ </xsl:template>
226
+
213
227
  <!-- Stub out the remaining file writers (every other template reachable -->
214
228
  <!-- from pretext-html.xsl that contains exsl:document). Under portable- -->
215
229
  <!-- html several of these are already suppressed; the stubs cover the -->
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ GENERATED FILE - do not edit by hand.
4
+ Regenerate with: npm run refresh-xsl -w @pretextbook/pretext-html
5
+
6
+ Wrapper around pretext-revealjs.xsl for in-memory reveal.js slideshow builds
7
+ (previews). The reveal.js conversion is already a single-page conversion, so
8
+ unlike preview-html.xsl this copies no upstream template: it stubs the file
9
+ writers (which a slide holding an "interactive" would otherwise trip) and
10
+ stamps the ids the preview's source map needs onto slides and sections.
11
+
12
+ Intended to be applied together with a publication file that forces
13
+ <revealjs><resources host="cdn" math="online"/></revealjs>, since neither
14
+ locally hosted nor embedded reveal.js resources exist for an in-memory build.
15
+ -->
16
+ <xsl:stylesheet
17
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
18
+ xmlns:exsl="http://exslt.org/common"
19
+ extension-element-prefixes="exsl"
20
+ >
21
+
22
+ <xsl:import href="pretext-revealjs.xsl"/>
23
+ <xsl:output method="html" encoding="UTF-8" doctype-system="about:legacy-compat"/>
24
+
25
+ <!-- Stamp @id onto the reveal.js "section" that upstream builds for each -->
26
+ <!-- slide (and each section of slides), without reproducing any of the -->
27
+ <!-- upstream markup: render it via apply-imports, then re-emit the result -->
28
+ <!-- with the id added to its first element. The id is the same @unique-id -->
29
+ <!-- the rest of PreTeXt's HTML uses, which is what makes it findable from -->
30
+ <!-- the source map. Attributes are copied before the id is set, so an -->
31
+ <!-- upstream id (if one is ever added) is overridden rather than -->
32
+ <!-- duplicated, and both precede any child content, as XSLT requires. -->
33
+ <!-- -->
34
+ <!-- Only the *first* element is stamped, because a "section" does not always -->
35
+ <!-- render as one element: under the "linear" navigation mode upstream emits -->
36
+ <!-- the section's title slide followed by its slides as siblings. Those -->
37
+ <!-- slides were rendered through this same template and carry their own ids -->
38
+ <!-- already, so stamping every top-level element would duplicate the -->
39
+ <!-- section's id across all of them. -->
40
+ <xsl:template match="slide|section">
41
+ <xsl:variable name="preview-id">
42
+ <xsl:apply-templates select="." mode="html-id"/>
43
+ </xsl:variable>
44
+ <xsl:variable name="rendered">
45
+ <xsl:apply-imports/>
46
+ </xsl:variable>
47
+ <!-- Bound once: two exsl:node-set calls on one fragment are not obliged -->
48
+ <!-- to yield the same node identities, which the comparison relies on. -->
49
+ <xsl:variable name="tree" select="exsl:node-set($rendered)"/>
50
+ <xsl:for-each select="$tree/node()">
51
+ <xsl:choose>
52
+ <xsl:when test="generate-id() = generate-id($tree/*[1])">
53
+ <xsl:copy>
54
+ <xsl:copy-of select="@*"/>
55
+ <xsl:attribute name="id">
56
+ <xsl:value-of select="$preview-id"/>
57
+ </xsl:attribute>
58
+ <xsl:copy-of select="node()"/>
59
+ </xsl:copy>
60
+ </xsl:when>
61
+ <xsl:otherwise>
62
+ <xsl:copy-of select="."/>
63
+ </xsl:otherwise>
64
+ </xsl:choose>
65
+ </xsl:for-each>
66
+ </xsl:template>
67
+
68
+ <!-- Same file-writer stubs as preview-html.xsl; see FILE_WRITER_STUBS. -->
69
+ <xsl:template name="index-redirect-page"/>
70
+ <xsl:template match="*" mode="manufacture-knowl"/>
71
+ <xsl:template name="ol-marker-styles"/>
72
+ <xsl:template name="doc-manifest"/>
73
+ <xsl:template name="search-page-construction"/>
74
+ <xsl:template name="scorm-manifest"/>
75
+ <!-- standalone pages for videos and iframe pages for interactives -->
76
+ <xsl:template match="*" mode="standalone-page"/>
77
+ <xsl:template match="*" mode="create-iframe-page"/>
78
+ <!-- runestone-manifest lives in pretext-runestone.xsl -->
79
+ <xsl:template match="*" mode="runestone-manifest"/>
80
+ <xsl:template match="*" mode="simple-file-wrap">
81
+ <xsl:param name="content"/>
82
+ <xsl:copy-of select="$content"/>
83
+ </xsl:template>
84
+
85
+ </xsl:stylesheet>
@@ -3,5 +3,5 @@
3
3
  "repository": "PreTeXtBook/pretext",
4
4
  "ref": "master"
5
5
  },
6
- "refreshed": "2026-07-26T23:26:59.210Z"
6
+ "refreshed": "2026-07-29T17:38:58.196Z"
7
7
  }
@@ -0,0 +1,16 @@
1
+ Copyright 2013 Robert A. Beezer
2
+
3
+ This file is part of PreTeXt.
4
+
5
+ PreTeXt is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 2 or version 3 of the
8
+ License (at your option).
9
+
10
+ PreTeXt is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
@@ -37,6 +37,11 @@
37
37
 
38
38
  <!ENTITY SPECIALIZED-DIVISION "exercises|worksheet|handout|reading-questions|references|glossary|solutions">
39
39
 
40
+ <!-- A "printout" is a specialized division whose content is laid out -->
41
+ <!-- for printing, with workspace for a reader to write. A collection -->
42
+ <!-- of nothing but printouts is a "workbook". -->
43
+ <!ENTITY PRINTOUT "worksheet|handout">
44
+
40
45
  <!-- "Division companions" are the non-structural companions of a -->
41
46
  <!-- structured traditional division: they may earn their own page -->
42
47
  <!-- (and links) when their parent is realized as a summary page in -->
@@ -52,6 +57,8 @@
52
57
 
53
58
  <!ENTITY SPECIALIZED-DIVISION-FILTER "self::exercises or self::worksheet or self::handout or self::reading-questions or self::references or self::glossary or self::solutions">
54
59
 
60
+ <!ENTITY PRINTOUT-FILTER "self::worksheet or self::handout">
61
+
55
62
  <!ENTITY DIVISION-COMPANION-FILTER "self::introduction or self::conclusion or self::objectives or self::outcomes">
56
63
 
57
64
  <!-- NB: (2019-06-12) Only the two metadata "filters" seem to -->
@@ -296,8 +296,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
296
296
  <xsl:variable name="the-ref">
297
297
  <xsl:value-of select="."/>
298
298
  </xsl:variable>
299
- <!-- context switch so id() function works -->
300
- <xsl:for-each select="$original">
299
+ <!-- context switch so id() function works; the assembled -->
300
+ <!-- tree, so content excluded by the version in play does -->
301
+ <!-- not validate a citation -->
302
+ <xsl:for-each select="$root">
301
303
  <xsl:variable name="target" select="id($the-ref)"/>
302
304
  <!-- vet each @ref value, only backmatter is considered -->
303
305
  <xsl:if test="$target/self::biblio/parent::references/parent::backmatter">
@@ -317,7 +319,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
317
319
  <xsl:element name="xref-csl" namespace="http://pretextbook.org/2020/pretext/internal">
318
320
  <!-- namespacing the attribute is sort of ugly -->
319
321
  <xsl:attribute name="id">
320
- <xsl:value-of select="@assembly-id"/>
322
+ <xsl:value-of select="@pi:assembly-id"/>
321
323
  </xsl:attribute>
322
324
  <xsl:value-of select="$citation-item-list"/>
323
325
  </xsl:element>
@@ -23,9 +23,11 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
23
23
  <!-- dynamic content. Create a standalone page for each. -->
24
24
 
25
25
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
26
+ xmlns:pi="http://pretextbook.org/2020/pretext/internal"
26
27
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
27
28
  xmlns:exsl="http://exslt.org/common"
28
29
  xmlns:str="http://exslt.org/strings"
30
+ exclude-result-prefixes="pi"
29
31
  extension-element-prefixes="exsl"
30
32
  >
31
33
 
@@ -69,7 +71,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
69
71
  <!-- exercise/setup indicates the exercise will -->
70
72
  <!-- require Runestone and javascript to generate -->
71
73
  <!-- the content. -->
72
- <!-- Stylesheet output is text, with "visible-id" -->
74
+ <!-- Stylesheet output is text, with "unique-id" -->
73
75
  <!-- of each exercise, one per line, to be captured -->
74
76
  <!-- captured in a text file to guide snapshotting -->
75
77
  <!-- Make the standalone page for each exercise -->
@@ -82,21 +84,21 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
82
84
  <xsl:text>]</xsl:text>
83
85
  </xsl:template>
84
86
 
85
- <xsl:template match="exercise[@exercise-interactive='fillin' and setup]
86
- | project[@exercise-interactive='fillin' and setup]
87
- | activity[@exercise-interactive='fillin' and setup]
88
- | exploration[@exercise-interactive='fillin' and setup]
89
- | investigation[@exercise-interactive='fillin' and setup]
90
- | exercise//task[@exercise-interactive='fillin' and setup]
91
- | project//task[@exercise-interactive='fillin' and setup]
92
- | activity//task[@exercise-interactive='fillin' and setup]
93
- | exploration//task[@exercise-interactive='fillin' and setup]
94
- | investigation//task[@exercise-interactive='fillin' and setup]"
87
+ <xsl:template match="exercise[@pi:exercise-interactive='fillin' and setup]
88
+ | project[@pi:exercise-interactive='fillin' and setup]
89
+ | activity[@pi:exercise-interactive='fillin' and setup]
90
+ | exploration[@pi:exercise-interactive='fillin' and setup]
91
+ | investigation[@pi:exercise-interactive='fillin' and setup]
92
+ | exercise//task[@pi:exercise-interactive='fillin' and setup]
93
+ | project//task[@pi:exercise-interactive='fillin' and setup]
94
+ | activity//task[@pi:exercise-interactive='fillin' and setup]
95
+ | exploration//task[@pi:exercise-interactive='fillin' and setup]
96
+ | investigation//task[@pi:exercise-interactive='fillin' and setup]"
95
97
  mode="extraction">
96
98
  <xsl:text>,&#xa;</xsl:text>
97
99
  <xsl:text>{</xsl:text>
98
100
  <xsl:text> "exercise_id": "</xsl:text>
99
- <!-- Key the round trip on @assembly-id, the early identifier the -->
101
+ <!-- Key the round trip on @pi:assembly-id, the early identifier the-->
100
102
  <!-- substitution pass reads back. @label only exists for labeled -->
101
103
  <!-- exercises, so it would miss unlabeled exercises and tasks. -->
102
104
  <xsl:apply-templates select="." mode="assembly-id" />
@@ -51,7 +51,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
51
51
  <xsl:variable name="exercise-style" select="'dynamic'"/>
52
52
 
53
53
  <!-- @preview indicates custom image is present -->
54
- <!-- Stylesheet output is text, with "visible-id" -->
54
+ <!-- Stylesheet output is text, with "unique-id" -->
55
55
  <!-- of each interactive, one per line, to be -->
56
56
  <!-- captured in a text file to guide snapshotting -->
57
57
  <!-- Make the iframe and standalone page for each -->
@@ -60,7 +60,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
60
60
  <!-- in pretext-html.xsl. Results are HTML files -->
61
61
  <!-- (despite this stylesheet having text output). -->
62
62
  <xsl:template match="interactive[not(@preview)]" mode="extraction">
63
- <xsl:apply-templates select="." mode="visible-id" />
63
+ <xsl:apply-templates select="." mode="unique-id" />
64
64
  <xsl:text>&#xa;</xsl:text>
65
65
  <!-- (2) Identical content, but now isolated on a reader-friendly page -->
66
66
  <!-- The standalone page has its own masthead h1, so headings inside -->
@@ -40,7 +40,7 @@
40
40
  <!-- data for how PG should be processed. This tree will be used by -->
41
41
  <!-- pretext.py in conjuction with some form of renderer (webwork2, local -->
42
42
  <!-- PG, or the standalone renderer) to write, for each webwork exercise, -->
43
- <!-- a file of representations of that problem (named by @assembly-id). -->
43
+ <!-- a file of representations of that problem (named by @pi:assembly-id). -->
44
44
 
45
45
  <!-- The top of the ephemeral XML tree has some global attributes. -->
46
46
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  <!-- The pretext/pretext script (-c webwork) uses all this to write, for -->
62
62
  <!-- each webwork exercise, an XML file of representations of that problem -->
63
- <!-- (named by @assembly-id). The script must be re-run whenever the -->
63
+ <!-- (named by @pi:assembly-id). The script must be re-run whenever the -->
64
64
  <!-- author source for a webwork exercise, a .pg file, or some -->
65
65
  <!-- configuration changes. -->
66
66
 
@@ -175,7 +175,7 @@
175
175
 
176
176
  <xsl:template match="webwork[@source|statement|task|text()]" mode="extraction">
177
177
  <xsl:variable name="problem">
178
- <xsl:value-of select="../@assembly-id"/>
178
+ <xsl:value-of select="../@pi:assembly-id"/>
179
179
  </xsl:variable>
180
180
  <problem>
181
181
  <xsl:attribute name="id">
@@ -192,10 +192,13 @@
192
192
  </xsl:when>
193
193
  </xsl:choose>
194
194
  </xsl:attribute>
195
- <!-- 1b. if this problem is a copy, record what it was copied from -->
196
- <xsl:if test="@copied-from">
195
+ <!-- 1b. if this problem is a copy, record what it was copied from. -->
196
+ <!-- The source is the tree stamp, in the internal namespace; the copy is -->
197
+ <!-- a plain attribute, since this file is an interchange format read by -->
198
+ <!-- the Python routines, which know it as "copied-from". -->
199
+ <xsl:if test="@pi:copied-from">
197
200
  <xsl:attribute name="copied-from">
198
- <xsl:value-of select="id(@copied-from)/../@assembly-id"/>
201
+ <xsl:value-of select="id(@pi:copied-from)/../@pi:assembly-id"/>
199
202
  </xsl:attribute>
200
203
  </xsl:if>
201
204
  <!-- 2. a seed for randomization (with a default explicitly declared) -->
@@ -536,14 +539,14 @@
536
539
  </xsl:call-template>
537
540
  <!-- All our problems load MathObjects, and so should have at least -->
538
541
  <!-- one explicit Context() load. -->
539
- <xsl:if test="not(contains(.//pg-code,'Context('))">
542
+ <xsl:if test="not(contains(pg-code,'Context('))">
540
543
  <xsl:text>Context('Numeric');</xsl:text>
541
544
  <xsl:text>&#xa;</xsl:text>
542
545
  </xsl:if>
543
546
  <!-- pg-code verbatim, but trim indentation -->
544
- <xsl:if test=".//pg-code">
547
+ <xsl:if test="pg-code">
545
548
  <xsl:call-template name="sanitize-text">
546
- <xsl:with-param name="text" select=".//pg-code" />
549
+ <xsl:with-param name="text" select="pg-code" />
547
550
  </xsl:call-template>
548
551
  </xsl:if>
549
552
  <!-- if there are latex-image in the problem, put their code here -->
@@ -88,7 +88,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
88
88
  <!-- representations, and by the Python script when -->
89
89
  <!-- generating QR code images. -->
90
90
  <xsl:variable name="the-id">
91
- <xsl:apply-templates select="." mode="visible-id"/>
91
+ <xsl:apply-templates select="." mode="unique-id"/>
92
92
  </xsl:variable>
93
93
  <exsl:document href="{$the-id}-url.xml" method="xml">
94
94
  <pi:qrcode-urls>
@@ -24,7 +24,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
24
24
  <!-- processed into a trace by the pretext/pretext script. -->
25
25
  <!-- It produces text output, with one line per program: -->
26
26
  <!-- -->
27
- <!-- visible-id, language, source -->
27
+ <!-- unique-id, language, source -->
28
28
 
29
29
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
30
30
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
@@ -57,7 +57,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
57
57
 
58
58
  <!-- Constructs a block of text for trace output -->
59
59
  <!-- Each of the following as its own line: -->
60
- <!-- visible-id -->
60
+ <!-- unique-id -->
61
61
  <!-- runestone-id -->
62
62
  <!-- trace filename -->
63
63
  <!-- language -->
@@ -66,7 +66,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
66
66
  <!-- Followed by 1 line per checkpoint question -->
67
67
  <!-- Block ends with blank line (double newline) -->
68
68
  <xsl:template match="program[@interactive = 'codelens']" mode="extraction">
69
- <xsl:apply-templates select="." mode="visible-id"/>
69
+ <xsl:apply-templates select="." mode="unique-id"/>
70
70
  <xsl:text>&#xa;</xsl:text>
71
71
  <xsl:apply-templates select="." mode="runestone-id"/>
72
72
  <xsl:text>&#xa;</xsl:text>
@@ -56,7 +56,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
56
56
  <xsl:variable name="first-video-id" select="substring-before(concat(normalize-space(str:replace(@youtube, ',', ' ')), ' '), ' ')" />
57
57
  <xsl:value-of select="$first-video-id" />
58
58
  <xsl:text>,</xsl:text>
59
- <xsl:apply-templates select="." mode="visible-id" />
59
+ <xsl:apply-templates select="." mode="unique-id" />
60
60
  <xsl:text>&#xa;</xsl:text>
61
61
  </xsl:template>
62
62
 
@@ -493,7 +493,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
493
493
  <xsl:text>{</xsl:text>
494
494
  <xsl:choose>
495
495
  <xsl:when test="@arg = 'unique-id'">
496
- <xsl:value-of select="$ptx-node/@unique-id"/>
496
+ <xsl:value-of select="$ptx-node/@pi:unique-id"/>
497
497
  </xsl:when>
498
498
  <xsl:when test="@arg = 'ordinal'">
499
499
  <xsl:apply-templates select="$ptx-node" mode="texstyle-number"/>
@@ -511,7 +511,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
511
511
  <xsl:text>[</xsl:text>
512
512
  <xsl:choose>
513
513
  <xsl:when test="@opt = 'unique-id'">
514
- <xsl:value-of select="$ptx-node/@unique-id"/>
514
+ <xsl:value-of select="$ptx-node/@pi:unique-id"/>
515
515
  </xsl:when>
516
516
  <xsl:when test="@arg = 'ordinal'">
517
517
  <xsl:apply-templates select="$ptx-node" mode="texstyle-number"/>
@@ -523,7 +523,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
523
523
  <xsl:text>{</xsl:text>
524
524
  <xsl:choose>
525
525
  <xsl:when test="@arg = 'unique-id'">
526
- <xsl:value-of select="$ptx-node/@unique-id"/>
526
+ <xsl:value-of select="$ptx-node/@pi:unique-id"/>
527
527
  </xsl:when>
528
528
  <xsl:when test="@arg = 'ordinal'">
529
529
  <xsl:apply-templates select="$ptx-node" mode="texstyle-number"/>