@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
|
@@ -67,6 +67,60 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
67
67
|
<!-- Not so much "include" as "manipulate" -->
|
|
68
68
|
<xsl:param name="math.punctuation.include" select="'all'"/>
|
|
69
69
|
|
|
70
|
+
<!-- Developer-only. Braille arriving from Speech Rule Engine -->
|
|
71
|
+
<!-- (mathematics) is Unicode braille cells (U+2800 through -->
|
|
72
|
+
<!-- U+283F). With "late" (the default) those cells ride through -->
|
|
73
|
+
<!-- the preprint intermediate unchanged and become BRF ASCII -->
|
|
74
|
+
<!-- symbols in the renderer. With "early" the conversion to BRF -->
|
|
75
|
+
<!-- ASCII symbols happens here, so the preprint file itself is -->
|
|
76
|
+
<!-- readable by anyone fluent in BRF, at no change to the final -->
|
|
77
|
+
<!-- BRF. The root element of the preprint records the choice so -->
|
|
78
|
+
<!-- the renderer can react. -->
|
|
79
|
+
<xsl:param name="debug.brf.symbols" select="'late'"/>
|
|
80
|
+
<xsl:variable name="brf-symbols">
|
|
81
|
+
<xsl:choose>
|
|
82
|
+
<xsl:when test="($debug.brf.symbols = 'early') or ($debug.brf.symbols = 'late')">
|
|
83
|
+
<xsl:value-of select="$debug.brf.symbols"/>
|
|
84
|
+
</xsl:when>
|
|
85
|
+
<xsl:otherwise>
|
|
86
|
+
<xsl:message>PTX:FALLBACK: the "debug.brf.symbols" string parameter must be "early" or "late", not "<xsl:value-of select="$debug.brf.symbols"/>", using "late" instead</xsl:message>
|
|
87
|
+
<xsl:text>late</xsl:text>
|
|
88
|
+
</xsl:otherwise>
|
|
89
|
+
</xsl:choose>
|
|
90
|
+
</xsl:variable>
|
|
91
|
+
<xsl:variable name="b-braille-symbols-early" select="$brf-symbols = 'early'"/>
|
|
92
|
+
|
|
93
|
+
<!-- The 64 Unicode braille cells, in numerical order, and their -->
|
|
94
|
+
<!-- BRF ASCII equivalents, generated with liblouis, which is what -->
|
|
95
|
+
<!-- the renderer employs for the identical conversion when the -->
|
|
96
|
+
<!-- cells ride through as Unicode ("late"). Exception: the blank -->
|
|
97
|
+
<!-- cell U+2800 maps to a NO-BREAK SPACE, not to a plain space: -->
|
|
98
|
+
<!-- it reads as a space, but the renderer can still distinguish -->
|
|
99
|
+
<!-- a (non-breaking) blank cell from an authored space when it -->
|
|
100
|
+
<!-- makes line-breaking decisions, and it becomes a plain space -->
|
|
101
|
+
<!-- in the final output, exactly as a blank cell does. -->
|
|
102
|
+
<xsl:variable name="unicode-braille-cells" select="'⠀⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿'"/>
|
|
103
|
+
<xsl:variable name="ascii-braille-cells"> a1b'k2l`cif/msp"e3h9o6r~djg>ntq,*5<-u8v.%{$+x!&;:4|0z7(_?w}#y)=</xsl:variable>
|
|
104
|
+
|
|
105
|
+
<!-- Convert Unicode braille cells to BRF ASCII symbols, when -->
|
|
106
|
+
<!-- elected ("early"); the text is otherwise undisturbed. -->
|
|
107
|
+
<!-- The conversion is all-or-nothing per text: when a -->
|
|
108
|
+
<!-- construction has no braille translation, Speech Rule Engine -->
|
|
109
|
+
<!-- can leave print residue among the cells, and such a mixture -->
|
|
110
|
+
<!-- must ride along whole (cells as Unicode) so the renderer -->
|
|
111
|
+
<!-- gives it the identical late treatment under either election. -->
|
|
112
|
+
<xsl:template name="brf-symbols-filter">
|
|
113
|
+
<xsl:param name="text"/>
|
|
114
|
+
<xsl:choose>
|
|
115
|
+
<xsl:when test="$b-braille-symbols-early and (translate($text, concat($unicode-braille-cells, ' 
	
 '), '') = '')">
|
|
116
|
+
<xsl:value-of select="translate($text, $unicode-braille-cells, $ascii-braille-cells)"/>
|
|
117
|
+
</xsl:when>
|
|
118
|
+
<xsl:otherwise>
|
|
119
|
+
<xsl:value-of select="$text"/>
|
|
120
|
+
</xsl:otherwise>
|
|
121
|
+
</xsl:choose>
|
|
122
|
+
</xsl:template>
|
|
123
|
+
|
|
70
124
|
<!-- ############################## -->
|
|
71
125
|
<!-- Incorporate (Meld) Mathematics -->
|
|
72
126
|
<!-- ############################## -->
|
|
@@ -203,70 +257,129 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
203
257
|
|
|
204
258
|
<!-- And we sneak in a warning that this conversion is underway, but not complete. -->
|
|
205
259
|
<xsl:template name="warning-unimplemented">
|
|
206
|
-
<xsl:message
|
|
207
|
-
<xsl:message
|
|
208
|
-
<xsl:message
|
|
209
|
-
<xsl:message
|
|
210
|
-
<xsl:message
|
|
211
|
-
<xsl:message
|
|
260
|
+
<xsl:message>PTX:INFO: Some PreTeXt elements lack full implementation in the braille conversion.</xsl:message>
|
|
261
|
+
<xsl:message>PTX:INFO: Smaller items will simply be missing from your output.</xsl:message>
|
|
262
|
+
<xsl:message>PTX:INFO: Larger items may have all-caps placeholders in your output.</xsl:message>
|
|
263
|
+
<xsl:message>PTX:INFO: These will all be reported as "Overlooked" in the log.</xsl:message>
|
|
264
|
+
<xsl:message>PTX:INFO: Please report the complete list in the PreTeXt support forum,</xsl:message>
|
|
265
|
+
<xsl:message>PTX:INFO: so we can prioritize making the output for your project complete.</xsl:message>
|
|
212
266
|
</xsl:template>
|
|
213
267
|
|
|
214
268
|
<!-- The entry template "waits" for the "$math-meld-rtf" and -->
|
|
215
269
|
<!-- "$segmented-rtf" global variables to form, then the actual -->
|
|
216
|
-
<!-- output
|
|
217
|
-
<!--
|
|
270
|
+
<!-- output comes from two post-processing passes: the modal -->
|
|
271
|
+
<!-- "meld-runin" templates absorb run-in titles into their -->
|
|
272
|
+
<!-- segments, and then the modal "flatten-runs" templates -->
|
|
273
|
+
<!-- dissolve nested font-change markup into a flat sequence -->
|
|
274
|
+
<!-- of "run" elements bearing composite "@typeform" values. -->
|
|
218
275
|
<xsl:template match="/">
|
|
219
|
-
<xsl:
|
|
276
|
+
<xsl:variable name="melded-runin-rtf">
|
|
277
|
+
<xsl:apply-templates select="exsl:node-set($segmented-rtf)/brf" mode="meld-runin"/>
|
|
278
|
+
</xsl:variable>
|
|
279
|
+
<xsl:apply-templates select="exsl:node-set($melded-runin-rtf)/brf" mode="flatten-runs"/>
|
|
280
|
+
</xsl:template>
|
|
281
|
+
|
|
282
|
+
<!-- ############################ -->
|
|
283
|
+
<!-- Flatten Font Changes to Runs -->
|
|
284
|
+
<!-- ############################ -->
|
|
285
|
+
|
|
286
|
+
<!-- Font-change markup ("italic", "bold", "code") arrives from the -->
|
|
287
|
+
<!-- earlier pass as elements, which may nest ("italic" containing -->
|
|
288
|
+
<!-- "code", say). A formatter wants a flat sequence, so each text -->
|
|
289
|
+
<!-- node becomes a "run" element whose "@typeform" records every -->
|
|
290
|
+
<!-- font change in effect, as space-separated tokens. Text with -->
|
|
291
|
+
<!-- no font change rides along bare. The font-change elements -->
|
|
292
|
+
<!-- themselves evaporate. Mathematics ("math") is already braille -->
|
|
293
|
+
<!-- cells and is preserved whole, its interior untouched. -->
|
|
294
|
+
|
|
295
|
+
<!-- Dissolve, children continue -->
|
|
296
|
+
<xsl:template match="italic|bold|code" mode="flatten-runs">
|
|
297
|
+
<xsl:apply-templates select="node()" mode="flatten-runs"/>
|
|
298
|
+
</xsl:template>
|
|
299
|
+
|
|
300
|
+
<!-- Mathematics is opaque, xerox entirely -->
|
|
301
|
+
<xsl:template match="math" mode="flatten-runs">
|
|
302
|
+
<xsl:copy-of select="."/>
|
|
303
|
+
</xsl:template>
|
|
304
|
+
|
|
305
|
+
<!-- Text nodes inside a segment (or a converted run-in title) -->
|
|
306
|
+
<!-- either ride bare (no font change) or become a "run". The -->
|
|
307
|
+
<!-- ancestor axis sees the font-change elements because they -->
|
|
308
|
+
<!-- are still present in the tree under examination. -->
|
|
309
|
+
<xsl:template match="text()" mode="flatten-runs">
|
|
310
|
+
<xsl:variable name="typeform">
|
|
311
|
+
<xsl:if test="ancestor::italic">
|
|
312
|
+
<xsl:text>italic </xsl:text>
|
|
313
|
+
</xsl:if>
|
|
314
|
+
<xsl:if test="ancestor::bold">
|
|
315
|
+
<xsl:text>bold </xsl:text>
|
|
316
|
+
</xsl:if>
|
|
317
|
+
<xsl:if test="ancestor::code">
|
|
318
|
+
<xsl:text>code </xsl:text>
|
|
319
|
+
</xsl:if>
|
|
320
|
+
</xsl:variable>
|
|
321
|
+
<xsl:choose>
|
|
322
|
+
<xsl:when test="$typeform = ''">
|
|
323
|
+
<xsl:value-of select="."/>
|
|
324
|
+
</xsl:when>
|
|
325
|
+
<xsl:otherwise>
|
|
326
|
+
<run>
|
|
327
|
+
<xsl:attribute name="typeform">
|
|
328
|
+
<xsl:value-of select="normalize-space($typeform)"/>
|
|
329
|
+
</xsl:attribute>
|
|
330
|
+
<xsl:value-of select="."/>
|
|
331
|
+
</run>
|
|
332
|
+
</xsl:otherwise>
|
|
333
|
+
</xsl:choose>
|
|
334
|
+
</xsl:template>
|
|
335
|
+
|
|
336
|
+
<!-- Xerox machine. Elements and attributes only: text nodes have -->
|
|
337
|
+
<!-- their own template above, and it must win the match. -->
|
|
338
|
+
<xsl:template match="*|@*" mode="flatten-runs">
|
|
339
|
+
<xsl:copy>
|
|
340
|
+
<xsl:apply-templates select="@*|node()" mode="flatten-runs"/>
|
|
341
|
+
</xsl:copy>
|
|
220
342
|
</xsl:template>
|
|
221
343
|
|
|
222
344
|
<!-- Process segments here, looking for run-in titles/headings -->
|
|
223
345
|
<xsl:template match="segment" mode="meld-runin">
|
|
224
|
-
<!-- Look for "run-in" material just prior -->
|
|
225
|
-
|
|
346
|
+
<!-- Look for "run-in" material just prior: the whole maximal -->
|
|
347
|
+
<!-- chain of consecutive "runin" siblings whose first -->
|
|
348
|
+
<!-- following non-"runin" sibling is this very segment. Each -->
|
|
349
|
+
<!-- melds in, in order, with its separator. Chains occur -->
|
|
350
|
+
<!-- routinely: an exercise, or a list item, may begin with a -->
|
|
351
|
+
<!-- nested list, stacking a marker for every level. -->
|
|
352
|
+
<xsl:variable name="runin-chain" select="preceding-sibling::runin[generate-id(following-sibling::*[not(self::runin)][1]) = generate-id(current())]"/>
|
|
226
353
|
<xsl:copy>
|
|
227
354
|
<xsl:apply-templates select="@*" mode="meld-runin"/>
|
|
228
|
-
|
|
229
|
-
<xsl:apply-templates select="$
|
|
230
|
-
<xsl:
|
|
355
|
+
<!-- the chain's first runin positions the merged segment -->
|
|
356
|
+
<xsl:apply-templates select="$runin-chain[1]/@indentation|$runin-chain[1]/@lines-before" mode="meld-runin"/>
|
|
357
|
+
<xsl:for-each select="$runin-chain">
|
|
358
|
+
<xsl:apply-templates select="node()" mode="meld-runin"/>
|
|
359
|
+
<xsl:value-of select="@separator"/>
|
|
360
|
+
</xsl:for-each>
|
|
231
361
|
<xsl:apply-templates select="node()" mode="meld-runin"/>
|
|
232
362
|
</xsl:copy>
|
|
233
363
|
</xsl:template>
|
|
234
364
|
|
|
235
|
-
<!--
|
|
236
|
-
<!--
|
|
237
|
-
<!--
|
|
238
|
-
<!--
|
|
239
|
-
<!--
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
<!--
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
<!-- subsequent "segment". -->
|
|
252
|
-
<xsl:template match="runin[following-sibling::*[1][self::runin]]" mode="meld-runin">
|
|
253
|
-
<segment>
|
|
254
|
-
<xsl:apply-templates select="@*|node()" mode="meld-runin"/>
|
|
255
|
-
</segment>
|
|
256
|
-
<xsl:if test="following-sibling::*[2][self::runin]">
|
|
257
|
-
<xsl:message>BUG: the braille conversion has encountered three "run-in" titles in a row,</xsl:message>
|
|
258
|
-
<xsl:message>which we had not expected. Please report me. Thank-you.</xsl:message>
|
|
259
|
-
<xsl:message>First: <xsl:value-of select="."/></xsl:message>
|
|
260
|
-
<xsl:message>Second: <xsl:value-of select="following-sibling::*[1][self::runin]"/></xsl:message>
|
|
261
|
-
<xsl:message>Third: <xsl:value-of select="following-sibling::*[2][self::runin]"/></xsl:message>
|
|
262
|
-
</xsl:if>
|
|
365
|
+
<!-- A "runin" whose chain ends at a "segment" has been absorbed -->
|
|
366
|
+
<!-- above; it must not persist. A "runin" whose chain does NOT -->
|
|
367
|
+
<!-- end at a segment (a block comes next, or nothing does) has no -->
|
|
368
|
+
<!-- host to meld into, so it becomes a segment of its own rather -->
|
|
369
|
+
<!-- than disappear: content is never dropped silently. -->
|
|
370
|
+
<xsl:template match="runin" mode="meld-runin">
|
|
371
|
+
<xsl:choose>
|
|
372
|
+
<xsl:when test="following-sibling::*[not(self::runin)][1][self::segment]">
|
|
373
|
+
<!-- absorbed by that segment -->
|
|
374
|
+
</xsl:when>
|
|
375
|
+
<xsl:otherwise>
|
|
376
|
+
<segment>
|
|
377
|
+
<xsl:apply-templates select="@*|node()" mode="meld-runin"/>
|
|
378
|
+
</segment>
|
|
379
|
+
</xsl:otherwise>
|
|
380
|
+
</xsl:choose>
|
|
263
381
|
</xsl:template>
|
|
264
382
|
|
|
265
|
-
<!-- Every "runin" has been absorbed into a trailing "segment" or -->
|
|
266
|
-
<!-- perhaps converted into a "segment". This will prevent the -->
|
|
267
|
-
<!-- absorbed ones from persisting. -->
|
|
268
|
-
<xsl:template match="runin" mode="meld-runin"/>
|
|
269
|
-
|
|
270
383
|
<!-- Xerox machine -->
|
|
271
384
|
<xsl:template match="@*|node()" mode="meld-runin">
|
|
272
385
|
<xsl:copy>
|
|
@@ -279,6 +392,21 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
279
392
|
<!-- Need an overall container -->
|
|
280
393
|
<!-- Maybe copy a language code? -->
|
|
281
394
|
<brf>
|
|
395
|
+
<!-- Record how braille cells are represented ("early" is -->
|
|
396
|
+
<!-- BRF ASCII symbols, "late" is Unicode braille cells) -->
|
|
397
|
+
<!-- so the renderer can react to mathematics accordingly. -->
|
|
398
|
+
<xsl:attribute name="brf-symbols">
|
|
399
|
+
<xsl:value-of select="$brf-symbols"/>
|
|
400
|
+
</xsl:attribute>
|
|
401
|
+
<!-- Page geometry, from the publication file (or the -->
|
|
402
|
+
<!-- defaults), for the renderer: cells in a line, lines -->
|
|
403
|
+
<!-- on an embossed page. -->
|
|
404
|
+
<xsl:attribute name="page-width">
|
|
405
|
+
<xsl:value-of select="$braille-page-width"/>
|
|
406
|
+
</xsl:attribute>
|
|
407
|
+
<xsl:attribute name="page-height">
|
|
408
|
+
<xsl:value-of select="$braille-page-height"/>
|
|
409
|
+
</xsl:attribute>
|
|
282
410
|
<!-- centered heading on line 1 -->
|
|
283
411
|
<segment centered="yes" lines-after="1">Transcriber Notes</segment>
|
|
284
412
|
<!-- Literal text for each note, control whitespace, -->
|
|
@@ -302,6 +430,14 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
302
430
|
</segment>
|
|
303
431
|
</xsl:if>
|
|
304
432
|
<!-- -->
|
|
433
|
+
<!-- [BANA-2016, 8.6.2(b)] bullet symbols used in lists are -->
|
|
434
|
+
<!-- listed in a transcriber's note -->
|
|
435
|
+
<xsl:if test="//ul">
|
|
436
|
+
<segment indentation="2">
|
|
437
|
+
<xsl:text>Items of unordered lists retain their print markers, each followed by a period. The symbols in use are: bullet (dots 456, 256), circle (dots 1246 and a grade one indicator, 123456), and square (dots 456, 1246, 3456, 145).</xsl:text>
|
|
438
|
+
</segment>
|
|
439
|
+
</xsl:if>
|
|
440
|
+
<!-- -->
|
|
305
441
|
<!-- automatically infers we have a note already for "sidebyside" -->
|
|
306
442
|
<xsl:if test="//sbsgroup">
|
|
307
443
|
<segment indentation="2">
|
|
@@ -884,7 +1020,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
884
1020
|
<!-- to coordinate text and manually inserted tactile versions. -->
|
|
885
1021
|
<xsl:template match="image" mode="block-title">
|
|
886
1022
|
<xsl:text>Image: </xsl:text>
|
|
887
|
-
<xsl:apply-templates select="." mode="
|
|
1023
|
+
<xsl:apply-templates select="." mode="unique-id"/>
|
|
888
1024
|
<xsl:text>.</xsl:text>
|
|
889
1025
|
</xsl:template>
|
|
890
1026
|
|
|
@@ -902,6 +1038,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
902
1038
|
<!-- pages, rather than across, since horizontal real estate is limited -->
|
|
903
1039
|
<!-- and images are going full (own) page. -->
|
|
904
1040
|
<!-- From discussion with Michael Cantino and Al Maneki, 2023-03-30 -->
|
|
1041
|
+
<!-- -->
|
|
1042
|
+
<!-- This is the same linear composition as the text conversion (no -->
|
|
1043
|
+
<!-- horizontal layout, so the -common machinery is unused), but -->
|
|
1044
|
+
<!-- with braille-idiomatic transcriber notes, so the two -->
|
|
1045
|
+
<!-- conversions share the design, not the code. -->
|
|
905
1046
|
|
|
906
1047
|
<xsl:template match="sidebyside">
|
|
907
1048
|
<xsl:variable name="npanels" select="count(*)"/>
|
|
@@ -963,18 +1104,49 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
963
1104
|
<!-- Lists -->
|
|
964
1105
|
<!-- ##### -->
|
|
965
1106
|
|
|
966
|
-
<!-- Lists are containers full of list items.
|
|
967
|
-
<!--
|
|
968
|
-
<!--
|
|
969
|
-
<!--
|
|
970
|
-
<!--
|
|
1107
|
+
<!-- Lists are containers full of list items. The container's -->
|
|
1108
|
+
<!-- one responsibility: [BANA-2016, 8.3.2(a)] a list is -->
|
|
1109
|
+
<!-- preceded and followed by a blank line. That means the -->
|
|
1110
|
+
<!-- OUTERMOST list; a nested list runs on without a break. -->
|
|
1111
|
+
<!-- (An empty segment demanding a line before it is the idiom -->
|
|
1112
|
+
<!-- for one blank line, suppressed at the top of a page.) -->
|
|
971
1113
|
<xsl:template match="ul|ol|dl">
|
|
1114
|
+
<xsl:variable name="b-outermost" select="not(ancestor::ol or ancestor::ul or ancestor::dl)"/>
|
|
1115
|
+
<xsl:if test="$b-outermost">
|
|
1116
|
+
<segment lines-before="1"/>
|
|
1117
|
+
</xsl:if>
|
|
972
1118
|
<xsl:apply-templates select="li"/>
|
|
1119
|
+
<xsl:if test="$b-outermost">
|
|
1120
|
+
<segment lines-before="1"/>
|
|
1121
|
+
</xsl:if>
|
|
973
1122
|
</xsl:template>
|
|
974
1123
|
|
|
975
1124
|
<xsl:template match="li">
|
|
1125
|
+
<!-- [BANA-2016, 8.3.1] a simple list has 1-3 margins -->
|
|
1126
|
+
<!-- [BANA-2016, 8.5.1(b)] each nested level begins two cells -->
|
|
1127
|
+
<!-- to the right of the previous level, and ALL runovers begin -->
|
|
1128
|
+
<!-- two cells to the right of the farthest indented level: one -->
|
|
1129
|
+
<!-- level is 1-3; two levels are 1-5, 3-5; three levels are -->
|
|
1130
|
+
<!-- 1-7, 3-7, 5-7. In the preprint's 0-based attributes: -->
|
|
1131
|
+
<!-- level k of an n-level list has indentation 2(k-1), and -->
|
|
1132
|
+
<!-- every segment of the list has runover 2n. -->
|
|
1133
|
+
<!-- The level of this item, and the deepest level anywhere in -->
|
|
1134
|
+
<!-- the outermost list containing it. (A list separated from -->
|
|
1135
|
+
<!-- an enclosing list by other structure still counts every -->
|
|
1136
|
+
<!-- list ancestor, deliberately: its margins nest visibly.) -->
|
|
1137
|
+
<xsl:variable name="level" select="count(ancestor::ol | ancestor::ul | ancestor::dl)"/>
|
|
1138
|
+
<xsl:variable name="outermost-list" select="ancestor::*[self::ol or self::ul or self::dl][last()]"/>
|
|
1139
|
+
<xsl:variable name="list-depth">
|
|
1140
|
+
<xsl:for-each select="$outermost-list//li">
|
|
1141
|
+
<xsl:sort select="count(ancestor::ol | ancestor::ul | ancestor::dl)" data-type="number" order="descending"/>
|
|
1142
|
+
<xsl:if test="position() = 1">
|
|
1143
|
+
<xsl:value-of select="count(ancestor::ol | ancestor::ul | ancestor::dl)"/>
|
|
1144
|
+
</xsl:if>
|
|
1145
|
+
</xsl:for-each>
|
|
1146
|
+
</xsl:variable>
|
|
1147
|
+
<xsl:variable name="list-runover" select="2 * $list-depth"/>
|
|
976
1148
|
<!-- Marker as a "runin" element -->
|
|
977
|
-
<runin indentation="
|
|
1149
|
+
<runin indentation="{2 * ($level - 1)}" separator=" ">
|
|
978
1150
|
<xsl:choose>
|
|
979
1151
|
<xsl:when test="parent::ol">
|
|
980
1152
|
<xsl:apply-templates select="." mode="item-number"/>
|
|
@@ -989,7 +1161,51 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
989
1161
|
</xsl:when>
|
|
990
1162
|
</xsl:choose>
|
|
991
1163
|
</runin>
|
|
992
|
-
<xsl:
|
|
1164
|
+
<xsl:choose>
|
|
1165
|
+
<!-- A structured list item carries paragraphs, or other -->
|
|
1166
|
+
<!-- block-shaped material, all of which make segments (or -->
|
|
1167
|
+
<!-- whole blocks) of their own. The test mirrors the -->
|
|
1168
|
+
<!-- schema exactly: an "li" may hold BlockStatement, which -->
|
|
1169
|
+
<!-- is BlockText (paragraph, blockquote, preformatted, -->
|
|
1170
|
+
<!-- image, video, audio, program, console, tabular), the -->
|
|
1171
|
+
<!-- figure family (figure, table, listing, list), aside, -->
|
|
1172
|
+
<!-- side-by-sides, and Sage cells. Displayed items that -->
|
|
1173
|
+
<!-- can live within a paragraph (nested lists, display -->
|
|
1174
|
+
<!-- mathematics) are deliberately NOT in this test: mixed -->
|
|
1175
|
+
<!-- content holds them, and the paragraph machinery -->
|
|
1176
|
+
<!-- splits them out correctly. -->
|
|
1177
|
+
<xsl:when test="p or blockquote or pre or image or video or audio or program or console or tabular or figure or table or listing or list or aside or sidebyside or sbsgroup or sage">
|
|
1178
|
+
<xsl:apply-templates select="node()">
|
|
1179
|
+
<xsl:with-param name="list-runover" select="$list-runover"/>
|
|
1180
|
+
</xsl:apply-templates>
|
|
1181
|
+
</xsl:when>
|
|
1182
|
+
<!-- An unstructured list item is a run of sentences, -->
|
|
1183
|
+
<!-- exactly the content of a paragraph. But with no -->
|
|
1184
|
+
<!-- "p" there is no template to make a segment of it, and -->
|
|
1185
|
+
<!-- unanchored content is lost. So manufacture the -->
|
|
1186
|
+
<!-- missing paragraph around a copy of the content, and -->
|
|
1187
|
+
<!-- process that: the ordinary paragraph templates then -->
|
|
1188
|
+
<!-- apply, including the splitting of displayed items -->
|
|
1189
|
+
<!-- (display mathematics, a nested list) into siblings. -->
|
|
1190
|
+
<!-- -->
|
|
1191
|
+
<!-- TODO: the project direction is to manufacture such -->
|
|
1192
|
+
<!-- missing wrappers ("p", "statement") once, during -->
|
|
1193
|
+
<!-- assembly, marked with a "pi:" attribute, so authors -->
|
|
1194
|
+
<!-- keep their freedom while conversions see uniform -->
|
|
1195
|
+
<!-- structure. When that arrives, this local device -->
|
|
1196
|
+
<!-- evaporates: the manufactured "p" is a real one here, -->
|
|
1197
|
+
<!-- and its flag guides any special list treatment. -->
|
|
1198
|
+
<xsl:otherwise>
|
|
1199
|
+
<xsl:variable name="virtual-paragraph-rtf">
|
|
1200
|
+
<p>
|
|
1201
|
+
<xsl:copy-of select="node()"/>
|
|
1202
|
+
</p>
|
|
1203
|
+
</xsl:variable>
|
|
1204
|
+
<xsl:apply-templates select="exsl:node-set($virtual-paragraph-rtf)/p">
|
|
1205
|
+
<xsl:with-param name="list-runover" select="$list-runover"/>
|
|
1206
|
+
</xsl:apply-templates>
|
|
1207
|
+
</xsl:otherwise>
|
|
1208
|
+
</xsl:choose>
|
|
993
1209
|
</xsl:template>
|
|
994
1210
|
|
|
995
1211
|
<xsl:template match="ul/li" mode="unicode-list-marker">
|
|
@@ -1193,7 +1409,10 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1193
1409
|
<!-- Bibliographic items in a "references" division have a -->
|
|
1194
1410
|
<!-- bracketed number leading each new entry, then two spaces -->
|
|
1195
1411
|
<!-- of indentation for the remainder . -->
|
|
1196
|
-
<!--
|
|
1412
|
+
<!-- An annotation ("note") produces a block, so it cannot live -->
|
|
1413
|
+
<!-- inside the entry's segment; it follows as a sibling. -->
|
|
1414
|
+
<!-- TODO: format annotations per BANA 22.3, rather than -->
|
|
1415
|
+
<!-- reusing the boxed rendering of a REMARK-LIKE "note". -->
|
|
1197
1416
|
<xsl:template match="biblio[@type='raw']">
|
|
1198
1417
|
<runin indentation="0" separator=" ">
|
|
1199
1418
|
<xsl:text>[</xsl:text>
|
|
@@ -1201,8 +1420,26 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1201
1420
|
<xsl:text>]</xsl:text>
|
|
1202
1421
|
</runin>
|
|
1203
1422
|
<segment indentation="0" runover="2">
|
|
1204
|
-
<xsl:apply-templates/>
|
|
1423
|
+
<xsl:apply-templates select="node()[not(self::note)]"/>
|
|
1424
|
+
</segment>
|
|
1425
|
+
<xsl:apply-templates select="note"/>
|
|
1426
|
+
</xsl:template>
|
|
1427
|
+
|
|
1428
|
+
<!-- Structured bibliographic entries ("bibtex" type, or untyped -->
|
|
1429
|
+
<!-- fallback) render their fields in document order, with the -->
|
|
1430
|
+
<!-- same [BANA-2016, 22.2.1] margins as the raw flavor above, and -->
|
|
1431
|
+
<!-- the same treatment of an annotation: a "note" produces a -->
|
|
1432
|
+
<!-- block, so it follows the entry as a sibling. -->
|
|
1433
|
+
<xsl:template match="biblio[not(@type = 'raw')]">
|
|
1434
|
+
<runin indentation="0" separator=" ">
|
|
1435
|
+
<xsl:text>[</xsl:text>
|
|
1436
|
+
<xsl:apply-templates select="." mode="serial-number"/>
|
|
1437
|
+
<xsl:text>]</xsl:text>
|
|
1438
|
+
</runin>
|
|
1439
|
+
<segment indentation="0" runover="2">
|
|
1440
|
+
<xsl:apply-templates select="*[not(self::note)]"/>
|
|
1205
1441
|
</segment>
|
|
1442
|
+
<xsl:apply-templates select="note"/>
|
|
1206
1443
|
</xsl:template>
|
|
1207
1444
|
|
|
1208
1445
|
<!-- Override usual killing of title, but perhaps a generic -->
|
|
@@ -1262,62 +1499,64 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1262
1499
|
<!-- as quotation mark styles, since we are limited ourselves to -->
|
|
1263
1500
|
<!-- English language documents by larger decisions elsewhere. -->
|
|
1264
1501
|
|
|
1265
|
-
<!-- Unicode
|
|
1266
|
-
<!--
|
|
1267
|
-
<!-- liblouis
|
|
1268
|
-
<!--
|
|
1269
|
-
<!--
|
|
1270
|
-
<!--
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
<!--
|
|
1276
|
-
<!--
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
<!--
|
|
1282
|
-
<!--
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
<!--
|
|
1288
|
-
<!--
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
<!--
|
|
1294
|
-
<!--
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
<xsl:
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
<xsl:
|
|
1308
|
-
|
|
1502
|
+
<!-- Each character reads the Unicode column of the representation -->
|
|
1503
|
+
<!-- table in pretext-common.xsl. A "braille" column entry -->
|
|
1504
|
+
<!-- substitutes where liblouis lacks the true code point; the -->
|
|
1505
|
+
<!-- entry "none" marks a character outside this repertoire, -->
|
|
1506
|
+
<!-- which warns, keeping the gap visible. -->
|
|
1507
|
+
<!-- -->
|
|
1508
|
+
<!-- Cells described in the liblouis table, for each Unicode -->
|
|
1509
|
+
<!-- character rendered here: -->
|
|
1510
|
+
<!-- -->
|
|
1511
|
+
<!-- nbsp (U+00A0): passed through in-kind; used in the -->
|
|
1512
|
+
<!-- manufacture of a cross-reference, we will want to strip -->
|
|
1513
|
+
<!-- just before it ends up in BRF -->
|
|
1514
|
+
<!-- ndash (U+2013): 6-36 -->
|
|
1515
|
+
<!-- mdash (U+2014): 6-36 -->
|
|
1516
|
+
<!-- thin-space (U+2009): 0, a braille space -->
|
|
1517
|
+
<!-- copyright (U+00A9): 45-14 -->
|
|
1518
|
+
<!-- registered (U+00AE): 45-1235 -->
|
|
1519
|
+
<!-- trademark (U+2122): 45-2345 -->
|
|
1520
|
+
<!-- degree (U+00B0): 45-245 -->
|
|
1521
|
+
<!-- prime (U+2032): 2356 -->
|
|
1522
|
+
<!-- dblprime (U+2033): 2356-2356 -->
|
|
1523
|
+
<!-- langle (U+3008): 4-126 -->
|
|
1524
|
+
<!-- rangle (U+3009): 4-345 -->
|
|
1525
|
+
<!-- ellipsis (U+2026): 256-256-256; [BANA-2016] Appendix G, -->
|
|
1526
|
+
<!-- UEB is three periods/256 -->
|
|
1527
|
+
<!-- midpoint (U+00B7): 4-16 -->
|
|
1528
|
+
<!-- swungdash: faked with TILDE (U+007E) -->
|
|
1529
|
+
<!-- pilcrow (U+00B6): 45-1234 -->
|
|
1530
|
+
<!-- section-mark (U+00A7): 45-234 -->
|
|
1531
|
+
<!-- minus (U+2212): 5-36 -->
|
|
1532
|
+
<!-- times (U+00D7): 5-236 -->
|
|
1533
|
+
<!-- solidus: faked with SOLIDUS (U+002F) -->
|
|
1534
|
+
<!-- obelus (U+00F7): 5-34 -->
|
|
1535
|
+
<!-- plusminus (U+00B1): 456-235 -->
|
|
1536
|
+
<xsl:template match="char" mode="character">
|
|
1537
|
+
<xsl:choose>
|
|
1538
|
+
<xsl:when test="@braille = 'none'">
|
|
1539
|
+
<xsl:call-template name="warn-unimplemented-character">
|
|
1540
|
+
<xsl:with-param name="char-name" select="@name"/>
|
|
1541
|
+
</xsl:call-template>
|
|
1542
|
+
</xsl:when>
|
|
1543
|
+
<xsl:when test="@braille">
|
|
1544
|
+
<xsl:value-of select="@braille"/>
|
|
1545
|
+
</xsl:when>
|
|
1546
|
+
<xsl:otherwise>
|
|
1547
|
+
<xsl:value-of select="@unicode"/>
|
|
1548
|
+
</xsl:otherwise>
|
|
1549
|
+
</xsl:choose>
|
|
1309
1550
|
</xsl:template>
|
|
1310
1551
|
|
|
1311
|
-
<!--
|
|
1312
|
-
<!--
|
|
1313
|
-
|
|
1314
|
-
|
|
1552
|
+
<!-- the CJK angle brackets: the liblouis table defines cells -->
|
|
1553
|
+
<!-- (above) only for these, not for the mathematical pair -->
|
|
1554
|
+
<!-- carried by the representation table -->
|
|
1555
|
+
<xsl:template match="char[@name = 'langle']" mode="character">
|
|
1556
|
+
<xsl:text>〈</xsl:text>
|
|
1315
1557
|
</xsl:template>
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
<!-- Liblouis: 2356-2356 -->
|
|
1319
|
-
<xsl:template name="dblprime-character">
|
|
1320
|
-
<xsl:text>″</xsl:text>
|
|
1558
|
+
<xsl:template match="char[@name = 'rangle']" mode="character">
|
|
1559
|
+
<xsl:text>〉</xsl:text>
|
|
1321
1560
|
</xsl:template>
|
|
1322
1561
|
|
|
1323
1562
|
<!-- Unicode Character 'LEFT SINGLE QUOTATION MARK' (U+2018) -->
|
|
@@ -1344,80 +1583,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1344
1583
|
<xsl:text>”</xsl:text>
|
|
1345
1584
|
</xsl:template>
|
|
1346
1585
|
|
|
1347
|
-
<!-- Unicode Character 'LEFT ANGLE BRACKET' (U+3008) -->
|
|
1348
|
-
<!-- Liblouis: 4-126 -->
|
|
1349
|
-
<xsl:template name="langle-character">
|
|
1350
|
-
<xsl:text>〈</xsl:text>
|
|
1351
|
-
</xsl:template>
|
|
1352
|
-
|
|
1353
|
-
<!-- Unicode Character 'RIGHT ANGLE BRACKET' (U+3009) -->
|
|
1354
|
-
<!-- Liblouis: 4-345 -->
|
|
1355
|
-
<xsl:template name="rangle-character">
|
|
1356
|
-
<xsl:text>〉</xsl:text>
|
|
1357
|
-
</xsl:template>
|
|
1358
|
-
|
|
1359
|
-
<!-- Unicode Character 'HORIZONTAL ELLIPSIS' (U+2026) -->
|
|
1360
|
-
<!-- Liblouis: 256-256-256 -->
|
|
1361
|
-
<!-- [BANA-2016] Appendix G, UEB is three periods/256 -->
|
|
1362
|
-
<xsl:template name="ellipsis-character">
|
|
1363
|
-
<xsl:text>…</xsl:text>
|
|
1364
|
-
</xsl:template>
|
|
1365
|
-
|
|
1366
|
-
<!-- Unicode Character 'MIDDLE DOT' (U+00B7) -->
|
|
1367
|
-
<!-- Liblouis: 4-16 -->
|
|
1368
|
-
<xsl:template name="midpoint-character">
|
|
1369
|
-
<xsl:text>·</xsl:text>
|
|
1370
|
-
</xsl:template>
|
|
1371
|
-
|
|
1372
|
-
<!-- Unicode Character 'SWUNG DASH' (U+2053) -->
|
|
1373
|
-
<!-- instead faking it with -->
|
|
1374
|
-
<!-- Unicode Character 'TILDE' (U+007E) -->
|
|
1375
|
-
<xsl:template name="swungdash-character">
|
|
1376
|
-
<xsl:text>~</xsl:text>
|
|
1377
|
-
</xsl:template>
|
|
1378
|
-
|
|
1379
|
-
<!-- Unicode Character 'PILCROW SIGN' (U+00B6) -->
|
|
1380
|
-
<!-- Liblouis: 45-1234 -->
|
|
1381
|
-
<xsl:template name="pilcrow-character">
|
|
1382
|
-
<xsl:text>¶</xsl:text>
|
|
1383
|
-
</xsl:template>
|
|
1384
|
-
|
|
1385
|
-
<!-- Unicode Character 'SECTION SIGN' (U+00A7) -->
|
|
1386
|
-
<!-- Liblouis: 45-234 -->
|
|
1387
|
-
<xsl:template name="section-mark-character">
|
|
1388
|
-
<xsl:text>§</xsl:text>
|
|
1389
|
-
</xsl:template>
|
|
1390
|
-
|
|
1391
|
-
<!-- Unicode Character 'MINUS SIGN' (U+2212) -->
|
|
1392
|
-
<!-- Liblouis: 5-36 -->
|
|
1393
|
-
<xsl:template name="minus-character">
|
|
1394
|
-
<xsl:text>−</xsl:text>
|
|
1395
|
-
</xsl:template>
|
|
1396
|
-
|
|
1397
|
-
<!-- Unicode Character 'MULTIPLICATION SIGN' (U+00D7) -->
|
|
1398
|
-
<!-- Liblouis: 5-236 -->
|
|
1399
|
-
<xsl:template name="times-character">
|
|
1400
|
-
<xsl:text>×</xsl:text>
|
|
1401
|
-
</xsl:template>
|
|
1402
|
-
|
|
1403
|
-
<!-- Unicode Character 'FRACTION SLASH' (U+2044) -->
|
|
1404
|
-
<!-- instead faking it with -->
|
|
1405
|
-
<!-- Unicode Character 'SOLIDUS' (U+002F) -->
|
|
1406
|
-
<xsl:template name="solidus-character">
|
|
1407
|
-
<xsl:text>/</xsl:text>
|
|
1408
|
-
</xsl:template>
|
|
1409
|
-
|
|
1410
|
-
<!-- Unicode Character 'DIVISION SIGN' (U+00F7) -->
|
|
1411
|
-
<!-- Liblouis: 5-34 -->
|
|
1412
|
-
<xsl:template name="obelus-character">
|
|
1413
|
-
<xsl:text>÷</xsl:text>
|
|
1414
|
-
</xsl:template>
|
|
1415
|
-
|
|
1416
|
-
<!-- Unicode Character 'PLUS-MINUS SIGN' (U+00B1) -->
|
|
1417
|
-
<!-- Liblouis: 456-235 -->
|
|
1418
|
-
<xsl:template name="plusminus-character">
|
|
1419
|
-
<xsl:text>±</xsl:text>
|
|
1420
|
-
</xsl:template>
|
|
1421
1586
|
|
|
1422
1587
|
<!-- Icons -->
|
|
1423
1588
|
<!-- Just the four arrows, unsure about the rest -->
|
|
@@ -1438,7 +1603,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1438
1603
|
<xsl:text>↓</xsl:text>
|
|
1439
1604
|
</xsl:when>
|
|
1440
1605
|
<xsl:otherwise>
|
|
1441
|
-
<xsl:message>WARNING:
|
|
1606
|
+
<xsl:message>PTX:WARNING: "icon" with @name attribute value "<xsl:value-of select="@name"/>" does not have an implementation for braille.</xsl:message>
|
|
1442
1607
|
</xsl:otherwise>
|
|
1443
1608
|
</xsl:choose>
|
|
1444
1609
|
</xsl:template>
|
|
@@ -1554,8 +1719,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1554
1719
|
<xsl:template match="m[not(contains(math-nemeth, '
'))]">
|
|
1555
1720
|
<!-- Unicode braille cells from Speech Rule Engine (SRE) -->
|
|
1556
1721
|
<!-- Not expecting any markup, so "value-of" is everything -->
|
|
1722
|
+
<!-- Possibly converted to BRF ASCII symbols ("early") -->
|
|
1557
1723
|
<xsl:variable name="raw-braille">
|
|
1558
|
-
<xsl:
|
|
1724
|
+
<xsl:call-template name="brf-symbols-filter">
|
|
1725
|
+
<xsl:with-param name="text" select="math-nemeth"/>
|
|
1726
|
+
</xsl:call-template>
|
|
1559
1727
|
</xsl:variable>
|
|
1560
1728
|
<!-- We investigate actual source for very simple math -->
|
|
1561
1729
|
<!-- such as one-letter variable names as Latin letters -->
|
|
@@ -1614,6 +1782,8 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1614
1782
|
</xsl:template>
|
|
1615
1783
|
|
|
1616
1784
|
<xsl:template match="m[contains(math-nemeth, '
')]|md">
|
|
1785
|
+
<!-- Lines are trimmed, and possibly converted to BRF ASCII -->
|
|
1786
|
+
<!-- symbols ("early"), one at a time, below -->
|
|
1617
1787
|
<xsl:variable name="nemeth">
|
|
1618
1788
|
<xsl:value-of select="math-nemeth"/>
|
|
1619
1789
|
<xsl:text>
</xsl:text>
|
|
@@ -1635,11 +1805,20 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1635
1805
|
<!-- done, nothing left to work on -->
|
|
1636
1806
|
<xsl:when test="$display-math = ''"/>
|
|
1637
1807
|
<xsl:otherwise>
|
|
1638
|
-
<!-- first line into a segment -->
|
|
1808
|
+
<!-- first line into a segment: trailing blank cells -->
|
|
1809
|
+
<!-- trimmed first, and then a possible conversion to -->
|
|
1810
|
+
<!-- BRF ASCII symbols ("early"), line by line, so a -->
|
|
1811
|
+
<!-- line of print residue rides along as Unicode -->
|
|
1812
|
+
<!-- without disqualifying its neighbors -->
|
|
1639
1813
|
<segment>
|
|
1640
|
-
<xsl:
|
|
1641
|
-
|
|
1642
|
-
|
|
1814
|
+
<xsl:variable name="trimmed">
|
|
1815
|
+
<xsl:call-template name="trim-nemeth-trailing-whitespace">
|
|
1816
|
+
<xsl:with-param name="text" select="substring-before($display-math, '
')"/>
|
|
1817
|
+
</xsl:call-template>
|
|
1818
|
+
</xsl:variable>
|
|
1819
|
+
<xsl:call-template name="brf-symbols-filter">
|
|
1820
|
+
<xsl:with-param name="text" select="$trimmed"/>
|
|
1821
|
+
</xsl:call-template>
|
|
1643
1822
|
</segment>
|
|
1644
1823
|
<!-- recurse on remainder -->
|
|
1645
1824
|
<xsl:call-template name="segmentize-display-math">
|
|
@@ -1985,9 +2164,17 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1985
2164
|
<!-- A paragraph without "displays" is straightforward and -->
|
|
1986
2165
|
<!-- we can bypass the more complicated procedure next. -->
|
|
1987
2166
|
<xsl:template match="p">
|
|
2167
|
+
<!-- Inside a list item ($list-runover is a number, not empty) -->
|
|
2168
|
+
<!-- every line of the paragraph belongs at the list's runover -->
|
|
2169
|
+
<!-- margin [BANA-2016, 8.5.1(b)]; the melded run-in marker -->
|
|
2170
|
+
<!-- supplies the first paragraph's first-line position. -->
|
|
2171
|
+
<xsl:param name="list-runover" select="''"/>
|
|
1988
2172
|
<segment>
|
|
1989
2173
|
<xsl:attribute name="indentation">
|
|
1990
2174
|
<xsl:choose>
|
|
2175
|
+
<xsl:when test="not($list-runover = '')">
|
|
2176
|
+
<xsl:value-of select="$list-runover"/>
|
|
2177
|
+
</xsl:when>
|
|
1991
2178
|
<xsl:when test="@pi:indent = 'no'">
|
|
1992
2179
|
<xsl:text>0</xsl:text>
|
|
1993
2180
|
</xsl:when>
|
|
@@ -1996,6 +2183,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1996
2183
|
</xsl:otherwise>
|
|
1997
2184
|
</xsl:choose>
|
|
1998
2185
|
</xsl:attribute>
|
|
2186
|
+
<xsl:if test="not($list-runover = '')">
|
|
2187
|
+
<xsl:attribute name="runover">
|
|
2188
|
+
<xsl:value-of select="$list-runover"/>
|
|
2189
|
+
</xsl:attribute>
|
|
2190
|
+
</xsl:if>
|
|
1999
2191
|
<xsl:apply-templates select="node()"/>
|
|
2000
2192
|
</segment>
|
|
2001
2193
|
</xsl:template>
|
|
@@ -2007,6 +2199,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2007
2199
|
<!-- Note: this is derived from a similar template in the HTML -->
|
|
2008
2200
|
<!-- conversion. -->
|
|
2009
2201
|
<xsl:template match="p[ol|ul|dl|m[contains(math-nemeth, '
')]|md|cd]">
|
|
2202
|
+
<!-- Inside a list item ($list-runover is a number, not empty) -->
|
|
2203
|
+
<!-- every piece of the paragraph belongs at the list's runover -->
|
|
2204
|
+
<!-- margin [BANA-2016, 8.5.1(b)]; nested lists among the -->
|
|
2205
|
+
<!-- displays compute their own, deeper, margins. -->
|
|
2206
|
+
<xsl:param name="list-runover" select="''"/>
|
|
2010
2207
|
<!-- will later loop over displays within paragraph -->
|
|
2011
2208
|
<!-- match guarantees at least one for $initial variable -->
|
|
2012
2209
|
<xsl:variable name="displays" select="ul|ol|dl|m[contains(math-nemeth, '
')]|md|cd" />
|
|
@@ -2019,7 +2216,22 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2019
2216
|
<xsl:apply-templates select="$initial"/>
|
|
2020
2217
|
</xsl:variable>
|
|
2021
2218
|
<xsl:if test="not(normalize-space($initial-content) = '')">
|
|
2022
|
-
<segment
|
|
2219
|
+
<segment>
|
|
2220
|
+
<xsl:attribute name="indentation">
|
|
2221
|
+
<xsl:choose>
|
|
2222
|
+
<xsl:when test="not($list-runover = '')">
|
|
2223
|
+
<xsl:value-of select="$list-runover"/>
|
|
2224
|
+
</xsl:when>
|
|
2225
|
+
<xsl:otherwise>
|
|
2226
|
+
<xsl:text>2</xsl:text>
|
|
2227
|
+
</xsl:otherwise>
|
|
2228
|
+
</xsl:choose>
|
|
2229
|
+
</xsl:attribute>
|
|
2230
|
+
<xsl:if test="not($list-runover = '')">
|
|
2231
|
+
<xsl:attribute name="runover">
|
|
2232
|
+
<xsl:value-of select="$list-runover"/>
|
|
2233
|
+
</xsl:attribute>
|
|
2234
|
+
</xsl:if>
|
|
2023
2235
|
<xsl:apply-templates select="$initial"/>
|
|
2024
2236
|
</segment>
|
|
2025
2237
|
</xsl:if>
|
|
@@ -2043,6 +2255,14 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2043
2255
|
</xsl:variable>
|
|
2044
2256
|
<xsl:if test="not(normalize-space($common-content) = '')">
|
|
2045
2257
|
<segment>
|
|
2258
|
+
<xsl:if test="not($list-runover = '')">
|
|
2259
|
+
<xsl:attribute name="indentation">
|
|
2260
|
+
<xsl:value-of select="$list-runover"/>
|
|
2261
|
+
</xsl:attribute>
|
|
2262
|
+
<xsl:attribute name="runover">
|
|
2263
|
+
<xsl:value-of select="$list-runover"/>
|
|
2264
|
+
</xsl:attribute>
|
|
2265
|
+
</xsl:if>
|
|
2046
2266
|
<xsl:apply-templates select="$common"/>
|
|
2047
2267
|
</segment>
|
|
2048
2268
|
</xsl:if>
|
|
@@ -2054,6 +2274,14 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2054
2274
|
</xsl:variable>
|
|
2055
2275
|
<xsl:if test="not(normalize-space($final-content) = '')">
|
|
2056
2276
|
<segment>
|
|
2277
|
+
<xsl:if test="not($list-runover = '')">
|
|
2278
|
+
<xsl:attribute name="indentation">
|
|
2279
|
+
<xsl:value-of select="$list-runover"/>
|
|
2280
|
+
</xsl:attribute>
|
|
2281
|
+
<xsl:attribute name="runover">
|
|
2282
|
+
<xsl:value-of select="$list-runover"/>
|
|
2283
|
+
</xsl:attribute>
|
|
2284
|
+
</xsl:if>
|
|
2057
2285
|
<xsl:apply-templates select="$rightward"/>
|
|
2058
2286
|
</segment>
|
|
2059
2287
|
</xsl:if>
|
|
@@ -2078,9 +2306,16 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2078
2306
|
|
|
2079
2307
|
<!-- The "titlepage" and front "colophon" should be mined to form front -->
|
|
2080
2308
|
<!-- matter material in the right places, etc. We kill them for now so -->
|
|
2081
|
-
<!-- we don't see their children being overlooked.
|
|
2309
|
+
<!-- we don't see their children being overlooked. "bibinfo" is pure -->
|
|
2310
|
+
<!-- metadata (authors, date, edition), mined by a title page when one -->
|
|
2311
|
+
<!-- is implemented; unhandled, its text leaks into the output stream -->
|
|
2312
|
+
<!-- with no anchor, so it is silenced the same way. -->
|
|
2082
2313
|
<xsl:template match="titlepage"/>
|
|
2083
2314
|
<xsl:template match="frontmatter/colophon"/>
|
|
2315
|
+
<!-- TODO: a braille title page [BANA-2016, 2.3] should mine -->
|
|
2316
|
+
<!-- "bibinfo" (title, authors, date, edition) rather than -->
|
|
2317
|
+
<!-- leaving it silenced here. -->
|
|
2318
|
+
<xsl:template match="bibinfo"/>
|
|
2084
2319
|
|
|
2085
2320
|
<!-- Many pieces of the "backmatter" have templates designed for divisions -->
|
|
2086
2321
|
<xsl:template match="backmatter">
|
|
@@ -2117,11 +2352,19 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2117
2352
|
<!-- structures. We report AND include a textual place holder. -->
|
|
2118
2353
|
|
|
2119
2354
|
<xsl:template match="notation-list">
|
|
2120
|
-
<
|
|
2355
|
+
<segment>NOTATIONLIST</segment>
|
|
2121
2356
|
</xsl:template>
|
|
2122
2357
|
|
|
2358
|
+
<!-- A real braille index awaits future work; until then the -->
|
|
2359
|
+
<!-- omission is announced in place, rather than silent. (The -->
|
|
2360
|
+
<!-- prior placeholder was bare text, which the renderer cannot -->
|
|
2361
|
+
<!-- anchor, so nothing at all appeared.) -->
|
|
2123
2362
|
<xsl:template match="index-list">
|
|
2124
|
-
<xsl:
|
|
2363
|
+
<xsl:apply-templates select="." mode="transcriber-note">
|
|
2364
|
+
<xsl:with-param name="message">
|
|
2365
|
+
<xsl:text>The index is not reproduced in this braille edition.</xsl:text>
|
|
2366
|
+
</xsl:with-param>
|
|
2367
|
+
</xsl:apply-templates>
|
|
2125
2368
|
</xsl:template>
|
|
2126
2369
|
|
|
2127
2370
|
<xsl:template match="poem">
|
|
@@ -2146,12 +2389,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2146
2389
|
</xsl:call-template>
|
|
2147
2390
|
</xsl:if>
|
|
2148
2391
|
<!-- -->
|
|
2149
|
-
<xsl:if test="//index-list">
|
|
2150
|
-
<xsl:call-template name="missing-implementation">
|
|
2151
|
-
<xsl:with-param name="element" select="'index-list'"/>
|
|
2152
|
-
<xsl:with-param name="ntimes" select="count(//index-list)"/>
|
|
2153
|
-
</xsl:call-template>
|
|
2154
|
-
</xsl:if>
|
|
2155
2392
|
<xsl:if test="//poem">
|
|
2156
2393
|
<xsl:call-template name="missing-implementation">
|
|
2157
2394
|
<xsl:with-param name="element" select="'poem'"/>
|
|
@@ -2179,11 +2416,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2179
2416
|
<xsl:param name="element"/>
|
|
2180
2417
|
<xsl:param name="ntimes"/>
|
|
2181
2418
|
|
|
2182
|
-
<xsl:message>Unimplemented: <xsl:value-of select="$element"/> (<xsl:value-of select="$ntimes"/> times)</xsl:message>
|
|
2419
|
+
<xsl:message>PTX:INFO: Unimplemented: <xsl:value-of select="$element"/> (<xsl:value-of select="$ntimes"/> times)</xsl:message>
|
|
2183
2420
|
</xsl:template>
|
|
2184
2421
|
|
|
2185
2422
|
<xsl:template match="*" mode="overlooked">
|
|
2186
|
-
<xsl:message>Overlooked: <xsl:value-of select="local-name()"/></xsl:message>
|
|
2423
|
+
<xsl:message>PTX:INFO: Overlooked: <xsl:value-of select="local-name()"/></xsl:message>
|
|
2187
2424
|
</xsl:template>
|
|
2188
2425
|
|
|
2189
2426
|
<!-- *Every* element needs an implementation, or it ends up here being -->
|
|
@@ -2245,5 +2482,24 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
2245
2482
|
</segment>
|
|
2246
2483
|
</xsl:template>
|
|
2247
2484
|
|
|
2485
|
+
<!-- ############## -->
|
|
2486
|
+
<!-- Invalid Source -->
|
|
2487
|
+
<!-- ############## -->
|
|
2488
|
+
|
|
2489
|
+
<!-- Constructions that violate the PreTeXt schema receive an error -->
|
|
2490
|
+
<!-- message describing the violation, and leave a placeholder in the -->
|
|
2491
|
+
<!-- output, rather than being accommodated. Generated content -->
|
|
2492
|
+
<!-- (STACK static representations) is the known supplier: a "p" -->
|
|
2493
|
+
<!-- within a "p", an "image" within a "p", and "div" (an HTML -->
|
|
2494
|
+
<!-- element, not PreTeXt at all). -->
|
|
2495
|
+
<!-- -->
|
|
2496
|
+
<!-- N.B. these templates are deliberately LAST in this stylesheet: -->
|
|
2497
|
+
<!-- a nested "p" can also match the display-splitting template for -->
|
|
2498
|
+
<!-- "p" at equal priority, and placement here settles the conflict -->
|
|
2499
|
+
<!-- in favor of the error. -->
|
|
2500
|
+
<xsl:template match="p/p|p/image|div">
|
|
2501
|
+
<xsl:message>PTX:ERROR: the braille conversion has encountered source that is not valid PreTeXt (a "<xsl:value-of select="local-name()"/>" element within a "<xsl:value-of select="local-name(parent::*)"/>"); a placeholder appears in the output in its place</xsl:message>
|
|
2502
|
+
<xsl:text>[INVALID SOURCE]</xsl:text>
|
|
2503
|
+
</xsl:template>
|
|
2248
2504
|
|
|
2249
2505
|
</xsl:stylesheet>
|