@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
|
@@ -95,6 +95,10 @@
|
|
|
95
95
|
</xsl:choose>
|
|
96
96
|
</xsl:variable>
|
|
97
97
|
|
|
98
|
+
<!-- Force level 2 as the top level heading for chunks -->
|
|
99
|
+
<!-- by overrideing this template than calling the original -->
|
|
100
|
+
<xsl:variable name="chunk-heading-level" select="2"/>
|
|
101
|
+
|
|
98
102
|
<!-- We disable the ToC level to avoid any conflicts with chunk level -->
|
|
99
103
|
<xsl:variable name="toc-level" select="number(0)" />
|
|
100
104
|
|
|
@@ -184,7 +188,7 @@
|
|
|
184
188
|
<!-- template in the entry template here, so these pages are not built (good). -->
|
|
185
189
|
<!-- But we do get little buttons to elect a printable version. We have to kill -->
|
|
186
190
|
<!-- those buttons, since EPUB wants to go looking for the printable-version files. -->
|
|
187
|
-
<xsl:template match="
|
|
191
|
+
<xsl:template match="&PRINTOUT;" mode="standalone-printout-links"/>
|
|
188
192
|
|
|
189
193
|
|
|
190
194
|
<!-- ############## -->
|
|
@@ -201,7 +205,7 @@
|
|
|
201
205
|
<xsl:call-template name="banner-warning">
|
|
202
206
|
<xsl:with-param name="warning">PTX:FATAL: EPUB creation is only implemented for a "book" or an "article",
not a "<xsl:value-of select="local-name($document-root)"/>", and we cannot recover</xsl:with-param>
|
|
203
207
|
</xsl:call-template>
|
|
204
|
-
<xsl:message terminate="yes">Quitting...</xsl:message>
|
|
208
|
+
<xsl:message terminate="yes">PTX:FATAL: Quitting...</xsl:message>
|
|
205
209
|
</xsl:if>
|
|
206
210
|
<!-- analyze authored source -->
|
|
207
211
|
<xsl:apply-templates select="$original" mode="generic-warnings"/>
|
|
@@ -215,11 +219,13 @@
|
|
|
215
219
|
<xsl:call-template name="packaging-info"/>
|
|
216
220
|
</xsl:template>
|
|
217
221
|
|
|
218
|
-
<!-- First,
|
|
222
|
+
<!-- First, create the cover page and table of contents files, which are -->
|
|
223
|
+
<!-- necessary for every EPUB, even when the source has no "frontmatter" -->
|
|
219
224
|
<!-- We process structural nodes via chunking routine in xsl/mathbook-common.xsl -->
|
|
220
225
|
<!-- This in turn calls specific modal templates defined elsewhere in this file -->
|
|
221
226
|
<xsl:template match="/pretext">
|
|
222
|
-
<xsl:
|
|
227
|
+
<xsl:call-template name="cover-page-file"/>
|
|
228
|
+
<xsl:call-template name="table-contents-file"/>
|
|
223
229
|
<xsl:call-template name="endnotes"/>
|
|
224
230
|
<xsl:apply-templates mode="chunking" />
|
|
225
231
|
</xsl:template>
|
|
@@ -235,7 +241,7 @@
|
|
|
235
241
|
<!-- EPUB conversion with "chapter" having "section" it gets an -->
|
|
236
242
|
<!-- HTML page of its own as part of the "summary" hack. Ditto -->
|
|
237
243
|
<!-- for "outcomes" which might appear in a different order. -->
|
|
238
|
-
<xsl:template match="&STRUCTURAL
|
|
244
|
+
<xsl:template match="&STRUCTURAL;|&DIVISION-COMPANION;" mode="file-wrap">
|
|
239
245
|
<xsl:param name="content" />
|
|
240
246
|
<xsl:variable name="file">
|
|
241
247
|
<xsl:value-of select="$content-dir" />
|
|
@@ -272,6 +278,13 @@
|
|
|
272
278
|
</exsl:document>
|
|
273
279
|
</xsl:template>
|
|
274
280
|
|
|
281
|
+
<!-- The "backmatter" has no page of its own (see above), so -->
|
|
282
|
+
<!-- a summary page never links to it: the links pass through -->
|
|
283
|
+
<!-- to its children, each of which is a genuine page -->
|
|
284
|
+
<xsl:template match="backmatter" mode="summary-nav">
|
|
285
|
+
<xsl:apply-templates select="*" mode="summary-nav"/>
|
|
286
|
+
</xsl:template>
|
|
287
|
+
|
|
275
288
|
<!-- The book element gets mined in various ways, -->
|
|
276
289
|
<!-- but the "usual" HTML treatment can/should be thrown out -->
|
|
277
290
|
<!-- At fixed level 2, this is a summary page from an -->
|
|
@@ -282,7 +295,7 @@
|
|
|
282
295
|
<!-- and they are going into their own files. So it seems the -->
|
|
283
296
|
<!-- right thing to do, while making minimal changes elsewhere. -->
|
|
284
297
|
<xsl:template match="chapter/conclusion|chapter/outcomes[preceding-sibling::section]" mode="containing-filename">
|
|
285
|
-
<xsl:apply-templates select="." mode="
|
|
298
|
+
<xsl:apply-templates select="." mode="unique-id"/>
|
|
286
299
|
<xsl:text>.xhtml</xsl:text>
|
|
287
300
|
</xsl:template>
|
|
288
301
|
|
|
@@ -303,23 +316,10 @@
|
|
|
303
316
|
<section class="{local-name(.)}">
|
|
304
317
|
<xsl:apply-templates select="." mode="html-id-attribute"/>
|
|
305
318
|
<xsl:apply-templates select="." mode="section-heading" />
|
|
306
|
-
<xsl:apply-templates select="author|
|
|
319
|
+
<xsl:apply-templates select="author|titlepage|abstract" />
|
|
307
320
|
<!-- deleted "nav" and summary links here -->
|
|
321
|
+
<!-- division companions become their own files, in the spine -->
|
|
308
322
|
</section>
|
|
309
|
-
<xsl:if test="conclusion">
|
|
310
|
-
<xsl:apply-templates select="conclusion" mode="file-wrap">
|
|
311
|
-
<xsl:with-param name="content">
|
|
312
|
-
<xsl:apply-templates select="conclusion"/>
|
|
313
|
-
</xsl:with-param>
|
|
314
|
-
</xsl:apply-templates>
|
|
315
|
-
</xsl:if>
|
|
316
|
-
<xsl:if test="outcomes">
|
|
317
|
-
<xsl:apply-templates select="outcomes" mode="file-wrap">
|
|
318
|
-
<xsl:with-param name="content">
|
|
319
|
-
<xsl:apply-templates select="outcomes"/>
|
|
320
|
-
</xsl:with-param>
|
|
321
|
-
</xsl:apply-templates>
|
|
322
|
-
</xsl:if>
|
|
323
323
|
</xsl:with-param>
|
|
324
324
|
</xsl:apply-templates>
|
|
325
325
|
</xsl:template>
|
|
@@ -451,12 +451,15 @@
|
|
|
451
451
|
<item id="table-contents"
|
|
452
452
|
href="{$xhtml-dir}/table-contents.xhtml"
|
|
453
453
|
media-type="application/xhtml+xml">
|
|
454
|
-
<!--
|
|
455
|
-
<!--
|
|
454
|
+
<!-- The file has been written by now, so rather than -->
|
|
455
|
+
<!-- predict which division titles the table of contents -->
|
|
456
|
+
<!-- displays, read it and see if any mathematics landed -->
|
|
457
|
+
<!-- there, exactly as "manifest-item" does per chunk -->
|
|
458
|
+
<xsl:variable name="toc-contents" select="document(concat($tmpdir, '/', $content-dir, '/', $xhtml-dir, '/table-contents.xhtml'))"/>
|
|
456
459
|
<xsl:attribute name="properties">
|
|
457
460
|
<xsl:choose>
|
|
458
|
-
<xsl:when test="
|
|
459
|
-
|
|
461
|
+
<xsl:when test="$toc-contents//svg:svg | $toc-contents//math:math">
|
|
462
|
+
<xsl:choose>
|
|
460
463
|
<xsl:when test="$math.format = 'mml' or
|
|
461
464
|
$math.format = 'kindle'">
|
|
462
465
|
<xsl:text>nav mathml</xsl:text>
|
|
@@ -464,6 +467,9 @@
|
|
|
464
467
|
<xsl:when test="$math.format = 'svg'">
|
|
465
468
|
<xsl:text>nav svg</xsl:text>
|
|
466
469
|
</xsl:when>
|
|
470
|
+
<xsl:otherwise>
|
|
471
|
+
<xsl:text>nav</xsl:text>
|
|
472
|
+
</xsl:otherwise>
|
|
467
473
|
</xsl:choose>
|
|
468
474
|
</xsl:when>
|
|
469
475
|
<xsl:otherwise>
|
|
@@ -533,10 +539,72 @@
|
|
|
533
539
|
<!-- recurse into contents for image files, etc -->
|
|
534
540
|
<!-- See "Core Media Type Resources" -->
|
|
535
541
|
<!-- Add to spine identically -->
|
|
536
|
-
<!--
|
|
537
|
-
<!--
|
|
538
|
-
<!--
|
|
539
|
-
|
|
542
|
+
<!-- A division is a page of the container exactly when the -->
|
|
543
|
+
<!-- chunking machinery makes one: a terminal chunk, or a summary -->
|
|
544
|
+
<!-- page above the chunk level (the document root's own summary -->
|
|
545
|
+
<!-- included). "backmatter" is the deliberate exception: it is -->
|
|
546
|
+
<!-- a pure container, with no content of its own, so its summary -->
|
|
547
|
+
<!-- page would be nothing but links to its children, and a -->
|
|
548
|
+
<!-- reading system's own navigation provides exactly that, so -->
|
|
549
|
+
<!-- the page is never produced (see mode="intermediate", above). -->
|
|
550
|
+
<!-- Contrast with "frontmatter", whose page renders genuine -->
|
|
551
|
+
<!-- content: a title page, an abstract, and so on. -->
|
|
552
|
+
<!-- The manifest and the spine both consult this one template, -->
|
|
553
|
+
<!-- and the files written are governed by the same machinery, so -->
|
|
554
|
+
<!-- the three can never disagree. -->
|
|
555
|
+
<xsl:template match="&STRUCTURAL;" mode="is-epub-page">
|
|
556
|
+
<xsl:variable name="chunk">
|
|
557
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
558
|
+
</xsl:variable>
|
|
559
|
+
<xsl:variable name="intermediate">
|
|
560
|
+
<xsl:apply-templates select="." mode="is-intermediate"/>
|
|
561
|
+
</xsl:variable>
|
|
562
|
+
<xsl:choose>
|
|
563
|
+
<xsl:when test="self::backmatter">
|
|
564
|
+
<xsl:text>false</xsl:text>
|
|
565
|
+
</xsl:when>
|
|
566
|
+
<!-- a "book" is the second exception: its summary page is -->
|
|
567
|
+
<!-- also deliberately not produced (see the "book" version -->
|
|
568
|
+
<!-- of mode="intermediate"), the table of contents being -->
|
|
569
|
+
<!-- the better organizer. An "article" root DOES produce -->
|
|
570
|
+
<!-- its summary page, and so is not excepted. -->
|
|
571
|
+
<xsl:when test="self::book">
|
|
572
|
+
<xsl:text>false</xsl:text>
|
|
573
|
+
</xsl:when>
|
|
574
|
+
<xsl:when test="($chunk = 'true') or ($intermediate = 'true')">
|
|
575
|
+
<xsl:text>true</xsl:text>
|
|
576
|
+
</xsl:when>
|
|
577
|
+
<xsl:otherwise>
|
|
578
|
+
<xsl:text>false</xsl:text>
|
|
579
|
+
</xsl:otherwise>
|
|
580
|
+
</xsl:choose>
|
|
581
|
+
</xsl:template>
|
|
582
|
+
|
|
583
|
+
<xsl:template match="&STRUCTURAL;" mode="manifest">
|
|
584
|
+
<xsl:variable name="is-page">
|
|
585
|
+
<xsl:apply-templates select="." mode="is-epub-page"/>
|
|
586
|
+
</xsl:variable>
|
|
587
|
+
<xsl:if test="$is-page = 'true'">
|
|
588
|
+
<xsl:call-template name="manifest-item"/>
|
|
589
|
+
</xsl:if>
|
|
590
|
+
<!-- recurse, eg from chapter down into a section -->
|
|
591
|
+
<xsl:apply-templates select="*" mode="manifest" />
|
|
592
|
+
</xsl:template>
|
|
593
|
+
|
|
594
|
+
<!-- A division companion is a file exactly when it is a chunk -->
|
|
595
|
+
<!-- (its parent is a summary page); it has no children that -->
|
|
596
|
+
<!-- could ever join the manifest, so there is no recursion -->
|
|
597
|
+
<xsl:template match="&DIVISION-COMPANION;" mode="manifest">
|
|
598
|
+
<xsl:variable name="chunk">
|
|
599
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
600
|
+
</xsl:variable>
|
|
601
|
+
<xsl:if test="$chunk = 'true'">
|
|
602
|
+
<xsl:call-template name="manifest-item"/>
|
|
603
|
+
</xsl:if>
|
|
604
|
+
</xsl:template>
|
|
605
|
+
|
|
606
|
+
<!-- One manifest "item" element for the context node's file -->
|
|
607
|
+
<xsl:template name="manifest-item">
|
|
540
608
|
<!-- Annotate manifest entries -->
|
|
541
609
|
<xsl:comment>
|
|
542
610
|
<xsl:apply-templates select="." mode="long-name" />
|
|
@@ -601,7 +669,6 @@
|
|
|
601
669
|
</xsl:attribute>
|
|
602
670
|
</xsl:element>
|
|
603
671
|
<!-- recurse, eg from chapter down into a section -->
|
|
604
|
-
<xsl:apply-templates select="*" mode="manifest" />
|
|
605
672
|
</xsl:template>
|
|
606
673
|
|
|
607
674
|
<!-- How the files are organized into the spine -->
|
|
@@ -623,19 +690,43 @@
|
|
|
623
690
|
<xsl:apply-templates select="*" mode="spine" />
|
|
624
691
|
</xsl:template>
|
|
625
692
|
|
|
693
|
+
<!-- A division companion joins the linear reading order exactly -->
|
|
694
|
+
<!-- when it is a file; document order places an "introduction" -->
|
|
695
|
+
<!-- right after its division's summary page, and a "conclusion" -->
|
|
696
|
+
<!-- after the last subdivision -->
|
|
697
|
+
<xsl:template match="&DIVISION-COMPANION;" mode="spine">
|
|
698
|
+
<xsl:variable name="chunk">
|
|
699
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
700
|
+
</xsl:variable>
|
|
701
|
+
<xsl:if test="$chunk = 'true'">
|
|
702
|
+
<xsl:element name="itemref" xmlns="http://www.idpf.org/2007/opf">
|
|
703
|
+
<xsl:attribute name="idref">
|
|
704
|
+
<xsl:apply-templates select="." mode="html-id" />
|
|
705
|
+
</xsl:attribute>
|
|
706
|
+
<xsl:attribute name="linear">
|
|
707
|
+
<xsl:text>yes</xsl:text>
|
|
708
|
+
</xsl:attribute>
|
|
709
|
+
</xsl:element>
|
|
710
|
+
</xsl:if>
|
|
711
|
+
</xsl:template>
|
|
712
|
+
|
|
626
713
|
<!-- Simplest scenario is spine matches manifest, all with @linear="yes" -->
|
|
627
|
-
<!--
|
|
628
|
-
<!--
|
|
629
|
-
|
|
630
|
-
<xsl:
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
714
|
+
<!-- The identical "is-epub-page" question asked by the "manifest" -->
|
|
715
|
+
<!-- templates above, so every spine reference resolves -->
|
|
716
|
+
<xsl:template match="&STRUCTURAL;" mode="spine">
|
|
717
|
+
<xsl:variable name="is-page">
|
|
718
|
+
<xsl:apply-templates select="." mode="is-epub-page"/>
|
|
719
|
+
</xsl:variable>
|
|
720
|
+
<xsl:if test="$is-page = 'true'">
|
|
721
|
+
<xsl:element name="itemref" xmlns="http://www.idpf.org/2007/opf">
|
|
722
|
+
<xsl:attribute name="idref">
|
|
723
|
+
<xsl:apply-templates select="." mode="html-id" />
|
|
724
|
+
</xsl:attribute>
|
|
725
|
+
<xsl:attribute name="linear">
|
|
726
|
+
<xsl:text>yes</xsl:text>
|
|
727
|
+
</xsl:attribute>
|
|
728
|
+
</xsl:element>
|
|
729
|
+
</xsl:if>
|
|
639
730
|
<xsl:apply-templates select="*" mode="spine" />
|
|
640
731
|
</xsl:template>
|
|
641
732
|
|
|
@@ -684,6 +775,14 @@
|
|
|
684
775
|
<!-- Decide what to do with preview images, etc. -->
|
|
685
776
|
<images>
|
|
686
777
|
<xsl:for-each select="$document-root//image">
|
|
778
|
+
<xsl:variable name="write-filename">
|
|
779
|
+
<xsl:apply-templates select="." mode="epub-base-filename">
|
|
780
|
+
<xsl:with-param name="purpose" select="'write'"/>
|
|
781
|
+
</xsl:apply-templates>
|
|
782
|
+
</xsl:variable>
|
|
783
|
+
<!-- a PDF-only image is replaced by a placeholder, -->
|
|
784
|
+
<!-- so the file itself is not copied in -->
|
|
785
|
+
<xsl:if test="not(substring($write-filename, string-length($write-filename) - 3) = '.pdf')">
|
|
687
786
|
<image>
|
|
688
787
|
<!-- filename begins with directories from publisher file -->
|
|
689
788
|
<xsl:attribute name="sourcename">
|
|
@@ -697,6 +796,7 @@
|
|
|
697
796
|
</xsl:apply-templates>
|
|
698
797
|
</xsl:attribute>
|
|
699
798
|
</image>
|
|
799
|
+
</xsl:if>
|
|
700
800
|
</xsl:for-each>
|
|
701
801
|
</images>
|
|
702
802
|
</packaging>
|
|
@@ -718,6 +818,12 @@
|
|
|
718
818
|
<!-- Content files -->
|
|
719
819
|
<!-- ############# -->
|
|
720
820
|
|
|
821
|
+
<!-- The cover page and table of contents files are listed in the -->
|
|
822
|
+
<!-- manifest and spine of every EPUB, and "package-manifest" reads -->
|
|
823
|
+
<!-- the table of contents file once written. So create both -->
|
|
824
|
+
<!-- unconditionally: their content comes from the document root, -->
|
|
825
|
+
<!-- not the optional "frontmatter". -->
|
|
826
|
+
|
|
721
827
|
<!-- "coverpage.html" comes in two flavors: -->
|
|
722
828
|
<!-- -->
|
|
723
829
|
<!-- 1. An author provides a cover image via the publication file and -->
|
|
@@ -731,7 +837,7 @@
|
|
|
731
837
|
<!-- here is backed out. More immediately, we build a simple page -->
|
|
732
838
|
<!-- (with CSS) having title, subtitle, and authors. -->
|
|
733
839
|
|
|
734
|
-
<xsl:template
|
|
840
|
+
<xsl:template name="cover-page-file">
|
|
735
841
|
<exsl:document href="{$content-dir}/{$xhtml-dir}/cover-page.xhtml" method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="no">
|
|
736
842
|
<html>
|
|
737
843
|
<xsl:call-template name="html-theme-attributes"/>
|
|
@@ -780,6 +886,9 @@
|
|
|
780
886
|
</body>
|
|
781
887
|
</html>
|
|
782
888
|
</exsl:document>
|
|
889
|
+
</xsl:template>
|
|
890
|
+
|
|
891
|
+
<xsl:template name="table-contents-file">
|
|
783
892
|
<exsl:document href="{$content-dir}/{$xhtml-dir}/table-contents.xhtml" method="xml" omit-xml-declaration="yes" encoding="UTF-8" indent="no">
|
|
784
893
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
|
785
894
|
<xsl:call-template name="html-theme-attributes"/>
|
|
@@ -790,7 +899,7 @@
|
|
|
790
899
|
</head>
|
|
791
900
|
<body class="ptx-content epub" epub:type="frontmatter">
|
|
792
901
|
<nav epub:type="toc" id="toc">
|
|
793
|
-
<
|
|
902
|
+
<h2>Table of Contents</h2>
|
|
794
903
|
<ol>
|
|
795
904
|
<!-- top-level divisions, for a book -->
|
|
796
905
|
<xsl:for-each select="$document-root/chapter[$b-is-book]|$document-root/section[$b-is-article]">
|
|
@@ -801,6 +910,7 @@
|
|
|
801
910
|
</xsl:attribute>
|
|
802
911
|
<xsl:apply-templates select="." mode="title-simple" />
|
|
803
912
|
</xsl:element>
|
|
913
|
+
<xsl:apply-templates select="." mode="nav-companions"/>
|
|
804
914
|
</li>
|
|
805
915
|
</xsl:for-each>
|
|
806
916
|
<!-- following divisions identical for book v. article -->
|
|
@@ -838,6 +948,35 @@
|
|
|
838
948
|
</exsl:document>
|
|
839
949
|
</xsl:template>
|
|
840
950
|
|
|
951
|
+
<!-- Division companions of a division, nested in the nav -->
|
|
952
|
+
<!-- document, exactly when they are files of the spine -->
|
|
953
|
+
<xsl:template match="*" mode="nav-companions">
|
|
954
|
+
<xsl:variable name="companion-files">
|
|
955
|
+
<xsl:for-each select="introduction|conclusion|objectives|outcomes">
|
|
956
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
957
|
+
</xsl:for-each>
|
|
958
|
+
</xsl:variable>
|
|
959
|
+
<xsl:if test="contains($companion-files, 'true')">
|
|
960
|
+
<ol>
|
|
961
|
+
<xsl:for-each select="introduction|conclusion|objectives|outcomes">
|
|
962
|
+
<xsl:variable name="chunk">
|
|
963
|
+
<xsl:apply-templates select="." mode="is-chunk"/>
|
|
964
|
+
</xsl:variable>
|
|
965
|
+
<xsl:if test="$chunk = 'true'">
|
|
966
|
+
<li class="no-marker">
|
|
967
|
+
<xsl:element name="a">
|
|
968
|
+
<xsl:attribute name="href">
|
|
969
|
+
<xsl:apply-templates select="." mode="containing-filename" />
|
|
970
|
+
</xsl:attribute>
|
|
971
|
+
<xsl:apply-templates select="." mode="division-companion-text" />
|
|
972
|
+
</xsl:element>
|
|
973
|
+
</li>
|
|
974
|
+
</xsl:if>
|
|
975
|
+
</xsl:for-each>
|
|
976
|
+
</ol>
|
|
977
|
+
</xsl:if>
|
|
978
|
+
</xsl:template>
|
|
979
|
+
|
|
841
980
|
<!-- An abstract named template accepts input text and -->
|
|
842
981
|
<!-- output text, then wraps it for the Sage Cell Server -->
|
|
843
982
|
<xsl:template match="sage" mode="sage-active-markup">
|
|
@@ -1014,6 +1153,14 @@
|
|
|
1014
1153
|
<xsl:with-param name="filename" select="@source|@pi:generated" />
|
|
1015
1154
|
</xsl:call-template>
|
|
1016
1155
|
</xsl:variable>
|
|
1156
|
+
<xsl:variable name="image-filename">
|
|
1157
|
+
<xsl:apply-templates select="." mode="epub-base-filename">
|
|
1158
|
+
<xsl:with-param name="purpose" select="'write'"/>
|
|
1159
|
+
</xsl:apply-templates>
|
|
1160
|
+
</xsl:variable>
|
|
1161
|
+
<!-- a PDF-only image is never displayed, never packaged: -->
|
|
1162
|
+
<!-- a placeholder appears in its place (see below) -->
|
|
1163
|
+
<xsl:if test="not(substring($image-filename, string-length($image-filename) - 3) = '.pdf')">
|
|
1017
1164
|
<!-- item element for manifest -->
|
|
1018
1165
|
<xsl:element name="item" namespace="http://www.idpf.org/2007/opf">
|
|
1019
1166
|
<!-- internal id of the image -->
|
|
@@ -1022,9 +1169,7 @@
|
|
|
1022
1169
|
<xsl:attribute name="href">
|
|
1023
1170
|
<xsl:value-of select="$xhtml-dir" />
|
|
1024
1171
|
<xsl:text>/</xsl:text>
|
|
1025
|
-
<xsl:
|
|
1026
|
-
<xsl:with-param name="purpose" select="'write'"/>
|
|
1027
|
-
</xsl:apply-templates>
|
|
1172
|
+
<xsl:value-of select="$image-filename"/>
|
|
1028
1173
|
</xsl:attribute>
|
|
1029
1174
|
<!-- media attribute -->
|
|
1030
1175
|
<xsl:attribute name="media-type">
|
|
@@ -1053,12 +1198,16 @@
|
|
|
1053
1198
|
<xsl:when test="@pi:generated and ($extension = 'jpg')">
|
|
1054
1199
|
<xsl:text>image/jpeg</xsl:text>
|
|
1055
1200
|
</xsl:when>
|
|
1201
|
+
<!-- these images switch to PNG for a Kindle build (see -->
|
|
1202
|
+
<!-- "best-file-extension") so the media type must express -->
|
|
1203
|
+
<!-- the same choice, else a reading system (or validator) -->
|
|
1204
|
+
<!-- tries to parse PNG bytes as XML -->
|
|
1056
1205
|
<xsl:when test="latex-image|asymptote|mermaid|pf:prefigure">
|
|
1057
|
-
<xsl:
|
|
1206
|
+
<xsl:call-template name="best-media-type"/>
|
|
1058
1207
|
</xsl:when>
|
|
1059
1208
|
<!-- A 2D "sageplot" is just like any other image built from source -->
|
|
1060
1209
|
<xsl:when test="sageplot[not(@variant) or (@variant = '2d')]">
|
|
1061
|
-
<xsl:
|
|
1210
|
+
<xsl:call-template name="best-media-type"/>
|
|
1062
1211
|
</xsl:when>
|
|
1063
1212
|
<!-- NB: a 3D "sageplot" only comes in PNG and HTML variants, -->
|
|
1064
1213
|
<!-- so we cannot manufacture the preferable SVG version, -->
|
|
@@ -1070,10 +1219,14 @@
|
|
|
1070
1219
|
<xsl:otherwise>
|
|
1071
1220
|
<xsl:message>PTX:BUG: EPUB image media-type not determined</xsl:message>
|
|
1072
1221
|
<xsl:apply-templates select="." mode="location-report" />
|
|
1222
|
+
<!-- an empty media-type is invalid; this is the -->
|
|
1223
|
+
<!-- honest generic type while the bug survives -->
|
|
1224
|
+
<xsl:text>application/octet-stream</xsl:text>
|
|
1073
1225
|
</xsl:otherwise>
|
|
1074
1226
|
</xsl:choose>
|
|
1075
1227
|
</xsl:attribute>
|
|
1076
1228
|
</xsl:element>
|
|
1229
|
+
</xsl:if>
|
|
1077
1230
|
<!-- likely a dead-end here, but we examine children anyway -->
|
|
1078
1231
|
<xsl:apply-templates select="*" mode="manifest" />
|
|
1079
1232
|
</xsl:template>
|
|
@@ -1108,33 +1261,50 @@
|
|
|
1108
1261
|
</xsl:template>
|
|
1109
1262
|
|
|
1110
1263
|
<!-- Now the actual image inclusion where born -->
|
|
1264
|
+
<!-- EPUB reading systems display no PDF, so an image available -->
|
|
1265
|
+
<!-- only in that format (STACK exercises supply these) becomes a -->
|
|
1266
|
+
<!-- placeholder, with a warning at build time. The manifest -->
|
|
1267
|
+
<!-- template asks the identical question, so the unusable file is -->
|
|
1268
|
+
<!-- not packaged either. -->
|
|
1111
1269
|
<xsl:template match="image">
|
|
1112
|
-
<xsl:
|
|
1113
|
-
<xsl:
|
|
1114
|
-
<xsl:
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
<xsl:
|
|
1119
|
-
<xsl:
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
</
|
|
1136
|
-
|
|
1137
|
-
|
|
1270
|
+
<xsl:variable name="filename">
|
|
1271
|
+
<xsl:apply-templates select="." mode="epub-base-filename">
|
|
1272
|
+
<xsl:with-param name="purpose" select="'write'"/>
|
|
1273
|
+
</xsl:apply-templates>
|
|
1274
|
+
</xsl:variable>
|
|
1275
|
+
<xsl:choose>
|
|
1276
|
+
<xsl:when test="substring($filename, string-length($filename) - 3) = '.pdf'">
|
|
1277
|
+
<xsl:message>PTX:ERROR: an image is available only as a PDF, which an EPUB reading system will not display; a placeholder appears in its place</xsl:message>
|
|
1278
|
+
<xsl:apply-templates select="." mode="location-report"/>
|
|
1279
|
+
<p class="image-placeholder">[An image belongs here, but it is available only in PDF form, which EPUB does not display.]</p>
|
|
1280
|
+
</xsl:when>
|
|
1281
|
+
<xsl:otherwise>
|
|
1282
|
+
<xsl:element name="img">
|
|
1283
|
+
<xsl:attribute name="src">
|
|
1284
|
+
<xsl:value-of select="$filename"/>
|
|
1285
|
+
</xsl:attribute>
|
|
1286
|
+
<xsl:if test="@width">
|
|
1287
|
+
<xsl:attribute name="style">
|
|
1288
|
+
<xsl:text>width: </xsl:text>
|
|
1289
|
+
<xsl:value-of select="@width" />
|
|
1290
|
+
<xsl:text>; margin: 0 auto;</xsl:text>
|
|
1291
|
+
</xsl:attribute>
|
|
1292
|
+
</xsl:if>
|
|
1293
|
+
</xsl:element>
|
|
1294
|
+
<xsl:if test="description">
|
|
1295
|
+
<details class="image-description">
|
|
1296
|
+
<summary>
|
|
1297
|
+
<xsl:call-template name="insert-symbol">
|
|
1298
|
+
<xsl:with-param name="name" select="'description'"/>
|
|
1299
|
+
</xsl:call-template>
|
|
1300
|
+
</summary>
|
|
1301
|
+
<div>
|
|
1302
|
+
<xsl:apply-templates select="description"/>
|
|
1303
|
+
</div>
|
|
1304
|
+
</details>
|
|
1305
|
+
</xsl:if>
|
|
1306
|
+
</xsl:otherwise>
|
|
1307
|
+
</xsl:choose>
|
|
1138
1308
|
</xsl:template>
|
|
1139
1309
|
|
|
1140
1310
|
<!-- ######### -->
|
|
@@ -1333,13 +1503,68 @@
|
|
|
1333
1503
|
</xsl:for-each>
|
|
1334
1504
|
</xsl:template>
|
|
1335
1505
|
|
|
1506
|
+
<!-- A hyperlink relative to the document (no scheme in the -->
|
|
1507
|
+
<!-- address) points *into* the reading system's container, at a -->
|
|
1508
|
+
<!-- file that is not packaged; the visible text appears, with no -->
|
|
1509
|
+
<!-- dead hyperlink -->
|
|
1510
|
+
<xsl:template match="url[@href and not(contains(@href, ':'))]">
|
|
1511
|
+
<xsl:choose>
|
|
1512
|
+
<xsl:when test="node()">
|
|
1513
|
+
<xsl:apply-templates/>
|
|
1514
|
+
</xsl:when>
|
|
1515
|
+
<xsl:otherwise>
|
|
1516
|
+
<xsl:value-of select="@visual"/>
|
|
1517
|
+
</xsl:otherwise>
|
|
1518
|
+
</xsl:choose>
|
|
1519
|
+
</xsl:template>
|
|
1520
|
+
|
|
1521
|
+
<!-- A MyOpenMath problem may arrive with a link whose address -->
|
|
1522
|
+
<!-- *is* an entire data file (a "data:" address), defused with a -->
|
|
1523
|
+
<!-- "denied:" prefix during harvesting. No reading system can -->
|
|
1524
|
+
<!-- use it, so a placeholder states what is missing, naming the -->
|
|
1525
|
+
<!-- type of the file, and the link's visible text as an -->
|
|
1526
|
+
<!-- identifier, when there is one -->
|
|
1527
|
+
<xsl:template match="url[starts-with(@href, 'denied:')]">
|
|
1528
|
+
<xsl:variable name="mime-type" select="substring-before(substring-after(@href, 'denied:data:'), ';')"/>
|
|
1529
|
+
<xsl:text>[</xsl:text>
|
|
1530
|
+
<xsl:choose>
|
|
1531
|
+
<xsl:when test="not($mime-type = '')">
|
|
1532
|
+
<xsl:value-of select="translate(substring-after($mime-type, '/'), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
|
|
1533
|
+
<xsl:text> data file not included here</xsl:text>
|
|
1534
|
+
</xsl:when>
|
|
1535
|
+
<xsl:otherwise>
|
|
1536
|
+
<xsl:text>Data file not included here</xsl:text>
|
|
1537
|
+
</xsl:otherwise>
|
|
1538
|
+
</xsl:choose>
|
|
1539
|
+
<xsl:if test="normalize-space(.) != ''">
|
|
1540
|
+
<xsl:text>: "</xsl:text>
|
|
1541
|
+
<xsl:value-of select="normalize-space(.)"/>
|
|
1542
|
+
<xsl:text>"</xsl:text>
|
|
1543
|
+
</xsl:if>
|
|
1544
|
+
<xsl:text>]</xsl:text>
|
|
1545
|
+
</xsl:template>
|
|
1546
|
+
|
|
1547
|
+
<!-- A data file packaged into a document is intended for reader -->
|
|
1548
|
+
<!-- download, which no reading system offers; the reference -->
|
|
1549
|
+
<!-- renders as its visible text, with no dead hyperlink -->
|
|
1550
|
+
<xsl:template match="dataurl[@source and not(@href)]">
|
|
1551
|
+
<xsl:choose>
|
|
1552
|
+
<xsl:when test="node()">
|
|
1553
|
+
<xsl:apply-templates/>
|
|
1554
|
+
</xsl:when>
|
|
1555
|
+
<xsl:otherwise>
|
|
1556
|
+
<xsl:value-of select="@visual"/>
|
|
1557
|
+
</xsl:otherwise>
|
|
1558
|
+
</xsl:choose>
|
|
1559
|
+
</xsl:template>
|
|
1560
|
+
|
|
1336
1561
|
<!-- #### -->
|
|
1337
1562
|
<!-- Math -->
|
|
1338
1563
|
<!-- #### -->
|
|
1339
1564
|
|
|
1340
1565
|
<!-- Pluck SVGs from the file full of them, with matching IDs -->
|
|
1341
1566
|
<xsl:template match="m|md[mrow]">
|
|
1342
|
-
<!-- NB: math-representation file writes with "
|
|
1567
|
+
<!-- NB: math-representation file writes with "unique-id" -->
|
|
1343
1568
|
<xsl:variable name="id">
|
|
1344
1569
|
<xsl:apply-templates select="." mode="unique-id"/>
|
|
1345
1570
|
</xsl:variable>
|
|
@@ -1377,11 +1602,11 @@
|
|
|
1377
1602
|
</xsl:apply-templates>
|
|
1378
1603
|
</xsl:when>
|
|
1379
1604
|
<xsl:when test="$math.format = 'mml'">
|
|
1380
|
-
<xsl:
|
|
1605
|
+
<xsl:apply-templates select="$math/div[@class = 'mathml']/math:math" mode="mml-edit"/>
|
|
1381
1606
|
</xsl:when>
|
|
1382
1607
|
<!-- Kindle does best with MathML format -->
|
|
1383
1608
|
<xsl:when test="$b-kindle">
|
|
1384
|
-
<xsl:
|
|
1609
|
+
<xsl:apply-templates select="$math/div[@class = 'mathml']/math:math" mode="mml-edit"/>
|
|
1385
1610
|
</xsl:when>
|
|
1386
1611
|
<!-- 2020-07-17: reprs needed a new "span.speech" wrapper -->
|
|
1387
1612
|
<xsl:when test="$math.format = 'speech'">
|
|
@@ -1402,6 +1627,21 @@
|
|
|
1402
1627
|
<!-- Identity template as a mode coursing through SVGs -->
|
|
1403
1628
|
<!-- We are stream editing to satisfy the EPUB standard -->
|
|
1404
1629
|
<!-- Mostly killing attrributes -->
|
|
1630
|
+
<!-- MathJax mints an HTML id from an equation's \tag for its own -->
|
|
1631
|
+
<!-- \eqref linking, which PreTeXt never uses; a tag used twice -->
|
|
1632
|
+
<!-- (symbols as tags invite this) would duplicate the id, so -->
|
|
1633
|
+
<!-- they are dropped, from SVG and MathML alike -->
|
|
1634
|
+
<xsl:template match="@id[starts-with(., 'mjx-eqn')]" mode="svg-edit"/>
|
|
1635
|
+
|
|
1636
|
+
<!-- MathML travels nearly as-is: an identity, less the ids -->
|
|
1637
|
+
<xsl:template match="@id[starts-with(., 'mjx-eqn')]" mode="mml-edit"/>
|
|
1638
|
+
|
|
1639
|
+
<xsl:template match="node()|@*" mode="mml-edit">
|
|
1640
|
+
<xsl:copy>
|
|
1641
|
+
<xsl:apply-templates select="node()|@*" mode="mml-edit"/>
|
|
1642
|
+
</xsl:copy>
|
|
1643
|
+
</xsl:template>
|
|
1644
|
+
|
|
1405
1645
|
<xsl:template match="node()|@*" mode="svg-edit">
|
|
1406
1646
|
<xsl:copy>
|
|
1407
1647
|
<xsl:apply-templates select="node()|@*" mode="svg-edit"/>
|