@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.
- package/README.md +160 -0
- package/assets/preview-html.xsl +230 -0
- package/assets/upstream.json +7 -0
- package/assets/xsl/README.md +31 -0
- package/assets/xsl/entities.ent +154 -0
- package/assets/xsl/extract-asymptote.xsl +68 -0
- package/assets/xsl/extract-biblio-csl.xsl +327 -0
- package/assets/xsl/extract-datafile.xsl +71 -0
- package/assets/xsl/extract-dynamic.xsl +139 -0
- package/assets/xsl/extract-identity.xsl +136 -0
- package/assets/xsl/extract-interactive.xsl +81 -0
- package/assets/xsl/extract-latex-image.xsl +118 -0
- package/assets/xsl/extract-mermaid.xsl +58 -0
- package/assets/xsl/extract-mom.xsl +63 -0
- package/assets/xsl/extract-pg.xsl +2897 -0
- package/assets/xsl/extract-prefigure.xsl +157 -0
- package/assets/xsl/extract-qrcode.xsl +100 -0
- package/assets/xsl/extract-runestone-page-template.xsl +139 -0
- package/assets/xsl/extract-sageplot.xsl +166 -0
- package/assets/xsl/extract-stack.xsl +56 -0
- package/assets/xsl/extract-trace.xsl +134 -0
- package/assets/xsl/extract-youtube.xsl +63 -0
- package/assets/xsl/html-symbols.xsl +3344 -0
- package/assets/xsl/latex/pretext-latex-AIM.xsl +56 -0
- package/assets/xsl/latex/pretext-latex-CLP.xsl +148 -0
- package/assets/xsl/latex/pretext-latex-chaos.xsl +317 -0
- package/assets/xsl/latex/pretext-latex-dyslexic-font.xsl +76 -0
- package/assets/xsl/latex/pretext-latex-guide.xsl +104 -0
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +862 -0
- package/assets/xsl/localizations/README.md +56 -0
- package/assets/xsl/localizations/af-ZA.xml +276 -0
- package/assets/xsl/localizations/bg-BG.xml +276 -0
- package/assets/xsl/localizations/ca-ES.xml +285 -0
- package/assets/xsl/localizations/cs-CZ.xml +280 -0
- package/assets/xsl/localizations/de-DE.xml +281 -0
- package/assets/xsl/localizations/en-US.xml +427 -0
- package/assets/xsl/localizations/es-ES.xml +287 -0
- package/assets/xsl/localizations/fi-FI.xml +275 -0
- package/assets/xsl/localizations/fr-CA.xml +276 -0
- package/assets/xsl/localizations/fr-FR.xml +280 -0
- package/assets/xsl/localizations/hu-HU.xml +280 -0
- package/assets/xsl/localizations/it-IT.xml +276 -0
- package/assets/xsl/localizations/ku-CKB.xml +275 -0
- package/assets/xsl/localizations/localizations.xml +48 -0
- package/assets/xsl/localizations/nl-NL.xml +275 -0
- package/assets/xsl/localizations/pt-BR.xml +288 -0
- package/assets/xsl/localizations/pt-PT.xml +292 -0
- package/assets/xsl/localizations/zh-HANS.xml +269 -0
- package/assets/xsl/pretext-assembly.xsl +4795 -0
- package/assets/xsl/pretext-basic-html.xsl +86 -0
- package/assets/xsl/pretext-beamer.xsl +662 -0
- package/assets/xsl/pretext-braille-preprint.xsl +2249 -0
- package/assets/xsl/pretext-common.xsl +12018 -0
- package/assets/xsl/pretext-dynamic.xsl +65 -0
- package/assets/xsl/pretext-epub.xsl +1483 -0
- package/assets/xsl/pretext-fo.xsl +4593 -0
- package/assets/xsl/pretext-html.xsl +14791 -0
- package/assets/xsl/pretext-json-manifest.xsl +150 -0
- package/assets/xsl/pretext-jupyter.xsl +868 -0
- package/assets/xsl/pretext-latex-classic.xsl +952 -0
- package/assets/xsl/pretext-latex-common.xsl +11563 -0
- package/assets/xsl/pretext-latex.xsl +47 -0
- package/assets/xsl/pretext-litprog.xsl +105 -0
- package/assets/xsl/pretext-merge.xsl +41 -0
- package/assets/xsl/pretext-numbers.xsl +875 -0
- package/assets/xsl/pretext-revealjs.xsl +522 -0
- package/assets/xsl/pretext-runestone-fitb.xsl +1233 -0
- package/assets/xsl/pretext-runestone-static.xsl +1438 -0
- package/assets/xsl/pretext-runestone.xsl +3083 -0
- package/assets/xsl/pretext-sage-doctest.xsl +289 -0
- package/assets/xsl/pretext-smc.xsl +492 -0
- package/assets/xsl/pretext-solution-manual-latex.xsl +323 -0
- package/assets/xsl/pretext-text-utilities.xsl +1217 -0
- package/assets/xsl/pretext-text.xsl +392 -0
- package/assets/xsl/pretext-units.xsl +195 -0
- package/assets/xsl/pretext-view-source.xsl +157 -0
- package/assets/xsl/pretext-ww-problem-sets.xsl +391 -0
- package/assets/xsl/publisher-variables.xsl +4756 -0
- package/assets/xsl/support/README.md +22 -0
- package/assets/xsl/support/extract-math.xsl +256 -0
- package/assets/xsl/support/package-math.xsl +141 -0
- package/assets/xsl/support/play-button/README.md +46 -0
- package/assets/xsl/support/play-button/play-button.png +0 -0
- package/assets/xsl/support/play-button/play-button.svg +3 -0
- package/assets/xsl/support/pretext-pg-macros.xsl +110 -0
- package/assets/xsl/support/webpack_static_imports.xml +14 -0
- package/assets/xsl/tests/README.md +24 -0
- package/assets/xsl/tests/null.xml +4 -0
- package/assets/xsl/tests/pretext-text-utilities-test.xsl +334 -0
- package/assets/xsl/utilities/README.md +31 -0
- package/assets/xsl/utilities/author-report.xsl +107 -0
- package/assets/xsl/utilities/deprecate-autoname.sed +18 -0
- package/assets/xsl/utilities/deprecate-index.sed +33 -0
- package/assets/xsl/utilities/fix-deprecations.xsl +663 -0
- package/assets/xsl/utilities/pretext-enhanced-source.xsl +112 -0
- package/assets/xsl/utilities/report-publisher-variables.xsl +162 -0
- package/assets/xsl/xml-to-json.xsl +326 -0
- package/assets/xsl/xml-to-string.xsl +328 -0
- package/cli.mjs +29 -0
- package/dist/cli-C6tfAVvi.js +553 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -0
- package/dist/mounts.d.ts +23 -0
- package/dist/publication.d.ts +16 -0
- package/dist/renderer.d.ts +84 -0
- package/dist/sourcemap.d.ts +41 -0
- package/dist/xinclude.d.ts +45 -0
- package/package.json +52 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
<?xml version='1.0'?>
|
|
2
|
+
|
|
3
|
+
<!--********************************************************************
|
|
4
|
+
Copyright 2022 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
|
+
<!-- Standalone testbed for pretext-text-utilities templates -->
|
|
23
|
+
<!-- Invoke this stylesheet on null.xml in the same folder: -->
|
|
24
|
+
<!-- xsltproc pretext-text-utilities-test.xsl null.xml -->
|
|
25
|
+
|
|
26
|
+
<!-- There are &LOWERCASE; and &UPPERCASE; entities -->
|
|
27
|
+
<!-- in the "file-extension" template (only?) -->
|
|
28
|
+
<!DOCTYPE xsl:stylesheet [
|
|
29
|
+
<!ENTITY % entities SYSTEM "../entities.ent">
|
|
30
|
+
%entities;
|
|
31
|
+
]>
|
|
32
|
+
|
|
33
|
+
<!-- EXSL needed for token list template (only?) -->
|
|
34
|
+
<xsl:stylesheet
|
|
35
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
|
|
36
|
+
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
|
37
|
+
xmlns:pi="http://pretextbook.org/2020/pretext/internal"
|
|
38
|
+
xmlns:str="http://exslt.org/strings"
|
|
39
|
+
xmlns:exsl="http://exslt.org/common"
|
|
40
|
+
xmlns:math="http://exslt.org/math"
|
|
41
|
+
xmlns:set="http://exslt.org/sets"
|
|
42
|
+
extension-element-prefixes="pi str math"
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
<!-- Allow serialization of XML in various contexts -->
|
|
46
|
+
<!-- See the XSL file for more info about Lenz' utility -->
|
|
47
|
+
<xsl:import href="../pretext-text-utilities.xsl"/>
|
|
48
|
+
|
|
49
|
+
<!-- Output helper -->
|
|
50
|
+
<xsl:variable name="verbose-output" select="false()"/>
|
|
51
|
+
|
|
52
|
+
<xsl:template name="assert-equal">
|
|
53
|
+
<xsl:param name="expected"/>
|
|
54
|
+
<xsl:param name="actual"/>
|
|
55
|
+
<xsl:param name="test-name"/>
|
|
56
|
+
<xsl:choose>
|
|
57
|
+
<xsl:when test="$expected = $actual">
|
|
58
|
+
<xsl:if test="$verbose-output">
|
|
59
|
+
<xsl:message>Test <xsl:value-of select="$test-name"/> passed.</xsl:message>
|
|
60
|
+
</xsl:if>
|
|
61
|
+
</xsl:when>
|
|
62
|
+
<xsl:otherwise>
|
|
63
|
+
<xsl:message>Test <xsl:value-of select="$test-name"/> failed: </xsl:message>
|
|
64
|
+
<xsl:message> expected = "<xsl:value-of select="$expected"/>" (<xsl:value-of select="exsl:object-type($expected)"/>)</xsl:message>
|
|
65
|
+
<xsl:message> actual = "<xsl:value-of select="$actual"/>" (<xsl:value-of select="exsl:object-type($actual)"/>)</xsl:message>
|
|
66
|
+
</xsl:otherwise>
|
|
67
|
+
</xsl:choose>
|
|
68
|
+
</xsl:template>
|
|
69
|
+
|
|
70
|
+
<!--========================================================================-->
|
|
71
|
+
<!-- test count-pad-length-->
|
|
72
|
+
<xsl:variable name="count-pad-length-0">
|
|
73
|
+
<xsl:variable name="test-val">
|
|
74
|
+
<xsl:call-template name="count-pad-length">
|
|
75
|
+
<xsl:with-param name="text" select="'a'"/>
|
|
76
|
+
</xsl:call-template>
|
|
77
|
+
</xsl:variable>
|
|
78
|
+
<xsl:call-template name="assert-equal">
|
|
79
|
+
<xsl:with-param name="expected" select="0"/>
|
|
80
|
+
<xsl:with-param name="actual" select="number($test-val)"/>
|
|
81
|
+
<xsl:with-param name="test-name" select="'count-pad-length-0'"/>
|
|
82
|
+
</xsl:call-template>
|
|
83
|
+
</xsl:variable>
|
|
84
|
+
|
|
85
|
+
<xsl:variable name="count-pad-length-2">
|
|
86
|
+
<xsl:variable name="test-val">
|
|
87
|
+
<xsl:call-template name="count-pad-length">
|
|
88
|
+
<xsl:with-param name="text" select="' a'"/>
|
|
89
|
+
</xsl:call-template>
|
|
90
|
+
</xsl:variable>
|
|
91
|
+
<xsl:call-template name="assert-equal">
|
|
92
|
+
<xsl:with-param name="expected" select="2"/>
|
|
93
|
+
<xsl:with-param name="actual" select="number($test-val)"/>
|
|
94
|
+
<xsl:with-param name="test-name" select="'count-pad-length-2'"/>
|
|
95
|
+
</xsl:call-template>
|
|
96
|
+
</xsl:variable>
|
|
97
|
+
|
|
98
|
+
<xsl:variable name="count-pad-length-2-empty">
|
|
99
|
+
<xsl:variable name="test-val">
|
|
100
|
+
<xsl:call-template name="count-pad-length">
|
|
101
|
+
<xsl:with-param name="text" select="' '"/>
|
|
102
|
+
</xsl:call-template>
|
|
103
|
+
</xsl:variable>
|
|
104
|
+
<xsl:call-template name="assert-equal">
|
|
105
|
+
<xsl:with-param name="expected" select="2"/>
|
|
106
|
+
<xsl:with-param name="actual" select="number($test-val)"/>
|
|
107
|
+
<xsl:with-param name="test-name" select="'count-pad-length-2'"/>
|
|
108
|
+
</xsl:call-template>
|
|
109
|
+
</xsl:variable>
|
|
110
|
+
|
|
111
|
+
<!--========================================================================-->
|
|
112
|
+
<!-- test substring-after-last-->
|
|
113
|
+
<xsl:variable name="substring-after-last-b1">
|
|
114
|
+
<xsl:variable name="test-val">
|
|
115
|
+
<xsl:call-template name="substring-after-last">
|
|
116
|
+
<xsl:with-param name="input" select="'aabcc'"/>
|
|
117
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
118
|
+
</xsl:call-template>
|
|
119
|
+
</xsl:variable>
|
|
120
|
+
<xsl:call-template name="assert-equal">
|
|
121
|
+
<xsl:with-param name="expected" select="'cc'"/>
|
|
122
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
123
|
+
<xsl:with-param name="test-name" select="'substring-after-last-b1'"/>
|
|
124
|
+
</xsl:call-template>
|
|
125
|
+
</xsl:variable>
|
|
126
|
+
|
|
127
|
+
<xsl:variable name="substring-after-last-b2">
|
|
128
|
+
<xsl:variable name="test-val">
|
|
129
|
+
<xsl:call-template name="substring-after-last">
|
|
130
|
+
<xsl:with-param name="input" select="'aabccbcc'"/>
|
|
131
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
132
|
+
</xsl:call-template>
|
|
133
|
+
</xsl:variable>
|
|
134
|
+
<xsl:call-template name="assert-equal">
|
|
135
|
+
<xsl:with-param name="expected" select="'cc'"/>
|
|
136
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
137
|
+
<xsl:with-param name="test-name" select="'substring-after-last-b2'"/>
|
|
138
|
+
</xsl:call-template>
|
|
139
|
+
</xsl:variable>
|
|
140
|
+
|
|
141
|
+
<xsl:variable name="substring-after-last-missing">
|
|
142
|
+
<xsl:variable name="test-val">
|
|
143
|
+
<xsl:call-template name="substring-after-last">
|
|
144
|
+
<xsl:with-param name="input" select="'aacc'"/>
|
|
145
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
146
|
+
</xsl:call-template>
|
|
147
|
+
</xsl:variable>
|
|
148
|
+
<xsl:call-template name="assert-equal">
|
|
149
|
+
<xsl:with-param name="expected" select="''"/>
|
|
150
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
151
|
+
<xsl:with-param name="test-name" select="'substring-after-last-missing'"/>
|
|
152
|
+
</xsl:call-template>
|
|
153
|
+
</xsl:variable>
|
|
154
|
+
|
|
155
|
+
<xsl:variable name="substring-after-last-leading">
|
|
156
|
+
<xsl:variable name="test-val">
|
|
157
|
+
<xsl:call-template name="substring-after-last">
|
|
158
|
+
<xsl:with-param name="input" select="'baacc'"/>
|
|
159
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
160
|
+
</xsl:call-template>
|
|
161
|
+
</xsl:variable>
|
|
162
|
+
<xsl:call-template name="assert-equal">
|
|
163
|
+
<xsl:with-param name="expected" select="'aacc'"/>
|
|
164
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
165
|
+
<xsl:with-param name="test-name" select="'substring-after-last-leading'"/>
|
|
166
|
+
</xsl:call-template>
|
|
167
|
+
</xsl:variable>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<!--========================================================================-->
|
|
171
|
+
<!-- test substring-before-last-->
|
|
172
|
+
<xsl:variable name="substring-before-last-b1">
|
|
173
|
+
<xsl:variable name="test-val">
|
|
174
|
+
<xsl:call-template name="substring-before-last">
|
|
175
|
+
<xsl:with-param name="input" select="'aabcc'"/>
|
|
176
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
177
|
+
</xsl:call-template>
|
|
178
|
+
</xsl:variable>
|
|
179
|
+
<xsl:call-template name="assert-equal">
|
|
180
|
+
<xsl:with-param name="expected" select="'aa'"/>
|
|
181
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
182
|
+
<xsl:with-param name="test-name" select="'substring-before-last-b1'"/>
|
|
183
|
+
</xsl:call-template>
|
|
184
|
+
</xsl:variable>
|
|
185
|
+
|
|
186
|
+
<xsl:variable name="substring-before-last-b2">
|
|
187
|
+
<xsl:variable name="test-val">
|
|
188
|
+
<xsl:call-template name="substring-before-last">
|
|
189
|
+
<xsl:with-param name="input" select="'aabccbcc'"/>
|
|
190
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
191
|
+
</xsl:call-template>
|
|
192
|
+
</xsl:variable>
|
|
193
|
+
<xsl:call-template name="assert-equal">
|
|
194
|
+
<xsl:with-param name="expected" select="'aabcc'"/>
|
|
195
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
196
|
+
<xsl:with-param name="test-name" select="'substring-before-last-b2'"/>
|
|
197
|
+
</xsl:call-template>
|
|
198
|
+
</xsl:variable>
|
|
199
|
+
|
|
200
|
+
<xsl:variable name="substring-before-last-missing">
|
|
201
|
+
<xsl:variable name="test-val">
|
|
202
|
+
<xsl:call-template name="substring-before-last">
|
|
203
|
+
<xsl:with-param name="input" select="'aacc'"/>
|
|
204
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
205
|
+
</xsl:call-template>
|
|
206
|
+
</xsl:variable>
|
|
207
|
+
<xsl:call-template name="assert-equal">
|
|
208
|
+
<xsl:with-param name="expected" select="''"/>
|
|
209
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
210
|
+
<xsl:with-param name="test-name" select="'substring-before-last-missing'"/>
|
|
211
|
+
</xsl:call-template>
|
|
212
|
+
</xsl:variable>
|
|
213
|
+
|
|
214
|
+
<!--========================================================================-->
|
|
215
|
+
<!-- test substring-after-preserve-->
|
|
216
|
+
<xsl:variable name="substring-after-preserve-b1">
|
|
217
|
+
<xsl:variable name="test-val">
|
|
218
|
+
<xsl:call-template name="substring-after-preserve">
|
|
219
|
+
<xsl:with-param name="input" select="'aabcc'"/>
|
|
220
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
221
|
+
</xsl:call-template>
|
|
222
|
+
</xsl:variable>
|
|
223
|
+
<xsl:call-template name="assert-equal">
|
|
224
|
+
<xsl:with-param name="expected" select="'cc'"/>
|
|
225
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
226
|
+
<xsl:with-param name="test-name" select="'substring-after-preserve-b1'"/>
|
|
227
|
+
</xsl:call-template>
|
|
228
|
+
</xsl:variable>
|
|
229
|
+
|
|
230
|
+
<xsl:variable name="substring-after-preserve-miss">
|
|
231
|
+
<xsl:variable name="test-val">
|
|
232
|
+
<xsl:call-template name="substring-after-preserve">
|
|
233
|
+
<xsl:with-param name="input" select="'aacc'"/>
|
|
234
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
235
|
+
</xsl:call-template>
|
|
236
|
+
</xsl:variable>
|
|
237
|
+
<xsl:call-template name="assert-equal">
|
|
238
|
+
<xsl:with-param name="expected" select="'aacc'"/>
|
|
239
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
240
|
+
<xsl:with-param name="test-name" select="'substring-after-preserve-miss'"/>
|
|
241
|
+
</xsl:call-template>
|
|
242
|
+
</xsl:variable>
|
|
243
|
+
|
|
244
|
+
<xsl:variable name="substring-after-preserve-empty">
|
|
245
|
+
<xsl:variable name="test-val">
|
|
246
|
+
<xsl:call-template name="substring-after-preserve">
|
|
247
|
+
<xsl:with-param name="input" select="''"/>
|
|
248
|
+
<xsl:with-param name="substr" select="'b'"/>
|
|
249
|
+
</xsl:call-template>
|
|
250
|
+
</xsl:variable>
|
|
251
|
+
<xsl:call-template name="assert-equal">
|
|
252
|
+
<xsl:with-param name="expected" select="''"/>
|
|
253
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
254
|
+
<xsl:with-param name="test-name" select="'substring-after-preserve-empty'"/>
|
|
255
|
+
</xsl:call-template>
|
|
256
|
+
</xsl:variable>
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
<!--========================================================================-->
|
|
260
|
+
<!-- test left-align-text -->
|
|
261
|
+
<xsl:variable name="align-left-first-line-shortest">
|
|
262
|
+
<xsl:variable name="test-val">
|
|
263
|
+
<xsl:call-template name="left-align-text">
|
|
264
|
+
<xsl:with-param name="text" select="' Line one Line two Line three'"/>
|
|
265
|
+
</xsl:call-template>
|
|
266
|
+
</xsl:variable>
|
|
267
|
+
<xsl:call-template name="assert-equal">
|
|
268
|
+
<!-- 2/3/4 spaces should become 0/1/2 spaces -->
|
|
269
|
+
<xsl:with-param name="expected" select="'Line one Line two Line three'"/>
|
|
270
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
271
|
+
<xsl:with-param name="test-name" select="'align-left-first-line-shortest'"/>
|
|
272
|
+
</xsl:call-template>
|
|
273
|
+
</xsl:variable>
|
|
274
|
+
|
|
275
|
+
<xsl:variable name="align-left-other-line-shortest">
|
|
276
|
+
<xsl:variable name="test-val-rtf">
|
|
277
|
+
<xsl:call-template name="left-align-text">
|
|
278
|
+
<xsl:with-param name="text" select="' Line one Line two Line three'"/>
|
|
279
|
+
</xsl:call-template>
|
|
280
|
+
</xsl:variable>
|
|
281
|
+
<xsl:variable name="test-val">
|
|
282
|
+
<xsl:value-of select="$test-val-rtf"/>
|
|
283
|
+
</xsl:variable>
|
|
284
|
+
<xsl:call-template name="assert-equal">
|
|
285
|
+
<!-- 4/1/2 spaces should become 3/0/1 spaces -->
|
|
286
|
+
<xsl:with-param name="expected" select="' Line one Line two Line three'"/>
|
|
287
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
288
|
+
<xsl:with-param name="test-name" select="'align-left-other-line-shortest'"/>
|
|
289
|
+
</xsl:call-template>
|
|
290
|
+
</xsl:variable>
|
|
291
|
+
|
|
292
|
+
<xsl:variable name="align-left-no-indent">
|
|
293
|
+
<xsl:variable name="test-val-rtf">
|
|
294
|
+
<xsl:call-template name="left-align-text">
|
|
295
|
+
<xsl:with-param name="text" select="' Line one Line two Line three'"/>
|
|
296
|
+
</xsl:call-template>
|
|
297
|
+
</xsl:variable>
|
|
298
|
+
<xsl:variable name="test-val">
|
|
299
|
+
<xsl:value-of select="$test-val-rtf"/>
|
|
300
|
+
</xsl:variable>
|
|
301
|
+
<xsl:call-template name="assert-equal">
|
|
302
|
+
<!-- 2/0/2 spaces should become 2/0/2 spaces -->
|
|
303
|
+
<xsl:with-param name="expected" select="' Line one Line two Line three'"/>
|
|
304
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
305
|
+
<xsl:with-param name="test-name" select="'align-left-no-indent'"/>
|
|
306
|
+
</xsl:call-template>
|
|
307
|
+
</xsl:variable>
|
|
308
|
+
|
|
309
|
+
<xsl:variable name="align-left-trailing-empty-preserved">
|
|
310
|
+
<xsl:variable name="test-val-rtf">
|
|
311
|
+
<xsl:call-template name="left-align-text">
|
|
312
|
+
<xsl:with-param name="text" select="' Line one Line two Line three '"/>
|
|
313
|
+
</xsl:call-template>
|
|
314
|
+
</xsl:variable>
|
|
315
|
+
<xsl:variable name="test-val">
|
|
316
|
+
<xsl:value-of select="$test-val-rtf"/>
|
|
317
|
+
</xsl:variable>
|
|
318
|
+
<xsl:call-template name="assert-equal">
|
|
319
|
+
<!-- 2/0/2 spaces should become 2/0/2 spaces -->
|
|
320
|
+
<xsl:with-param name="expected" select="' Line one Line two Line three '"/>
|
|
321
|
+
<xsl:with-param name="actual" select="$test-val"/>
|
|
322
|
+
<xsl:with-param name="test-name" select="'align-left-trailing-empty-preserved'"/>
|
|
323
|
+
</xsl:call-template>
|
|
324
|
+
</xsl:variable>
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
<!--========================================================================-->
|
|
328
|
+
|
|
329
|
+
<!-- "main" -->
|
|
330
|
+
<xsl:template match="/">
|
|
331
|
+
<xsl:message>Tests complete!</xsl:message>
|
|
332
|
+
</xsl:template>
|
|
333
|
+
|
|
334
|
+
</xsl:stylesheet>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Utilities
|
|
2
|
+
|
|
3
|
+
## Source-to-Source conversions
|
|
4
|
+
|
|
5
|
+
For utility programs here which rewrite your source, be **sure** to use version control (collect and review changes on a branch, stash and drop undesirable outcomes), or have backups handy. The effects are not reversible. Stylesheets will output to standard output, so you can redirect their output, or you can use something like the `-o` flag on the `xsltproc` command-line invocation. Experiment first.
|
|
6
|
+
|
|
7
|
+
### `fix-deprecations.xsl`
|
|
8
|
+
|
|
9
|
+
This will convert any obsolete element names or constructions to their replacements. As deprecations are added, you may run it anew, and only the new changes will be applied. Despite the name, it does make some minor changes. Empty tags will get a single space prior to the closing backslash.
|
|
10
|
+
|
|
11
|
+
Be sure to read all the details in the Author's Guide before using this on your source. Here is an absolute minimal example.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ xsltproc /path/to/xsl/utilities/fix-deprecations.xsl -stringparam fix all /path/to/examples/sample-errors-and-warnings.xml > new-sample.xml
|
|
15
|
+
|
|
16
|
+
$ diff /path/to/examples/sample-errors-and-warnings.xml new-sample.xml
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
(Updated: 2017-07-04)
|
|
20
|
+
|
|
21
|
+
## Author Report
|
|
22
|
+
|
|
23
|
+
`author-report.xsl` is a very simple stylesheet which will produce a text version of items in your source that could benefit from your attention. This is different than validating your PreTeXt source against the schema, but is part of using automated tools to ensure healthy source material.
|
|
24
|
+
|
|
25
|
+
(Updated: 2018-12-09)
|
|
26
|
+
|
|
27
|
+
## Intermediate Enhanced Source
|
|
28
|
+
|
|
29
|
+
`pretext-enhanced-source.xsl` is mainly meant for development use. It outputs an XML file, which is not necessarily valid PreTeXt, at a key stage of the processing. It gives you a look under the hood (or bonnet). So generally not useful (or necessary) for authors.
|
|
30
|
+
|
|
31
|
+
(Updated: 2020-02-25)
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
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
|
+
<!-- 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
|
+
|
|
32
|
+
<!-- NB: (2020-06-07) xref/@provisional gets replaced by placeholder -->
|
|
33
|
+
<!-- text in the "assembly" phase, so think carefully about whether -->
|
|
34
|
+
<!-- or not this stylesheet should run against orginal source or -->
|
|
35
|
+
<!-- enhanced source, they *are* different. -->
|
|
36
|
+
|
|
37
|
+
<!-- Uses "strip-leading-whitespace" and more -->
|
|
38
|
+
<!-- Standard conversion groundwork -->
|
|
39
|
+
<xsl:import href="../publisher-variables.xsl"/>
|
|
40
|
+
<xsl:import href="../pretext-assembly.xsl"/>
|
|
41
|
+
<xsl:import href="../pretext-common.xsl"/>
|
|
42
|
+
|
|
43
|
+
<!-- ASCII output intended, consistent with -common -->
|
|
44
|
+
<xsl:output method="text" />
|
|
45
|
+
|
|
46
|
+
<!-- Generally, traverse the tree, -->
|
|
47
|
+
<!-- looking for things to do -->
|
|
48
|
+
<!-- http://stackoverflow.com/questions/3776333/ -->
|
|
49
|
+
<!-- stripping-all-elements-except-one-in-xml-using-xslt -->
|
|
50
|
+
<xsl:template match="@*|node()|comment()">
|
|
51
|
+
<xsl:apply-templates select="@*|node()|comment()"/>
|
|
52
|
+
</xsl:template>
|
|
53
|
+
|
|
54
|
+
<!-- ############## -->
|
|
55
|
+
<!-- Entry Template -->
|
|
56
|
+
<!-- ############## -->
|
|
57
|
+
|
|
58
|
+
<xsl:template match="/">
|
|
59
|
+
<xsl:call-template name="converter-blurb-text"/>
|
|
60
|
+
<xsl:apply-templates select="$document-root" />
|
|
61
|
+
</xsl:template>
|
|
62
|
+
|
|
63
|
+
<!-- Headers, per division or structure -->
|
|
64
|
+
<xsl:template match="&STRUCTURAL;">
|
|
65
|
+
<xsl:text>
**************************************
</xsl:text>
|
|
66
|
+
<xsl:apply-templates select="." mode="long-name" />
|
|
67
|
+
<xsl:text>
**************************************
</xsl:text>
|
|
68
|
+
<xsl:apply-templates select="*[not(self::subtitle)]|comment()"/>
|
|
69
|
+
</xsl:template>
|
|
70
|
+
|
|
71
|
+
<!-- Kill titles as metadata, but restore behavior on nodes to -->
|
|
72
|
+
<!-- allow the "long-name" template above to perform as intended -->
|
|
73
|
+
<xsl:template match="title"/>
|
|
74
|
+
<xsl:template match="title/node()">
|
|
75
|
+
<xsl:value-of select="." />
|
|
76
|
+
</xsl:template>
|
|
77
|
+
|
|
78
|
+
<!-- Looking for todo's and provisional citations, cross-references -->
|
|
79
|
+
<!-- May need to abandon counting if conditions get more complex -->
|
|
80
|
+
|
|
81
|
+
<!-- This template comes close to doing the right thing, -->
|
|
82
|
+
<!-- but is off by one (or more) in strange ways, so we -->
|
|
83
|
+
<!-- are not numbering the reported items -->
|
|
84
|
+
<xsl:template match="xref|comment()" mode="overall-number">
|
|
85
|
+
<xsl:number level="any" count="xref[@provisional]|comment()[translate(substring(normalize-space(string(.)), 1, 4), &UPPERCASE;, &LOWERCASE;) = 'todo']"/>
|
|
86
|
+
</xsl:template>
|
|
87
|
+
|
|
88
|
+
<xsl:template match="comment()[translate(substring(normalize-space(string(.)), 1, 4), &UPPERCASE;, &LOWERCASE;) = 'todo']">
|
|
89
|
+
<!-- <xsl:apply-templates select="." mode="overall-number"/> -->
|
|
90
|
+
<!-- <xsl:text>. </xsl:text> -->
|
|
91
|
+
<xsl:call-template name="strip-leading-whitespace">
|
|
92
|
+
<xsl:with-param name="text">
|
|
93
|
+
<xsl:value-of select="."/>
|
|
94
|
+
</xsl:with-param>
|
|
95
|
+
</xsl:call-template>
|
|
96
|
+
<xsl:text>
</xsl:text>
|
|
97
|
+
</xsl:template>
|
|
98
|
+
|
|
99
|
+
<xsl:template match="xref[@provisional]">
|
|
100
|
+
<!-- <xsl:apply-templates select="." mode="overall-number"/> -->
|
|
101
|
+
<!-- <xsl:text>.</xsl:text> -->
|
|
102
|
+
<xsl:text>xref: </xsl:text>
|
|
103
|
+
<xsl:value-of select="@provisional" />
|
|
104
|
+
<xsl:text>
</xsl:text>
|
|
105
|
+
</xsl:template>
|
|
106
|
+
|
|
107
|
+
</xsl:stylesheet>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# PreTeXt deprecations of xref/@autoname attribute
|
|
2
|
+
# Robert Beezer, 2017-07-25
|
|
3
|
+
|
|
4
|
+
# Sample usage on directory of *.xml files
|
|
5
|
+
# Converts from current directory to "newdir" subdirectory
|
|
6
|
+
#
|
|
7
|
+
# for f in *.xml; do echo $f; sed -f mathbook/xsl/utilities/deprecate-autoname.sed $f > newdir/$f; done
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
s/autoname="no"/text="global"/g
|
|
11
|
+
s/autoname = "no"/text = "global"/g
|
|
12
|
+
|
|
13
|
+
s/autoname="yes"/text="type-global"/g
|
|
14
|
+
s/autoname = "yes"/text = "type-global"/g
|
|
15
|
+
|
|
16
|
+
s/autoname="title"/text="title"/g
|
|
17
|
+
s/autoname = "title"/text = "title"/g
|
|
18
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# PreTeXt deprecations of index creation elements
|
|
2
|
+
# Robert Beezer, 2017-07-14
|
|
3
|
+
|
|
4
|
+
# Sample usage on directory of *.xml files
|
|
5
|
+
# Converts from current directory to "newdir" subdirectory
|
|
6
|
+
#
|
|
7
|
+
# for f in *.xml; do echo $f; sed -f mathbook/xsl/utilities/deprecate-index.sed $f > newdir/$f; done
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# First, protect elements that begin with "index"
|
|
11
|
+
# so "index" match below will not affect them
|
|
12
|
+
s/<index-part/PARTPART/g
|
|
13
|
+
s/<\/index-part>/PARTENDPARTEND/g
|
|
14
|
+
s/<index-list/LISTLIST/g
|
|
15
|
+
|
|
16
|
+
# index -> idx
|
|
17
|
+
s/<index/<idx/g
|
|
18
|
+
s/<\/index>/<\/idx>/g
|
|
19
|
+
|
|
20
|
+
# main -> h
|
|
21
|
+
s/<main/<h/g
|
|
22
|
+
s/<\/main>/<\/h>/g
|
|
23
|
+
|
|
24
|
+
# sub -> h
|
|
25
|
+
# careful not to clobber <subsection>, etc.
|
|
26
|
+
s/<sub /<h /g
|
|
27
|
+
s/<sub>/<h>/g
|
|
28
|
+
s/<\/sub>/<\/h>/g
|
|
29
|
+
|
|
30
|
+
# Remove protection, convert to new elements
|
|
31
|
+
s/PARTPART/<index/g
|
|
32
|
+
s/PARTENDPARTEND/<\/index>/g
|
|
33
|
+
s/LISTLIST/<index-list/g
|