@pretextbook/pretext-html 0.1.0 → 0.1.1

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 (111) hide show
  1. package/README.md +42 -3
  2. package/assets/preview-html.xsl +230 -230
  3. package/assets/upstream.json +7 -7
  4. package/assets/xsl/README.md +0 -0
  5. package/assets/xsl/entities.ent +154 -154
  6. package/assets/xsl/extract-asymptote.xsl +68 -68
  7. package/assets/xsl/extract-biblio-csl.xsl +327 -327
  8. package/assets/xsl/extract-datafile.xsl +71 -71
  9. package/assets/xsl/extract-dynamic.xsl +139 -139
  10. package/assets/xsl/extract-identity.xsl +136 -136
  11. package/assets/xsl/extract-interactive.xsl +81 -81
  12. package/assets/xsl/extract-latex-image.xsl +118 -118
  13. package/assets/xsl/extract-mermaid.xsl +58 -58
  14. package/assets/xsl/extract-mom.xsl +63 -63
  15. package/assets/xsl/extract-pg.xsl +2897 -2897
  16. package/assets/xsl/extract-prefigure.xsl +157 -157
  17. package/assets/xsl/extract-qrcode.xsl +100 -100
  18. package/assets/xsl/extract-runestone-page-template.xsl +139 -139
  19. package/assets/xsl/extract-sageplot.xsl +166 -166
  20. package/assets/xsl/extract-stack.xsl +56 -56
  21. package/assets/xsl/extract-trace.xsl +134 -134
  22. package/assets/xsl/extract-youtube.xsl +63 -63
  23. package/assets/xsl/html-symbols.xsl +3344 -3344
  24. package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -56
  25. package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -148
  26. package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -317
  27. package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -76
  28. package/assets/xsl/latex/pretext-latex-guide.xsl +104 -104
  29. package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -862
  30. package/assets/xsl/localizations/README.md +0 -0
  31. package/assets/xsl/localizations/af-ZA.xml +276 -276
  32. package/assets/xsl/localizations/bg-BG.xml +276 -276
  33. package/assets/xsl/localizations/ca-ES.xml +285 -285
  34. package/assets/xsl/localizations/cs-CZ.xml +280 -280
  35. package/assets/xsl/localizations/de-DE.xml +281 -281
  36. package/assets/xsl/localizations/en-US.xml +427 -427
  37. package/assets/xsl/localizations/es-ES.xml +287 -287
  38. package/assets/xsl/localizations/fi-FI.xml +275 -275
  39. package/assets/xsl/localizations/fr-CA.xml +276 -276
  40. package/assets/xsl/localizations/fr-FR.xml +280 -280
  41. package/assets/xsl/localizations/hu-HU.xml +280 -280
  42. package/assets/xsl/localizations/it-IT.xml +276 -276
  43. package/assets/xsl/localizations/ku-CKB.xml +275 -275
  44. package/assets/xsl/localizations/localizations.xml +48 -48
  45. package/assets/xsl/localizations/nl-NL.xml +275 -275
  46. package/assets/xsl/localizations/pt-BR.xml +288 -288
  47. package/assets/xsl/localizations/pt-PT.xml +292 -292
  48. package/assets/xsl/localizations/zh-HANS.xml +269 -269
  49. package/assets/xsl/pretext-assembly.xsl +4795 -4795
  50. package/assets/xsl/pretext-basic-html.xsl +86 -86
  51. package/assets/xsl/pretext-beamer.xsl +662 -662
  52. package/assets/xsl/pretext-braille-preprint.xsl +2249 -2249
  53. package/assets/xsl/pretext-common.xsl +12018 -12018
  54. package/assets/xsl/pretext-dynamic.xsl +65 -65
  55. package/assets/xsl/pretext-epub.xsl +1483 -1483
  56. package/assets/xsl/pretext-fo.xsl +4593 -4593
  57. package/assets/xsl/pretext-html.xsl +14791 -14791
  58. package/assets/xsl/pretext-json-manifest.xsl +150 -150
  59. package/assets/xsl/pretext-jupyter.xsl +868 -868
  60. package/assets/xsl/pretext-latex-classic.xsl +952 -952
  61. package/assets/xsl/pretext-latex-common.xsl +11563 -11563
  62. package/assets/xsl/pretext-latex.xsl +47 -47
  63. package/assets/xsl/pretext-litprog.xsl +105 -105
  64. package/assets/xsl/pretext-merge.xsl +41 -41
  65. package/assets/xsl/pretext-numbers.xsl +875 -875
  66. package/assets/xsl/pretext-revealjs.xsl +522 -522
  67. package/assets/xsl/pretext-runestone-fitb.xsl +1233 -1233
  68. package/assets/xsl/pretext-runestone-static.xsl +1438 -1438
  69. package/assets/xsl/pretext-runestone.xsl +3083 -3083
  70. package/assets/xsl/pretext-sage-doctest.xsl +289 -289
  71. package/assets/xsl/pretext-smc.xsl +492 -492
  72. package/assets/xsl/pretext-solution-manual-latex.xsl +323 -323
  73. package/assets/xsl/pretext-text-utilities.xsl +1217 -1217
  74. package/assets/xsl/pretext-text.xsl +392 -392
  75. package/assets/xsl/pretext-units.xsl +195 -195
  76. package/assets/xsl/pretext-view-source.xsl +157 -157
  77. package/assets/xsl/pretext-ww-problem-sets.xsl +391 -391
  78. package/assets/xsl/publisher-variables.xsl +4756 -4756
  79. package/assets/xsl/support/README.md +0 -0
  80. package/assets/xsl/support/extract-math.xsl +256 -256
  81. package/assets/xsl/support/package-math.xsl +141 -141
  82. package/assets/xsl/support/play-button/README.md +0 -0
  83. package/assets/xsl/support/play-button/play-button.png +0 -0
  84. package/assets/xsl/support/play-button/play-button.svg +3 -3
  85. package/assets/xsl/support/pretext-pg-macros.xsl +110 -110
  86. package/assets/xsl/support/webpack_static_imports.xml +14 -14
  87. package/assets/xsl/tests/README.md +0 -0
  88. package/assets/xsl/tests/null.xml +3 -3
  89. package/assets/xsl/tests/pretext-text-utilities-test.xsl +333 -333
  90. package/assets/xsl/utilities/README.md +0 -0
  91. package/assets/xsl/utilities/author-report.xsl +107 -107
  92. package/assets/xsl/utilities/deprecate-autoname.sed +18 -18
  93. package/assets/xsl/utilities/deprecate-index.sed +33 -33
  94. package/assets/xsl/utilities/fix-deprecations.xsl +663 -663
  95. package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -112
  96. package/assets/xsl/utilities/report-publisher-variables.xsl +162 -162
  97. package/assets/xsl/xml-to-json.xsl +326 -326
  98. package/assets/xsl/xml-to-string.xsl +328 -328
  99. package/dist/{cli-C6tfAVvi.js → cli-BQizBK0N.js} +74 -72
  100. package/dist/cli.d.ts +0 -0
  101. package/dist/cli.js +1 -1
  102. package/dist/index.d.ts +2 -0
  103. package/dist/index.js +12 -6
  104. package/dist/mounts.d.ts +0 -0
  105. package/dist/publication.d.ts +0 -0
  106. package/dist/renderer.d.ts +10 -0
  107. package/dist/sourcemap.d.ts +0 -0
  108. package/dist/theme.d.ts +68 -0
  109. package/dist/theme.js +93 -0
  110. package/dist/xinclude.d.ts +0 -0
  111. package/package.json +14 -2
@@ -1,323 +1,323 @@
1
- <?xml version='1.0'?> <!-- As XML file -->
2
-
3
- <!--********************************************************************
4
- Copyright 2018 Robert A. Beezer
5
-
6
- This file is part of PreTeXt.
7
-
8
- MathBook XML 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
- MathBook XML 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 MathBook XML. If not, see <http://www.gnu.org/licenses/>.
20
- *********************************************************************-->
21
-
22
- <!-- http://pimpmyxslt.com/articles/entity-tricks-part2/ -->
23
- <!DOCTYPE xsl:stylesheet [
24
- <!ENTITY % entities SYSTEM "entities.ent">
25
- %entities;
26
- ]>
27
-
28
- <!-- Identify as a stylesheet -->
29
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
30
- xmlns:xml="http://www.w3.org/XML/1998/namespace"
31
- xmlns:exsl="http://exslt.org/common"
32
- xmlns:date="http://exslt.org/dates-and-times"
33
- xmlns:str="http://exslt.org/strings"
34
- extension-element-prefixes="exsl date str"
35
- >
36
-
37
- <!-- This import will include the assembly phase, which is -->
38
- <!-- necessary as support for a private solutions file -->
39
- <xsl:import href="./pretext-latex.xsl" />
40
-
41
- <!-- Intend output for rendering by pdflatex -->
42
- <xsl:output method="text" />
43
-
44
- <!-- These variables are interpreted in pretext-common.xsl and -->
45
- <!-- so may be used/set in a custom XSL stylesheet for a -->
46
- <!-- project's solution manual. -->
47
- <!-- -->
48
- <!-- exercise.inline.statement -->
49
- <!-- exercise.inline.hint -->
50
- <!-- exercise.inline.answer -->
51
- <!-- exercise.inline.solution -->
52
- <!-- exercise.divisional.statement -->
53
- <!-- exercise.divisional.hint -->
54
- <!-- exercise.divisional.answer -->
55
- <!-- exercise.divisional.solution -->
56
- <!-- exercise.worksheet.statement -->
57
- <!-- exercise.worksheet.hint -->
58
- <!-- exercise.worksheet.answer -->
59
- <!-- exercise.worksheet.solution -->
60
- <!-- exercise.reading.statement -->
61
- <!-- exercise.reading.hint -->
62
- <!-- exercise.reading.answer -->
63
- <!-- exercise.reading.solution -->
64
- <!-- project.statement -->
65
- <!-- project.hint -->
66
- <!-- project.answer -->
67
- <!-- project.solution -->
68
- <!-- -->
69
- <!-- The second set of variables are internal, and are derived -->
70
- <!-- from the above via careful routines in pretext-common.xsl. -->
71
- <!-- -->
72
- <!-- b-has-inline-statement -->
73
- <!-- b-has-inline-hint -->
74
- <!-- b-has-inline-answer -->
75
- <!-- b-has-inline-solution -->
76
- <!-- b-has-divisional-statement -->
77
- <!-- b-has-divisional-hint -->
78
- <!-- b-has-divisional-answer -->
79
- <!-- b-has-divisional-solution -->
80
- <!-- b-has-worksheet-statement -->
81
- <!-- b-has-worksheet-hint -->
82
- <!-- b-has-worksheet-answer -->
83
- <!-- b-has-worksheet-solution -->
84
- <!-- b-has-reading-statement -->
85
- <!-- b-has-reading-hint -->
86
- <!-- b-has-reading-answer -->
87
- <!-- b-has-reading-solution -->
88
- <!-- b-has-project-statement -->
89
- <!-- b-has-project-hint -->
90
- <!-- b-has-project-answer -->
91
- <!-- b-has-project-solution -->
92
-
93
- <!-- Conceived as a "print only" PDF, this is also necessary -->
94
- <!-- to keep links (such as a solution number linking back to -->
95
- <!-- the original) from being seen/interpreted as actual links. -->
96
- <!-- Here, we override a variable from the stylesheet -->
97
- <!-- pulisher-variables.xsl. Note that it is important to -->
98
- <!-- change the boolean variable, so other properties default -->
99
- <!-- properly, such as "sided-ness". -->
100
- <xsl:variable name="b-latex-print" select="true()"/>
101
- <!-- There are not even labels for page numbers, beside -->
102
- <!-- the fact that they don't make much sense -->
103
- <xsl:variable name="latex-pageref" select="'no'"/>
104
-
105
- <!-- We have a switch for just this situation, to force -->
106
- <!-- (overrule) the auto-detetion of the necessity for -->
107
- <!-- LaTeX styles for the solutions to exercises. -->
108
- <!-- See pretext-latex.xsl for more explanation. -->
109
- <xsl:variable name="b-needs-solution-styles" select="true()"/>
110
-
111
- <!-- We hardcode the numbers of 2D displays so they are correct where -->
112
- <!-- born, this switch could be expanded to the cross-references -->
113
- <xsl:variable name="b-latex-hardcode-numbers" select="true()"/>
114
-
115
- <!-- For a "book" we replace the first chapter by a call to the -->
116
- <!-- solutions generator. So we burrow into parts to get at chapters. -->
117
-
118
- <xsl:template match="part|chapter|section|backmatter/solutions" />
119
-
120
- <xsl:template match="part[1]">
121
- <xsl:apply-templates select="chapter[1]" />
122
- </xsl:template>
123
-
124
- <!-- The publisher switches for solution components, packed into the -->
125
- <!-- single string parameter the "solutions-generator" expects -->
126
- <xsl:variable name="component-spec">
127
- <xsl:variable name="inline-components">
128
- <xsl:if test="$b-has-inline-statement">
129
- <xsl:text>statement </xsl:text>
130
- </xsl:if>
131
- <xsl:if test="$b-has-inline-hint">
132
- <xsl:text>hint </xsl:text>
133
- </xsl:if>
134
- <xsl:if test="$b-has-inline-answer">
135
- <xsl:text>answer </xsl:text>
136
- </xsl:if>
137
- <xsl:if test="$b-has-inline-solution">
138
- <xsl:text>solution </xsl:text>
139
- </xsl:if>
140
- </xsl:variable>
141
- <xsl:variable name="divisional-components">
142
- <xsl:if test="$b-has-divisional-statement">
143
- <xsl:text>statement </xsl:text>
144
- </xsl:if>
145
- <xsl:if test="$b-has-divisional-hint">
146
- <xsl:text>hint </xsl:text>
147
- </xsl:if>
148
- <xsl:if test="$b-has-divisional-answer">
149
- <xsl:text>answer </xsl:text>
150
- </xsl:if>
151
- <xsl:if test="$b-has-divisional-solution">
152
- <xsl:text>solution </xsl:text>
153
- </xsl:if>
154
- </xsl:variable>
155
- <xsl:variable name="worksheet-components">
156
- <xsl:if test="$b-has-worksheet-statement">
157
- <xsl:text>statement </xsl:text>
158
- </xsl:if>
159
- <xsl:if test="$b-has-worksheet-hint">
160
- <xsl:text>hint </xsl:text>
161
- </xsl:if>
162
- <xsl:if test="$b-has-worksheet-answer">
163
- <xsl:text>answer </xsl:text>
164
- </xsl:if>
165
- <xsl:if test="$b-has-worksheet-solution">
166
- <xsl:text>solution </xsl:text>
167
- </xsl:if>
168
- </xsl:variable>
169
- <xsl:variable name="reading-components">
170
- <xsl:if test="$b-has-reading-statement">
171
- <xsl:text>statement </xsl:text>
172
- </xsl:if>
173
- <xsl:if test="$b-has-reading-hint">
174
- <xsl:text>hint </xsl:text>
175
- </xsl:if>
176
- <xsl:if test="$b-has-reading-answer">
177
- <xsl:text>answer </xsl:text>
178
- </xsl:if>
179
- <xsl:if test="$b-has-reading-solution">
180
- <xsl:text>solution </xsl:text>
181
- </xsl:if>
182
- </xsl:variable>
183
- <xsl:variable name="project-components">
184
- <xsl:if test="$b-has-project-statement">
185
- <xsl:text>statement </xsl:text>
186
- </xsl:if>
187
- <xsl:if test="$b-has-project-hint">
188
- <xsl:text>hint </xsl:text>
189
- </xsl:if>
190
- <xsl:if test="$b-has-project-answer">
191
- <xsl:text>answer </xsl:text>
192
- </xsl:if>
193
- <xsl:if test="$b-has-project-solution">
194
- <xsl:text>solution </xsl:text>
195
- </xsl:if>
196
- </xsl:variable>
197
- <xsl:call-template name="solutions-component-spec">
198
- <xsl:with-param name="inline" select="$inline-components"/>
199
- <xsl:with-param name="divisional" select="$divisional-components"/>
200
- <xsl:with-param name="worksheet" select="$worksheet-components"/>
201
- <xsl:with-param name="reading" select="$reading-components"/>
202
- <xsl:with-param name="project" select="$project-components"/>
203
- </xsl:call-template>
204
- </xsl:variable>
205
-
206
- <!-- provoke the "solutions-generator" at the first sign of main matter content -->
207
- <xsl:template match="chapter[1]|article/section[1]">
208
- <xsl:apply-templates select="$document-root" mode="solutions-generator">
209
- <xsl:with-param name="purpose" select="'solutionmanual'" />
210
- <xsl:with-param name="admit" select="'all'" />
211
- <xsl:with-param name="scope" select="$document-root"/>
212
- <xsl:with-param name="component-spec" select="$component-spec"/>
213
- </xsl:apply-templates>
214
- </xsl:template>
215
-
216
- <!-- Not really "duplicate" here in solutions manual, but conforms to -common -->
217
- <xsl:template match="*" mode="duplicate-heading">
218
- <xsl:param name="heading-stack" select="."/>
219
-
220
- <!-- Iterate through heading-stack, opening divisions -->
221
- <!-- and creating toc entry. -->
222
- <!-- Number is hard-coded into title -->
223
- <xsl:for-each select="$heading-stack">
224
- <xsl:variable name="the-number">
225
- <xsl:apply-templates select="." mode="number" />
226
- </xsl:variable>
227
- <xsl:variable name="original-title">
228
- <!-- no trailing space if no number -->
229
- <xsl:if test="not($the-number = '')">
230
- <xsl:value-of select="$the-number" />
231
- <xsl:text> </xsl:text>
232
- </xsl:if>
233
- <xsl:apply-templates select="." mode="title-full" />
234
- </xsl:variable>
235
- <xsl:variable name="moving-title">
236
- <!-- no trailing space if no number -->
237
- <xsl:if test="not($the-number = '')">
238
- <xsl:value-of select="$the-number" />
239
- <xsl:text> </xsl:text>
240
- </xsl:if>
241
- <xsl:apply-templates select="." mode="title-simple" />
242
- </xsl:variable>
243
-
244
- <xsl:text>\</xsl:text>
245
- <xsl:apply-templates select="." mode="division-name" />
246
- <xsl:text>*{</xsl:text>
247
- <xsl:value-of select="$original-title"/>
248
- <xsl:text>}&#xa;</xsl:text>
249
- <!-- An entry for the ToC, since we hard-code numbers -->
250
- <!-- These mainmatter divisions should always have a number -->
251
- <xsl:text>\addcontentsline{toc}{</xsl:text>
252
- <xsl:apply-templates select="." mode="division-name" />
253
- <xsl:text>}{</xsl:text>
254
- <xsl:value-of select="$moving-title"/>
255
- <xsl:text>}&#xa;</xsl:text>
256
- <!-- Explicit marks, since divisions are the starred form -->
257
- <xsl:choose>
258
- <xsl:when test="self::chapter">
259
- <xsl:text>\chaptermark{</xsl:text>
260
- <xsl:value-of select="$moving-title"/>
261
- <xsl:text>}&#xa;</xsl:text>
262
- </xsl:when>
263
- <!-- "section", "exercises", "worksheet", at section-level, etc. -->
264
- <xsl:when test="parent::chapter">
265
- <xsl:text>\sectionmark{</xsl:text>
266
- <xsl:value-of select="$moving-title"/>
267
- <xsl:text>}&#xa;</xsl:text>
268
- </xsl:when>
269
- </xsl:choose>
270
- </xsl:for-each>
271
- </xsl:template>
272
-
273
- <!-- Page headers + Chapter/Section XYZ Title -->
274
- <!-- \sethead[even-left][even-center][even-right] -->
275
- <!-- {odd-left}{odd-center}{odd-right} -->
276
- <xsl:template match="book" mode="titleps-headings">
277
- <xsl:text>{&#xa;</xsl:text>
278
- <xsl:text>\sethead[\thepage][][\textsl{\chaptertitle}]&#xa;</xsl:text>
279
- <xsl:text>{\textsl{\sectiontitle}}{}{\thepage}&#xa;</xsl:text>
280
- <xsl:text>}&#xa;</xsl:text>
281
- </xsl:template>
282
-
283
- <!-- Hard-Coded Numbers -->
284
- <!-- As a subset of full content, we can't -->
285
- <!-- point to much of the content with hyperlinks -->
286
- <!-- But we do have the full context as we process, -->
287
- <!-- so we can get numbers for cross-references -->
288
- <!-- and *hard-code* them into the LaTeX -->
289
-
290
- <!-- We don't dither about possibly using a \ref{} and -->
291
- <!-- just produce numbers. These might lack the "part" -->
292
- <xsl:template match="*" mode="xref-number">
293
- <xsl:apply-templates select="." mode="number" />
294
- </xsl:template>
295
-
296
- <!-- The actual link is not a \hyperlink nor a -->
297
- <!-- hyperref, but instead is just plain 'ol text -->
298
- <xsl:template match="*" mode="xref-link">
299
- <xsl:param name="content" select="'MISSING LINK CONTENT'"/>
300
- <xsl:value-of select="$content" />
301
- </xsl:template>
302
-
303
- <!-- Exercise numbers are always hard-coded at birth, given -->
304
- <!-- complications of numbering, placement, duplication -->
305
-
306
- <!-- Since divisions have hard-coded numbers, a \label{} -->
307
- <!-- on an equation will be inaccurate. These versions of -->
308
- <!-- the templates for hard-coded equation numbers are -->
309
- <!-- from the HTML conversion. -->
310
-
311
- <xsl:template match="mrow" mode="tag">
312
- <xsl:text>\tag{</xsl:text>
313
- <xsl:apply-templates select="." mode="number" />
314
- <xsl:text>}</xsl:text>
315
- </xsl:template>
316
-
317
- <xsl:template match="mrow[@tag]" mode="tag">
318
- <xsl:text>\tag{</xsl:text>
319
- <xsl:apply-templates select="@tag" mode="tag-symbol" />
320
- <xsl:text>}</xsl:text>
321
- </xsl:template>
322
-
323
- </xsl:stylesheet>
1
+ <?xml version='1.0'?> <!-- As XML file -->
2
+
3
+ <!--********************************************************************
4
+ Copyright 2018 Robert A. Beezer
5
+
6
+ This file is part of PreTeXt.
7
+
8
+ MathBook XML 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
+ MathBook XML 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 MathBook XML. If not, see <http://www.gnu.org/licenses/>.
20
+ *********************************************************************-->
21
+
22
+ <!-- http://pimpmyxslt.com/articles/entity-tricks-part2/ -->
23
+ <!DOCTYPE xsl:stylesheet [
24
+ <!ENTITY % entities SYSTEM "entities.ent">
25
+ %entities;
26
+ ]>
27
+
28
+ <!-- Identify as a stylesheet -->
29
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
30
+ xmlns:xml="http://www.w3.org/XML/1998/namespace"
31
+ xmlns:exsl="http://exslt.org/common"
32
+ xmlns:date="http://exslt.org/dates-and-times"
33
+ xmlns:str="http://exslt.org/strings"
34
+ extension-element-prefixes="exsl date str"
35
+ >
36
+
37
+ <!-- This import will include the assembly phase, which is -->
38
+ <!-- necessary as support for a private solutions file -->
39
+ <xsl:import href="./pretext-latex.xsl" />
40
+
41
+ <!-- Intend output for rendering by pdflatex -->
42
+ <xsl:output method="text" />
43
+
44
+ <!-- These variables are interpreted in pretext-common.xsl and -->
45
+ <!-- so may be used/set in a custom XSL stylesheet for a -->
46
+ <!-- project's solution manual. -->
47
+ <!-- -->
48
+ <!-- exercise.inline.statement -->
49
+ <!-- exercise.inline.hint -->
50
+ <!-- exercise.inline.answer -->
51
+ <!-- exercise.inline.solution -->
52
+ <!-- exercise.divisional.statement -->
53
+ <!-- exercise.divisional.hint -->
54
+ <!-- exercise.divisional.answer -->
55
+ <!-- exercise.divisional.solution -->
56
+ <!-- exercise.worksheet.statement -->
57
+ <!-- exercise.worksheet.hint -->
58
+ <!-- exercise.worksheet.answer -->
59
+ <!-- exercise.worksheet.solution -->
60
+ <!-- exercise.reading.statement -->
61
+ <!-- exercise.reading.hint -->
62
+ <!-- exercise.reading.answer -->
63
+ <!-- exercise.reading.solution -->
64
+ <!-- project.statement -->
65
+ <!-- project.hint -->
66
+ <!-- project.answer -->
67
+ <!-- project.solution -->
68
+ <!-- -->
69
+ <!-- The second set of variables are internal, and are derived -->
70
+ <!-- from the above via careful routines in pretext-common.xsl. -->
71
+ <!-- -->
72
+ <!-- b-has-inline-statement -->
73
+ <!-- b-has-inline-hint -->
74
+ <!-- b-has-inline-answer -->
75
+ <!-- b-has-inline-solution -->
76
+ <!-- b-has-divisional-statement -->
77
+ <!-- b-has-divisional-hint -->
78
+ <!-- b-has-divisional-answer -->
79
+ <!-- b-has-divisional-solution -->
80
+ <!-- b-has-worksheet-statement -->
81
+ <!-- b-has-worksheet-hint -->
82
+ <!-- b-has-worksheet-answer -->
83
+ <!-- b-has-worksheet-solution -->
84
+ <!-- b-has-reading-statement -->
85
+ <!-- b-has-reading-hint -->
86
+ <!-- b-has-reading-answer -->
87
+ <!-- b-has-reading-solution -->
88
+ <!-- b-has-project-statement -->
89
+ <!-- b-has-project-hint -->
90
+ <!-- b-has-project-answer -->
91
+ <!-- b-has-project-solution -->
92
+
93
+ <!-- Conceived as a "print only" PDF, this is also necessary -->
94
+ <!-- to keep links (such as a solution number linking back to -->
95
+ <!-- the original) from being seen/interpreted as actual links. -->
96
+ <!-- Here, we override a variable from the stylesheet -->
97
+ <!-- pulisher-variables.xsl. Note that it is important to -->
98
+ <!-- change the boolean variable, so other properties default -->
99
+ <!-- properly, such as "sided-ness". -->
100
+ <xsl:variable name="b-latex-print" select="true()"/>
101
+ <!-- There are not even labels for page numbers, beside -->
102
+ <!-- the fact that they don't make much sense -->
103
+ <xsl:variable name="latex-pageref" select="'no'"/>
104
+
105
+ <!-- We have a switch for just this situation, to force -->
106
+ <!-- (overrule) the auto-detetion of the necessity for -->
107
+ <!-- LaTeX styles for the solutions to exercises. -->
108
+ <!-- See pretext-latex.xsl for more explanation. -->
109
+ <xsl:variable name="b-needs-solution-styles" select="true()"/>
110
+
111
+ <!-- We hardcode the numbers of 2D displays so they are correct where -->
112
+ <!-- born, this switch could be expanded to the cross-references -->
113
+ <xsl:variable name="b-latex-hardcode-numbers" select="true()"/>
114
+
115
+ <!-- For a "book" we replace the first chapter by a call to the -->
116
+ <!-- solutions generator. So we burrow into parts to get at chapters. -->
117
+
118
+ <xsl:template match="part|chapter|section|backmatter/solutions" />
119
+
120
+ <xsl:template match="part[1]">
121
+ <xsl:apply-templates select="chapter[1]" />
122
+ </xsl:template>
123
+
124
+ <!-- The publisher switches for solution components, packed into the -->
125
+ <!-- single string parameter the "solutions-generator" expects -->
126
+ <xsl:variable name="component-spec">
127
+ <xsl:variable name="inline-components">
128
+ <xsl:if test="$b-has-inline-statement">
129
+ <xsl:text>statement </xsl:text>
130
+ </xsl:if>
131
+ <xsl:if test="$b-has-inline-hint">
132
+ <xsl:text>hint </xsl:text>
133
+ </xsl:if>
134
+ <xsl:if test="$b-has-inline-answer">
135
+ <xsl:text>answer </xsl:text>
136
+ </xsl:if>
137
+ <xsl:if test="$b-has-inline-solution">
138
+ <xsl:text>solution </xsl:text>
139
+ </xsl:if>
140
+ </xsl:variable>
141
+ <xsl:variable name="divisional-components">
142
+ <xsl:if test="$b-has-divisional-statement">
143
+ <xsl:text>statement </xsl:text>
144
+ </xsl:if>
145
+ <xsl:if test="$b-has-divisional-hint">
146
+ <xsl:text>hint </xsl:text>
147
+ </xsl:if>
148
+ <xsl:if test="$b-has-divisional-answer">
149
+ <xsl:text>answer </xsl:text>
150
+ </xsl:if>
151
+ <xsl:if test="$b-has-divisional-solution">
152
+ <xsl:text>solution </xsl:text>
153
+ </xsl:if>
154
+ </xsl:variable>
155
+ <xsl:variable name="worksheet-components">
156
+ <xsl:if test="$b-has-worksheet-statement">
157
+ <xsl:text>statement </xsl:text>
158
+ </xsl:if>
159
+ <xsl:if test="$b-has-worksheet-hint">
160
+ <xsl:text>hint </xsl:text>
161
+ </xsl:if>
162
+ <xsl:if test="$b-has-worksheet-answer">
163
+ <xsl:text>answer </xsl:text>
164
+ </xsl:if>
165
+ <xsl:if test="$b-has-worksheet-solution">
166
+ <xsl:text>solution </xsl:text>
167
+ </xsl:if>
168
+ </xsl:variable>
169
+ <xsl:variable name="reading-components">
170
+ <xsl:if test="$b-has-reading-statement">
171
+ <xsl:text>statement </xsl:text>
172
+ </xsl:if>
173
+ <xsl:if test="$b-has-reading-hint">
174
+ <xsl:text>hint </xsl:text>
175
+ </xsl:if>
176
+ <xsl:if test="$b-has-reading-answer">
177
+ <xsl:text>answer </xsl:text>
178
+ </xsl:if>
179
+ <xsl:if test="$b-has-reading-solution">
180
+ <xsl:text>solution </xsl:text>
181
+ </xsl:if>
182
+ </xsl:variable>
183
+ <xsl:variable name="project-components">
184
+ <xsl:if test="$b-has-project-statement">
185
+ <xsl:text>statement </xsl:text>
186
+ </xsl:if>
187
+ <xsl:if test="$b-has-project-hint">
188
+ <xsl:text>hint </xsl:text>
189
+ </xsl:if>
190
+ <xsl:if test="$b-has-project-answer">
191
+ <xsl:text>answer </xsl:text>
192
+ </xsl:if>
193
+ <xsl:if test="$b-has-project-solution">
194
+ <xsl:text>solution </xsl:text>
195
+ </xsl:if>
196
+ </xsl:variable>
197
+ <xsl:call-template name="solutions-component-spec">
198
+ <xsl:with-param name="inline" select="$inline-components"/>
199
+ <xsl:with-param name="divisional" select="$divisional-components"/>
200
+ <xsl:with-param name="worksheet" select="$worksheet-components"/>
201
+ <xsl:with-param name="reading" select="$reading-components"/>
202
+ <xsl:with-param name="project" select="$project-components"/>
203
+ </xsl:call-template>
204
+ </xsl:variable>
205
+
206
+ <!-- provoke the "solutions-generator" at the first sign of main matter content -->
207
+ <xsl:template match="chapter[1]|article/section[1]">
208
+ <xsl:apply-templates select="$document-root" mode="solutions-generator">
209
+ <xsl:with-param name="purpose" select="'solutionmanual'" />
210
+ <xsl:with-param name="admit" select="'all'" />
211
+ <xsl:with-param name="scope" select="$document-root"/>
212
+ <xsl:with-param name="component-spec" select="$component-spec"/>
213
+ </xsl:apply-templates>
214
+ </xsl:template>
215
+
216
+ <!-- Not really "duplicate" here in solutions manual, but conforms to -common -->
217
+ <xsl:template match="*" mode="duplicate-heading">
218
+ <xsl:param name="heading-stack" select="."/>
219
+
220
+ <!-- Iterate through heading-stack, opening divisions -->
221
+ <!-- and creating toc entry. -->
222
+ <!-- Number is hard-coded into title -->
223
+ <xsl:for-each select="$heading-stack">
224
+ <xsl:variable name="the-number">
225
+ <xsl:apply-templates select="." mode="number" />
226
+ </xsl:variable>
227
+ <xsl:variable name="original-title">
228
+ <!-- no trailing space if no number -->
229
+ <xsl:if test="not($the-number = '')">
230
+ <xsl:value-of select="$the-number" />
231
+ <xsl:text> </xsl:text>
232
+ </xsl:if>
233
+ <xsl:apply-templates select="." mode="title-full" />
234
+ </xsl:variable>
235
+ <xsl:variable name="moving-title">
236
+ <!-- no trailing space if no number -->
237
+ <xsl:if test="not($the-number = '')">
238
+ <xsl:value-of select="$the-number" />
239
+ <xsl:text> </xsl:text>
240
+ </xsl:if>
241
+ <xsl:apply-templates select="." mode="title-simple" />
242
+ </xsl:variable>
243
+
244
+ <xsl:text>\</xsl:text>
245
+ <xsl:apply-templates select="." mode="division-name" />
246
+ <xsl:text>*{</xsl:text>
247
+ <xsl:value-of select="$original-title"/>
248
+ <xsl:text>}&#xa;</xsl:text>
249
+ <!-- An entry for the ToC, since we hard-code numbers -->
250
+ <!-- These mainmatter divisions should always have a number -->
251
+ <xsl:text>\addcontentsline{toc}{</xsl:text>
252
+ <xsl:apply-templates select="." mode="division-name" />
253
+ <xsl:text>}{</xsl:text>
254
+ <xsl:value-of select="$moving-title"/>
255
+ <xsl:text>}&#xa;</xsl:text>
256
+ <!-- Explicit marks, since divisions are the starred form -->
257
+ <xsl:choose>
258
+ <xsl:when test="self::chapter">
259
+ <xsl:text>\chaptermark{</xsl:text>
260
+ <xsl:value-of select="$moving-title"/>
261
+ <xsl:text>}&#xa;</xsl:text>
262
+ </xsl:when>
263
+ <!-- "section", "exercises", "worksheet", at section-level, etc. -->
264
+ <xsl:when test="parent::chapter">
265
+ <xsl:text>\sectionmark{</xsl:text>
266
+ <xsl:value-of select="$moving-title"/>
267
+ <xsl:text>}&#xa;</xsl:text>
268
+ </xsl:when>
269
+ </xsl:choose>
270
+ </xsl:for-each>
271
+ </xsl:template>
272
+
273
+ <!-- Page headers + Chapter/Section XYZ Title -->
274
+ <!-- \sethead[even-left][even-center][even-right] -->
275
+ <!-- {odd-left}{odd-center}{odd-right} -->
276
+ <xsl:template match="book" mode="titleps-headings">
277
+ <xsl:text>{&#xa;</xsl:text>
278
+ <xsl:text>\sethead[\thepage][][\textsl{\chaptertitle}]&#xa;</xsl:text>
279
+ <xsl:text>{\textsl{\sectiontitle}}{}{\thepage}&#xa;</xsl:text>
280
+ <xsl:text>}&#xa;</xsl:text>
281
+ </xsl:template>
282
+
283
+ <!-- Hard-Coded Numbers -->
284
+ <!-- As a subset of full content, we can't -->
285
+ <!-- point to much of the content with hyperlinks -->
286
+ <!-- But we do have the full context as we process, -->
287
+ <!-- so we can get numbers for cross-references -->
288
+ <!-- and *hard-code* them into the LaTeX -->
289
+
290
+ <!-- We don't dither about possibly using a \ref{} and -->
291
+ <!-- just produce numbers. These might lack the "part" -->
292
+ <xsl:template match="*" mode="xref-number">
293
+ <xsl:apply-templates select="." mode="number" />
294
+ </xsl:template>
295
+
296
+ <!-- The actual link is not a \hyperlink nor a -->
297
+ <!-- hyperref, but instead is just plain 'ol text -->
298
+ <xsl:template match="*" mode="xref-link">
299
+ <xsl:param name="content" select="'MISSING LINK CONTENT'"/>
300
+ <xsl:value-of select="$content" />
301
+ </xsl:template>
302
+
303
+ <!-- Exercise numbers are always hard-coded at birth, given -->
304
+ <!-- complications of numbering, placement, duplication -->
305
+
306
+ <!-- Since divisions have hard-coded numbers, a \label{} -->
307
+ <!-- on an equation will be inaccurate. These versions of -->
308
+ <!-- the templates for hard-coded equation numbers are -->
309
+ <!-- from the HTML conversion. -->
310
+
311
+ <xsl:template match="mrow" mode="tag">
312
+ <xsl:text>\tag{</xsl:text>
313
+ <xsl:apply-templates select="." mode="number" />
314
+ <xsl:text>}</xsl:text>
315
+ </xsl:template>
316
+
317
+ <xsl:template match="mrow[@tag]" mode="tag">
318
+ <xsl:text>\tag{</xsl:text>
319
+ <xsl:apply-templates select="@tag" mode="tag-symbol" />
320
+ <xsl:text>}</xsl:text>
321
+ </xsl:template>
322
+
323
+ </xsl:stylesheet>