@pretextbook/pretext-html 0.3.0 → 0.4.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.
- package/README.md +20 -9
- package/assets/preview-html.xsl +8 -4
- package/assets/upstream.json +1 -1
- package/assets/xsl/README.md +25 -24
- package/assets/xsl/entities.ent +20 -0
- package/assets/xsl/extract-biblio-csl.xsl +1 -1
- package/assets/xsl/extract-pg.xsl +111 -297
- package/assets/xsl/extract-qrcode.xsl +11 -1
- package/assets/xsl/extract-sageplot.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +1 -2
- package/assets/xsl/localizations/README.md +24 -24
- package/assets/xsl/pretext-assembly.xsl +101 -11
- package/assets/xsl/pretext-beamer.xsl +43 -146
- package/assets/xsl/pretext-braille-preprint.xsl +457 -201
- package/assets/xsl/pretext-common.xsl +388 -423
- package/assets/xsl/pretext-epub.xsl +301 -72
- package/assets/xsl/pretext-fo.xsl +70 -86
- package/assets/xsl/pretext-html.xsl +331 -259
- package/assets/xsl/pretext-jupyter.xsl +534 -322
- package/assets/xsl/pretext-latex-classic.xsl +14 -15
- package/assets/xsl/pretext-latex-common.xsl +385 -2389
- package/assets/xsl/pretext-latex.xsl +1995 -5
- package/assets/xsl/pretext-markdown.xsl +919 -0
- package/assets/xsl/pretext-numbers.xsl +22 -4
- package/assets/xsl/pretext-revealjs.xsl +241 -33
- package/assets/xsl/pretext-runestone-fitb.xsl +20 -22
- package/assets/xsl/pretext-runestone.xsl +3 -3
- package/assets/xsl/pretext-sage-doctest.xsl +2 -2
- package/assets/xsl/pretext-text-utilities.xsl +69 -1
- package/assets/xsl/pretext-text.xsl +1077 -107
- package/assets/xsl/publisher-variables.xsl +396 -452
- package/assets/xsl/support/play-button/README.md +1 -3
- package/assets/xsl/tests/README.md +1 -1
- package/assets/xsl/utilities/README.md +6 -8
- package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
- package/assets/xsl-bundle.json +1 -1
- package/dist/{cli-CzoinNle.js → cli-Cp6C0sif.js} +220 -205
- package/dist/cli.js +1 -1
- package/dist/index.browser.js +351 -342
- package/dist/index.js +1 -1
- package/dist/publication.d.ts +9 -1
- package/dist/renderer.d.ts +20 -0
- package/package.json +1 -1
|
@@ -389,7 +389,9 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
389
389
|
<!-- group as its serial number. -->
|
|
390
390
|
<xsl:template match="exercisegroup" mode="serial-number">
|
|
391
391
|
<xsl:apply-templates select="exercise[1]" mode="serial-number" />
|
|
392
|
-
<xsl:call-template name="
|
|
392
|
+
<xsl:call-template name="character">
|
|
393
|
+
<xsl:with-param name="name" select="'ndash'"/>
|
|
394
|
+
</xsl:call-template>
|
|
393
395
|
<xsl:apply-templates select="exercise[last()]" mode="serial-number" />
|
|
394
396
|
</xsl:template>
|
|
395
397
|
|
|
@@ -450,7 +452,23 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
450
452
|
<!-- Lists live in paragraphs, exercises, objectives, so -->
|
|
451
453
|
<!-- should be referenced as part of some enclosing element. -->
|
|
452
454
|
<!-- "mathbook" helps some tree-climbing routines halt -->
|
|
453
|
-
<xsl:template match="mathbook|pretext|
|
|
455
|
+
<xsl:template match="mathbook|pretext|frontmatter|backmatter|sidebyside|sbsgroup|ol|ul|dl|statement" mode="serial-number" />
|
|
456
|
+
|
|
457
|
+
<!-- An "introduction" or "conclusion" of a structured division (a -->
|
|
458
|
+
<!-- "division companion") occurs at most once per division, and so -->
|
|
459
|
+
<!-- takes its number from the parent, exactly as GOAL-LIKE does. -->
|
|
460
|
+
<!-- The number is never displayed where born; it only serves to -->
|
|
461
|
+
<!-- identify the target of a cross-reference. Every other flavor -->
|
|
462
|
+
<!-- (in blocks, tasks, exercise groups, ...) has no number at all. -->
|
|
463
|
+
<xsl:template match="introduction|conclusion" mode="serial-number"/>
|
|
464
|
+
|
|
465
|
+
<xsl:template match="introduction[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]|conclusion[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]" mode="serial-number">
|
|
466
|
+
<xsl:apply-templates select="parent::*" mode="serial-number"/>
|
|
467
|
+
</xsl:template>
|
|
468
|
+
|
|
469
|
+
<xsl:template match="introduction[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]|conclusion[parent::article or parent::chapter or parent::appendix or parent::section or parent::subsection]" mode="structure-number">
|
|
470
|
+
<xsl:apply-templates select="parent::*" mode="structure-number"/>
|
|
471
|
+
</xsl:template>
|
|
454
472
|
|
|
455
473
|
<!-- Poems go by their titles, not numbers -->
|
|
456
474
|
<xsl:template match="poem" mode="serial-number" />
|
|
@@ -541,7 +559,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
541
559
|
<!-- Should not drop in here. Ever. -->
|
|
542
560
|
<xsl:template match="*" mode="serial-number">
|
|
543
561
|
<xsl:text>[NUM]</xsl:text>
|
|
544
|
-
<xsl:message>PTX:
|
|
562
|
+
<xsl:message>PTX:BUG: An object (<xsl:value-of select="local-name(.)" />) lacks a serial number, search output for "[NUM]"</xsl:message>
|
|
545
563
|
<xsl:apply-templates select="." mode="location-report" />
|
|
546
564
|
</xsl:template>
|
|
547
565
|
|
|
@@ -784,7 +802,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
784
802
|
<!-- Should not drop in here. Ever. -->
|
|
785
803
|
<xsl:template match="*" mode="structure-number">
|
|
786
804
|
<xsl:text>[STRUCT]</xsl:text>
|
|
787
|
-
<xsl:message>PTX:
|
|
805
|
+
<xsl:message>PTX:BUG: An object (<xsl:value-of select="local-name(.)" />) lacks a structure number, search output for "[STRUCT]"</xsl:message>
|
|
788
806
|
<xsl:apply-templates select="." mode="location-report" />
|
|
789
807
|
</xsl:template>
|
|
790
808
|
|
|
@@ -31,10 +31,13 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
31
31
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
32
32
|
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
33
33
|
xmlns:pi="http://pretextbook.org/2020/pretext/internal"
|
|
34
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
35
|
+
xmlns:pf="https://prefigure.org"
|
|
34
36
|
xmlns:exsl="http://exslt.org/common"
|
|
35
37
|
xmlns:date="http://exslt.org/dates-and-times"
|
|
36
38
|
xmlns:str="http://exslt.org/strings"
|
|
37
39
|
extension-element-prefixes="exsl date str"
|
|
40
|
+
exclude-result-prefixes="svg pf"
|
|
38
41
|
>
|
|
39
42
|
|
|
40
43
|
<!-- Necessary to get some HTML constructions, -->
|
|
@@ -52,6 +55,17 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
52
55
|
<!-- HTML conversion (preferably avoid using this). -->
|
|
53
56
|
<xsl:variable name="b-reveal-build" select="true()" />
|
|
54
57
|
|
|
58
|
+
<!-- Embedded mathematics: files of per-equation SVG and speech -->
|
|
59
|
+
<!-- representations, keyed by id, manufactured at build time by -->
|
|
60
|
+
<!-- the "mathjax_latex()" routine and passed in here as string -->
|
|
61
|
+
<!-- parameters. Both are empty for online mathematics (the -->
|
|
62
|
+
<!-- default), and then the derived variables are empty node-sets, -->
|
|
63
|
+
<!-- never consulted. -->
|
|
64
|
+
<xsl:param name="mathfile" select="''"/>
|
|
65
|
+
<xsl:param name="speechfile" select="''"/>
|
|
66
|
+
<xsl:variable name="math-repr" select="document($mathfile)/pi:math-representations"/>
|
|
67
|
+
<xsl:variable name="speech-repr" select="document($speechfile)/pi:math-representations"/>
|
|
68
|
+
|
|
55
69
|
<!-- Reveal.js output is one monolithic page, so heading levels are -->
|
|
56
70
|
<!-- threaded, not chunked. The slideshow title (h1) and subtitle -->
|
|
57
71
|
<!-- (h2) are fixed. A "section" is always level 2 (sections never -->
|
|
@@ -129,18 +143,34 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
129
143
|
<xsl:apply-templates select="." mode="sagecell" />
|
|
130
144
|
<xsl:call-template name="syntax-highlight"/>
|
|
131
145
|
|
|
132
|
-
<!-- load reveal.js resources; w/ v
|
|
133
|
-
<!--
|
|
146
|
+
<!-- load reveal.js resources; w/ v 6.x -->
|
|
147
|
+
<!-- paths are relative to the distribution's "dist" -->
|
|
148
|
+
<!-- directory, whose layout a "local" resource host -->
|
|
149
|
+
<!-- must reproduce -->
|
|
134
150
|
<link href="{$reveal-root}/reset.css" rel="stylesheet"></link>
|
|
135
151
|
<link href="{$reveal-root}/reveal.css" rel="stylesheet"></link>
|
|
136
152
|
<link href="{$reveal-root}/theme/{$reveal-theme}.css" rel="stylesheet"></link>
|
|
137
153
|
<script src="{$reveal-root}/reveal.js"></script>
|
|
138
|
-
|
|
154
|
+
<!-- embedded mathematics needs no typesetting, so no math plugin -->
|
|
155
|
+
<xsl:if test="not($b-reveal-embedded-math)">
|
|
156
|
+
<script src="{$reveal-root}/plugin/math.js"></script>
|
|
157
|
+
</xsl:if>
|
|
139
158
|
|
|
140
159
|
<link href="_static/pretext/css/pretext-reveal.css" rel="stylesheet"></link>
|
|
141
160
|
<style>
|
|
161
|
+
<xsl:if test="$b-reveal-embedded-math">
|
|
162
|
+
<!-- layout for build-time SVG images of mathematics; the -->
|
|
163
|
+
<!-- class names are those of the EPUB conversion, which -->
|
|
164
|
+
<!-- pioneered this device -->
|
|
165
|
+
<xsl:text>span.mjpage { display: inline; }
</xsl:text>
|
|
166
|
+
<xsl:text>span.mjpage__block { display: block; text-align: center; margin: 0.5em 0; }
</xsl:text>
|
|
167
|
+
</xsl:if>
|
|
142
168
|
</style>
|
|
143
|
-
|
|
169
|
+
<!-- no diagcess machinery with embedded mathematics: an -->
|
|
170
|
+
<!-- annotated PreFigure diagram is then a static image -->
|
|
171
|
+
<xsl:if test="not($b-reveal-embedded-math)">
|
|
172
|
+
<xsl:call-template name="diagcess-header"/>
|
|
173
|
+
</xsl:if>
|
|
144
174
|
|
|
145
175
|
<!-- custom-css, if specified, should be last -->
|
|
146
176
|
<xsl:if test="not($reveal-custom-css = '')">
|
|
@@ -157,15 +187,22 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
157
187
|
|
|
158
188
|
<body>
|
|
159
189
|
<div class="reveal ptx-content">
|
|
160
|
-
<!-- For mathematics/MathJax, must be located
|
|
161
|
-
<!-- within div.reveal to be effective
|
|
162
|
-
|
|
190
|
+
<!-- For mathematics/MathJax, must be located -->
|
|
191
|
+
<!-- within div.reveal to be effective. With -->
|
|
192
|
+
<!-- embedded mathematics the macros are baked -->
|
|
193
|
+
<!-- into the SVG images at build time, so the -->
|
|
194
|
+
<!-- hidden macro division would be inert. -->
|
|
195
|
+
<xsl:if test="not($b-reveal-embedded-math)">
|
|
196
|
+
<xsl:apply-templates select="." mode="latex-macros"/>
|
|
197
|
+
</xsl:if>
|
|
163
198
|
<div class="slides">
|
|
164
199
|
<xsl:apply-templates select="frontmatter"/>
|
|
165
200
|
<xsl:apply-templates select="section|slide"/>
|
|
166
201
|
</div>
|
|
167
202
|
</div>
|
|
168
|
-
<xsl:
|
|
203
|
+
<xsl:if test="not($b-reveal-embedded-math)">
|
|
204
|
+
<xsl:call-template name="diagcess-footer"/>
|
|
205
|
+
</xsl:if>
|
|
169
206
|
</body>
|
|
170
207
|
|
|
171
208
|
<script>
|
|
@@ -206,27 +243,41 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
206
243
|
<xsl:text> transition: 'fade',
</xsl:text>
|
|
207
244
|
<xsl:text> width: "100%",
</xsl:text>
|
|
208
245
|
<xsl:text> height: "100%",
</xsl:text>
|
|
209
|
-
|
|
210
|
-
<!--
|
|
211
|
-
<!--
|
|
212
|
-
<!--
|
|
213
|
-
<!--
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
246
|
+
<!-- "margin" must be a JavaScript number. The PDF export -->
|
|
247
|
+
<!-- computes its page size as (slide dimension)*(1 + margin); -->
|
|
248
|
+
<!-- a quoted value concatenates instead of adding, producing -->
|
|
249
|
+
<!-- pages ten times too large, and a print dialog then -->
|
|
250
|
+
<!-- shrinks each slide to a small fraction of the paper. -->
|
|
251
|
+
<xsl:text> margin: 0.025,
</xsl:text>
|
|
252
|
+
<xsl:choose>
|
|
253
|
+
<!-- Embedded mathematics is finished SVG images: -->
|
|
254
|
+
<!-- no math plugin, no typesetting configuration -->
|
|
255
|
+
<xsl:when test="$b-reveal-embedded-math">
|
|
256
|
+
<xsl:text> plugins: []
</xsl:text>
|
|
257
|
+
</xsl:when>
|
|
258
|
+
<!-- Explicitly enable AMS-style inline \(...\), -->
|
|
259
|
+
<!-- and explicitly disable TeX-style inline $...$ -->
|
|
260
|
+
<!-- The main HTML conversion does not do anything -->
|
|
261
|
+
<!-- special for display math, so we disable any such -->
|
|
262
|
+
<!-- markup, since we use environments exclusively. -->
|
|
263
|
+
<!-- N.B. default HTML adds a "zero-width" space into -->
|
|
264
|
+
<!-- a \( authored in a non-math context. -->
|
|
265
|
+
<!-- The MathJax version matches the main HTML -->
|
|
266
|
+
<!-- conversion; the "mathjax4" adapter of the math -->
|
|
267
|
+
<!-- plugin loads it from the URL given and passes -->
|
|
268
|
+
<!-- the "tex" object into the MathJax configuration. -->
|
|
269
|
+
<!-- Suggested by https://revealjs.com/math/, 2026-07-22 -->
|
|
270
|
+
<xsl:otherwise>
|
|
271
|
+
<xsl:text> mathjax4: {
</xsl:text>
|
|
272
|
+
<xsl:text> mathjax: 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js',
</xsl:text>
|
|
273
|
+
<xsl:text> tex: {
</xsl:text>
|
|
274
|
+
<xsl:text> inlineMath: [['\\(','\\)']],
</xsl:text>
|
|
275
|
+
<xsl:text> displayMath: [],
</xsl:text>
|
|
276
|
+
<xsl:text> }
</xsl:text>
|
|
277
|
+
<xsl:text> },
</xsl:text>
|
|
278
|
+
<xsl:text> plugins: [ RevealMath.MathJax4 ]
</xsl:text>
|
|
279
|
+
</xsl:otherwise>
|
|
280
|
+
</xsl:choose>
|
|
230
281
|
<xsl:text>});
</xsl:text>
|
|
231
282
|
</script>
|
|
232
283
|
</html>
|
|
@@ -416,8 +467,12 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
416
467
|
</xsl:template>
|
|
417
468
|
|
|
418
469
|
<!-- Side-By-Side -->
|
|
419
|
-
<!--
|
|
420
|
-
<!--
|
|
470
|
+
<!-- Same container-declared composition as HTML and LaTeX, -->
|
|
471
|
+
<!-- realized here with CSS table display: margins are declared on -->
|
|
472
|
+
<!-- the wrapper div, and each panel div carries its width and -->
|
|
473
|
+
<!-- vertical alignment. Built by implementing the two abstract -->
|
|
474
|
+
<!-- templates ("panel-panel", "compose-panels") of the -common -->
|
|
475
|
+
<!-- machinery. -->
|
|
421
476
|
|
|
422
477
|
<!-- Overall wrapper of a sidebyside -->
|
|
423
478
|
<xsl:template match="sidebyside" mode="compose-panels">
|
|
@@ -511,12 +566,165 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
511
566
|
<xsl:with-param name="warning">Conversion to reveal.js presentations/slideshows is experimental
Requests for additional specific constructions welcome
Additional PreTeXt elements are subject to change</xsl:with-param>
|
|
512
567
|
</xsl:call-template>
|
|
513
568
|
<xsl:if test="not($theme = '')">
|
|
514
|
-
<xsl:message >PTX:
|
|
569
|
+
<xsl:message >PTX:DEPRECATE: the temporary "theme" stringparam is deprecated and is being ignored by the conversion to a Reveal.js slideshow. Please switch to using a publisher file to set this option, see documentation in The Guide. The default theme is "simple".</xsl:message>
|
|
515
570
|
<xsl:text>simple</xsl:text>
|
|
516
571
|
</xsl:if>
|
|
517
572
|
<xsl:if test="not($local = '')">
|
|
518
|
-
<xsl:message >PTX:
|
|
573
|
+
<xsl:message >PTX:DEPRECATE: the temporary "local" stringparam is deprecated and is being ignored. Please switch to using a publisher file to set this option, see documentation in The Guide. The default behavior is to get resources from a CDN.</xsl:message>
|
|
519
574
|
</xsl:if>
|
|
520
575
|
</xsl:template>
|
|
521
576
|
|
|
577
|
+
<!-- #################### -->
|
|
578
|
+
<!-- Embedded Mathematics -->
|
|
579
|
+
<!-- #################### -->
|
|
580
|
+
|
|
581
|
+
<!-- Online mathematics (the default) is authored LaTeX passed -->
|
|
582
|
+
<!-- through, inherited from the HTML conversion, for the math -->
|
|
583
|
+
<!-- plugin and MathJax to typeset in the browser. Embedded -->
|
|
584
|
+
<!-- mathematics substitutes an SVG image and a speech string, -->
|
|
585
|
+
<!-- both manufactured at build time, so the slideshow performs no -->
|
|
586
|
+
<!-- typesetting at all: the same device as the EPUB conversion, -->
|
|
587
|
+
<!-- whose templates these mirror. Every "md" has "mrow" children -->
|
|
588
|
+
<!-- once the assembly repairs an authored one-line "md", so the -->
|
|
589
|
+
<!-- match covers all mathematics. Slides never link to an -->
|
|
590
|
+
<!-- equation (a cross-reference renders as its text), so no HTML -->
|
|
591
|
+
<!-- id is placed, unlike EPUB. -->
|
|
592
|
+
<xsl:template match="m|md[mrow]">
|
|
593
|
+
<xsl:choose>
|
|
594
|
+
<xsl:when test="$b-reveal-embedded-math">
|
|
595
|
+
<!-- NB: math-representation file writes with "visible-id" -->
|
|
596
|
+
<xsl:variable name="id">
|
|
597
|
+
<xsl:apply-templates select="." mode="unique-id"/>
|
|
598
|
+
</xsl:variable>
|
|
599
|
+
<xsl:variable name="math" select="$math-repr/pi:math[@id = $id]"/>
|
|
600
|
+
<xsl:variable name="speech" select="$speech-repr/pi:math[@id = $id]"/>
|
|
601
|
+
<span>
|
|
602
|
+
<xsl:attribute name="class">
|
|
603
|
+
<xsl:choose>
|
|
604
|
+
<xsl:when test="$math/@context = 'inline'">
|
|
605
|
+
<xsl:text>mjpage</xsl:text>
|
|
606
|
+
</xsl:when>
|
|
607
|
+
<xsl:when test="$math/@context = 'displaymath'">
|
|
608
|
+
<xsl:text>mjpage mjpage__block</xsl:text>
|
|
609
|
+
</xsl:when>
|
|
610
|
+
</xsl:choose>
|
|
611
|
+
</xsl:attribute>
|
|
612
|
+
<xsl:apply-templates select="$math/div[@class = 'svg']/svg:svg" mode="svg-edit">
|
|
613
|
+
<xsl:with-param name="speech" select="$speech"/>
|
|
614
|
+
<xsl:with-param name="base-id" select="$id"/>
|
|
615
|
+
</xsl:apply-templates>
|
|
616
|
+
</span>
|
|
617
|
+
</xsl:when>
|
|
618
|
+
<!-- online: the usual LaTeX-within-delimiters construction -->
|
|
619
|
+
<xsl:otherwise>
|
|
620
|
+
<xsl:apply-imports/>
|
|
621
|
+
</xsl:otherwise>
|
|
622
|
+
</xsl:choose>
|
|
623
|
+
</xsl:template>
|
|
624
|
+
|
|
625
|
+
<!-- An annotated PreFigure diagram is normally embedded for the -->
|
|
626
|
+
<!-- diagcess library: an interactive, keyboard-driven exploration -->
|
|
627
|
+
<!-- for a screen reader. With embedded mathematics the slideshow -->
|
|
628
|
+
<!-- has already traded such interactivity for fixed alternatives, -->
|
|
629
|
+
<!-- so the diagram becomes a static image (its plain SVG), and the -->
|
|
630
|
+
<!-- diagcess machinery is omitted entirely. -->
|
|
631
|
+
<xsl:template match="image[pf:prefigure[pf:diagram/pf:annotations]]" mode="image-inclusion">
|
|
632
|
+
<xsl:choose>
|
|
633
|
+
<xsl:when test="$b-reveal-embedded-math">
|
|
634
|
+
<xsl:variable name="base-pathname">
|
|
635
|
+
<xsl:value-of select="$generated-directory"/>
|
|
636
|
+
<xsl:if test="$b-managed-directories">
|
|
637
|
+
<xsl:text>prefigure/</xsl:text>
|
|
638
|
+
</xsl:if>
|
|
639
|
+
<xsl:apply-templates select="pf:prefigure" mode="image-source-basename"/>
|
|
640
|
+
</xsl:variable>
|
|
641
|
+
<xsl:apply-templates select="." mode="svg-png-wrapper">
|
|
642
|
+
<xsl:with-param name="image-filename" select="concat($base-pathname, '.svg')"/>
|
|
643
|
+
</xsl:apply-templates>
|
|
644
|
+
<!-- possibly annotate with archive links -->
|
|
645
|
+
<xsl:apply-templates select="." mode="archive">
|
|
646
|
+
<xsl:with-param name="base-pathname" select="$base-pathname"/>
|
|
647
|
+
</xsl:apply-templates>
|
|
648
|
+
<!-- possibly give a long description -->
|
|
649
|
+
<xsl:apply-templates select="." mode="description"/>
|
|
650
|
+
</xsl:when>
|
|
651
|
+
<!-- online: the diagcess embedding, inherited -->
|
|
652
|
+
<xsl:otherwise>
|
|
653
|
+
<xsl:apply-imports/>
|
|
654
|
+
</xsl:otherwise>
|
|
655
|
+
</xsl:choose>
|
|
656
|
+
</xsl:template>
|
|
657
|
+
|
|
658
|
+
<!-- MathJax mints an HTML id from an equation's \tag for its own -->
|
|
659
|
+
<!-- \eqref linking, which PreTeXt never uses; a tag used twice -->
|
|
660
|
+
<!-- (symbols as tags invite this) would duplicate the id, so they -->
|
|
661
|
+
<!-- are dropped -->
|
|
662
|
+
<xsl:template match="@id[starts-with(., 'mjx-eqn')]" mode="svg-edit"/>
|
|
663
|
+
|
|
664
|
+
<!-- Identity for the SVG stream-edit -->
|
|
665
|
+
<xsl:template match="node()|@*" mode="svg-edit">
|
|
666
|
+
<xsl:copy>
|
|
667
|
+
<xsl:apply-templates select="node()|@*" mode="svg-edit"/>
|
|
668
|
+
</xsl:copy>
|
|
669
|
+
</xsl:template>
|
|
670
|
+
|
|
671
|
+
<!-- We enrich the main "svg" element with a speech string. -->
|
|
672
|
+
<!-- 1. Since this is the "entry template" for this mode, -->
|
|
673
|
+
<!-- this is the only place we accept the "speech" param. -->
|
|
674
|
+
<!-- 2. MathJax seems to use SVGs inside of SVGs for placing -->
|
|
675
|
+
<!-- numbers/tags of numbered equations, so we only enrich -->
|
|
676
|
+
<!-- "top-level" SVG - that is the point of the filter. -->
|
|
677
|
+
<!-- 3. The id of the math element will be used as the base -->
|
|
678
|
+
<!-- of (unique) ids necessary to point to the speech. -->
|
|
679
|
+
<!-- Pattern 11 at: -->
|
|
680
|
+
<!-- https://www.deque.com/blog/creating-accessible-svgs/ -->
|
|
681
|
+
<!-- 4. Seems -->
|
|
682
|
+
<!-- "title" + @aria-labelledby -->
|
|
683
|
+
<!-- "desc" + @aria-describedby -->
|
|
684
|
+
<!-- cover all the bases. It is suggested that the two -->
|
|
685
|
+
<!-- elements alone would be recognized by screen readers. -->
|
|
686
|
+
<xsl:template match="svg:svg[not(ancestor::svg:svg)]" mode="svg-edit">
|
|
687
|
+
<xsl:param name="speech"/>
|
|
688
|
+
<xsl:param name="base-id"/>
|
|
689
|
+
|
|
690
|
+
<!-- manufacture id values for consistency, uniqueness -->
|
|
691
|
+
<xsl:variable name="title-id">
|
|
692
|
+
<xsl:value-of select="$base-id"/>
|
|
693
|
+
<xsl:text>-title</xsl:text>
|
|
694
|
+
</xsl:variable>
|
|
695
|
+
<xsl:variable name="desc-id">
|
|
696
|
+
<xsl:value-of select="$base-id"/>
|
|
697
|
+
<xsl:text>-desc</xsl:text>
|
|
698
|
+
</xsl:variable>
|
|
699
|
+
|
|
700
|
+
<xsl:copy>
|
|
701
|
+
<!-- attributes first -->
|
|
702
|
+
<xsl:apply-templates select="@*" mode="svg-edit"/>
|
|
703
|
+
<xsl:attribute name="role">
|
|
704
|
+
<xsl:text>img</xsl:text>
|
|
705
|
+
</xsl:attribute>
|
|
706
|
+
<xsl:attribute name="aria-labelledby">
|
|
707
|
+
<xsl:value-of select="$title-id"/>
|
|
708
|
+
</xsl:attribute>
|
|
709
|
+
<xsl:attribute name="aria-describedby">
|
|
710
|
+
<xsl:value-of select="$desc-id"/>
|
|
711
|
+
</xsl:attribute>
|
|
712
|
+
<!-- now additional metadata, of sorts -->
|
|
713
|
+
<xsl:element name="title" namespace="http://www.w3.org/2000/svg">
|
|
714
|
+
<xsl:attribute name="id">
|
|
715
|
+
<xsl:value-of select="$title-id"/>
|
|
716
|
+
</xsl:attribute>
|
|
717
|
+
<xsl:text>Math Expression</xsl:text>
|
|
718
|
+
</xsl:element>
|
|
719
|
+
<xsl:element name="desc" namespace="http://www.w3.org/2000/svg">
|
|
720
|
+
<xsl:attribute name="id">
|
|
721
|
+
<xsl:value-of select="$desc-id"/>
|
|
722
|
+
</xsl:attribute>
|
|
723
|
+
<xsl:value-of select="$speech"/>
|
|
724
|
+
</xsl:element>
|
|
725
|
+
<!-- and all the rest of the nodes -->
|
|
726
|
+
<xsl:apply-templates select="node()" mode="svg-edit"/>
|
|
727
|
+
</xsl:copy>
|
|
728
|
+
</xsl:template>
|
|
729
|
+
|
|
522
730
|
</xsl:stylesheet>
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
</xsl:when>
|
|
84
84
|
<xsl:otherwise>
|
|
85
85
|
<!-- Report if a seed is not provided-->
|
|
86
|
-
<xsl:message>PTX:
|
|
86
|
+
<xsl:message>PTX:FALLBACK: Dynamic exercise "<xsl:value-of select="@visible-id"/>" is missing setup @seed for static content generation.</xsl:message>
|
|
87
87
|
<xsl:text>1234</xsl:text>
|
|
88
88
|
</xsl:otherwise>
|
|
89
89
|
</xsl:choose>
|
|
@@ -421,42 +421,32 @@
|
|
|
421
421
|
</xsl:apply-templates>
|
|
422
422
|
</xsl:when>
|
|
423
423
|
<!-- If no explicit test is provided, use given answer. -->
|
|
424
|
+
<!-- NB: The @answer cases (mode='number' and mode='string') are now -->
|
|
425
|
+
<!-- handled upstream in pretext-assembly.xsl (exercise pass), which -->
|
|
426
|
+
<!-- injects a synthesized <test correct="yes"> element. -->
|
|
427
|
+
<!-- The remaining cases are for fillins that use @ansobj that -->
|
|
428
|
+
<!-- reference an object that was dynamically created (random). -->
|
|
424
429
|
<xsl:otherwise>
|
|
425
430
|
<xsl:text>{</xsl:text>
|
|
426
431
|
<xsl:choose>
|
|
427
|
-
<xsl:when test="$match-fillin/@answer">
|
|
428
|
-
<xsl:choose>
|
|
429
|
-
<xsl:when test="$match-fillin/@mode='number'">
|
|
430
|
-
<xsl:text>"number": [</xsl:text>
|
|
431
|
-
<xsl:value-of select="$match-fillin/@answer"/>
|
|
432
|
-
<xsl:text>,</xsl:text>
|
|
433
|
-
<xsl:value-of select="$match-fillin/@answer"/>
|
|
434
|
-
<xsl:text>]</xsl:text>
|
|
435
|
-
</xsl:when>
|
|
436
|
-
<xsl:when test="$match-fillin/@mode='string'">
|
|
437
|
-
<xsl:text>"regex": "</xsl:text>
|
|
438
|
-
<xsl:value-of select="$match-fillin/@answer"/>
|
|
439
|
-
<xsl:text>"</xsl:text>
|
|
440
|
-
</xsl:when>
|
|
441
|
-
<xsl:otherwise>
|
|
442
|
-
<xsl:message>PTX:ERROR: fillin has an @answer with invalid or missing mode (valid: number or string) in "<xsl:value-of select="@visible-id"/>. If dynamic, you should use @ansobj.".</xsl:message>
|
|
443
|
-
</xsl:otherwise>
|
|
444
|
-
</xsl:choose>
|
|
445
|
-
</xsl:when>
|
|
446
432
|
<xsl:when test="$match-fillin/@ansobj">
|
|
447
433
|
<xsl:choose>
|
|
434
|
+
<!-- Number objects — assume match with very tight tolerance -->
|
|
448
435
|
<xsl:when test="$match-fillin/@mode='number'">
|
|
449
436
|
<xsl:text>function() {
</xsl:text>
|
|
450
437
|
<xsl:text> return (Math.abs(</xsl:text>
|
|
451
438
|
<xsl:value-of select="$match-fillin/@ansobj"/>
|
|
452
439
|
<xsl:text>- ans) < 1e-10);
}</xsl:text>
|
|
453
440
|
</xsl:when>
|
|
441
|
+
<!-- String objects — assume require exact string match -->
|
|
442
|
+
<!-- otherwise the author should specify the test -->
|
|
454
443
|
<xsl:when test="$match-fillin/@mode='string'">
|
|
455
444
|
<xsl:text>function() {
</xsl:text>
|
|
456
445
|
<xsl:text> return (</xsl:text>
|
|
457
446
|
<xsl:value-of select="$match-fillin/@ansobj"/>
|
|
458
447
|
<xsl:text>== ans);
}</xsl:text>
|
|
459
448
|
</xsl:when>
|
|
449
|
+
<!-- Dynamic math objects: compare expressions -->
|
|
460
450
|
<xsl:when test="$match-fillin/@mode='math'">
|
|
461
451
|
<xsl:text>function() {
</xsl:text>
|
|
462
452
|
<xsl:text> return _mobjs.compareExpressions(</xsl:text>
|
|
@@ -717,8 +707,16 @@
|
|
|
717
707
|
<xsl:otherwise>
|
|
718
708
|
<xsl:variable name="answer">
|
|
719
709
|
<xsl:choose>
|
|
710
|
+
<!-- If comparing with actual answer, implicitly a literal check -->
|
|
720
711
|
<xsl:when test="strcmp/@use-answer='yes'">
|
|
721
|
-
<xsl:
|
|
712
|
+
<xsl:call-template name="escape-regexp-literal">
|
|
713
|
+
<xsl:with-param name="text" select="$fillin/@answer"/>
|
|
714
|
+
</xsl:call-template>
|
|
715
|
+
</xsl:when>
|
|
716
|
+
<xsl:when test="strcmp/@literal='yes'">
|
|
717
|
+
<xsl:call-template name="escape-regexp-literal">
|
|
718
|
+
<xsl:with-param name="text" select="strcmp"/>
|
|
719
|
+
</xsl:call-template>
|
|
722
720
|
</xsl:when>
|
|
723
721
|
<xsl:otherwise>
|
|
724
722
|
<xsl:value-of select="strcmp"/>
|
|
@@ -892,7 +890,7 @@
|
|
|
892
890
|
<xsl:when test="name($curTest)='mathcmp' and $curTest/@use-answer='yes'">
|
|
893
891
|
<xsl:choose>
|
|
894
892
|
<xsl:when test="not($fillin/@ansobj)">
|
|
895
|
-
<xsl:message>PTX:
|
|
893
|
+
<xsl:message>PTX:ERROR: Feedback for "<xsl:value-of select="@visible-id"/>" says to use given math answer, but @ansobj not defined. </xsl:message>
|
|
896
894
|
<xsl:text>UNDEFINED</xsl:text>
|
|
897
895
|
</xsl:when>
|
|
898
896
|
<xsl:otherwise>
|
|
@@ -1154,7 +1154,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1154
1154
|
<xsl:variable name="id">
|
|
1155
1155
|
<xsl:apply-templates select="." mode="unique-id"/>
|
|
1156
1156
|
</xsl:variable>
|
|
1157
|
-
<xsl:message>PTX:WARNING: Parsons problems need a @
|
|
1157
|
+
<xsl:message>PTX:WARNING: Parsons problems need a @language that is a valid activecode language to be runnable</xsl:message>
|
|
1158
1158
|
<xsl:message> id: <xsl:value-of select="$id"></xsl:value-of></xsl:message>
|
|
1159
1159
|
</xsl:otherwise>
|
|
1160
1160
|
</xsl:choose>
|
|
@@ -2413,7 +2413,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2413
2413
|
<xsl:if test="tests/iotest">
|
|
2414
2414
|
<xsl:choose>
|
|
2415
2415
|
<xsl:when test="not(normalize-space(tests/text()) = '')">
|
|
2416
|
-
<xsl:message>
|
|
2416
|
+
<xsl:message>PTX:FALLBACK: You can either write text based tests or use iotests, but not both. iotests ignored in <xsl:value-of select="$rsid"/>.</xsl:message>
|
|
2417
2417
|
</xsl:when>
|
|
2418
2418
|
<xsl:otherwise>
|
|
2419
2419
|
<xsl:text>===iotests===
</xsl:text>
|
|
@@ -3068,7 +3068,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
3068
3068
|
</xsl:when>
|
|
3069
3069
|
<xsl:otherwise>
|
|
3070
3070
|
<xsl:apply-templates select="$target" mode="runestone-id"/>
|
|
3071
|
-
<xsl:message>PTX:
|
|
3071
|
+
<xsl:message>PTX:BUG: runestone-targets template was called with an invalid @output-field value "<xsl:value-of select="$output-field"/>"</xsl:message>
|
|
3072
3072
|
</xsl:otherwise>
|
|
3073
3073
|
</xsl:choose>
|
|
3074
3074
|
<!-- n - 1 separators, required by receiving Javascript -->
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
<xsl:value-of select="@tolerance" />
|
|
125
125
|
</xsl:when>
|
|
126
126
|
<xsl:otherwise>
|
|
127
|
-
<xsl:message>PTX:
|
|
127
|
+
<xsl:message>PTX:ERROR: '<xsl:value-of select="@doctest" /> tolerance' Sage doctest needs 'tolerance=' attribute</xsl:message>
|
|
128
128
|
</xsl:otherwise>
|
|
129
129
|
</xsl:choose>
|
|
130
130
|
</xsl:when>
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
<xsl:value-of select="@package" />
|
|
138
138
|
</xsl:when>
|
|
139
139
|
<xsl:otherwise>
|
|
140
|
-
<xsl:message>PTX:
|
|
140
|
+
<xsl:message>PTX:ERROR: 'optional' Sage doctest missing package, supply a 'package=' attribute</xsl:message>
|
|
141
141
|
</xsl:otherwise>
|
|
142
142
|
</xsl:choose>
|
|
143
143
|
</xsl:when>
|
|
@@ -932,6 +932,31 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
932
932
|
</xsl:choose>
|
|
933
933
|
</xsl:template>
|
|
934
934
|
|
|
935
|
+
<!-- Collapse each newline, and the horizontal space around -->
|
|
936
|
+
<!-- it, to a single space: hard-wrapped, indented source -->
|
|
937
|
+
<!-- becomes one long line -->
|
|
938
|
+
<xsl:template name="flatten-line-breaks">
|
|
939
|
+
<xsl:param name="text"/>
|
|
940
|
+
<xsl:choose>
|
|
941
|
+
<xsl:when test="contains($text, '
')">
|
|
942
|
+
<xsl:call-template name="strip-trailing-whitespace">
|
|
943
|
+
<xsl:with-param name="text" select="substring-before($text, '
')"/>
|
|
944
|
+
</xsl:call-template>
|
|
945
|
+
<xsl:text> </xsl:text>
|
|
946
|
+
<xsl:call-template name="flatten-line-breaks">
|
|
947
|
+
<xsl:with-param name="text">
|
|
948
|
+
<xsl:call-template name="strip-leading-whitespace">
|
|
949
|
+
<xsl:with-param name="text" select="substring-after($text, '
')"/>
|
|
950
|
+
</xsl:call-template>
|
|
951
|
+
</xsl:with-param>
|
|
952
|
+
</xsl:call-template>
|
|
953
|
+
</xsl:when>
|
|
954
|
+
<xsl:otherwise>
|
|
955
|
+
<xsl:value-of select="$text"/>
|
|
956
|
+
</xsl:otherwise>
|
|
957
|
+
</xsl:choose>
|
|
958
|
+
</xsl:template>
|
|
959
|
+
|
|
935
960
|
<!-- spurious newlines introduce whitespace on either side -->
|
|
936
961
|
<!-- we split at newlines, strip consecutive whitesapce on either side, -->
|
|
937
962
|
<!-- and replace newlines by spaces (could restore a single newline) -->
|
|
@@ -1010,6 +1035,49 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1010
1035
|
<xsl:value-of select="str:replace($text, $json-replacements-search-set, $json-replacements-replace-set)" />
|
|
1011
1036
|
</xsl:template>
|
|
1012
1037
|
|
|
1038
|
+
<!-- REGEX Escaped Strings -->
|
|
1039
|
+
<!-- When a string will be passed for comparison using regexp -->
|
|
1040
|
+
<!-- but we want a literal match, we need to escape all of the -->
|
|
1041
|
+
<!-- special characters by putting a slash in front. -->
|
|
1042
|
+
<xsl:variable name="regexp-replacements">
|
|
1043
|
+
<search>\</search>
|
|
1044
|
+
<replace>\\</replace>
|
|
1045
|
+
<search>.</search>
|
|
1046
|
+
<replace>\.</replace>
|
|
1047
|
+
<search>^</search>
|
|
1048
|
+
<replace>\^</replace>
|
|
1049
|
+
<search>$</search>
|
|
1050
|
+
<replace>\$</replace>
|
|
1051
|
+
<search>*</search>
|
|
1052
|
+
<replace>\*</replace>
|
|
1053
|
+
<search>+</search>
|
|
1054
|
+
<replace>\+</replace>
|
|
1055
|
+
<search>?</search>
|
|
1056
|
+
<replace>\?</replace>
|
|
1057
|
+
<search>{</search>
|
|
1058
|
+
<replace>\{</replace>
|
|
1059
|
+
<search>}</search>
|
|
1060
|
+
<replace>\}</replace>
|
|
1061
|
+
<search>[</search>
|
|
1062
|
+
<replace>\[</replace>
|
|
1063
|
+
<search>]</search>
|
|
1064
|
+
<replace>\]</replace>
|
|
1065
|
+
<search>(</search>
|
|
1066
|
+
<replace>\(</replace>
|
|
1067
|
+
<search>)</search>
|
|
1068
|
+
<replace>\)</replace>
|
|
1069
|
+
<search>|</search>
|
|
1070
|
+
<replace>\|</replace>
|
|
1071
|
+
</xsl:variable>
|
|
1072
|
+
<xsl:variable name="regexp-replacements-search-set" select="exsl:node-set($regexp-replacements)/search" />
|
|
1073
|
+
<xsl:variable name="regexp-replacements-replace-set" select="exsl:node-set($regexp-replacements)/replace" />
|
|
1074
|
+
|
|
1075
|
+
<xsl:template name="escape-regexp-literal">
|
|
1076
|
+
<xsl:param name="text"/>
|
|
1077
|
+
|
|
1078
|
+
<xsl:value-of select="str:replace($text, $regexp-replacements-search-set, $regexp-replacements-replace-set)" />
|
|
1079
|
+
</xsl:template>
|
|
1080
|
+
|
|
1013
1081
|
<xsl:template name="quote-string">
|
|
1014
1082
|
<xsl:param name="text" />
|
|
1015
1083
|
<xsl:text>"</xsl:text>
|
|
@@ -1093,7 +1161,7 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1093
1161
|
<xsl:when test="$characters = ''">
|
|
1094
1162
|
<xsl:message>PTX:FATAL: Unable to find an unused character in:
<xsl:value-of select="$string" />
using characters from: <xsl:value-of select="$charset" /></xsl:message>
|
|
1095
1163
|
<xsl:apply-templates select="." mode="location-report" />
|
|
1096
|
-
<xsl:message terminate="yes">
|
|
1164
|
+
<xsl:message terminate="yes">PTX:FATAL: Quitting...</xsl:message>
|
|
1097
1165
|
</xsl:when>
|
|
1098
1166
|
<xsl:otherwise>
|
|
1099
1167
|
<xsl:value-of select="substring($characters, 1, 1)"/>
|