@pretextbook/pretext-html 0.3.0 → 0.5.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 +106 -10
- package/assets/preview-html.xsl +8 -4
- package/assets/preview-revealjs.xsl +85 -0
- package/assets/upstream.json +1 -1
- package/assets/xsl/LICENSE-pretext +16 -0
- package/assets/xsl/README.md +25 -24
- package/assets/xsl/entities.ent +27 -0
- package/assets/xsl/extract-biblio-csl.xsl +6 -4
- package/assets/xsl/extract-dynamic.xsl +14 -12
- package/assets/xsl/extract-interactive.xsl +2 -2
- package/assets/xsl/extract-pg.xsl +123 -306
- package/assets/xsl/extract-qrcode.xsl +12 -2
- package/assets/xsl/extract-sageplot.xsl +1 -1
- package/assets/xsl/extract-trace.xsl +3 -3
- package/assets/xsl/extract-youtube.xsl +1 -1
- package/assets/xsl/latex/pretext-latex-texstyle.xsl +4 -5
- package/assets/xsl/localizations/README.md +24 -24
- package/assets/xsl/pretext-assembly.xsl +463 -368
- package/assets/xsl/pretext-beamer.xsl +43 -146
- package/assets/xsl/pretext-braille-preprint.xsl +458 -202
- package/assets/xsl/pretext-common.xsl +486 -510
- package/assets/xsl/pretext-epub.xsl +318 -78
- package/assets/xsl/pretext-fo.xsl +80 -96
- package/assets/xsl/pretext-html.xsl +413 -318
- package/assets/xsl/pretext-jupyter.xsl +534 -322
- package/assets/xsl/pretext-latex-classic.xsl +14 -15
- package/assets/xsl/pretext-latex-common.xsl +393 -2397
- package/assets/xsl/pretext-latex.xsl +1995 -5
- package/assets/xsl/pretext-markdown.xsl +919 -0
- package/assets/xsl/pretext-numbers.xsl +57 -39
- package/assets/xsl/pretext-revealjs.xsl +241 -33
- package/assets/xsl/pretext-runestone-fitb.xsl +34 -35
- package/assets/xsl/pretext-runestone-static.xsl +17 -17
- package/assets/xsl/pretext-runestone.xsl +36 -34
- package/assets/xsl/pretext-sage-doctest.xsl +2 -2
- package/assets/xsl/pretext-text-utilities.xsl +69 -1
- package/assets/xsl/pretext-text.xsl +1077 -107
- package/assets/xsl/pretext-view-source.xsl +5 -3
- package/assets/xsl/pretext-ww-problem-sets.xsl +6 -1
- package/assets/xsl/publisher-variables.xsl +397 -477
- package/assets/xsl/support/play-button/README.md +1 -3
- package/assets/xsl/tests/README.md +1 -1
- package/assets/xsl/utilities/README.md +6 -8
- package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
- package/assets/xsl-bundle.json +1 -1
- package/dist/cli-DZsyZERX.js +694 -0
- package/dist/cli.js +1 -1
- package/dist/index.browser.d.ts +5 -0
- package/dist/index.browser.js +499 -344
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -18
- package/dist/publication.d.ts +26 -12
- package/dist/renderer.d.ts +68 -0
- package/dist/reveal.d.ts +77 -0
- package/dist/reveal.js +110 -0
- package/dist/target.d.ts +34 -0
- package/package.json +12 -1
- package/dist/cli-CzoinNle.js +0 -639
|
@@ -62,41 +62,807 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
62
62
|
|
|
63
63
|
<xsl:output method="text"/>
|
|
64
64
|
|
|
65
|
+
<!-- Elect the absorption of clause-ending punctuation into -->
|
|
66
|
+
<!-- display mathematics (only), where our templates re-place it -->
|
|
67
|
+
<!-- on the final row; inline mathematics keeps its punctuation -->
|
|
68
|
+
<!-- in the prose, where it reads naturally. -->
|
|
69
|
+
<xsl:param name="math.punctuation.include" select="'display'"/>
|
|
70
|
+
|
|
65
71
|
<!-- if chunking, this is the extension of the files produced -->
|
|
66
72
|
<xsl:variable name="file-extension" select="'.txt'"/>
|
|
67
73
|
|
|
68
74
|
|
|
69
75
|
<!-- Entry Template -->
|
|
70
|
-
<!-- Kickstart the process, ignore "docinfo" -->
|
|
76
|
+
<!-- Kickstart the process, ignore "docinfo". A positive chunk -->
|
|
77
|
+
<!-- level (the common election) writes a tree of files instead -->
|
|
78
|
+
<!-- of a single stream; see the Chunking section below. -->
|
|
71
79
|
<xsl:template match="/">
|
|
72
|
-
<xsl:
|
|
73
|
-
<xsl:
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
<xsl:choose>
|
|
81
|
+
<xsl:when test="$chunk-level > 0">
|
|
82
|
+
<xsl:apply-templates select="$document-root" mode="chunking"/>
|
|
83
|
+
</xsl:when>
|
|
84
|
+
<xsl:otherwise>
|
|
85
|
+
<xsl:apply-templates select="$document-root"/>
|
|
86
|
+
</xsl:otherwise>
|
|
87
|
+
</xsl:choose>
|
|
76
88
|
</xsl:template>
|
|
77
89
|
|
|
78
90
|
<!-- TEMPORARY: defined to stop errors, need stubs in -common -->
|
|
79
91
|
<xsl:template name="inline-warning"/>
|
|
80
92
|
<xsl:template name="margin-warning"/>
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
|
|
94
|
+
<!-- ################ -->
|
|
95
|
+
<!-- Producer's Notes -->
|
|
96
|
+
<!-- ################ -->
|
|
97
|
+
|
|
98
|
+
<!-- Content that text cannot express is announced, not dropped: -->
|
|
99
|
+
<!-- a bracketed note with a localized label, a fixed convention -->
|
|
100
|
+
<!-- a reader (or a consuming program) can recognize and strip. -->
|
|
101
|
+
<xsl:template name="producer-note">
|
|
102
|
+
<xsl:param name="message"/>
|
|
103
|
+
<xsl:text>[</xsl:text>
|
|
104
|
+
<xsl:apply-templates select="." mode="type-name">
|
|
105
|
+
<xsl:with-param name="string-id" select="'note'"/>
|
|
106
|
+
</xsl:apply-templates>
|
|
107
|
+
<xsl:text>: </xsl:text>
|
|
108
|
+
<xsl:copy-of select="$message"/>
|
|
109
|
+
<xsl:text>]</xsl:text>
|
|
110
|
+
</xsl:template>
|
|
111
|
+
|
|
112
|
+
<!-- Structured lines ("department", "attribution", a "cell" of -->
|
|
113
|
+
<!-- "line") break onto new lines; -common's default is a -->
|
|
114
|
+
<!-- "[LINESEP]" marker demanding this implementation -->
|
|
115
|
+
<xsl:template name="line-separator">
|
|
116
|
+
<xsl:text>
</xsl:text>
|
|
117
|
+
</xsl:template>
|
|
118
|
+
|
|
119
|
+
<!-- A landing spot for a link with a fragment identifier: -->
|
|
120
|
+
<!-- nothing in plain text, realized by the markdown flavor -->
|
|
121
|
+
<xsl:template match="*" mode="fragment-anchor"/>
|
|
122
|
+
|
|
123
|
+
<!-- Macro definitions preceding a page's mathematics: nothing -->
|
|
124
|
+
<!-- in plain text (the mathematics is authored LaTeX, macros -->
|
|
125
|
+
<!-- and all), realized by the markdown flavor for renderers -->
|
|
126
|
+
<xsl:template match="*" mode="latex-macros"/>
|
|
127
|
+
|
|
128
|
+
<!-- ######## -->
|
|
129
|
+
<!-- Verbatim -->
|
|
130
|
+
<!-- ######## -->
|
|
131
|
+
|
|
132
|
+
<!-- A verbatim block: contents on their own lines, every line -->
|
|
133
|
+
<!-- indented four spaces (which is set-off in plain text, and -->
|
|
134
|
+
<!-- happens to be a code block in markdown). A caller may -->
|
|
135
|
+
<!-- extend the indentation, say with a prompt. -->
|
|
136
|
+
<xsl:template name="verbatim-block">
|
|
137
|
+
<xsl:param name="content"/>
|
|
138
|
+
<xsl:param name="indent" select="' '"/>
|
|
139
|
+
<!-- the blank line preceding the block; a caller abutting -->
|
|
140
|
+
<!-- two blocks (Sage input, output) empties the second's -->
|
|
141
|
+
<xsl:param name="lead" select="'
'"/>
|
|
142
|
+
<xsl:variable name="sanitized">
|
|
143
|
+
<xsl:call-template name="sanitize-text">
|
|
144
|
+
<xsl:with-param name="text" select="$content"/>
|
|
145
|
+
</xsl:call-template>
|
|
146
|
+
</xsl:variable>
|
|
147
|
+
<xsl:value-of select="$lead"/>
|
|
148
|
+
<xsl:call-template name="add-indentation">
|
|
149
|
+
<xsl:with-param name="text" select="$sanitized"/>
|
|
150
|
+
<xsl:with-param name="indent" select="$indent"/>
|
|
151
|
+
</xsl:call-template>
|
|
152
|
+
<xsl:text>
</xsl:text>
|
|
153
|
+
</xsl:template>
|
|
154
|
+
|
|
155
|
+
<xsl:template match="pre">
|
|
156
|
+
<xsl:call-template name="verbatim-block">
|
|
157
|
+
<xsl:with-param name="content">
|
|
158
|
+
<xsl:apply-templates select="." mode="interior"/>
|
|
159
|
+
</xsl:with-param>
|
|
160
|
+
</xsl:call-template>
|
|
161
|
+
</xsl:template>
|
|
162
|
+
|
|
163
|
+
<xsl:template match="cd">
|
|
164
|
+
<xsl:call-template name="verbatim-block">
|
|
165
|
+
<xsl:with-param name="content">
|
|
166
|
+
<xsl:choose>
|
|
167
|
+
<xsl:when test="cline">
|
|
168
|
+
<xsl:apply-templates select="cline"/>
|
|
169
|
+
</xsl:when>
|
|
170
|
+
<xsl:otherwise>
|
|
171
|
+
<xsl:value-of select="."/>
|
|
172
|
+
</xsl:otherwise>
|
|
173
|
+
</xsl:choose>
|
|
174
|
+
</xsl:with-param>
|
|
175
|
+
</xsl:call-template>
|
|
176
|
+
</xsl:template>
|
|
177
|
+
|
|
178
|
+
<xsl:template match="program">
|
|
179
|
+
<xsl:call-template name="verbatim-block">
|
|
180
|
+
<xsl:with-param name="content">
|
|
181
|
+
<xsl:value-of select="code"/>
|
|
182
|
+
</xsl:with-param>
|
|
183
|
+
</xsl:call-template>
|
|
184
|
+
</xsl:template>
|
|
185
|
+
|
|
186
|
+
<xsl:template match="console">
|
|
187
|
+
<xsl:apply-templates select="input|output"/>
|
|
188
|
+
</xsl:template>
|
|
189
|
+
|
|
190
|
+
<xsl:template match="console/input">
|
|
191
|
+
<xsl:call-template name="verbatim-block">
|
|
192
|
+
<xsl:with-param name="content">
|
|
193
|
+
<xsl:value-of select="../@prompt"/>
|
|
194
|
+
<xsl:value-of select="."/>
|
|
195
|
+
</xsl:with-param>
|
|
196
|
+
</xsl:call-template>
|
|
197
|
+
</xsl:template>
|
|
198
|
+
|
|
199
|
+
<xsl:template match="console/output">
|
|
200
|
+
<xsl:call-template name="verbatim-block">
|
|
201
|
+
<xsl:with-param name="content">
|
|
202
|
+
<xsl:value-of select="."/>
|
|
203
|
+
</xsl:with-param>
|
|
204
|
+
</xsl:call-template>
|
|
205
|
+
</xsl:template>
|
|
206
|
+
|
|
207
|
+
<!-- Input carries a prompt on every line, named for the cell's -->
|
|
208
|
+
<!-- language (Sage by default) in the manner of a session, so -->
|
|
209
|
+
<!-- it reads apart from the bare output, which follows after a -->
|
|
210
|
+
<!-- single blank line -->
|
|
211
|
+
<xsl:template match="sage" mode="sage-active-markup">
|
|
212
|
+
<xsl:param name="in"/>
|
|
213
|
+
<xsl:param name="out"/>
|
|
214
|
+
<xsl:variable name="the-language">
|
|
215
|
+
<xsl:choose>
|
|
216
|
+
<xsl:when test="@language">
|
|
217
|
+
<xsl:value-of select="@language"/>
|
|
218
|
+
</xsl:when>
|
|
219
|
+
<xsl:otherwise>
|
|
220
|
+
<xsl:text>sage</xsl:text>
|
|
221
|
+
</xsl:otherwise>
|
|
222
|
+
</xsl:choose>
|
|
223
|
+
</xsl:variable>
|
|
224
|
+
<xsl:call-template name="verbatim-block">
|
|
225
|
+
<xsl:with-param name="content" select="$in"/>
|
|
226
|
+
<xsl:with-param name="indent" select="concat(' ', $the-language, ': ')"/>
|
|
227
|
+
</xsl:call-template>
|
|
228
|
+
<xsl:if test="not($out = '')">
|
|
229
|
+
<xsl:call-template name="verbatim-block">
|
|
230
|
+
<xsl:with-param name="content" select="$out"/>
|
|
231
|
+
<xsl:with-param name="lead" select="''"/>
|
|
232
|
+
</xsl:call-template>
|
|
233
|
+
</xsl:if>
|
|
234
|
+
</xsl:template>
|
|
235
|
+
|
|
236
|
+
<xsl:template name="sage-display-markup">
|
|
237
|
+
<xsl:param name="in"/>
|
|
238
|
+
<xsl:call-template name="verbatim-block">
|
|
239
|
+
<xsl:with-param name="content" select="$in"/>
|
|
240
|
+
</xsl:call-template>
|
|
241
|
+
</xsl:template>
|
|
242
|
+
|
|
243
|
+
<!-- ##### -->
|
|
244
|
+
<!-- Media -->
|
|
245
|
+
<!-- ##### -->
|
|
246
|
+
|
|
247
|
+
<!-- An image is its author-provided description; failing that, a -->
|
|
248
|
+
<!-- note that an image was here -->
|
|
249
|
+
<xsl:template match="image">
|
|
250
|
+
<xsl:text>
</xsl:text>
|
|
251
|
+
<xsl:call-template name="producer-note">
|
|
252
|
+
<xsl:with-param name="message">
|
|
253
|
+
<xsl:choose>
|
|
254
|
+
<xsl:when test="shortdescription">
|
|
255
|
+
<xsl:apply-templates select="shortdescription"/>
|
|
256
|
+
</xsl:when>
|
|
257
|
+
<xsl:when test="description">
|
|
258
|
+
<xsl:apply-templates select="description"/>
|
|
259
|
+
</xsl:when>
|
|
260
|
+
<xsl:otherwise>
|
|
261
|
+
<xsl:text>an image, undescribed by its author</xsl:text>
|
|
262
|
+
</xsl:otherwise>
|
|
263
|
+
</xsl:choose>
|
|
264
|
+
</xsl:with-param>
|
|
265
|
+
</xsl:call-template>
|
|
266
|
+
<xsl:text>
</xsl:text>
|
|
267
|
+
</xsl:template>
|
|
268
|
+
|
|
269
|
+
<xsl:template match="shortdescription|description">
|
|
270
|
+
<xsl:apply-templates/>
|
|
271
|
+
</xsl:template>
|
|
272
|
+
|
|
273
|
+
<xsl:template match="video|audio|interactive|slate">
|
|
274
|
+
<xsl:text>
</xsl:text>
|
|
275
|
+
<xsl:call-template name="producer-note">
|
|
276
|
+
<xsl:with-param name="message">
|
|
277
|
+
<xsl:text>a </xsl:text>
|
|
278
|
+
<xsl:value-of select="local-name()"/>
|
|
279
|
+
<xsl:text> element is not realizable in this format</xsl:text>
|
|
280
|
+
<xsl:if test="@source|@href">
|
|
281
|
+
<xsl:text>; see </xsl:text>
|
|
282
|
+
<xsl:value-of select="@source|@href"/>
|
|
283
|
+
</xsl:if>
|
|
284
|
+
</xsl:with-param>
|
|
285
|
+
</xsl:call-template>
|
|
286
|
+
<xsl:text>
</xsl:text>
|
|
287
|
+
</xsl:template>
|
|
288
|
+
|
|
289
|
+
<!-- A linear format has no horizontal layout, so the -common -->
|
|
290
|
+
<!-- composition machinery, whose entire product is the -->
|
|
291
|
+
<!-- distribution of horizontal space, is deliberately unused. A -->
|
|
292
|
+
<!-- side-by-side is announced with a producer note and its panels -->
|
|
293
|
+
<!-- are realized in order by their ordinary templates. This -->
|
|
294
|
+
<!-- template is the shared realization for linear formats: the -->
|
|
295
|
+
<!-- Markdown conversion inherits it by import. -->
|
|
296
|
+
<xsl:template match="sidebyside">
|
|
297
|
+
<xsl:text>
</xsl:text>
|
|
298
|
+
<xsl:call-template name="producer-note">
|
|
299
|
+
<xsl:with-param name="message">
|
|
300
|
+
<xsl:text>the following </xsl:text>
|
|
301
|
+
<xsl:value-of select="count(*)"/>
|
|
302
|
+
<xsl:text> elements are arranged side-by-side in other formats</xsl:text>
|
|
303
|
+
</xsl:with-param>
|
|
304
|
+
</xsl:call-template>
|
|
305
|
+
<xsl:text>
</xsl:text>
|
|
306
|
+
<xsl:apply-templates select="*"/>
|
|
307
|
+
</xsl:template>
|
|
308
|
+
|
|
309
|
+
<!-- A group announces itself, with each member's panel count -->
|
|
310
|
+
<xsl:template match="sbsgroup">
|
|
311
|
+
<xsl:text>
</xsl:text>
|
|
312
|
+
<xsl:call-template name="producer-note">
|
|
313
|
+
<xsl:with-param name="message">
|
|
314
|
+
<xsl:text>the following is a group of </xsl:text>
|
|
315
|
+
<xsl:value-of select="count(sidebyside)"/>
|
|
316
|
+
<xsl:text> side-by-side with </xsl:text>
|
|
317
|
+
<xsl:for-each select="sidebyside">
|
|
318
|
+
<xsl:value-of select="count(*)"/>
|
|
319
|
+
<xsl:if test="following-sibling::sidebyside">
|
|
320
|
+
<xsl:text>, </xsl:text>
|
|
321
|
+
</xsl:if>
|
|
322
|
+
</xsl:for-each>
|
|
323
|
+
<xsl:text> panels respectively</xsl:text>
|
|
324
|
+
</xsl:with-param>
|
|
325
|
+
</xsl:call-template>
|
|
326
|
+
<xsl:text>
</xsl:text>
|
|
327
|
+
<xsl:apply-templates select="sidebyside"/>
|
|
328
|
+
</xsl:template>
|
|
83
329
|
|
|
84
330
|
<!-- ######### -->
|
|
85
|
-
<!--
|
|
331
|
+
<!-- Footnotes -->
|
|
86
332
|
<!-- ######### -->
|
|
87
333
|
|
|
88
|
-
|
|
89
|
-
|
|
334
|
+
<!-- A numbered mark in place; the text collects at the end of -->
|
|
335
|
+
<!-- the division (see the division template) -->
|
|
336
|
+
<xsl:template match="fn">
|
|
337
|
+
<xsl:text>[</xsl:text>
|
|
338
|
+
<xsl:apply-templates select="." mode="serial-number"/>
|
|
339
|
+
<xsl:text>]</xsl:text>
|
|
340
|
+
</xsl:template>
|
|
341
|
+
|
|
342
|
+
<xsl:template match="fn" mode="collected">
|
|
343
|
+
<xsl:text>[</xsl:text>
|
|
344
|
+
<xsl:apply-templates select="." mode="serial-number"/>
|
|
345
|
+
<xsl:text>] </xsl:text>
|
|
346
|
+
<xsl:apply-templates/>
|
|
90
347
|
<xsl:text>
</xsl:text>
|
|
91
|
-
|
|
348
|
+
</xsl:template>
|
|
349
|
+
|
|
350
|
+
<!-- ####### -->
|
|
351
|
+
<!-- Tabular -->
|
|
352
|
+
<!-- ####### -->
|
|
353
|
+
|
|
354
|
+
<!-- Modest: each row a line, cells separated by double spaces. -->
|
|
355
|
+
<!-- No column alignment (yet), spanning cells simply run in. -->
|
|
356
|
+
<xsl:template match="tabular">
|
|
357
|
+
<xsl:text>
</xsl:text>
|
|
358
|
+
<xsl:apply-templates select="row"/>
|
|
359
|
+
<xsl:text>
</xsl:text>
|
|
360
|
+
</xsl:template>
|
|
361
|
+
|
|
362
|
+
<xsl:template match="row">
|
|
363
|
+
<xsl:text> </xsl:text>
|
|
364
|
+
<xsl:for-each select="cell">
|
|
365
|
+
<xsl:apply-templates/>
|
|
366
|
+
<xsl:if test="following-sibling::cell">
|
|
367
|
+
<xsl:text> </xsl:text>
|
|
368
|
+
</xsl:if>
|
|
369
|
+
</xsl:for-each>
|
|
370
|
+
<xsl:text>
</xsl:text>
|
|
371
|
+
</xsl:template>
|
|
372
|
+
|
|
373
|
+
<!-- ###### -->
|
|
374
|
+
<!-- Poetry -->
|
|
375
|
+
<!-- ###### -->
|
|
376
|
+
|
|
377
|
+
<xsl:template match="poem">
|
|
378
|
+
<xsl:text>
</xsl:text>
|
|
379
|
+
<xsl:if test="title">
|
|
380
|
+
<xsl:apply-templates select="." mode="title-full"/>
|
|
381
|
+
<xsl:text>
</xsl:text>
|
|
382
|
+
</xsl:if>
|
|
383
|
+
<xsl:apply-templates select="stanza"/>
|
|
384
|
+
</xsl:template>
|
|
385
|
+
|
|
386
|
+
<xsl:template match="stanza">
|
|
387
|
+
<xsl:apply-templates select="line"/>
|
|
388
|
+
<xsl:text>
</xsl:text>
|
|
389
|
+
</xsl:template>
|
|
390
|
+
|
|
391
|
+
<xsl:template match="stanza/line">
|
|
392
|
+
<xsl:text> </xsl:text>
|
|
393
|
+
<xsl:apply-templates/>
|
|
394
|
+
<xsl:text>
</xsl:text>
|
|
395
|
+
</xsl:template>
|
|
396
|
+
|
|
397
|
+
<!-- #### -->
|
|
398
|
+
<!-- URLs -->
|
|
399
|
+
<!-- #### -->
|
|
400
|
+
|
|
401
|
+
<!-- visible text (when there is some), address in angle brackets -->
|
|
402
|
+
<xsl:template match="url">
|
|
403
|
+
<xsl:choose>
|
|
404
|
+
<xsl:when test="node()">
|
|
405
|
+
<xsl:apply-templates/>
|
|
406
|
+
<xsl:text> <</xsl:text>
|
|
407
|
+
<xsl:value-of select="@href"/>
|
|
408
|
+
<xsl:text>></xsl:text>
|
|
409
|
+
</xsl:when>
|
|
410
|
+
<xsl:otherwise>
|
|
411
|
+
<xsl:text><</xsl:text>
|
|
412
|
+
<xsl:value-of select="@href"/>
|
|
413
|
+
<xsl:text>></xsl:text>
|
|
414
|
+
</xsl:otherwise>
|
|
415
|
+
</xsl:choose>
|
|
416
|
+
</xsl:template>
|
|
417
|
+
|
|
418
|
+
<!-- ##### -->
|
|
419
|
+
<!-- Index -->
|
|
420
|
+
<!-- ##### -->
|
|
421
|
+
|
|
422
|
+
<!-- An "idx" element is invisible where it is authored; the index -->
|
|
423
|
+
<!-- machinery of -common mines them all to manufacture the index -->
|
|
424
|
+
<!-- division, which renders through the presentation templates -->
|
|
425
|
+
<!-- below (modeled on the -fo implementations). -->
|
|
426
|
+
<xsl:template match="idx"/>
|
|
427
|
+
|
|
428
|
+
<!-- the assembled index needs no wrapper -->
|
|
429
|
+
<xsl:template name="present-index">
|
|
430
|
+
<xsl:param name="content"/>
|
|
431
|
+
<xsl:copy-of select="$content"/>
|
|
432
|
+
</xsl:template>
|
|
433
|
+
|
|
434
|
+
<!-- a blank line separates letter groups -->
|
|
435
|
+
<xsl:template name="present-letter-group">
|
|
436
|
+
<xsl:param name="the-index-list"/>
|
|
437
|
+
<xsl:param name="letter-group"/>
|
|
438
|
+
<xsl:param name="current-letter"/>
|
|
439
|
+
<xsl:param name="content"/>
|
|
440
|
+
<xsl:copy-of select="$content"/>
|
|
441
|
+
<xsl:text>
</xsl:text>
|
|
442
|
+
</xsl:template>
|
|
443
|
+
|
|
444
|
+
<!-- one line of the index: two spaces of indentation per level -->
|
|
445
|
+
<!-- of subentry, locators trailing the deepest heading -->
|
|
446
|
+
<xsl:template name="present-index-heading">
|
|
447
|
+
<xsl:param name="the-index-list"/>
|
|
448
|
+
<xsl:param name="heading-group"/>
|
|
449
|
+
<xsl:param name="b-write-locators"/>
|
|
450
|
+
<xsl:param name="heading-level"/>
|
|
451
|
+
<xsl:param name="content"/>
|
|
452
|
+
<xsl:value-of select="str:padding(2 * ($heading-level - 1), ' ')"/>
|
|
453
|
+
<xsl:copy-of select="$content"/>
|
|
454
|
+
<xsl:if test="$b-write-locators">
|
|
455
|
+
<xsl:call-template name="locator-list">
|
|
456
|
+
<xsl:with-param name="the-index-list" select="$the-index-list"/>
|
|
457
|
+
<xsl:with-param name="heading-group" select="$heading-group"/>
|
|
458
|
+
<xsl:with-param name="cross-reference-separator" select="', '"/>
|
|
459
|
+
</xsl:call-template>
|
|
460
|
+
</xsl:if>
|
|
461
|
+
<xsl:text>
</xsl:text>
|
|
462
|
+
</xsl:template>
|
|
463
|
+
|
|
464
|
+
<!-- the pieces of a locator: processed content suffices -->
|
|
465
|
+
<xsl:template name="present-index-locator">
|
|
466
|
+
<xsl:param name="content"/>
|
|
467
|
+
<xsl:copy-of select="$content"/>
|
|
468
|
+
</xsl:template>
|
|
469
|
+
|
|
470
|
+
<xsl:template name="present-index-see">
|
|
471
|
+
<xsl:param name="content"/>
|
|
472
|
+
<xsl:copy-of select="$content"/>
|
|
473
|
+
</xsl:template>
|
|
474
|
+
|
|
475
|
+
<xsl:template name="present-index-see-also">
|
|
476
|
+
<xsl:param name="content"/>
|
|
477
|
+
<xsl:copy-of select="$content"/>
|
|
478
|
+
</xsl:template>
|
|
479
|
+
|
|
480
|
+
<!-- italics for a "see" word: plain text has no italics -->
|
|
481
|
+
<xsl:template name="present-index-italics">
|
|
482
|
+
<xsl:param name="content"/>
|
|
483
|
+
<xsl:copy-of select="$content"/>
|
|
484
|
+
</xsl:template>
|
|
485
|
+
|
|
486
|
+
<!-- One locator: climb from the "idx" to the nearest enclosure -->
|
|
487
|
+
<!-- that is structural or a block AND has a number (the HTML -->
|
|
488
|
+
<!-- conversion's approach; there are no page numbers to cite), -->
|
|
489
|
+
<!-- then present it through the "index-locator" flavor template -->
|
|
490
|
+
<xsl:template match="index-list" mode="index-enclosure">
|
|
491
|
+
<xsl:param name="enclosure"/>
|
|
492
|
+
<xsl:variable name="structural">
|
|
493
|
+
<xsl:apply-templates select="$enclosure" mode="is-structural"/>
|
|
494
|
+
</xsl:variable>
|
|
495
|
+
<xsl:variable name="block">
|
|
496
|
+
<xsl:apply-templates select="$enclosure" mode="is-block"/>
|
|
497
|
+
</xsl:variable>
|
|
498
|
+
<xsl:variable name="the-number">
|
|
499
|
+
<xsl:if test="($structural = 'true') or ($block = 'true')">
|
|
500
|
+
<xsl:apply-templates select="$enclosure" mode="number"/>
|
|
501
|
+
</xsl:if>
|
|
502
|
+
</xsl:variable>
|
|
503
|
+
<xsl:choose>
|
|
504
|
+
<!-- climbed past the document root (an "idx" in an unnumbered -->
|
|
505
|
+
<!-- peripheral of the root): the type of the root must suffice -->
|
|
506
|
+
<xsl:when test="not($enclosure)">
|
|
507
|
+
<xsl:apply-templates select="$document-root" mode="type-name"/>
|
|
508
|
+
</xsl:when>
|
|
509
|
+
<xsl:when test="not($the-number = '')">
|
|
510
|
+
<xsl:apply-templates select="." mode="index-locator">
|
|
511
|
+
<xsl:with-param name="enclosure" select="$enclosure"/>
|
|
512
|
+
<xsl:with-param name="the-number" select="$the-number"/>
|
|
513
|
+
</xsl:apply-templates>
|
|
514
|
+
</xsl:when>
|
|
515
|
+
<!-- climb; the "index-list" context rides along -->
|
|
516
|
+
<xsl:otherwise>
|
|
517
|
+
<xsl:apply-templates select="." mode="index-enclosure">
|
|
518
|
+
<xsl:with-param name="enclosure" select="$enclosure/parent::*"/>
|
|
519
|
+
</xsl:apply-templates>
|
|
520
|
+
</xsl:otherwise>
|
|
521
|
+
</xsl:choose>
|
|
522
|
+
</xsl:template>
|
|
523
|
+
|
|
524
|
+
<!-- "Theorem 2.1", "Section 3": the type announces what the -->
|
|
525
|
+
<!-- number leads to; the markdown flavor adds the link -->
|
|
526
|
+
<xsl:template match="index-list" mode="index-locator">
|
|
527
|
+
<xsl:param name="enclosure"/>
|
|
528
|
+
<xsl:param name="the-number"/>
|
|
529
|
+
<xsl:apply-templates select="$enclosure" mode="type-name"/>
|
|
92
530
|
<xsl:text> </xsl:text>
|
|
93
|
-
<xsl:
|
|
531
|
+
<xsl:value-of select="$the-number"/>
|
|
532
|
+
</xsl:template>
|
|
533
|
+
|
|
534
|
+
<!-- Hooks for generated lists (list of figures, etc.): the -->
|
|
535
|
+
<!-- entries suffice, no surrounding apparatus -->
|
|
536
|
+
<xsl:template name="list-of-begin"/>
|
|
537
|
+
<xsl:template name="list-of-end"/>
|
|
538
|
+
|
|
539
|
+
<!-- ############ -->
|
|
540
|
+
<!-- Bibliography -->
|
|
541
|
+
<!-- ############ -->
|
|
542
|
+
|
|
543
|
+
<!-- Font modes required by -common's bibliography machinery. -->
|
|
544
|
+
<!-- Plain text has no fonts: content rides through unadorned. -->
|
|
545
|
+
<!-- (The markdown conversion overrides these with emphasis.) -->
|
|
546
|
+
<xsl:template match="*" mode="italic">
|
|
547
|
+
<xsl:apply-templates/>
|
|
548
|
+
</xsl:template>
|
|
549
|
+
|
|
550
|
+
<xsl:template match="*" mode="bold">
|
|
551
|
+
<xsl:apply-templates/>
|
|
552
|
+
</xsl:template>
|
|
553
|
+
|
|
554
|
+
<xsl:template match="*" mode="monospace">
|
|
555
|
+
<xsl:apply-templates/>
|
|
556
|
+
</xsl:template>
|
|
557
|
+
|
|
558
|
+
<xsl:template name="biblio-period">
|
|
559
|
+
<xsl:text>.</xsl:text>
|
|
560
|
+
</xsl:template>
|
|
561
|
+
|
|
562
|
+
<!-- Literal code phrases ("c") funnel through this wrapper; -->
|
|
563
|
+
<!-- plain text passes the content through unadorned. (The -->
|
|
564
|
+
<!-- markdown conversion overrides with backtick spans.) -->
|
|
565
|
+
<xsl:template name="code-wrapper">
|
|
566
|
+
<xsl:param name="content"/>
|
|
567
|
+
<xsl:copy-of select="$content"/>
|
|
568
|
+
</xsl:template>
|
|
569
|
+
|
|
570
|
+
<!-- Every bibliography flavor funnels through this wrapper in -->
|
|
571
|
+
<!-- -common: a bracketed number, then the entry's content -->
|
|
572
|
+
<xsl:template match="biblio" mode="bibentry-wrapper">
|
|
573
|
+
<xsl:param name="content"/>
|
|
574
|
+
<xsl:if test="preceding-sibling::biblio">
|
|
575
|
+
<xsl:text>
</xsl:text>
|
|
576
|
+
</xsl:if>
|
|
577
|
+
<xsl:text>[</xsl:text>
|
|
578
|
+
<xsl:apply-templates select="." mode="serial-number"/>
|
|
579
|
+
<xsl:text>] </xsl:text>
|
|
580
|
+
<xsl:copy-of select="$content"/>
|
|
581
|
+
<xsl:text>
</xsl:text>
|
|
582
|
+
</xsl:template>
|
|
583
|
+
|
|
584
|
+
<!-- ######### -->
|
|
585
|
+
<!-- Divisions -->
|
|
586
|
+
<!-- ######### -->
|
|
587
|
+
|
|
588
|
+
<!-- A heading is the division's usual "Type Number Title" line, -->
|
|
589
|
+
<!-- underlined in the manner of typewritten manuscripts (and, -->
|
|
590
|
+
<!-- happily, of markdown's setext headings for the top two -->
|
|
591
|
+
<!-- levels): one underline character per depth. -->
|
|
592
|
+
<xsl:variable name="heading-underline-characters" select="'=-~^"'"/>
|
|
593
|
+
|
|
594
|
+
<!-- The text of a heading: "Type Number Title". -->
|
|
595
|
+
<!-- Unnumbered peripheral divisions (preface, colophon, ...) -->
|
|
596
|
+
<!-- take just their title: the default title IS the type-name, -->
|
|
597
|
+
<!-- and "Preface Preface" serves nobody. -->
|
|
598
|
+
<xsl:template match="*" mode="heading-text">
|
|
599
|
+
<xsl:variable name="the-number">
|
|
600
|
+
<xsl:apply-templates select="." mode="number"/>
|
|
601
|
+
</xsl:variable>
|
|
602
|
+
<xsl:if test="not($the-number = '')">
|
|
603
|
+
<xsl:apply-templates select="." mode="type-name"/>
|
|
604
|
+
<xsl:text> </xsl:text>
|
|
605
|
+
<xsl:value-of select="$the-number"/>
|
|
606
|
+
<xsl:text> </xsl:text>
|
|
607
|
+
</xsl:if>
|
|
94
608
|
<!-- Title is required (or default is supplied) -->
|
|
95
|
-
<xsl:text> </xsl:text>
|
|
96
609
|
<xsl:apply-templates select="." mode="title-full"/>
|
|
610
|
+
</xsl:template>
|
|
611
|
+
|
|
612
|
+
<!-- The heading and its underline, assembled once so the -->
|
|
613
|
+
<!-- heading can be measured -->
|
|
614
|
+
<xsl:template match="*" mode="heading-lines">
|
|
615
|
+
<xsl:variable name="heading">
|
|
616
|
+
<xsl:apply-templates select="." mode="heading-text"/>
|
|
617
|
+
</xsl:variable>
|
|
618
|
+
<!-- depth chooses the underline character; anything deeper -->
|
|
619
|
+
<!-- than the repertoire reuses the last character -->
|
|
620
|
+
<xsl:variable name="raw-level">
|
|
621
|
+
<xsl:apply-templates select="." mode="level"/>
|
|
622
|
+
</xsl:variable>
|
|
623
|
+
<xsl:variable name="level">
|
|
624
|
+
<xsl:choose>
|
|
625
|
+
<xsl:when test="$raw-level > 5">
|
|
626
|
+
<xsl:text>5</xsl:text>
|
|
627
|
+
</xsl:when>
|
|
628
|
+
<xsl:otherwise>
|
|
629
|
+
<xsl:value-of select="$raw-level"/>
|
|
630
|
+
</xsl:otherwise>
|
|
631
|
+
</xsl:choose>
|
|
632
|
+
</xsl:variable>
|
|
633
|
+
<!-- empty line prior -->
|
|
97
634
|
<xsl:text>
</xsl:text>
|
|
635
|
+
<xsl:value-of select="$heading"/>
|
|
636
|
+
<xsl:text>
</xsl:text>
|
|
637
|
+
<xsl:value-of select="str:padding(string-length($heading), substring($heading-underline-characters, $level, 1))"/>
|
|
638
|
+
<xsl:text>

</xsl:text>
|
|
639
|
+
</xsl:template>
|
|
640
|
+
|
|
641
|
+
<!-- Footnotes belonging to a division (and not to a deeper -->
|
|
642
|
+
<!-- one) collect at its end -->
|
|
643
|
+
<xsl:template match="*" mode="division-footnotes">
|
|
644
|
+
<xsl:variable name="the-notes" select=".//fn[count(ancestor::*[&STRUCTURAL-FILTER;][1]|current()) = 1]"/>
|
|
645
|
+
<xsl:if test="$the-notes">
|
|
646
|
+
<xsl:text>
</xsl:text>
|
|
647
|
+
<xsl:apply-templates select="$the-notes" mode="collected"/>
|
|
648
|
+
</xsl:if>
|
|
649
|
+
</xsl:template>
|
|
650
|
+
|
|
651
|
+
<xsl:template match="part|chapter|appendix|preface|acknowledgement|biography|foreword|dedication|colophon|section|subsection|subsubsection|exercises|reading-questions|worksheet|handout|glossary|references|solutions|index">
|
|
652
|
+
<xsl:apply-templates select="." mode="heading-lines"/>
|
|
98
653
|
<!-- metadata-ish, eg "title", should be killed by default -->
|
|
99
654
|
<xsl:apply-templates select="*"/>
|
|
655
|
+
<xsl:apply-templates select="." mode="division-footnotes"/>
|
|
656
|
+
</xsl:template>
|
|
657
|
+
|
|
658
|
+
<!-- The document itself: its title as the topmost heading, then -->
|
|
659
|
+
<!-- the content. ("docinfo" is ignored by the entry template.) -->
|
|
660
|
+
<xsl:template match="book|article" mode="heading-lines">
|
|
661
|
+
<xsl:variable name="heading">
|
|
662
|
+
<xsl:apply-templates select="." mode="title-full"/>
|
|
663
|
+
</xsl:variable>
|
|
664
|
+
<xsl:value-of select="$heading"/>
|
|
665
|
+
<xsl:text>
</xsl:text>
|
|
666
|
+
<xsl:value-of select="str:padding(string-length($heading), '*')"/>
|
|
667
|
+
<xsl:text>

</xsl:text>
|
|
668
|
+
</xsl:template>
|
|
669
|
+
|
|
670
|
+
<xsl:template match="book|article">
|
|
671
|
+
<xsl:apply-templates select="." mode="heading-lines"/>
|
|
672
|
+
<xsl:apply-templates select="." mode="latex-macros"/>
|
|
673
|
+
<xsl:apply-templates select="*"/>
|
|
674
|
+
</xsl:template>
|
|
675
|
+
|
|
676
|
+
<!-- Whole-document containers with no heading of their own -->
|
|
677
|
+
<xsl:template match="frontmatter|backmatter|mainmatter">
|
|
678
|
+
<xsl:apply-templates select="*"/>
|
|
679
|
+
</xsl:template>
|
|
680
|
+
|
|
681
|
+
<!-- ######## -->
|
|
682
|
+
<!-- Chunking -->
|
|
683
|
+
<!-- ######## -->
|
|
684
|
+
|
|
685
|
+
<!-- The common election (common/chunking/@level in the publication -->
|
|
686
|
+
<!-- file): a positive level writes each division at that depth as -->
|
|
687
|
+
<!-- its own file, driven by the generic chunking machinery of -->
|
|
688
|
+
<!-- -common. No election produces the document as a single file. -->
|
|
689
|
+
<xsl:variable name="chunk-level">
|
|
690
|
+
<xsl:choose>
|
|
691
|
+
<xsl:when test="$chunk-level-entered != ''">
|
|
692
|
+
<xsl:value-of select="$chunk-level-entered"/>
|
|
693
|
+
</xsl:when>
|
|
694
|
+
<xsl:otherwise>
|
|
695
|
+
<xsl:text>0</xsl:text>
|
|
696
|
+
</xsl:otherwise>
|
|
697
|
+
</xsl:choose>
|
|
698
|
+
</xsl:variable>
|
|
699
|
+
|
|
700
|
+
<!-- Every chunk of a chunked build, in reading order, each known -->
|
|
701
|
+
<!-- by its (unique) filename: the basis of each file's -->
|
|
702
|
+
<!-- navigation line -->
|
|
703
|
+
<xsl:variable name="chunk-list-rtf">
|
|
704
|
+
<xsl:if test="$chunk-level > 0">
|
|
705
|
+
<xsl:for-each select="($document-root|$document-root//*)[&STRUCTURAL-FILTER;]">
|
|
706
|
+
<xsl:variable name="is-chunk">
|
|
707
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
708
|
+
</xsl:variable>
|
|
709
|
+
<xsl:if test="$is-chunk = 'true'">
|
|
710
|
+
<chunk>
|
|
711
|
+
<xsl:attribute name="filename">
|
|
712
|
+
<xsl:apply-templates select="." mode="containing-filename"/>
|
|
713
|
+
</xsl:attribute>
|
|
714
|
+
</chunk>
|
|
715
|
+
</xsl:if>
|
|
716
|
+
</xsl:for-each>
|
|
717
|
+
</xsl:if>
|
|
718
|
+
</xsl:variable>
|
|
719
|
+
<xsl:variable name="chunk-list" select="exsl:node-set($chunk-list-rtf)/chunk"/>
|
|
720
|
+
|
|
721
|
+
<!-- The file every navigation line points back to: the -->
|
|
722
|
+
<!-- summary page of the document root (or the root as -->
|
|
723
|
+
<!-- one big chunk, for a shallow document) -->
|
|
724
|
+
<xsl:variable name="contents-filename">
|
|
725
|
+
<xsl:if test="$chunk-level > 0">
|
|
726
|
+
<xsl:apply-templates select="$document-root" mode="containing-filename"/>
|
|
727
|
+
</xsl:if>
|
|
728
|
+
</xsl:variable>
|
|
729
|
+
|
|
730
|
+
<!-- Realize one file: macro support for its mathematics -->
|
|
731
|
+
<!-- (nothing in plain text), the content, then a -->
|
|
732
|
+
<!-- navigation line -->
|
|
733
|
+
<xsl:template match="*" mode="file-wrap">
|
|
734
|
+
<xsl:param name="content"/>
|
|
735
|
+
<xsl:variable name="filename">
|
|
736
|
+
<xsl:apply-templates select="." mode="containing-filename"/>
|
|
737
|
+
</xsl:variable>
|
|
738
|
+
<exsl:document href="{$filename}" method="text" encoding="UTF-8">
|
|
739
|
+
<xsl:apply-templates select="." mode="latex-macros"/>
|
|
740
|
+
<xsl:copy-of select="$content"/>
|
|
741
|
+
<xsl:apply-templates select="." mode="navigation-line"/>
|
|
742
|
+
</exsl:document>
|
|
743
|
+
</xsl:template>
|
|
744
|
+
|
|
745
|
+
<!-- A division above the chunk frontier becomes a summary page: -->
|
|
746
|
+
<!-- its heading, its unstructured content, and one line naming -->
|
|
747
|
+
<!-- the file of each structural child -->
|
|
748
|
+
<xsl:template match="&STRUCTURAL;" mode="intermediate">
|
|
749
|
+
<xsl:apply-templates select="." mode="file-wrap">
|
|
750
|
+
<xsl:with-param name="content">
|
|
751
|
+
<xsl:apply-templates select="." mode="heading-lines"/>
|
|
752
|
+
<xsl:apply-templates select="introduction"/>
|
|
753
|
+
<xsl:text>
</xsl:text>
|
|
754
|
+
<xsl:for-each select="*[&STRUCTURAL-FILTER;]">
|
|
755
|
+
<xsl:apply-templates select="." mode="summary-entry"/>
|
|
756
|
+
</xsl:for-each>
|
|
757
|
+
<xsl:apply-templates select="conclusion"/>
|
|
758
|
+
<xsl:apply-templates select="." mode="division-footnotes"/>
|
|
759
|
+
</xsl:with-param>
|
|
760
|
+
</xsl:apply-templates>
|
|
761
|
+
</xsl:template>
|
|
762
|
+
|
|
763
|
+
<!-- One line of a summary page, naming a subsidiary file; the -->
|
|
764
|
+
<!-- markdown flavor overrides with a genuine link -->
|
|
765
|
+
<xsl:template match="*" mode="summary-entry">
|
|
766
|
+
<xsl:text>- </xsl:text>
|
|
767
|
+
<xsl:apply-templates select="." mode="heading-text"/>
|
|
768
|
+
<xsl:text> (</xsl:text>
|
|
769
|
+
<xsl:apply-templates select="." mode="containing-filename"/>
|
|
770
|
+
<xsl:text>)
</xsl:text>
|
|
771
|
+
</xsl:template>
|
|
772
|
+
|
|
773
|
+
<!-- The file of the division containing a chunk, when that is -->
|
|
774
|
+
<!-- neither the chunk itself nor the contents page: worthwhile -->
|
|
775
|
+
<!-- in a deeply chunked document. The document root has no -->
|
|
776
|
+
<!-- containing division, so nothing at all. -->
|
|
777
|
+
<xsl:template match="*" mode="up-filename">
|
|
778
|
+
<xsl:if test="parent::*[&STRUCTURAL-FILTER;]">
|
|
779
|
+
<xsl:variable name="parent-filename">
|
|
780
|
+
<xsl:apply-templates select=".." mode="containing-filename"/>
|
|
781
|
+
</xsl:variable>
|
|
782
|
+
<xsl:if test="not($parent-filename = $contents-filename)">
|
|
783
|
+
<xsl:value-of select="$parent-filename"/>
|
|
784
|
+
</xsl:if>
|
|
785
|
+
</xsl:if>
|
|
786
|
+
</xsl:template>
|
|
787
|
+
|
|
788
|
+
<!-- The trailing navigation line of a file that has a neighbor; -->
|
|
789
|
+
<!-- labels localize, and the markdown flavor overrides with links -->
|
|
790
|
+
<xsl:template match="*" mode="navigation-line">
|
|
791
|
+
<xsl:variable name="the-filename">
|
|
792
|
+
<xsl:apply-templates select="." mode="containing-filename"/>
|
|
793
|
+
</xsl:variable>
|
|
794
|
+
<xsl:variable name="entry" select="$chunk-list[@filename = $the-filename]"/>
|
|
795
|
+
<xsl:variable name="previous" select="$entry/preceding-sibling::chunk[1]"/>
|
|
796
|
+
<xsl:variable name="next" select="$entry/following-sibling::chunk[1]"/>
|
|
797
|
+
<xsl:variable name="up">
|
|
798
|
+
<xsl:apply-templates select="." mode="up-filename"/>
|
|
799
|
+
</xsl:variable>
|
|
800
|
+
<xsl:if test="$previous or $next">
|
|
801
|
+
<xsl:text>
[</xsl:text>
|
|
802
|
+
<xsl:apply-templates select="." mode="type-name">
|
|
803
|
+
<xsl:with-param name="string-id" select="'toc'"/>
|
|
804
|
+
</xsl:apply-templates>
|
|
805
|
+
<xsl:text>: </xsl:text>
|
|
806
|
+
<xsl:value-of select="$contents-filename"/>
|
|
807
|
+
<xsl:if test="$previous">
|
|
808
|
+
<xsl:text> | </xsl:text>
|
|
809
|
+
<xsl:apply-templates select="." mode="type-name">
|
|
810
|
+
<xsl:with-param name="string-id" select="'previous'"/>
|
|
811
|
+
</xsl:apply-templates>
|
|
812
|
+
<xsl:text>: </xsl:text>
|
|
813
|
+
<xsl:value-of select="$previous/@filename"/>
|
|
814
|
+
</xsl:if>
|
|
815
|
+
<xsl:if test="not($up = '')">
|
|
816
|
+
<xsl:text> | </xsl:text>
|
|
817
|
+
<xsl:apply-templates select="." mode="type-name">
|
|
818
|
+
<xsl:with-param name="string-id" select="'up'"/>
|
|
819
|
+
</xsl:apply-templates>
|
|
820
|
+
<xsl:text>: </xsl:text>
|
|
821
|
+
<xsl:value-of select="$up"/>
|
|
822
|
+
</xsl:if>
|
|
823
|
+
<xsl:if test="$next">
|
|
824
|
+
<xsl:text> | </xsl:text>
|
|
825
|
+
<xsl:apply-templates select="." mode="type-name">
|
|
826
|
+
<xsl:with-param name="string-id" select="'next'"/>
|
|
827
|
+
</xsl:apply-templates>
|
|
828
|
+
<xsl:text>: </xsl:text>
|
|
829
|
+
<xsl:value-of select="$next/@filename"/>
|
|
830
|
+
</xsl:if>
|
|
831
|
+
<xsl:text>]
</xsl:text>
|
|
832
|
+
</xsl:if>
|
|
833
|
+
</xsl:template>
|
|
834
|
+
|
|
835
|
+
<!-- The title page is mined for a byline, rather than templates -->
|
|
836
|
+
<xsl:template match="titlepage">
|
|
837
|
+
<xsl:for-each select="../../docinfo/../frontmatter/bibinfo/author/personname">
|
|
838
|
+
<xsl:apply-templates/>
|
|
839
|
+
<xsl:text>
</xsl:text>
|
|
840
|
+
</xsl:for-each>
|
|
841
|
+
</xsl:template>
|
|
842
|
+
|
|
843
|
+
<!-- Bibliographic metadata: quiet, mined above -->
|
|
844
|
+
<xsl:template match="bibinfo"/>
|
|
845
|
+
|
|
846
|
+
<!-- Unstructured containers: just their content; an addressable -->
|
|
847
|
+
<!-- one is a landing spot, glued to its title or first content -->
|
|
848
|
+
<!-- so the anchor never sits alone on a line -->
|
|
849
|
+
<xsl:template match="introduction|conclusion|statement|paragraphs|subexercises|exercisegroup">
|
|
850
|
+
<xsl:choose>
|
|
851
|
+
<xsl:when test="title">
|
|
852
|
+
<xsl:text>
</xsl:text>
|
|
853
|
+
<xsl:if test="@xml:id">
|
|
854
|
+
<xsl:apply-templates select="." mode="fragment-anchor"/>
|
|
855
|
+
</xsl:if>
|
|
856
|
+
<xsl:apply-templates select="." mode="title-full"/>
|
|
857
|
+
<xsl:text>
</xsl:text>
|
|
858
|
+
</xsl:when>
|
|
859
|
+
<xsl:otherwise>
|
|
860
|
+
<xsl:if test="@xml:id">
|
|
861
|
+
<xsl:apply-templates select="." mode="fragment-anchor"/>
|
|
862
|
+
</xsl:if>
|
|
863
|
+
</xsl:otherwise>
|
|
864
|
+
</xsl:choose>
|
|
865
|
+
<xsl:apply-templates select="*"/>
|
|
100
866
|
</xsl:template>
|
|
101
867
|
|
|
102
868
|
<!-- ################ -->
|
|
@@ -118,72 +884,148 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
118
884
|
<xsl:value-of select="$content"/>
|
|
119
885
|
</xsl:template>
|
|
120
886
|
|
|
887
|
+
<!-- ########## -->
|
|
121
888
|
<!-- Characters -->
|
|
889
|
+
<!-- ########## -->
|
|
122
890
|
|
|
123
|
-
<!--
|
|
124
|
-
<!--
|
|
125
|
-
<!--
|
|
891
|
+
<!-- Each character element renders per the publication file's -->
|
|
892
|
+
<!-- character repertoire: a genuine Unicode character, or a 7-bit -->
|
|
893
|
+
<!-- ASCII stand-in in the long plain-text tradition. The file is -->
|
|
894
|
+
<!-- UTF-8 either way; with the "ascii" election that fact is -->
|
|
895
|
+
<!-- invisible. ($b-text-unicode arrives from the publication -->
|
|
896
|
+
<!-- machinery; "unicode" is the default.) -->
|
|
126
897
|
|
|
127
|
-
<!--
|
|
128
|
-
<!--
|
|
129
|
-
<!-- (braille). They would likely need to use Unicode characters -->
|
|
130
|
-
<!-- like «, » rather than cheap 7-bit ASCII versions, like -->
|
|
131
|
-
<!-- <<, >>. So this would force the issue of a Unicode (8-bit -->
|
|
132
|
-
<!-- and more-than) switch and supporting that. So as of -->
|
|
133
|
-
<!-- 2026-02-18 we are punting. -->
|
|
898
|
+
<!-- TODO: quotation marks should localize by language in the -->
|
|
899
|
+
<!-- unicode repertoire, as other conversions do. -->
|
|
134
900
|
|
|
135
|
-
<!--
|
|
136
|
-
|
|
137
|
-
|
|
901
|
+
<!-- A character reads its elected column of the representation -->
|
|
902
|
+
<!-- table in pretext-common.xsl. The unicode repertoire is -->
|
|
903
|
+
<!-- complete; a row without an "ascii" stand-in warns under the -->
|
|
904
|
+
<!-- ascii election, so those gaps stay visible. -->
|
|
905
|
+
<xsl:template match="char" mode="character">
|
|
906
|
+
<xsl:choose>
|
|
907
|
+
<xsl:when test="$b-text-unicode">
|
|
908
|
+
<xsl:value-of select="@unicode"/>
|
|
909
|
+
</xsl:when>
|
|
910
|
+
<xsl:when test="@ascii">
|
|
911
|
+
<xsl:value-of select="@ascii"/>
|
|
912
|
+
</xsl:when>
|
|
913
|
+
<xsl:otherwise>
|
|
914
|
+
<xsl:call-template name="warn-unimplemented-character">
|
|
915
|
+
<xsl:with-param name="char-name" select="@name"/>
|
|
916
|
+
</xsl:call-template>
|
|
917
|
+
</xsl:otherwise>
|
|
918
|
+
</xsl:choose>
|
|
138
919
|
</xsl:template>
|
|
139
920
|
|
|
140
|
-
<xsl:template
|
|
141
|
-
<xsl:
|
|
921
|
+
<xsl:template match="*" mode="lsq-character">
|
|
922
|
+
<xsl:choose>
|
|
923
|
+
<xsl:when test="$b-text-unicode"><xsl:text>‘</xsl:text></xsl:when>
|
|
924
|
+
<xsl:otherwise><xsl:text>'</xsl:text></xsl:otherwise>
|
|
925
|
+
</xsl:choose>
|
|
142
926
|
</xsl:template>
|
|
143
927
|
|
|
144
|
-
<xsl:template
|
|
145
|
-
<xsl:
|
|
928
|
+
<xsl:template match="*" mode="rsq-character">
|
|
929
|
+
<xsl:choose>
|
|
930
|
+
<xsl:when test="$b-text-unicode"><xsl:text>’</xsl:text></xsl:when>
|
|
931
|
+
<xsl:otherwise><xsl:text>'</xsl:text></xsl:otherwise>
|
|
932
|
+
</xsl:choose>
|
|
146
933
|
</xsl:template>
|
|
147
934
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
935
|
+
<xsl:template match="*" mode="lq-character">
|
|
936
|
+
<xsl:choose>
|
|
937
|
+
<xsl:when test="$b-text-unicode"><xsl:text>“</xsl:text></xsl:when>
|
|
938
|
+
<xsl:otherwise><xsl:text>"</xsl:text></xsl:otherwise>
|
|
939
|
+
</xsl:choose>
|
|
940
|
+
</xsl:template>
|
|
152
941
|
|
|
153
|
-
|
|
154
|
-
<xsl:
|
|
155
|
-
|
|
942
|
+
<xsl:template match="*" mode="rq-character">
|
|
943
|
+
<xsl:choose>
|
|
944
|
+
<xsl:when test="$b-text-unicode"><xsl:text>”</xsl:text></xsl:when>
|
|
945
|
+
<xsl:otherwise><xsl:text>"</xsl:text></xsl:otherwise>
|
|
946
|
+
</xsl:choose>
|
|
156
947
|
</xsl:template>
|
|
157
948
|
|
|
158
|
-
|
|
159
|
-
|
|
949
|
+
<!-- #### -->
|
|
950
|
+
<!-- Math -->
|
|
951
|
+
<!-- #### -->
|
|
952
|
+
|
|
953
|
+
<!-- Mathematics never renders in plain text: throughout this -->
|
|
954
|
+
<!-- section the output is the LaTeX an author wrote, verbatim, -->
|
|
955
|
+
<!-- with no processor in prospect. -->
|
|
956
|
+
|
|
957
|
+
<!-- LaTeX is the lingua franca of plain-text mathematics, so -->
|
|
958
|
+
<!-- authored LaTeX rides along verbatim between dollar signs. -->
|
|
959
|
+
<!-- Two simple cases need no dressing at all: a single Latin -->
|
|
960
|
+
<!-- letter (a variable name), and an integer. (The same -->
|
|
961
|
+
<!-- analysis the braille conversion performs.) -->
|
|
962
|
+
<xsl:template name="inline-math-wrapper">
|
|
963
|
+
<xsl:param name="math"/>
|
|
964
|
+
<xsl:variable name="clean" select="normalize-space($math)"/>
|
|
965
|
+
<xsl:choose>
|
|
966
|
+
<xsl:when test="(string-length($clean) = 1) and contains(&ALPHABET;, $clean)">
|
|
967
|
+
<xsl:value-of select="$clean"/>
|
|
968
|
+
</xsl:when>
|
|
969
|
+
<xsl:when test="not($clean = '') and (translate($clean, &DIGIT;, '') = '')">
|
|
970
|
+
<xsl:value-of select="$clean"/>
|
|
971
|
+
</xsl:when>
|
|
972
|
+
<xsl:otherwise>
|
|
973
|
+
<xsl:text>$</xsl:text>
|
|
974
|
+
<xsl:value-of select="$clean"/>
|
|
975
|
+
<xsl:text>$</xsl:text>
|
|
976
|
+
</xsl:otherwise>
|
|
977
|
+
</xsl:choose>
|
|
160
978
|
</xsl:template>
|
|
161
979
|
|
|
162
|
-
|
|
163
|
-
|
|
980
|
+
<!-- Display mathematics: set off by blank lines, each row -->
|
|
981
|
+
<!-- indented, LaTeX verbatim. Alignment marks and such are -->
|
|
982
|
+
<!-- part of the mathematics and remain. -->
|
|
983
|
+
<xsl:template match="md">
|
|
984
|
+
<xsl:text>
</xsl:text>
|
|
985
|
+
<xsl:apply-templates select="mrow|intertext"/>
|
|
986
|
+
<xsl:text>
</xsl:text>
|
|
164
987
|
</xsl:template>
|
|
165
988
|
|
|
166
|
-
<xsl:template match="
|
|
167
|
-
<xsl:text
|
|
989
|
+
<xsl:template match="md[not(mrow)]">
|
|
990
|
+
<xsl:text>
 </xsl:text>
|
|
991
|
+
<xsl:value-of select="normalize-space(text())"/>
|
|
992
|
+
<!-- clause-ending punctuation absorbed by the display, restored -->
|
|
993
|
+
<xsl:apply-templates select="." mode="get-clause-punctuation-mark"/>
|
|
994
|
+
<xsl:text>

</xsl:text>
|
|
168
995
|
</xsl:template>
|
|
169
996
|
|
|
170
|
-
<xsl:template match="
|
|
171
|
-
<xsl:text>
|
|
997
|
+
<xsl:template match="mrow">
|
|
998
|
+
<xsl:text> </xsl:text>
|
|
999
|
+
<xsl:value-of select="normalize-space(.)"/>
|
|
1000
|
+
<!-- the display's absorbed punctuation lands on the last row -->
|
|
1001
|
+
<xsl:if test="not(following-sibling::mrow)">
|
|
1002
|
+
<xsl:apply-templates select="parent::md" mode="get-clause-punctuation-mark"/>
|
|
1003
|
+
</xsl:if>
|
|
1004
|
+
<xsl:text>
</xsl:text>
|
|
172
1005
|
</xsl:template>
|
|
173
1006
|
|
|
174
|
-
<xsl:template
|
|
175
|
-
<xsl:
|
|
1007
|
+
<xsl:template match="md/intertext">
|
|
1008
|
+
<xsl:apply-templates/>
|
|
1009
|
+
<xsl:text>
</xsl:text>
|
|
176
1010
|
</xsl:template>
|
|
177
1011
|
|
|
178
|
-
<!--
|
|
179
|
-
<!--
|
|
180
|
-
<!--
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
1012
|
+
<!-- ################# -->
|
|
1013
|
+
<!-- Prose Text Nodes -->
|
|
1014
|
+
<!-- ################# -->
|
|
1015
|
+
|
|
1016
|
+
<!-- Authors hard-wrap and indent their source; none of that -->
|
|
1017
|
+
<!-- belongs in the output. -common's "text()" template handles -->
|
|
1018
|
+
<!-- punctuation migration and whitespace at the edges of nodes, -->
|
|
1019
|
+
<!-- and offers this hook for conversion-specific processing: -->
|
|
1020
|
+
<!-- every interior newline (with the indentation following it) -->
|
|
1021
|
+
<!-- collapses to a single space, so a paragraph becomes one long -->
|
|
1022
|
+
<!-- line, ready for any pager to soft-wrap. The workhorse, -->
|
|
1023
|
+
<!-- "flatten-line-breaks", lives with the text utilities. -->
|
|
1024
|
+
<xsl:template name="text-processing">
|
|
1025
|
+
<xsl:param name="text"/>
|
|
1026
|
+
<xsl:call-template name="flatten-line-breaks">
|
|
1027
|
+
<xsl:with-param name="text" select="$text"/>
|
|
1028
|
+
</xsl:call-template>
|
|
187
1029
|
</xsl:template>
|
|
188
1030
|
|
|
189
1031
|
<xsl:template match="p">
|
|
@@ -193,6 +1035,12 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
193
1035
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
194
1036
|
<xsl:text>
</xsl:text>
|
|
195
1037
|
</xsl:if>
|
|
1038
|
+
<!-- within a list item or task, a paragraph indents to the -->
|
|
1039
|
+
<!-- item's content, except the one leading a list item, -->
|
|
1040
|
+
<!-- which runs in right after the marker -->
|
|
1041
|
+
<xsl:if test="(ancestor::li or ancestor::task) and not(parent::li and not(preceding-sibling::*[not(self::title)]))">
|
|
1042
|
+
<xsl:apply-templates select="." mode="item-indent"/>
|
|
1043
|
+
</xsl:if>
|
|
196
1044
|
<!-- mixed-content -->
|
|
197
1045
|
<xsl:apply-templates/>
|
|
198
1046
|
<!-- end onto a newline -->
|
|
@@ -203,23 +1051,90 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
203
1051
|
<!-- Environments -->
|
|
204
1052
|
<!-- ############ -->
|
|
205
1053
|
|
|
206
|
-
|
|
1054
|
+
<!-- A block's heading sits on its own line, set off from the -->
|
|
1055
|
+
<!-- content by a blank line; the markdown flavor overrides to -->
|
|
1056
|
+
<!-- embolden it -->
|
|
1057
|
+
<xsl:template name="block-heading-line">
|
|
1058
|
+
<xsl:param name="heading"/>
|
|
1059
|
+
<xsl:copy-of select="$heading"/>
|
|
1060
|
+
<xsl:text>

</xsl:text>
|
|
1061
|
+
</xsl:template>
|
|
1062
|
+
|
|
1063
|
+
<!-- The heading line of a block: type, number when there is one, -->
|
|
1064
|
+
<!-- a parenthesized creator for the theorem-like and axiom-like, -->
|
|
1065
|
+
<!-- title when there is one -->
|
|
1066
|
+
<xsl:template match="*" mode="block-heading">
|
|
1067
|
+
<xsl:call-template name="block-heading-line">
|
|
1068
|
+
<xsl:with-param name="heading">
|
|
1069
|
+
<xsl:apply-templates select="." mode="type-name"/>
|
|
1070
|
+
<xsl:variable name="the-number">
|
|
1071
|
+
<xsl:apply-templates select="." mode="number"/>
|
|
1072
|
+
</xsl:variable>
|
|
1073
|
+
<xsl:if test="not($the-number = '')">
|
|
1074
|
+
<xsl:text> </xsl:text>
|
|
1075
|
+
<xsl:value-of select="$the-number"/>
|
|
1076
|
+
</xsl:if>
|
|
1077
|
+
<xsl:if test="creator and (&THEOREM-FILTER; or &AXIOM-FILTER;)">
|
|
1078
|
+
<xsl:text> (</xsl:text>
|
|
1079
|
+
<xsl:apply-templates select="." mode="creator-full"/>
|
|
1080
|
+
<xsl:text>)</xsl:text>
|
|
1081
|
+
</xsl:if>
|
|
1082
|
+
<xsl:choose>
|
|
1083
|
+
<xsl:when test="title">
|
|
1084
|
+
<xsl:text> </xsl:text>
|
|
1085
|
+
<xsl:apply-templates select="." mode="title-full"/>
|
|
1086
|
+
</xsl:when>
|
|
1087
|
+
<xsl:otherwise>
|
|
1088
|
+
<xsl:text>.</xsl:text>
|
|
1089
|
+
</xsl:otherwise>
|
|
1090
|
+
</xsl:choose>
|
|
1091
|
+
</xsl:with-param>
|
|
1092
|
+
</xsl:call-template>
|
|
1093
|
+
</xsl:template>
|
|
1094
|
+
|
|
1095
|
+
<xsl:template match="&REMARK-LIKE;|&DEFINITION-LIKE;|&COMPUTATION-LIKE;|&ASIDE-LIKE;|&GOAL-LIKE;|assemblage">
|
|
207
1096
|
<!-- space with a blank line if not -->
|
|
208
1097
|
<!-- first in a structured element -->
|
|
209
1098
|
<!-- barring metadata-ish -->
|
|
210
1099
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
211
1100
|
<xsl:text>
</xsl:text>
|
|
212
1101
|
</xsl:if>
|
|
213
|
-
<xsl:apply-templates select="." mode="
|
|
214
|
-
|
|
215
|
-
<xsl:apply-templates select="
|
|
1102
|
+
<xsl:apply-templates select="." mode="block-heading"/>
|
|
1103
|
+
<!-- structured -->
|
|
1104
|
+
<xsl:apply-templates select="*"/>
|
|
1105
|
+
</xsl:template>
|
|
1106
|
+
|
|
1107
|
+
<xsl:template match="&PROJECT-LIKE;|&OPENPROBLEM-LIKE;">
|
|
1108
|
+
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
1109
|
+
<xsl:text>
</xsl:text>
|
|
1110
|
+
</xsl:if>
|
|
1111
|
+
<xsl:apply-templates select="." mode="block-heading"/>
|
|
1112
|
+
<xsl:apply-templates select="introduction|statement|task|conclusion|&SOLUTION-LIKE;"/>
|
|
1113
|
+
</xsl:template>
|
|
1114
|
+
|
|
1115
|
+
<!-- A task is an item of a list, in the manner of "ol/li": its -->
|
|
1116
|
+
<!-- serial marker indented to its depth, its content indented -->
|
|
1117
|
+
<!-- one level deeper (the item-indent and paragraph machinery of -->
|
|
1118
|
+
<!-- the Lists section counts "task" ancestors too). Markdown -->
|
|
1119
|
+
<!-- prefixes a genuine list marker so renderers nest properly. -->
|
|
1120
|
+
<xsl:template match="task" mode="item-marker">
|
|
1121
|
+
<xsl:text>(</xsl:text>
|
|
1122
|
+
<xsl:apply-templates select="." mode="serial-number"/>
|
|
1123
|
+
<xsl:text>)</xsl:text>
|
|
1124
|
+
</xsl:template>
|
|
1125
|
+
|
|
1126
|
+
<xsl:template match="task">
|
|
1127
|
+
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
1128
|
+
<xsl:text>
</xsl:text>
|
|
1129
|
+
</xsl:if>
|
|
1130
|
+
<xsl:apply-templates select="." mode="item-indent"/>
|
|
1131
|
+
<xsl:apply-templates select="." mode="item-marker"/>
|
|
216
1132
|
<xsl:if test="title">
|
|
217
1133
|
<xsl:text> </xsl:text>
|
|
218
1134
|
<xsl:apply-templates select="." mode="title-full"/>
|
|
219
1135
|
</xsl:if>
|
|
220
1136
|
<xsl:text>
</xsl:text>
|
|
221
|
-
|
|
222
|
-
<xsl:apply-templates select="*"/>
|
|
1137
|
+
<xsl:apply-templates select="*[not(self::title)]"/>
|
|
223
1138
|
</xsl:template>
|
|
224
1139
|
|
|
225
1140
|
<xsl:template match="&EXAMPLE-LIKE;">
|
|
@@ -229,21 +1144,14 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
229
1144
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
230
1145
|
<xsl:text>
</xsl:text>
|
|
231
1146
|
</xsl:if>
|
|
232
|
-
<xsl:apply-templates select="." mode="
|
|
233
|
-
<xsl:text> </xsl:text>
|
|
234
|
-
<xsl:apply-templates select="." mode="number"/>
|
|
235
|
-
<xsl:if test="title">
|
|
236
|
-
<xsl:text> </xsl:text>
|
|
237
|
-
<xsl:apply-templates select="." mode="title-full"/>
|
|
238
|
-
</xsl:if>
|
|
239
|
-
<xsl:text>
</xsl:text>
|
|
1147
|
+
<xsl:apply-templates select="." mode="block-heading"/>
|
|
240
1148
|
<xsl:choose>
|
|
241
1149
|
<xsl:when test="statement">
|
|
242
1150
|
<xsl:apply-templates select="statement"/>
|
|
243
1151
|
<xsl:apply-templates select="&SOLUTION-LIKE;"/>
|
|
244
1152
|
</xsl:when>
|
|
245
1153
|
<xsl:otherwise>
|
|
246
|
-
<xsl:apply-templates select="*[self::
|
|
1154
|
+
<xsl:apply-templates select="*[not(self::title)]"/>
|
|
247
1155
|
</xsl:otherwise>
|
|
248
1156
|
</xsl:choose>
|
|
249
1157
|
</xsl:template>
|
|
@@ -255,14 +1163,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
255
1163
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
256
1164
|
<xsl:text>
</xsl:text>
|
|
257
1165
|
</xsl:if>
|
|
258
|
-
<xsl:apply-templates select="." mode="
|
|
259
|
-
<xsl:text> </xsl:text>
|
|
260
|
-
<xsl:apply-templates select="." mode="number"/>
|
|
261
|
-
<xsl:if test="title">
|
|
262
|
-
<xsl:text> </xsl:text>
|
|
263
|
-
<xsl:apply-templates select="." mode="title-full"/>
|
|
264
|
-
</xsl:if>
|
|
265
|
-
<xsl:text>
</xsl:text>
|
|
1166
|
+
<xsl:apply-templates select="." mode="block-heading"/>
|
|
266
1167
|
<xsl:choose>
|
|
267
1168
|
<xsl:when test="statement">
|
|
268
1169
|
<xsl:apply-templates select="statement"/>
|
|
@@ -274,17 +1175,18 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
274
1175
|
</xsl:choose>
|
|
275
1176
|
</xsl:template>
|
|
276
1177
|
|
|
277
|
-
<!-- General-purpose container, we -->
|
|
278
|
-
<!-- do not enforce possibilities -->
|
|
279
|
-
<xsl:template match="statement">
|
|
280
|
-
<!-- structured -->
|
|
281
|
-
<xsl:apply-templates select="*"/>
|
|
282
|
-
</xsl:template>
|
|
283
|
-
|
|
284
1178
|
<!-- THEOREM-LIKE only -->
|
|
285
1179
|
<xsl:template match="&PROOF-LIKE;">
|
|
286
|
-
|
|
287
|
-
<xsl:
|
|
1180
|
+
<!-- set off from a preceding statement -->
|
|
1181
|
+
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
1182
|
+
<xsl:text>
</xsl:text>
|
|
1183
|
+
</xsl:if>
|
|
1184
|
+
<xsl:call-template name="block-heading-line">
|
|
1185
|
+
<xsl:with-param name="heading">
|
|
1186
|
+
<xsl:apply-templates select="." mode="type-name"/>
|
|
1187
|
+
<xsl:text>.</xsl:text>
|
|
1188
|
+
</xsl:with-param>
|
|
1189
|
+
</xsl:call-template>
|
|
288
1190
|
<!-- structured -->
|
|
289
1191
|
<xsl:apply-templates select="*"/>
|
|
290
1192
|
</xsl:template>
|
|
@@ -293,6 +1195,25 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
293
1195
|
<!-- Exercises -->
|
|
294
1196
|
<!-- ######### -->
|
|
295
1197
|
|
|
1198
|
+
<!-- An inline exercise (a "Checkpoint") reads as a block, with -->
|
|
1199
|
+
<!-- the full heading treatment; a divisional exercise keeps its -->
|
|
1200
|
+
<!-- run-in serial number below, reading as a numbered item -->
|
|
1201
|
+
<xsl:template match="exercise[&INLINE-EXERCISE-FILTER;]">
|
|
1202
|
+
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
1203
|
+
<xsl:text>
</xsl:text>
|
|
1204
|
+
</xsl:if>
|
|
1205
|
+
<xsl:apply-templates select="." mode="block-heading"/>
|
|
1206
|
+
<xsl:choose>
|
|
1207
|
+
<xsl:when test="statement">
|
|
1208
|
+
<xsl:apply-templates select="statement"/>
|
|
1209
|
+
<xsl:apply-templates select="&SOLUTION-LIKE;"/>
|
|
1210
|
+
</xsl:when>
|
|
1211
|
+
<xsl:otherwise>
|
|
1212
|
+
<xsl:apply-templates select="*[self::hint|self::answer|self::solution]"/>
|
|
1213
|
+
</xsl:otherwise>
|
|
1214
|
+
</xsl:choose>
|
|
1215
|
+
</xsl:template>
|
|
1216
|
+
|
|
296
1217
|
<xsl:template match="exercise">
|
|
297
1218
|
<!-- space with a blank line if not -->
|
|
298
1219
|
<!-- first in a structured element -->
|
|
@@ -300,6 +1221,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
300
1221
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
301
1222
|
<xsl:text>
</xsl:text>
|
|
302
1223
|
</xsl:if>
|
|
1224
|
+
<xsl:apply-templates select="." mode="fragment-anchor"/>
|
|
303
1225
|
<xsl:apply-templates select="." mode="serial-number"/>
|
|
304
1226
|
<xsl:text>.</xsl:text>
|
|
305
1227
|
<xsl:if test="title">
|
|
@@ -320,38 +1242,56 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
320
1242
|
</xsl:template>
|
|
321
1243
|
|
|
322
1244
|
<xsl:template match="&SOLUTION-LIKE;">
|
|
323
|
-
|
|
324
|
-
<xsl:
|
|
325
|
-
<xsl:
|
|
326
|
-
</xsl:variable>
|
|
327
|
-
<!-- An empty value means element is a singleton -->
|
|
328
|
-
<!-- else the serial number comes through -->
|
|
329
|
-
<xsl:if test="not($the-number = '')">
|
|
330
|
-
<xsl:text> </xsl:text>
|
|
331
|
-
<xsl:apply-templates select="." mode="serial-number" />
|
|
1245
|
+
<!-- set off from a preceding statement -->
|
|
1246
|
+
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
1247
|
+
<xsl:text>
</xsl:text>
|
|
332
1248
|
</xsl:if>
|
|
333
|
-
<xsl:
|
|
1249
|
+
<xsl:call-template name="block-heading-line">
|
|
1250
|
+
<xsl:with-param name="heading">
|
|
1251
|
+
<xsl:apply-templates select="." mode="type-name"/>
|
|
1252
|
+
<xsl:variable name="the-number">
|
|
1253
|
+
<xsl:apply-templates select="." mode="non-singleton-number" />
|
|
1254
|
+
</xsl:variable>
|
|
1255
|
+
<!-- An empty value means element is a singleton -->
|
|
1256
|
+
<!-- else the serial number comes through -->
|
|
1257
|
+
<xsl:if test="not($the-number = '')">
|
|
1258
|
+
<xsl:text> </xsl:text>
|
|
1259
|
+
<xsl:apply-templates select="." mode="serial-number" />
|
|
1260
|
+
</xsl:if>
|
|
1261
|
+
<xsl:text>.</xsl:text>
|
|
1262
|
+
</xsl:with-param>
|
|
1263
|
+
</xsl:call-template>
|
|
334
1264
|
<xsl:apply-templates select="*"/>
|
|
335
|
-
<!-- not needed if structured -->
|
|
336
|
-
<xsl:text>
</xsl:text>
|
|
337
1265
|
</xsl:template>
|
|
338
1266
|
|
|
339
1267
|
<!-- ############### -->
|
|
340
1268
|
<!-- Captioned Items -->
|
|
341
1269
|
<!-- ############### -->
|
|
342
1270
|
|
|
343
|
-
|
|
1271
|
+
<!-- A figure — or a table, listing, or named list — presents its -->
|
|
1272
|
+
<!-- content, and then a caption line: type, number, and the -->
|
|
1273
|
+
<!-- caption (or the title, for the types that have titles) -->
|
|
1274
|
+
<xsl:template match="&FIGURE-LIKE;">
|
|
344
1275
|
<!-- space with a blank line if not -->
|
|
345
1276
|
<!-- first in a structured element -->
|
|
346
1277
|
<!-- barring metadata-ish -->
|
|
347
1278
|
<xsl:if test="preceding-sibling::*[not(self::title)]">
|
|
348
1279
|
<xsl:text>
</xsl:text>
|
|
349
1280
|
</xsl:if>
|
|
1281
|
+
<xsl:apply-templates select="*[not(self::caption or self::title)]"/>
|
|
1282
|
+
<xsl:apply-templates select="." mode="fragment-anchor"/>
|
|
350
1283
|
<xsl:apply-templates select="." mode="type-name"/>
|
|
351
1284
|
<xsl:text> </xsl:text>
|
|
352
1285
|
<xsl:apply-templates select="." mode="number"/>
|
|
353
1286
|
<xsl:text>: </xsl:text>
|
|
354
|
-
<xsl:
|
|
1287
|
+
<xsl:choose>
|
|
1288
|
+
<xsl:when test="caption">
|
|
1289
|
+
<xsl:apply-templates select="caption"/>
|
|
1290
|
+
</xsl:when>
|
|
1291
|
+
<xsl:otherwise>
|
|
1292
|
+
<xsl:apply-templates select="." mode="title-full"/>
|
|
1293
|
+
</xsl:otherwise>
|
|
1294
|
+
</xsl:choose>
|
|
355
1295
|
<xsl:text>
</xsl:text>
|
|
356
1296
|
</xsl:template>
|
|
357
1297
|
|
|
@@ -364,29 +1304,59 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
364
1304
|
<!-- Lists -->
|
|
365
1305
|
<!-- ##### -->
|
|
366
1306
|
|
|
1307
|
+
<!-- The indentation of an item at its depth: four spaces per -->
|
|
1308
|
+
<!-- level of containing item, list or task alike, which is the -->
|
|
1309
|
+
<!-- nesting convention markdown recognizes -->
|
|
1310
|
+
<xsl:template match="*" mode="item-indent">
|
|
1311
|
+
<xsl:value-of select="str:padding(4 * (count(ancestor::li) + count(ancestor::task)), ' ')"/>
|
|
1312
|
+
</xsl:template>
|
|
1313
|
+
|
|
367
1314
|
<xsl:template match="ul|ol|dl">
|
|
368
1315
|
<xsl:text>
</xsl:text>
|
|
369
1316
|
<xsl:apply-templates select="li"/>
|
|
370
1317
|
</xsl:template>
|
|
371
1318
|
|
|
372
|
-
|
|
373
|
-
|
|
1319
|
+
<!-- A structured item's blocks (paragraphs, nested lists) supply -->
|
|
1320
|
+
<!-- their own trailing newlines; an unstructured item needs one -->
|
|
1321
|
+
<xsl:template match="li" mode="finish-item">
|
|
1322
|
+
<xsl:if test="not(p or ol or ul or dl)">
|
|
1323
|
+
<xsl:text>
</xsl:text>
|
|
1324
|
+
</xsl:if>
|
|
1325
|
+
</xsl:template>
|
|
1326
|
+
|
|
1327
|
+
<!-- The marker of an ordered list item is its own number in the -->
|
|
1328
|
+
<!-- authored format ("item-number"), not the dotted hierarchy -->
|
|
1329
|
+
<!-- ("serial-number", which cross-references still use); the -->
|
|
1330
|
+
<!-- nesting shows in the indentation -->
|
|
1331
|
+
<xsl:template match="ol/li" mode="item-marker">
|
|
1332
|
+
<xsl:apply-templates select="." mode="item-number"/>
|
|
374
1333
|
<xsl:text>. </xsl:text>
|
|
1334
|
+
</xsl:template>
|
|
1335
|
+
|
|
1336
|
+
<xsl:template match="ol/li">
|
|
1337
|
+
<xsl:apply-templates select="." mode="item-indent"/>
|
|
1338
|
+
<xsl:apply-templates select="." mode="item-marker"/>
|
|
1339
|
+
<!-- an addressable item is a landing spot -->
|
|
1340
|
+
<xsl:if test="@xml:id">
|
|
1341
|
+
<xsl:apply-templates select="." mode="fragment-anchor"/>
|
|
1342
|
+
</xsl:if>
|
|
375
1343
|
<xsl:apply-templates/>
|
|
376
|
-
<xsl:
|
|
1344
|
+
<xsl:apply-templates select="." mode="finish-item"/>
|
|
377
1345
|
</xsl:template>
|
|
378
1346
|
|
|
379
1347
|
<xsl:template match="ul/li">
|
|
1348
|
+
<xsl:apply-templates select="." mode="item-indent"/>
|
|
380
1349
|
<xsl:text>* </xsl:text>
|
|
381
1350
|
<xsl:apply-templates/>
|
|
382
|
-
<xsl:
|
|
1351
|
+
<xsl:apply-templates select="." mode="finish-item"/>
|
|
383
1352
|
</xsl:template>
|
|
384
1353
|
|
|
385
1354
|
<xsl:template match="dl/li">
|
|
1355
|
+
<xsl:apply-templates select="." mode="item-indent"/>
|
|
386
1356
|
<xsl:apply-templates select="." mode="title-full"/>
|
|
387
1357
|
<xsl:text> </xsl:text>
|
|
388
1358
|
<xsl:apply-templates/>
|
|
389
|
-
<xsl:
|
|
1359
|
+
<xsl:apply-templates select="." mode="finish-item"/>
|
|
390
1360
|
</xsl:template>
|
|
391
1361
|
|
|
392
1362
|
</xsl:stylesheet>
|