@pretextbook/pretext-html 0.1.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 (110) hide show
  1. package/README.md +160 -0
  2. package/assets/preview-html.xsl +230 -0
  3. package/assets/upstream.json +7 -0
  4. package/assets/xsl/README.md +31 -0
  5. package/assets/xsl/entities.ent +154 -0
  6. package/assets/xsl/extract-asymptote.xsl +68 -0
  7. package/assets/xsl/extract-biblio-csl.xsl +327 -0
  8. package/assets/xsl/extract-datafile.xsl +71 -0
  9. package/assets/xsl/extract-dynamic.xsl +139 -0
  10. package/assets/xsl/extract-identity.xsl +136 -0
  11. package/assets/xsl/extract-interactive.xsl +81 -0
  12. package/assets/xsl/extract-latex-image.xsl +118 -0
  13. package/assets/xsl/extract-mermaid.xsl +58 -0
  14. package/assets/xsl/extract-mom.xsl +63 -0
  15. package/assets/xsl/extract-pg.xsl +2897 -0
  16. package/assets/xsl/extract-prefigure.xsl +157 -0
  17. package/assets/xsl/extract-qrcode.xsl +100 -0
  18. package/assets/xsl/extract-runestone-page-template.xsl +139 -0
  19. package/assets/xsl/extract-sageplot.xsl +166 -0
  20. package/assets/xsl/extract-stack.xsl +56 -0
  21. package/assets/xsl/extract-trace.xsl +134 -0
  22. package/assets/xsl/extract-youtube.xsl +63 -0
  23. package/assets/xsl/html-symbols.xsl +3344 -0
  24. package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -0
  25. package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -0
  26. package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -0
  27. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -0
  28. package/assets/xsl/latex/pretext-latex-guide.xsl +104 -0
  29. package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -0
  30. package/assets/xsl/localizations/README.md +56 -0
  31. package/assets/xsl/localizations/af-ZA.xml +276 -0
  32. package/assets/xsl/localizations/bg-BG.xml +276 -0
  33. package/assets/xsl/localizations/ca-ES.xml +285 -0
  34. package/assets/xsl/localizations/cs-CZ.xml +280 -0
  35. package/assets/xsl/localizations/de-DE.xml +281 -0
  36. package/assets/xsl/localizations/en-US.xml +427 -0
  37. package/assets/xsl/localizations/es-ES.xml +287 -0
  38. package/assets/xsl/localizations/fi-FI.xml +275 -0
  39. package/assets/xsl/localizations/fr-CA.xml +276 -0
  40. package/assets/xsl/localizations/fr-FR.xml +280 -0
  41. package/assets/xsl/localizations/hu-HU.xml +280 -0
  42. package/assets/xsl/localizations/it-IT.xml +276 -0
  43. package/assets/xsl/localizations/ku-CKB.xml +275 -0
  44. package/assets/xsl/localizations/localizations.xml +48 -0
  45. package/assets/xsl/localizations/nl-NL.xml +275 -0
  46. package/assets/xsl/localizations/pt-BR.xml +288 -0
  47. package/assets/xsl/localizations/pt-PT.xml +292 -0
  48. package/assets/xsl/localizations/zh-HANS.xml +269 -0
  49. package/assets/xsl/pretext-assembly.xsl +4795 -0
  50. package/assets/xsl/pretext-basic-html.xsl +86 -0
  51. package/assets/xsl/pretext-beamer.xsl +662 -0
  52. package/assets/xsl/pretext-braille-preprint.xsl +2249 -0
  53. package/assets/xsl/pretext-common.xsl +12018 -0
  54. package/assets/xsl/pretext-dynamic.xsl +65 -0
  55. package/assets/xsl/pretext-epub.xsl +1483 -0
  56. package/assets/xsl/pretext-fo.xsl +4593 -0
  57. package/assets/xsl/pretext-html.xsl +14791 -0
  58. package/assets/xsl/pretext-json-manifest.xsl +150 -0
  59. package/assets/xsl/pretext-jupyter.xsl +868 -0
  60. package/assets/xsl/pretext-latex-classic.xsl +952 -0
  61. package/assets/xsl/pretext-latex-common.xsl +11563 -0
  62. package/assets/xsl/pretext-latex.xsl +47 -0
  63. package/assets/xsl/pretext-litprog.xsl +105 -0
  64. package/assets/xsl/pretext-merge.xsl +41 -0
  65. package/assets/xsl/pretext-numbers.xsl +875 -0
  66. package/assets/xsl/pretext-revealjs.xsl +522 -0
  67. package/assets/xsl/pretext-runestone-fitb.xsl +1233 -0
  68. package/assets/xsl/pretext-runestone-static.xsl +1438 -0
  69. package/assets/xsl/pretext-runestone.xsl +3083 -0
  70. package/assets/xsl/pretext-sage-doctest.xsl +289 -0
  71. package/assets/xsl/pretext-smc.xsl +492 -0
  72. package/assets/xsl/pretext-solution-manual-latex.xsl +323 -0
  73. package/assets/xsl/pretext-text-utilities.xsl +1217 -0
  74. package/assets/xsl/pretext-text.xsl +392 -0
  75. package/assets/xsl/pretext-units.xsl +195 -0
  76. package/assets/xsl/pretext-view-source.xsl +157 -0
  77. package/assets/xsl/pretext-ww-problem-sets.xsl +391 -0
  78. package/assets/xsl/publisher-variables.xsl +4756 -0
  79. package/assets/xsl/support/README.md +22 -0
  80. package/assets/xsl/support/extract-math.xsl +256 -0
  81. package/assets/xsl/support/package-math.xsl +141 -0
  82. package/assets/xsl/support/play-button/README.md +46 -0
  83. package/assets/xsl/support/play-button/play-button.png +0 -0
  84. package/assets/xsl/support/play-button/play-button.svg +3 -0
  85. package/assets/xsl/support/pretext-pg-macros.xsl +110 -0
  86. package/assets/xsl/support/webpack_static_imports.xml +14 -0
  87. package/assets/xsl/tests/README.md +24 -0
  88. package/assets/xsl/tests/null.xml +4 -0
  89. package/assets/xsl/tests/pretext-text-utilities-test.xsl +334 -0
  90. package/assets/xsl/utilities/README.md +31 -0
  91. package/assets/xsl/utilities/author-report.xsl +107 -0
  92. package/assets/xsl/utilities/deprecate-autoname.sed +18 -0
  93. package/assets/xsl/utilities/deprecate-index.sed +33 -0
  94. package/assets/xsl/utilities/fix-deprecations.xsl +663 -0
  95. package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -0
  96. package/assets/xsl/utilities/report-publisher-variables.xsl +162 -0
  97. package/assets/xsl/xml-to-json.xsl +326 -0
  98. package/assets/xsl/xml-to-string.xsl +328 -0
  99. package/cli.mjs +29 -0
  100. package/dist/cli-C6tfAVvi.js +553 -0
  101. package/dist/cli.d.ts +10 -0
  102. package/dist/cli.js +7 -0
  103. package/dist/index.d.ts +6 -0
  104. package/dist/index.js +10 -0
  105. package/dist/mounts.d.ts +23 -0
  106. package/dist/publication.d.ts +16 -0
  107. package/dist/renderer.d.ts +84 -0
  108. package/dist/sourcemap.d.ts +41 -0
  109. package/dist/xinclude.d.ts +45 -0
  110. package/package.json +52 -0
@@ -0,0 +1,22 @@
1
+ # PreTeXt (Miscellaneous) Support Files
2
+
3
+ ### Runestone Services
4
+
5
+ The `webpack_static_imports.xml` file contains the current version of the minimal set of JS and CSS files for providing "Runestone Services", either when hosted on a Runestone Server or when creating HTML for self-hosting.
6
+
7
+ As of 2024-07-31 the latest version can obtained with a `wget` from [https://runestone.academy/cdn/runestone/latest/webpack_static_imports.xml](https://runestone.academy/cdn/runestone/latest/webpack_static_imports.xml).
8
+
9
+ An outline of the procedure to update this file is:
10
+
11
+ ```
12
+ cd xsl/support
13
+ wget -O webpack_static_imports.xml https://runestone.academy/cdn/runestone/latest/webpack_static_imports.xml
14
+ git diff
15
+ git st
16
+
17
+ <verify/obtain new version number in diff, use in commit message>
18
+
19
+ git commit -am "Runestone: update services file to vX.Y.Z"
20
+
21
+ <push new commit to PreTeXt repository>
22
+ ```
@@ -0,0 +1,256 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2020 Robert A. Beezer
5
+
6
+ This file is part of PreTeXt.
7
+
8
+ PreTeXt is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 2 or version 3 of the
11
+ License (at your option).
12
+
13
+ PreTeXt is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
20
+ *********************************************************************-->
21
+
22
+ <!-- We build a very basic HTML page intended for MathJax -->
23
+ <!-- to process with its *-page tools -->
24
+ <!-- -->
25
+ <!-- Pro: faster than a new system call for each and -->
26
+ <!-- every math element -->
27
+ <!-- Pro: if MathJax produces output that is not XHTML -->
28
+ <!-- any defects will be minimal and controllable -->
29
+ <!-- Con: one massive cache of font info, which could be -->
30
+ <!-- much more than an eventual chunked page might need -->
31
+ <!-- -->
32
+ <!-- The result is meant to be processed by the -->
33
+ <!-- package-math.xsl stylesheet for eventual use -->
34
+
35
+ <!-- NB: string functions can leave if latex macros get fixed elsewhere -->
36
+ <xsl:stylesheet
37
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
38
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
39
+ xmlns:str="http://exslt.org/strings"
40
+ extension-element-prefixes="str"
41
+ >
42
+
43
+ <!-- Get internal ID's for filenames, etc -->
44
+ <!-- Standard conversion groundwork -->
45
+ <xsl:import href="../publisher-variables.xsl"/>
46
+ <xsl:import href="../pretext-assembly.xsl"/>
47
+ <xsl:import href="../pretext-common.xsl"/>
48
+
49
+ <!-- Use the HTML variants, as we are making input for MathJax -->
50
+ <xsl:import href="../pretext-html.xsl" />
51
+
52
+ <!-- Extraction infrastructure, plus redefinition -->
53
+ <!-- of entry template, so *after* HTML template -->
54
+ <xsl:import href="../extract-identity.xsl" />
55
+
56
+ <!-- Write XML, since 'output="html"' creates things -->
57
+ <!-- like unclosed "meta" and these get replicated by -->
58
+ <!-- the MathJax tools, producing a non-XML file. -->
59
+
60
+ <!-- Output an HTML for MathJax to consume page -->
61
+ <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" doctype-system="about:legacy-compat"/>
62
+
63
+ <!-- This variable controls representations of interactive exercises -->
64
+ <!-- built in pretext-assembly.xsl. The imported pretext-html.xsl -->
65
+ <!-- stylesheet sets it to "dynamic". But for this stylesheet we want -->
66
+ <!-- to utilize the "standard" PreTeXt exercise versions built with -->
67
+ <!-- "static". See both pretext-assembly.xsl and pretext-html.xsl -->
68
+ <!-- for more discussion. -->
69
+ <xsl:variable name="exercise-style" select="'static'"/>
70
+
71
+ <!-- This stylesheet is parameterized by how trailing punctuation -->
72
+ <!-- is handled by math elements. An xsl:param immediately overrides -->
73
+ <!-- the global cross-stylesheet variable, to counteract how the HTML -->
74
+ <!-- routinely incorporates trailing punctuation into the LaTeX math. -->
75
+ <!-- The param default is the same as the variable default. -->
76
+ <!-- NB: a stylesheet that eventually consumes this math will need to -->
77
+ <!-- use the modal "get-clause-punctuation" template to coordinate with -->
78
+ <!-- what happens here. Give the global varible the same value and -->
79
+ <!-- then the "get-clause-punctuation" used at the end of the -->
80
+ <!-- construction of the math element should produce the right action. -->
81
+ <xsl:param name="math.punctuation" select="'none'"/>
82
+ <xsl:variable name="math.punctuation.include" select="$math.punctuation"/>
83
+
84
+ <!-- A consumer that renders the math SVG into a single-file target -->
85
+ <!-- (such as the XSL-FO conversion to PDF) can make a -->
86
+ <!-- cross-reference inside math an active link by setting this to -->
87
+ <!-- 'yes': the "xref" then emits a \href{#id} that MathJax turns -->
88
+ <!-- into an SVG "a" element. The "#id" is the shared "unique-id" of -->
89
+ <!-- the target, so it matches the anchor that conversion places on -->
90
+ <!-- the target. Off ('no') by default, since a chunked target -->
91
+ <!-- (HTML, EPUB) needs a filename, not a bare fragment, and not -->
92
+ <!-- every reader honors the SVG link. -->
93
+ <xsl:param name="math.cross-references" select="'no'"/>
94
+
95
+ <!-- We import the HTML stylesheet since we want HTML versions of -->
96
+ <!-- the math bits, but we don't need all the chunking machinery -->
97
+ <!-- for extracting math, since we are building a single file, -->
98
+ <!-- so we set the level to control associated templates -->
99
+ <xsl:variable name="chunk-level" select="number(0)"/>
100
+
101
+ <!-- Base HTML conversion (which we have imported) wraps mathematics -->
102
+ <!-- with a class "process-math", which is specified in the MathJax 3 -->
103
+ <!-- configuration so we can ignore non-math bits and not get confused -->
104
+ <!-- by stray LaTeX/ASCIIMath/MathJax markup. Here we just rip out -->
105
+ <!-- and package math for subsequent processing, so no such -->
106
+ <!-- contortions are necessary and a simpler wrapping is possible. -->
107
+
108
+ <!-- Inline math does not need a "span", just delimiters -->
109
+ <xsl:template name="inline-math-wrapper">
110
+ <xsl:param name="math"/>
111
+ <xsl:text>\(</xsl:text>
112
+ <xsl:value-of select="$math"/>
113
+ <xsl:text>\)</xsl:text>
114
+ </xsl:template>
115
+
116
+ <!-- No special wrapping needed for display -->
117
+ <!-- mathematics, so just copy the content -->
118
+ <xsl:template match="md[mrow]" mode="display-math-wrapper">
119
+ <xsl:param name="content" />
120
+ <xsl:copy-of select="$content" />
121
+ </xsl:template>
122
+
123
+ <!-- Build a super-simple HTML page, whose only -->
124
+ <!-- purpose is to serve as input to a MathJax -->
125
+ <!-- *-page routine. -->
126
+ <!-- calling context is $root, or subtree root -->
127
+ <xsl:template match="*" mode="extraction-wrapper">
128
+ <html>
129
+ <!-- no "head" at all -->
130
+ <body>
131
+ <!-- MathJax predefines \lt and \gt to avoid XML's <, > -->
132
+ <!-- We therefore define these for LaTeX use to be -->
133
+ <!-- universal. Usually no harm having them in HTML output, -->
134
+ <!-- BUT MathJax puts raw LaTeX into the @alttext attribute, -->
135
+ <!-- where our definitions with unescaped version of <, > -->
136
+ <!-- are a syntax violation. So we scrub them. -->
137
+ <!-- TODO: move this and make two $latex-macros, -->
138
+ <!-- one for HTML and one for LaTeX -->
139
+ <xsl:variable name="no-less-than" select="str:replace($latex-macros, '\newcommand{\lt}{&lt;}&#xa;', '')"/>
140
+ <xsl:variable name="latex-macros-html" select="str:replace($no-less-than, '\newcommand{\gt}{&gt;}&#xa;', '')"/>
141
+ <!-- put macros and packages early for MJ to find -->
142
+ <!-- give the div an @id so we can trash it as a leftover -->
143
+ <!-- NB: "math support" macros (fillin-math, sfrac) must -->
144
+ <!-- be defined here AND in the "latex-macros" named -->
145
+ <!-- template in pretext-html.xsl -->
146
+ <div id="latex-macros">
147
+ <xsl:call-template name="inline-math-wrapper">
148
+ <xsl:with-param name="math">
149
+ <xsl:value-of select="$latex-packages-mathjax"/>
150
+ <xsl:value-of select="$latex-macros-html"/>
151
+ <xsl:call-template name="fillin-math"/>
152
+ <!-- legacy built-in support for "slanted|beveled|nice" fractions -->
153
+ <xsl:if test="$b-has-sfrac">
154
+ <xsl:text>\newcommand{\sfrac}[2]{{#1}/{#2}}&#xa;</xsl:text>
155
+ </xsl:if>
156
+ </xsl:with-param>
157
+ </xsl:call-template>
158
+ </div>
159
+ <!-- initiate tree-walker "extraction" templates -->
160
+ <xsl:apply-imports/>
161
+ </body>
162
+ </html>
163
+ </xsl:template>
164
+
165
+ <!-- Associate IDs with the LaTeX so we know where -->
166
+ <!-- the processed results belong when reinserted. -->
167
+ <!-- Flag the context as "inline" v. "displaymath" -->
168
+ <!-- so that we can do things like place a CSS class -->
169
+ <!-- for MathJax to see when processing the math bits. -->
170
+ <xsl:template match="m|md" mode="extraction">
171
+ <xsl:variable name="context">
172
+ <xsl:choose>
173
+ <xsl:when test="self::m">
174
+ <xsl:text>inline</xsl:text>
175
+ </xsl:when>
176
+ <xsl:when test="self::md">
177
+ <xsl:text>displaymath</xsl:text>
178
+ </xsl:when>
179
+ </xsl:choose>
180
+ </xsl:variable>
181
+ <div context="{$context}">
182
+ <!-- NB: stylesheets receiving these representations will -->
183
+ <!-- want to *also* mark math bits via the "unique-id" -->
184
+ <!-- The speed of the "unique-id" is critical here -->
185
+ <xsl:attribute name="id">
186
+ <xsl:apply-templates select="." mode="unique-id"/>
187
+ </xsl:attribute>
188
+ <xsl:apply-templates select="."/>
189
+ </div>
190
+ </xsl:template>
191
+
192
+
193
+ <!-- An "xref" inside of math is a delicate matter. -->
194
+ <!-- -->
195
+ <!-- 1. A number is computed based on various numbering switches so this -->
196
+ <!-- sort of information needs to be available to this conversion. -->
197
+ <!-- -->
198
+ <!-- 2. A \href{} is recognized by MathJax and puts an "a" element into -->
199
+ <!-- an output SVG. But Calibre (for example) does not seem to recognize this. -->
200
+ <!-- See "xLinks" section of https://wiki.mobileread.com/wiki/SVG (2020-03-25), -->
201
+ <!-- perhaps the MathJax version does not have enough namespace info, etc. -->
202
+ <!-- The \knowl{} extension of the conversion to HTML is not understood at all. -->
203
+ <!-- A knowl requires that PreTeXt Javascript named like "mathjaxknowl.js" -->
204
+ <!-- loaded as a MathJax extension for knowls to possibly render -->
205
+ <!-- -->
206
+ <!-- 3. Our links' base filename will depend on chunking level, and the file -->
207
+ <!-- extension may need to ".xhtml" (not ".html") if the destination is EPUB. -->
208
+ <!-- And the lxml parser complains when a global XSL variable is redefined -->
209
+ <!-- in an override/import. -->
210
+ <!-- -->
211
+ <!-- We drop in text (1, the computed number, already wrapped in a LaTeX \text{}), -->
212
+ <!-- which is all a chunked target (3) can use, and is the default ('no') because not -->
213
+ <!-- every reader honors an SVG link (2). But when "math.cross-references" is 'yes' a -->
214
+ <!-- single-file target (such as the XSL-FO conversion to PDF) wants the live link of -->
215
+ <!-- (2): wrap that same text in a \href to the target's "#id", which MathJax renders -->
216
+ <!-- as an "a" element in the SVG. -->
217
+ <xsl:template match="*" mode="xref-link-display-math">
218
+ <xsl:param name="target"/>
219
+ <xsl:param name="content"/>
220
+ <xsl:choose>
221
+ <xsl:when test="$math.cross-references = 'yes'">
222
+ <xsl:text>\href{#</xsl:text>
223
+ <xsl:apply-templates select="$target" mode="unique-id"/>
224
+ <xsl:text>}{</xsl:text>
225
+ <xsl:choose>
226
+ <!-- an electronic PDF colors the reference like every -->
227
+ <!-- other link (the dark blue of "link-attributes" in -->
228
+ <!-- pretext-fo.xsl), via MathJax's \color; print leaves -->
229
+ <!-- it black, exactly as the other links do -->
230
+ <xsl:when test="$b-latex-print">
231
+ <xsl:value-of select="$content"/>
232
+ </xsl:when>
233
+ <xsl:otherwise>
234
+ <xsl:text>\color{#000080}{</xsl:text>
235
+ <xsl:value-of select="$content"/>
236
+ <xsl:text>}</xsl:text>
237
+ </xsl:otherwise>
238
+ </xsl:choose>
239
+ <xsl:text>}</xsl:text>
240
+ </xsl:when>
241
+ <xsl:otherwise>
242
+ <xsl:value-of select="$content"/>
243
+ </xsl:otherwise>
244
+ </xsl:choose>
245
+ </xsl:template>
246
+
247
+ <!-- Knowls -->
248
+ <!-- No cross-reference should be a knowl -->
249
+ <!-- Turn off knowls so SVG production goes OK -->
250
+ <!-- TODO: Need to know desired chunk level for links to be -->
251
+ <!-- correct, possibly in the publisher file once revisited -->
252
+ <xsl:template match="*" mode="xref-as-knowl">
253
+ <xsl:value-of select="false()" />
254
+ </xsl:template>
255
+
256
+ </xsl:stylesheet>
@@ -0,0 +1,141 @@
1
+ <?xml version='1.0'?>
2
+
3
+ <!--********************************************************************
4
+ Copyright 2020 Robert A. Beezer
5
+
6
+ This file is part of PreTeXt.
7
+
8
+ PreTeXt is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 2 or version 3 of the
11
+ License (at your option).
12
+
13
+ PreTeXt is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
20
+ *********************************************************************-->
21
+
22
+ <!-- This stylesheet expects the XHTML built by the extract-math.xsl -->
23
+ <!-- stylesheet, to have been processed by MathJax 3 and Speech Rule -->
24
+ <!-- Engine (SRE). The result, which as an organization created by -->
25
+ <!-- the script from mathJax is here repackaged with PreTeXt -->
26
+ <!-- internal elements (in a different namespace). -->
27
+ <!-- The output is organized as follows: -->
28
+ <!-- -->
29
+ <!-- pi:math-representations -->
30
+ <!-- pi:math -->
31
+ <!-- ... -->
32
+ <!-- pi:math -->
33
+ <!-- svg/defs -->
34
+ <!-- -->
35
+ <!-- The multiple pi:math elements have -->
36
+ <!-- @id: matches the id of its progenitor in the source -->
37
+ <!-- @context: category of progenitor ("inline" v. "displaymath") -->
38
+ <!-- div: one to four, with classes indicating content -->
39
+ <!-- MathML and/or SVG (structured) -->
40
+ <!-- braille, speech (raw content) -->
41
+ <!-- -->
42
+ <!-- The final element is a font cache, which -->
43
+ <!-- has the @id attribute value "font-data" -->
44
+
45
+ <xsl:stylesheet
46
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
47
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
48
+ xmlns:pi="http://pretextbook.org/2020/pretext/internal"
49
+ xmlns:svg="http://www.w3.org/2000/svg"
50
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
51
+ exclude-result-prefixes="svg"
52
+ >
53
+
54
+ <xsl:output method="xml" encoding="UTF-8"/>
55
+
56
+ <!-- Our simple webpage is processed by MathJax via the mathjax-node-page -->
57
+ <!-- program. This invocation is parameterized by a choice of SVG output -->
58
+ <!-- or MathML output. Either way, the structure of the page is -->
59
+ <!-- identical, so we seem to handle both simultaneously here. However, -->
60
+ <!-- only one or the other is present. -->
61
+
62
+ <!-- This is "pure" MathJax output, we leave adjustments to consumers -->
63
+
64
+ <!-- Entry template, and cruiser -->
65
+ <!-- We start here, and at each node, we simply descend, -->
66
+ <!-- *unless* some template below kicks into action -->
67
+ <xsl:template match="/|node()|@*">
68
+ <xsl:apply-templates select="node()|@*"/>
69
+ </xsl:template>
70
+
71
+ <!-- We explicitly kill the LaTeX macro div, lest -->
72
+ <!-- it get picked up as similar to the other math -->
73
+ <xsl:template match="div[@id = 'latex-macros']"/>
74
+
75
+ <!-- Body has what we want/need -->
76
+ <xsl:template match="body">
77
+ <pi:math-representations>
78
+ <xsl:apply-templates select="node()|@*"/>
79
+ <xsl:text>&#xa;&#xa;</xsl:text>
80
+ </pi:math-representations>
81
+ </xsl:template>
82
+
83
+ <!-- Replace PreTeXt "div" w/ location info plus MJ "mjx-data" -->
84
+ <!-- container by a consolidated PreteXt "pi:math" container -->
85
+ <!-- with location info -->
86
+ <xsl:template match="div/mjx-data">
87
+ <xsl:text>&#xa;&#xa;</xsl:text>
88
+ <pi:math>
89
+ <!-- duplicate location, context info -->
90
+ <xsl:copy-of select="../@*"/>
91
+ <!-- pickup whatever gets produced by MJ/SRE script with -->
92
+ <!-- its own containerization: MathML, SVG, braille, speech -->
93
+ <xsl:apply-templates select="math:math|svg:svg|mjx-braille|mjx-speech"/>
94
+ </pi:math>
95
+ </xsl:template>
96
+
97
+ <!-- Now duplicate actual representations (structured or -->
98
+ <!-- raw content), always wrapped in an identifying div -->
99
+
100
+ <xsl:template match="math:math">
101
+ <div class="mathml">
102
+ <xsl:copy-of select="."/>
103
+ </div>
104
+ </xsl:template>
105
+
106
+ <xsl:template match="svg:svg">
107
+ <div class="svg">
108
+ <xsl:copy-of select="."/>
109
+ </div>
110
+ </xsl:template>
111
+
112
+ <xsl:template match="mjx-braille">
113
+ <div class="braille">
114
+ <xsl:copy-of select="node()"/>
115
+ </div>
116
+ </xsl:template>
117
+
118
+ <xsl:template match="mjx-speech">
119
+ <div class="speech">
120
+ <xsl:copy-of select="node()"/>
121
+ </div>
122
+ </xsl:template>
123
+
124
+ <!-- SVG font (glyphs) cache -->
125
+ <!-- Following depends on font caching behavior -->
126
+ <!-- as passed to mathjax-node-page routine -->
127
+ <!-- global cache: a pile of defs in a single SVG -->
128
+ <!-- no caching: defs are per-SVG, no match here -->
129
+ <!-- NB: need to have this prefixed with "body" to -->
130
+ <!-- identify it as top-level, global situation, -->
131
+ <!-- rather than local to each individual SVG -->
132
+ <xsl:template match="body/svg:svg[svg:defs]">
133
+ <xsl:copy>
134
+ <xsl:attribute name="id">
135
+ <xsl:text>font-data</xsl:text>
136
+ </xsl:attribute>
137
+ <xsl:apply-templates select="node()|@*"/>
138
+ </xsl:copy>
139
+ </xsl:template>
140
+
141
+ </xsl:stylesheet>
@@ -0,0 +1,46 @@
1
+ Generic Video Preview Image
2
+
3
+ ```
4
+
5
+ 2023-02-07: This image was previously provided for LaTeX output as a macro that resolves to a TikZ version. See removed code and comments below. In HTML we use an SVG we have mildly edited. Search the HTML conversion for a template with name "generic-preview-svg".
6
+
7
+ The SVG image in this directory is a copy of the HTML SVG code.
8
+
9
+ ImageMagick's `convert` command has been used to make the PNG here. The option `-density 600` was used to reduce pixelated lines.
10
+
11
+ The purpose of the PNG image is to be the static version created via the pre-processor.
12
+
13
+
14
+ %% Page: https://commons.wikimedia.org/wiki/File:YouTube_Play_Button.svg
15
+ %% File: https://upload.wikimedia.org/wikipedia/commons/d/d1/YouTube_Play_Button.svg
16
+ %% License text: This image only consists of simple geometric shapes or text.
17
+ %% It does not meet the threshold of originality needed for copyright protection,
18
+ %% and is therefore in the public domain.
19
+ %% Converted from HTML's SVG into tikZ code via github.com/kjellmf/svg2tikz.git
20
+ %% Generic red play button (from SVG)
21
+ %% tikz package should be loaded by now
22
+ \definecolor{playred}{RGB}{230,33,23}
23
+ \newcommand{\genericpreview}{
24
+ \begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
25
+ \path[fill=playred] (94.9800,28.8400) .. controls (94.9800,28.8400) and
26
+ (94.0400,22.2400) .. (91.1700,19.3400) .. controls (87.5300,15.5300) and
27
+ (83.4500,15.5100) .. (81.5800,15.2900) .. controls (68.1800,14.3200) and
28
+ (48.0600,14.4400) .. (48.0600,14.4400) .. controls (48.0600,14.4400) and
29
+ (27.9400,14.3200) .. (14.5400,15.2900) .. controls (12.6700,15.5100) and
30
+ (8.5900,15.5300) .. (4.9500,19.3400) .. controls (2.0800,22.2400) and
31
+ (1.1400,28.8400) .. (1.1400,28.8400) .. controls (1.1400,28.8400) and
32
+ (0.1800,36.5800) .. (0.0000,44.3300) -- (0.0000,51.5900) .. controls
33
+ (0.1800,59.3400) and (1.1400,67.0800) .. (1.1400,67.0800) .. controls
34
+ (1.1400,67.0800) and (2.0700,73.6800) .. (4.9500,76.5800) .. controls
35
+ (8.5900,80.3900) and (13.3800,80.2700) .. (15.5100,80.6700) .. controls
36
+ (23.0400,81.3900) and (47.2100,81.5600) .. (48.0500,81.5700) .. controls
37
+ (48.0600,81.5700) and (68.1900,81.6000) .. (81.5900,80.6300) .. controls
38
+ (83.4600,80.4100) and (87.5400,80.3900) .. (91.1800,76.5800) .. controls
39
+ (94.0500,73.6800) and (94.9900,67.0800) .. (94.9900,67.0800) .. controls
40
+ (94.9900,67.0800) and (95.9500,59.3300) .. (96.0100,51.5900) --
41
+ (96.0100,44.3300) .. controls (95.9400,36.5800) and (94.9800,28.8400) ..
42
+ (94.9800,28.8400) -- cycle(38.2800,61.4100) -- (38.2800,34.4100) --
43
+ (64.0200,47.9100) -- (38.2800,61.4100) -- cycle;
44
+ \end{tikzpicture}
45
+ }
46
+ ```
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 14 96 68" style="cursor:pointer; position: absolute; top: 0; left: 0; width: 100%; height: 100%;" preserveAspectRatio="none">
2
+ <path fill="#e62117" d="M94.98,28.84c0,0-0.94-6.6-3.81-9.5c-3.64-3.81-7.72-3.83-9.59-4.05c-13.4-0.97-33.52-0.85-33.52-0.85s-20.12-0.12-33.52,0.85c-1.87,0.22-5.95,0.24-9.59,4.05c-2.87,2.9-3.81,9.5-3.81,9.5S0.18,36.58,0,44.33v7.26c0.18,7.75,1.14,15.49,1.14,15.49s0.93,6.6,3.81,9.5c3.64,3.81,8.43,3.69,10.56,4.09c7.53,0.72,31.7,0.89,32.54,0.9c0.01,0,20.14,0.03,33.54-0.94c1.87-0.22,5.95-0.24,9.59-4.05c2.87-2.9,3.81-9.5,3.81-9.5s0.96-7.75,1.02-15.49v-7.26C95.94,36.58,94.98,28.84,94.98,28.84z M38.28,61.41v-27l25.74,13.5L38.28,61.41z"/>
3
+ </svg>
@@ -0,0 +1,110 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <!-- ********************************************************************* -->
4
+ <!-- Copyright 2021 -->
5
+ <!-- Robert A. Beezer -->
6
+ <!-- -->
7
+ <!-- This file is part of PreTeXt. -->
8
+ <!-- -->
9
+ <!-- PreTeXt is free software: you can redistribute it and/or modify -->
10
+ <!-- it under the terms of the GNU General Public License as published by -->
11
+ <!-- the Free Software Foundation, either version 2 or version 3 of the -->
12
+ <!-- License (at your option). -->
13
+ <!-- -->
14
+ <!-- PreTeXt is distributed in the hope that it will be useful, -->
15
+ <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
16
+ <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
17
+ <!-- GNU General Public License for more details. -->
18
+ <!-- -->
19
+ <!-- You should have received a copy of the GNU General Public License -->
20
+ <!-- along with PreTeXt. If not, see <http://www.gnu.org/licenses/>. -->
21
+ <!-- ********************************************************************* -->
22
+
23
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
24
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
25
+ xmlns:exsl="http://exslt.org/common"
26
+ xmlns:str="http://exslt.org/strings"
27
+ extension-element-prefixes="exsl str"
28
+ >
29
+
30
+ <!-- This style sheet creates a perl library (.pl) file with WeBWorK PG -->
31
+ <!-- macros that support WeBWorK problems authored in a PreTeXt project. -->
32
+ <!-- Eventually when used by the pretext script, the name of the perl -->
33
+ <!-- library file will be generated from the project title. -->
34
+
35
+ <!-- Standard conversion groundwork -->
36
+ <xsl:import href="../publisher-variables.xsl"/>
37
+ <xsl:import href="../pretext-assembly.xsl"/>
38
+ <xsl:import href="../pretext-common.xsl"/>
39
+
40
+ <!-- We need to alert the pretext-assembly.xsl stylesheet -->
41
+ <!-- that it is being used in the very specific instance -->
42
+ <!-- of extracting these objects for processing externally, -->
43
+ <!-- with results collected in additional files, for -->
44
+ <!-- consultation/collection in a more general use of this -->
45
+ <!-- stylesheet for the purpose of actually building a useful -->
46
+ <!-- output format. This variable declaration here overrides -->
47
+ <!-- the default setting of "false" in pretext-assembly.xsl. -->
48
+ <!-- Look there for a more comprehensive discussion of the -->
49
+ <!-- necessity of this scheme. -->
50
+ <xsl:variable name="b-extracting-pg" select="true()"/>
51
+
52
+ <!-- We are outputting perl code, and there is no reason to output -->
53
+ <!-- anything other than "text" -->
54
+ <xsl:output method="text" encoding="UTF-8" />
55
+
56
+ <!--#######################################################################-->
57
+ <!-- Entry Template -->
58
+ <!--#######################################################################-->
59
+
60
+ <xsl:template match="/">
61
+ <xsl:variable name="macro-file-name">
62
+ <xsl:choose>
63
+ <xsl:when test="$docinfo/initialism">
64
+ <xsl:value-of select="$docinfo/initialism"/>
65
+ </xsl:when>
66
+ <xsl:otherwise>
67
+ <xsl:apply-templates select="$document-root" mode="title-filesafe"/>
68
+ </xsl:otherwise>
69
+ </xsl:choose>
70
+ <text>.pl</text>
71
+ </xsl:variable>
72
+ <xsl:variable name="macro-file-content">
73
+ <xsl:call-template name="header"/>
74
+ <xsl:apply-templates select="$document-root" mode="latex-image-preamble"/>
75
+ </xsl:variable>
76
+ <exsl:document href="{$macro-file-name}" method="text">
77
+ <xsl:call-template name="sanitize-text">
78
+ <xsl:with-param name="text" select="$macro-file-content" />
79
+ </xsl:call-template>
80
+ </exsl:document>
81
+ </xsl:template>
82
+
83
+ <xsl:template match="book|article" mode="latex-image-preamble">
84
+ <xsl:if test="$docinfo/latex-image-preamble">
85
+ <xsl:text># Return a string containing the latex-image-preamble contents.&#xa;</xsl:text>
86
+ <xsl:text># To be used by LaTeXImage objects as in:&#xa;</xsl:text>
87
+ <xsl:text># $image->addToPreamble(latexImagePreamble())&#xa;</xsl:text>
88
+ <xsl:text>&#xa;</xsl:text>
89
+ <xsl:text>sub latexImagePreamble {&#xa;</xsl:text>
90
+ <xsl:text>return &lt;&lt;'END_LATEX_IMAGE_PREAMBLE'&#xa;</xsl:text>
91
+ <xsl:call-template name="sanitize-text">
92
+ <xsl:with-param name="text" select="$docinfo/latex-image-preamble" />
93
+ </xsl:call-template>
94
+ <xsl:text>&#xa;</xsl:text>
95
+ <xsl:text>END_LATEX_IMAGE_PREAMBLE&#xa;</xsl:text>
96
+ <xsl:text>}&#xa;&#xa;</xsl:text>
97
+ </xsl:if>
98
+ </xsl:template>
99
+
100
+ <xsl:template name="header">
101
+ <xsl:text>#############################################################################&#xa;</xsl:text>
102
+ <xsl:text># This macro library supports WeBWorK problems from the PreTeXt project named&#xa;</xsl:text>
103
+ <xsl:text># </xsl:text>
104
+ <xsl:apply-templates select="$document-root" mode="title-full" />
105
+ <xsl:text>&#xa;</xsl:text>
106
+ <xsl:text>#############################################################################&#xa;</xsl:text>
107
+ <xsl:text>&#xa;&#xa;</xsl:text>
108
+ </xsl:template>
109
+
110
+ </xsl:stylesheet>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" ?>
2
+ <all>
3
+ <js type="list">
4
+ <item type="str">prefix-runtime.00db6230172ad960.bundle.js</item>
5
+ <item type="str">prefix-347.8328b60515045466.bundle.js</item>
6
+ <item type="str">prefix-runestone.aa624e4071d017c3.bundle.js</item>
7
+ </js>
8
+ <css type="list">
9
+ <item type="str">prefix-347.f9add1ca35d5ad93.css</item>
10
+ <item type="str">prefix-runestone.51d479d87f8466bb.css</item>
11
+ </css>
12
+ <cdn-url type="str">https://runestone.academy/cdn/runestone/</cdn-url>
13
+ <version type="str">7.4.4</version>
14
+ </all>
@@ -0,0 +1,24 @@
1
+ # XSL Automated Tests
2
+
3
+ This folder contains testing utilities for XSL templates. The tests focus on function-like templates for tasks like string manipulation that are used as helpers throughout the XSL stylesheets. Most of these functions are otherwise only observable indirectly through their effects on the output of the main XSL stylesheets.
4
+
5
+ ## Running Tests
6
+
7
+ To run the tests, you can use the `xsltproc` command-line tool. For example:
8
+
9
+ ```
10
+ xsltproc pretext-text-utilities-test.xsl null.xml
11
+ ```
12
+
13
+ A successfully run will just produce the output `Tests complete!`. If there are any issues, the output will include error messages indicating what went wrong.
14
+
15
+ ## Writing Tests
16
+
17
+ Ideally, before making changes to any low-level utility XSL templates, a developer should document the intended behavior of the template in a set of tests. These tests can be submitted as part of a pull request as evidence the XSL works as intended and to prevent regressions in the future.
18
+
19
+ Refer to the existing tests in `pretext-text-utilities-test.xsl` for examples of how to do so.
20
+
21
+ ## Files
22
+
23
+ - `pretext-text-utilities-test.xsl`: Contains tests for the text utilities templates.
24
+ - `null.xml`: A minimal XML file used as input for the tests.
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!-- intentionally empty valid XML file for use with pretext-text-utilities-text.xsl -->
3
+ <nothing>
4
+ </nothing>