@pretextbook/pretext-html 0.3.0 → 0.4.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.
Files changed (43) hide show
  1. package/README.md +20 -9
  2. package/assets/preview-html.xsl +8 -4
  3. package/assets/upstream.json +1 -1
  4. package/assets/xsl/README.md +25 -24
  5. package/assets/xsl/entities.ent +20 -0
  6. package/assets/xsl/extract-biblio-csl.xsl +1 -1
  7. package/assets/xsl/extract-pg.xsl +111 -297
  8. package/assets/xsl/extract-qrcode.xsl +11 -1
  9. package/assets/xsl/extract-sageplot.xsl +1 -1
  10. package/assets/xsl/latex/pretext-latex-texstyle.xsl +1 -2
  11. package/assets/xsl/localizations/README.md +24 -24
  12. package/assets/xsl/pretext-assembly.xsl +101 -11
  13. package/assets/xsl/pretext-beamer.xsl +43 -146
  14. package/assets/xsl/pretext-braille-preprint.xsl +457 -201
  15. package/assets/xsl/pretext-common.xsl +388 -423
  16. package/assets/xsl/pretext-epub.xsl +301 -72
  17. package/assets/xsl/pretext-fo.xsl +70 -86
  18. package/assets/xsl/pretext-html.xsl +331 -259
  19. package/assets/xsl/pretext-jupyter.xsl +534 -322
  20. package/assets/xsl/pretext-latex-classic.xsl +14 -15
  21. package/assets/xsl/pretext-latex-common.xsl +385 -2389
  22. package/assets/xsl/pretext-latex.xsl +1995 -5
  23. package/assets/xsl/pretext-markdown.xsl +919 -0
  24. package/assets/xsl/pretext-numbers.xsl +22 -4
  25. package/assets/xsl/pretext-revealjs.xsl +241 -33
  26. package/assets/xsl/pretext-runestone-fitb.xsl +20 -22
  27. package/assets/xsl/pretext-runestone.xsl +3 -3
  28. package/assets/xsl/pretext-sage-doctest.xsl +2 -2
  29. package/assets/xsl/pretext-text-utilities.xsl +69 -1
  30. package/assets/xsl/pretext-text.xsl +1077 -107
  31. package/assets/xsl/publisher-variables.xsl +396 -452
  32. package/assets/xsl/support/play-button/README.md +1 -3
  33. package/assets/xsl/tests/README.md +1 -1
  34. package/assets/xsl/utilities/README.md +6 -8
  35. package/assets/xsl/utilities/report-publisher-variables.xsl +15 -0
  36. package/assets/xsl-bundle.json +1 -1
  37. package/dist/{cli-CzoinNle.js → cli-Cp6C0sif.js} +220 -205
  38. package/dist/cli.js +1 -1
  39. package/dist/index.browser.js +351 -342
  40. package/dist/index.js +1 -1
  41. package/dist/publication.d.ts +9 -1
  42. package/dist/renderer.d.ts +20 -0
  43. package/package.json +1 -1
@@ -143,10 +143,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
143
143
  </xsl:choose>
144
144
  </xsl:variable>
145
145
 
146
- <!-- Annotation -->
147
- <xsl:param name="html.annotation" select="''" />
148
- <xsl:variable name="b-activate-hypothesis" select="boolean($html.annotation='hypothesis')" />
149
-
150
146
  <!-- Should we build the SCORM manifest file? -->
151
147
  <xsl:param name="html.scorm" select="'no'" />
152
148
  <!-- b-host-scorm is true when building a SCORM package -->
@@ -187,6 +183,10 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
187
183
  <!-- so lightweight stylesheets can access the same logic. -->
188
184
  <xsl:variable name="chunk-level" select="$html-chunk-level"/>
189
185
 
186
+ <!-- A document with chunking set to 0, or with no chapters or sections -->
187
+ <!-- will be a single page. -->
188
+ <xsl:variable name="b-is-single-page" select="$chunk-level = 0 or ($b-is-article and count($document-root/section) = 0) or ($b-is-book and count($document-root//chapter) = 0)"/>
189
+
190
190
  <!-- HTML files as output -->
191
191
  <xsl:variable name="file-extension" select="'.html'" />
192
192
 
@@ -200,6 +200,10 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
200
200
  <!-- Used to identify if target is reveal.js instead of vanilla html -->
201
201
  <xsl:variable name="b-reveal-build" select="false()" />
202
202
 
203
+ <!-- Standard HTML builds start chunks from level 1. Other builds like epub -->
204
+ <!-- may need a different value. -->
205
+ <xsl:variable name="chunk-heading-level" select="1"/>
206
+
203
207
  <!-- ############### -->
204
208
  <!-- Source Analysis -->
205
209
  <!-- ############### -->
@@ -395,7 +399,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
395
399
  <!-- But first, we see if there is a coding error, due to -->
396
400
  <!-- the critical chunk level variable being overridden -->
397
401
  <xsl:if test="$chunk-level = ''">
398
- <xsl:message>PTX:BUG the $chunk-level variable has been left undefined&#xa;due to a change in a stylesheet that imports the HTML conversion&#xa;and the computation of an index page may fail spectacularly (infinite recursion?)"</xsl:message>
402
+ <xsl:message>PTX:BUG: the $chunk-level variable has been left undefined&#xa;due to a change in a stylesheet that imports the HTML conversion&#xa;and the computation of an index page may fail spectacularly (infinite recursion?)"</xsl:message>
399
403
  </xsl:if>
400
404
  <xsl:variable name="sanitized-ref">
401
405
  <xsl:choose>
@@ -416,7 +420,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
416
420
  <xsl:value-of select="$html-index-page-entered-ref"/>
417
421
  </xsl:when>
418
422
  <xsl:otherwise>
419
- <xsl:message>PTX:WARNING: the requested HTML index page cannot be constructed since "<xsl:value-of select="$html-index-page-entered-ref"/>" is not a complete web page at the current chunking level (level <xsl:value-of select="$chunk-level"/>). Defaults will be used instead</xsl:message>
423
+ <xsl:message>PTX:FALLBACK: the requested HTML index page cannot be constructed since "<xsl:value-of select="$html-index-page-entered-ref"/>" is not a complete web page at the current chunking level (level <xsl:value-of select="$chunk-level"/>). Defaults will be used instead</xsl:message>
420
424
  <xsl:text/>
421
425
  </xsl:otherwise>
422
426
  </xsl:choose>
@@ -487,15 +491,18 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
487
491
  <!-- The "file-wrap" routine should accept a $content -->
488
492
  <!-- parameter holding the contents of the body of the page -->
489
493
 
494
+ <!-- The HTML conversion (and hence its derivatives) opts in -->
495
+ <!-- to "division companion" chunks: introduction, conclusion, -->
496
+ <!-- objectives, outcomes of a division realized as a summary -->
497
+ <!-- page become pages themselves (see pretext-common.xsl) -->
498
+ <xsl:variable name="b-division-companion-chunks" select="true()"/>
499
+
490
500
  <!-- A complete page for a structural division -->
491
- <!-- Unlike the base implemenation in -common we pass a -->
492
- <!-- "heading-level", which begins at 2 to account for an "h1" -->
493
- <!-- being used in the masthead of the page infrastructure. -->
494
501
  <xsl:template match="&STRUCTURAL;" mode="chunk">
495
502
  <xsl:apply-templates select="." mode="file-wrap">
496
503
  <xsl:with-param name="content">
497
504
  <xsl:apply-templates select=".">
498
- <xsl:with-param name="heading-level" select="2"/>
505
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
499
506
  </xsl:apply-templates>
500
507
  </xsl:with-param>
501
508
  <!-- Set b-has-printout to true if the structural node is or contains a worksheet or handout -->
@@ -506,9 +513,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
506
513
  <!-- A summary page for a structural division -->
507
514
  <!-- Processing of a structural node realized as an -->
508
515
  <!-- intermediate/summary node. -->
509
- <!-- We pass in a "heading-level", which begins at 2 to -->
510
- <!-- account for an "h1" being used in the masthead of the -->
511
- <!-- page infrastructure. -->
512
516
  <xsl:template match="&STRUCTURAL;" mode="intermediate">
513
517
  <xsl:apply-templates select="." mode="file-wrap">
514
518
  <xsl:with-param name="content">
@@ -518,15 +522,15 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
518
522
  <section class="{local-name(.)}">
519
523
  <xsl:apply-templates select="." mode="html-id-attribute"/>
520
524
  <xsl:apply-templates select="." mode="section-heading">
521
- <xsl:with-param name="heading-level" select="2"/>
525
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
522
526
  </xsl:apply-templates>
523
527
  <xsl:apply-templates select="." mode="author-byline"/>
524
528
  <!-- Special case when building page for frontmatter without a titlepage -->
525
529
  <xsl:if test="self::frontmatter[not(titlepage)]">
526
530
  <xsl:call-template name="frontmatter-title" />
527
531
  </xsl:if>
528
- <xsl:apply-templates select="objectives|introduction|titlepage|abstract">
529
- <xsl:with-param name="heading-level" select="3"/>
532
+ <xsl:apply-templates select="titlepage|abstract">
533
+ <xsl:with-param name="heading-level" select="$chunk-heading-level + 1"/>
530
534
  </xsl:apply-templates>
531
535
  <!-- Links to subsidiary divisions, as a group of button/hyperlinks -->
532
536
  <nav class="summary-links">
@@ -534,9 +538,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
534
538
  <xsl:apply-templates select="*" mode="summary-nav" />
535
539
  </ul>
536
540
  </nav>
537
- <xsl:apply-templates select="conclusion|outcomes">
538
- <xsl:with-param name="heading-level" select="3"/>
539
- </xsl:apply-templates>
540
541
  <!-- Insert permalink -->
541
542
  <xsl:apply-templates select="." mode="permalink"/>
542
543
  </section>
@@ -571,9 +572,87 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
571
572
  </li>
572
573
  </xsl:template>
573
574
 
574
- <!-- introduction (etc.) and conclusion get dropped -->
575
+ <!-- Division companions become links, like the structural children; -->
576
+ <!-- document order places an "introduction" before the subdivision -->
577
+ <!-- links and a "conclusion" after, with no extra machinery -->
578
+ <xsl:template match="&DIVISION-COMPANION;" mode="summary-nav">
579
+ <!-- a link only when realized as a page (a conversion that -->
580
+ <!-- has not opted in renders no link, and no bare content) -->
581
+ <xsl:variable name="chunk">
582
+ <xsl:apply-templates select="." mode="is-chunk"/>
583
+ </xsl:variable>
584
+ <xsl:if test="$chunk = 'true'">
585
+ <xsl:variable name="url">
586
+ <xsl:apply-templates select="." mode="url" />
587
+ </xsl:variable>
588
+ <li>
589
+ <a href="{$url}" class="internal">
590
+ <span class="title">
591
+ <xsl:apply-templates select="." mode="division-companion-text"/>
592
+ </span>
593
+ </a>
594
+ </li>
595
+ </xsl:if>
596
+ </xsl:template>
597
+
598
+ <!-- everything else on a summary page gets dropped -->
575
599
  <xsl:template match="*" mode="summary-nav" />
576
600
 
601
+ <!-- Text for links (and ToC entries) to a division companion page. -->
602
+ <!-- "introduction"/"conclusion": the localized type-name only (an -->
603
+ <!-- authored title is silently ignored, pending deprecation). -->
604
+ <!-- "objectives"/"outcomes": the localized type-name, plus the -->
605
+ <!-- title when authored, mirroring the inline block headings. -->
606
+ <xsl:template match="introduction|conclusion" mode="division-companion-text">
607
+ <xsl:apply-templates select="." mode="type-name"/>
608
+ </xsl:template>
609
+
610
+ <xsl:template match="objectives|outcomes" mode="division-companion-text">
611
+ <xsl:apply-templates select="." mode="type-name"/>
612
+ <xsl:if test="title">
613
+ <xsl:text>: </xsl:text>
614
+ <xsl:apply-templates select="." mode="title-short"/>
615
+ </xsl:if>
616
+ </xsl:template>
617
+
618
+ <!-- A division companion realized as its own page -->
619
+ <xsl:template match="&DIVISION-COMPANION;" mode="chunk">
620
+ <xsl:apply-templates select="." mode="file-wrap">
621
+ <xsl:with-param name="content">
622
+ <xsl:apply-templates select="." mode="division-companion-page"/>
623
+ </xsl:with-param>
624
+ </xsl:apply-templates>
625
+ </xsl:template>
626
+
627
+ <!-- Page content: a manufactured heading (the link text), then the -->
628
+ <!-- children, much as the inline realization would present them -->
629
+ <xsl:template match="introduction|conclusion" mode="division-companion-page">
630
+ <xsl:text>&#xa;</xsl:text>
631
+ <section>
632
+ <xsl:attribute name="class">
633
+ <xsl:value-of select="local-name(.)" />
634
+ </xsl:attribute>
635
+ <xsl:apply-templates select="." mode="html-id-attribute"/>
636
+ <xsl:apply-templates select="." mode="heading-generic">
637
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
638
+ <xsl:with-param name="heading-title">
639
+ <xsl:apply-templates select="." mode="division-companion-text"/>
640
+ </xsl:with-param>
641
+ </xsl:apply-templates>
642
+ <xsl:apply-templates select="*">
643
+ <xsl:with-param name="heading-level" select="$chunk-heading-level + 1"/>
644
+ </xsl:apply-templates>
645
+ </section>
646
+ </xsl:template>
647
+
648
+ <!-- Page content: the ordinary block realization, whose heading -->
649
+ <!-- already displays the type-name and any authored title -->
650
+ <xsl:template match="objectives|outcomes" mode="division-companion-page">
651
+ <xsl:apply-templates select=".">
652
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
653
+ </xsl:apply-templates>
654
+ </xsl:template>
655
+
577
656
  <!-- Default template for content of a structural -->
578
657
  <!-- division, which could be an entire page's -->
579
658
  <!-- worth, or just a subdivision within a page -->
@@ -632,7 +711,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
632
711
  <xsl:apply-templates select="." mode="author-byline"/>
633
712
  <!-- If there is watermark text, we print it here in an assistive p -->
634
713
  <!-- so that it is the first thing read by a screen-reader user. -->
635
- <xsl:if test="$b-watermark and $heading-level = 2">
714
+ <xsl:if test="$b-watermark and $heading-level = $chunk-heading-level">
636
715
  <p class="watermark">
637
716
  <xsl:text>Watermark text: </xsl:text>
638
717
  <xsl:value-of select="$watermark-text"/>
@@ -646,16 +725,12 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
646
725
  <!-- and the method is defined there. -->
647
726
  <xsl:apply-templates select="." mode="view-source-widget"/>
648
727
 
649
- <!-- This is usually recurrence, so increment heading-level, -->
650
- <!-- but "book" and "article" have an h1 masthead, so if -->
651
- <!-- this is the context, we just pass along the level of -->
652
- <!-- "2" which is supplied by the chunking templates -->
653
- <!-- N.B. the modal "solutions" templates increment -->
654
- <!-- $heading-level as "exercise" are produced, so -->
655
- <!-- we by-pass the increment here. -->
728
+ <!-- The "solutions" modal templates increment $heading-level -->
729
+ <!-- themselves, so bypassing the increment here avoids a skip -->
730
+ <!-- for both a solutions page and an inline "solutions". -->
656
731
  <xsl:variable name="next-level">
657
732
  <xsl:choose>
658
- <xsl:when test="self::book or self::article or self::solutions">
733
+ <xsl:when test="self::solutions">
659
734
  <xsl:value-of select="$heading-level"/>
660
735
  </xsl:when>
661
736
  <xsl:otherwise>
@@ -821,15 +896,47 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
821
896
  </xsl:if>
822
897
  </xsl:template>
823
898
 
824
- <!-- The front and back matter have their own style -->
825
- <xsl:template match="frontmatter|backmatter" mode="section-heading" />
899
+ <!-- The frontmatter has its own style -->
900
+ <xsl:template match="frontmatter" mode="section-heading" />
901
+
902
+ <!-- Fixed header for the backmatter contents. -->
903
+ <!-- We generally will hide this for sighted users. -->
904
+ <xsl:template match="backmatter" mode="section-heading">
905
+ <xsl:if test="not($b-is-single-page)">
906
+ <xsl:variable name="html-heading">
907
+ <xsl:apply-templates select="." mode="html-heading">
908
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
909
+ </xsl:apply-templates>
910
+ </xsl:variable>
911
+ <xsl:element name="{$html-heading}">
912
+ <xsl:attribute name="class">heading ptx-backmatter-heading</xsl:attribute>
913
+ <xsl:apply-templates select="." mode="type-name">
914
+ <xsl:with-param name="string-id" select="'backmatter'"/>
915
+ </xsl:apply-templates>
916
+ </xsl:element>
917
+ </xsl:if>
918
+ </xsl:template>
826
919
 
827
- <!-- A book or article is the top level, so the -->
828
- <!-- masthead might suffice, else an author can -->
829
- <!-- provide a frontmatter/titlepage to provide -->
830
- <!-- more specific information. In either event, -->
831
- <!-- a typical section heading is out of place. -->
832
- <xsl:template match="book|article" mode="section-heading" />
920
+ <!-- A book or article is the top level, using the title would be -->
921
+ <!-- duplicative of the banner. Instead, the page-specific header -->
922
+ <!-- announces that this is the table of contents unless build is -->
923
+ <!-- a single page. -->
924
+ <!-- We generally will hide this for sighted users. -->
925
+ <xsl:template match="book|article" mode="section-heading">
926
+ <xsl:if test="not($b-is-single-page)">
927
+ <xsl:variable name="html-heading">
928
+ <xsl:apply-templates select="." mode="html-heading">
929
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
930
+ </xsl:apply-templates>
931
+ </xsl:variable>
932
+ <xsl:element name="{$html-heading}">
933
+ <xsl:attribute name="class">heading ptx-toc-heading</xsl:attribute>
934
+ <xsl:apply-templates select="." mode="type-name">
935
+ <xsl:with-param name="string-id" select="'toc'"/>
936
+ </xsl:apply-templates>
937
+ </xsl:element>
938
+ </xsl:if>
939
+ </xsl:template>
833
940
 
834
941
  <!-- An abstract needs structure, and an ID for a -->
835
942
  <!-- link out of the ToC sidebar for an article -->
@@ -967,7 +1074,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
967
1074
  <!-- This is all within a .frontmatter class for CSS -->
968
1075
  <xsl:template match="titlepage">
969
1076
  <!-- Use a context-free template to generate -->
970
- <!-- an "h2" title/subtitle heading -->
1077
+ <!-- an "h1" title/subtitle heading -->
971
1078
  <xsl:call-template name="frontmatter-title"/>
972
1079
  <!-- text generator for title page items from "bibinfo" -->
973
1080
  <xsl:apply-templates select="$document-root/frontmatter/titlepage/titlepage-items" />
@@ -988,7 +1095,14 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
988
1095
  <!-- generated by a "frontmatter" element (including, e.g., an intermediate page). -->
989
1096
  <xsl:template name="frontmatter-title">
990
1097
  <xsl:variable name="b-has-subtitle" select="$document-root/subtitle"/>
991
- <h2 class="heading">
1098
+ <!-- heading level should match default chunk heading level -->
1099
+ <xsl:variable name="html-heading">
1100
+ <xsl:apply-templates select="." mode="html-heading">
1101
+ <xsl:with-param name="heading-level" select="$chunk-heading-level"/>
1102
+ </xsl:apply-templates>
1103
+ </xsl:variable>
1104
+ <xsl:element name="{$html-heading}">
1105
+ <xsl:attribute name="class">heading</xsl:attribute>
992
1106
  <span class="title">
993
1107
  <xsl:apply-templates select="$document-root" mode="title-full" />
994
1108
  </span>
@@ -997,7 +1111,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
997
1111
  <xsl:apply-templates select="$document-root" mode="subtitle" />
998
1112
  </span>
999
1113
  </xsl:if>
1000
- </h2>
1114
+ </xsl:element>
1001
1115
  </xsl:template>
1002
1116
 
1003
1117
  <!-- A "credit" required "title" followed by an author (or several) -->
@@ -1161,7 +1275,9 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
1161
1275
 
1162
1276
  <xsl:template match="bibinfo/copyright">
1163
1277
  <div class="para copyright">
1164
- <xsl:call-template name="copyright-character"/>
1278
+ <xsl:call-template name="character">
1279
+ <xsl:with-param name="name" select="'copyright'"/>
1280
+ </xsl:call-template>
1165
1281
  <xsl:apply-templates select="year" />
1166
1282
  <xsl:text> </xsl:text>
1167
1283
  <xsl:apply-templates select="holder" />
@@ -1883,8 +1999,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
1883
1999
  <!-- progression corresponding to "section" and "article" nodes -->
1884
2000
  <!-- of the HTML tree. -->
1885
2001
  <!-- -->
1886
- <!-- We set the "heading-level" to "2" when chunking is initiated, -->
1887
- <!-- since we expect the masthead/banner to contain an "h1". -->
2002
+ <!-- We set the "heading-level" to "1" when chunking is initiated. -->
1888
2003
  <!-- Whenever a template processes its children, we increment the -->
1889
2004
  <!-- variable as we pass it down, so a template receives the correct -->
1890
2005
  <!-- level (and before it ever gets here, since we have consciously -->
@@ -1921,9 +2036,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
1921
2036
 
1922
2037
  <!-- Emit the "hN" tag name for a heading element. Every caller is -->
1923
2038
  <!-- expected to thread a $heading-level parameter through from the -->
1924
- <!-- chunk-template starting point (currently 2, accounting for the -->
1925
- <!-- masthead h1) via "body", "wrapped-content", and the various -->
1926
- <!-- heading-* helper templates. -->
2039
+ <!-- chunk-template starting point. -->
1927
2040
  <xsl:template match="*" mode="hN">
1928
2041
  <xsl:param name="heading-level" />
1929
2042
  <xsl:variable name="actual-heading-level">
@@ -1938,8 +2051,8 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
1938
2051
  <!-- and the various heading-* templates. If you see -->
1939
2052
  <!-- this message, locate the apply-templates chain -->
1940
2053
  <!-- that omitted the parameter and add it. -->
1941
- <xsl:message>PTX:BUG: "hN" template reached without a $heading-level parameter on element &lt;<xsl:value-of select="local-name(.)"/>&gt; at <xsl:for-each select="ancestor::*"><xsl:value-of select="local-name(.)"/><xsl:text>/</xsl:text></xsl:for-each><xsl:value-of select="local-name(.)"/>; defaulting to h2</xsl:message>
1942
- <xsl:text>2</xsl:text>
2054
+ <xsl:message>PTX:BUG: "hN" template reached without a $heading-level parameter on element &lt;<xsl:value-of select="local-name(.)"/>&gt; at <xsl:for-each select="ancestor::*"><xsl:value-of select="local-name(.)"/><xsl:text>/</xsl:text></xsl:for-each><xsl:value-of select="local-name(.)"/>; defaulting to h1</xsl:message>
2055
+ <xsl:text>1</xsl:text>
1943
2056
  </xsl:otherwise>
1944
2057
  </xsl:choose>
1945
2058
  </xsl:variable>
@@ -4335,8 +4448,13 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
4335
4448
  <!-- When born use this heading -->
4336
4449
  <xsl:template match="&SOLUTION-LIKE;" mode="heading-birth">
4337
4450
  <xsl:param name="heading-level"/>
4451
+ <!-- consult the single "heading-birth-is-h" predicate, so the -->
4452
+ <!-- "body" heading-level increment cannot disagree with this -->
4453
+ <xsl:variable name="heads-with-h">
4454
+ <xsl:apply-templates select="." mode="heading-birth-is-h"/>
4455
+ </xsl:variable>
4338
4456
  <xsl:choose>
4339
- <xsl:when test="($knowl-example-solution = 'no') and ancestor::*[&EXAMPLE-FILTER;]">
4457
+ <xsl:when test="$heads-with-h = 'yes'">
4340
4458
  <xsl:apply-templates select="." mode="heading-non-singleton-number">
4341
4459
  <xsl:with-param name="heading-level" select="$heading-level"/>
4342
4460
  </xsl:apply-templates>
@@ -5203,11 +5321,15 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
5203
5321
  <xsl:apply-templates select="." mode="heading-generic">
5204
5322
  <xsl:with-param name="heading-level" select="$heading-level"/>
5205
5323
  <xsl:with-param name="heading-title">
5206
- <xsl:call-template name="langle-character"/>
5324
+ <xsl:call-template name="character">
5325
+ <xsl:with-param name="name" select="'langle'"/>
5326
+ </xsl:call-template>
5207
5327
  <xsl:apply-templates select="." mode="number"/>
5208
5328
  <xsl:text> </xsl:text>
5209
5329
  <xsl:apply-templates select="." mode="title-full"/>
5210
- <xsl:call-template name="rangle-character"/>
5330
+ <xsl:call-template name="character">
5331
+ <xsl:with-param name="name" select="'rangle'"/>
5332
+ </xsl:call-template>
5211
5333
  <!-- U+2261 ≡ IDENTICAL TO -->
5212
5334
  <xsl:text> &#x2261;</xsl:text>
5213
5335
  </xsl:with-param>
@@ -5244,6 +5366,29 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
5244
5366
  <!-- are in the order presented above: simple first, -->
5245
5367
  <!-- and top-down when components are also knowled. -->
5246
5368
 
5369
+ <!-- Does a block's "heading-birth" emit an actual "h" at its -->
5370
+ <!-- level? Consulted by the "body" increment and the "solution" -->
5371
+ <!-- heading-birth so their notion of an "h" heading stays one. -->
5372
+ <xsl:template match="*" mode="heading-birth-is-h">
5373
+ <xsl:text>yes</xsl:text>
5374
+ </xsl:template>
5375
+
5376
+ <xsl:template match="&FIGURE-LIKE;" mode="heading-birth-is-h">
5377
+ <xsl:text>no</xsl:text>
5378
+ </xsl:template>
5379
+
5380
+ <xsl:template match="&SOLUTION-LIKE;" mode="heading-birth-is-h">
5381
+ <xsl:choose>
5382
+ <!-- an example's solution, shown un-knowled, is a numbered "h" -->
5383
+ <xsl:when test="($knowl-example-solution = 'no') and ancestor::*[&EXAMPLE-FILTER;]">
5384
+ <xsl:text>yes</xsl:text>
5385
+ </xsl:when>
5386
+ <xsl:otherwise>
5387
+ <xsl:text>no</xsl:text>
5388
+ </xsl:otherwise>
5389
+ </xsl:choose>
5390
+ </xsl:template>
5391
+
5247
5392
 
5248
5393
  <xsl:template match="&REMARK-LIKE;|&COMPUTATION-LIKE;|&DEFINITION-LIKE;|&ASIDE-LIKE;|poem|&FIGURE-LIKE;|assemblage|blockquote|paragraphs|&GOAL-LIKE;|&OPENPROBLEM-LIKE;|&EXAMPLE-LIKE;|subexercises|exercisegroup|exercise|&PROJECT-LIKE;|task|&SOLUTION-LIKE;|&DISCUSSION-LIKE;|&THEOREM-LIKE;|&AXIOM-LIKE;|&PROOF-LIKE;|case|fn|contributor|biblio|biblio/note|interactive/instructions|fragment" mode="body">
5249
5394
  <xsl:param name="b-original" select="true()"/>
@@ -5296,11 +5441,25 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
5296
5441
  <xsl:apply-templates select="." mode="view-source-widget"/>
5297
5442
  <!-- Then actual content, respecting b-original flag -->
5298
5443
  <!-- Pass $block-type for Sage cells to know environs -->
5299
- <!-- Increment heading-level for descendant blocks -->
5444
+ <!-- Descendant blocks step down a heading level, unless -->
5445
+ <!-- this block heads with something other than an "h"; -->
5446
+ <!-- the "heading-birth-is-h" predicate decides. -->
5447
+ <xsl:variable name="heads-with-h">
5448
+ <xsl:apply-templates select="." mode="heading-birth-is-h"/>
5449
+ </xsl:variable>
5300
5450
  <xsl:apply-templates select="." mode="wrapped-content">
5301
5451
  <xsl:with-param name="b-original" select="$b-original" />
5302
5452
  <xsl:with-param name="block-type" select="$block-type" />
5303
- <xsl:with-param name="heading-level" select="$heading-level + 1"/>
5453
+ <xsl:with-param name="heading-level">
5454
+ <xsl:choose>
5455
+ <xsl:when test="$heads-with-h = 'no'">
5456
+ <xsl:value-of select="$heading-level"/>
5457
+ </xsl:when>
5458
+ <xsl:otherwise>
5459
+ <xsl:value-of select="$heading-level + 1"/>
5460
+ </xsl:otherwise>
5461
+ </xsl:choose>
5462
+ </xsl:with-param>
5304
5463
  </xsl:apply-templates>
5305
5464
  <!-- Apply workspace div (but not in project, exercises or tasks, -->
5306
5465
  <!-- since they get them applied in their exercise-content -->
@@ -6400,7 +6559,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
6400
6559
  </xsl:when>
6401
6560
  <!-- failure -->
6402
6561
  <xsl:otherwise>
6403
- <xsl:message>PTX:ERROR: the Asymptote diagram produced in "<xsl:value-of select="$image-xml"/>" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its width cannot be determined (which you might report as a bug). We might be able to proceed as if the diagram is square, but results can be unpredictable.</xsl:message>
6562
+ <xsl:message>PTX:FALLBACK: the Asymptote diagram produced in "<xsl:value-of select="$image-xml"/>" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its width cannot be determined (which you might report as a bug). We might be able to proceed as if the diagram is square, but results can be unpredictable.</xsl:message>
6404
6563
  <!-- reasonable guess at points/pixels -->
6405
6564
  <xsl:text>400</xsl:text>
6406
6565
  </xsl:otherwise>
@@ -6422,7 +6581,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
6422
6581
  </xsl:when>
6423
6582
  <!-- failure -->
6424
6583
  <xsl:otherwise>
6425
- <xsl:message>PTX:ERROR: the Asymptote diagram produced in "<xsl:value-of select="$image-xml"/>" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its height cannot be determined (which you might report as a bug). We might be able to proceed as if the diagram is square, but results can be unpredictable.</xsl:message>
6584
+ <xsl:message>PTX:FALLBACK: the Asymptote diagram produced in "<xsl:value-of select="$image-xml"/>" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its height cannot be determined (which you might report as a bug). We might be able to proceed as if the diagram is square, but results can be unpredictable.</xsl:message>
6426
6585
  <!-- reasonable guess at points/pixels -->
6427
6586
  <xsl:text>400</xsl:text>
6428
6587
  </xsl:otherwise>
@@ -6941,11 +7100,13 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
6941
7100
  </xsl:element>
6942
7101
  </xsl:template>
6943
7102
 
6944
- <!-- We take in all three rows and package -->
6945
- <!-- them up inside an overriding "sidebyside" -->
6946
- <!-- div containing three "sbsrow" divs. Purely -->
6947
- <!-- a container, never a target, so no xml:id -->
6948
- <!-- in source, so no HTML id on div.sidebyside -->
7103
+ <!-- The finished panels arrive as one opaque fragment and are -->
7104
+ <!-- copied, untouched, into a "sidebyside" div holding a single -->
7105
+ <!-- "sbsrow" grid div. All layout (margins, column widths, column -->
7106
+ <!-- gap) is declared as CSS on the containers, so wrapping the -->
7107
+ <!-- panels as a unit is exactly the right granularity. Purely a -->
7108
+ <!-- container, never a target, so no xml:id in source, no HTML id -->
7109
+ <!-- on the div. -->
6949
7110
  <xsl:template match="sidebyside" mode="compose-panels">
6950
7111
  <xsl:param name="layout" />
6951
7112
  <xsl:param name="panels" />
@@ -7248,11 +7409,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
7248
7409
  <!-- this *must* be first for maximum utility -->
7249
7410
  <xsl:call-template name="skip-to-content-link" />
7250
7411
  <xsl:apply-templates select="." mode="latex-macros" />
7251
- <header id="ptx-masthead" class="ptx-masthead">
7412
+ <header id="ptx-masthead" class="ptx-masthead" role="banner">
7252
7413
  <div class="ptx-banner">
7253
7414
  <xsl:call-template name="brand-logo" />
7254
7415
  <div class="title-container">
7255
- <h1 class="heading">
7416
+ <div class="heading ptx-banner-heading">
7256
7417
  <xsl:variable name="root-filename">
7257
7418
  <xsl:apply-templates select="$document-root" mode="containing-filename" />
7258
7419
  </xsl:variable>
@@ -7270,7 +7431,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
7270
7431
  </span>
7271
7432
  </xsl:if>
7272
7433
  </a>
7273
- </h1>
7434
+ </div>
7274
7435
  <!-- Serial list of authors/editors -->
7275
7436
  <xsl:if test="$b-html-banner-byline">
7276
7437
  <p class="byline">
@@ -8688,56 +8849,6 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
8688
8849
  </s>
8689
8850
  </xsl:template>
8690
8851
 
8691
- <!-- Copyright symbol -->
8692
- <xsl:template name="copyright-character">
8693
- <xsl:text>&#xa9;</xsl:text>
8694
- </xsl:template>
8695
-
8696
- <!-- Phonomark symbol -->
8697
- <xsl:template name="phonomark-character">
8698
- <xsl:text>&#x2117;</xsl:text>
8699
- </xsl:template>
8700
-
8701
- <!-- Copyleft symbol -->
8702
- <!-- May not be universally available in fonts -->
8703
- <!-- Open C (U+254) plus Combining Circle (U+20dd) can imitate -->
8704
- <xsl:template name="copyleft-character">
8705
- <xsl:text>&#x1f12f;</xsl:text>
8706
- </xsl:template>
8707
-
8708
- <!-- Registered symbol -->
8709
- <!-- Bringhurst: should be superscript -->
8710
- <!-- We consider it a font mistake if not superscripted, -->
8711
- <!-- since if we use a "sup" tag then a correct font will -->
8712
- <!-- get way too small -->
8713
- <xsl:template name="registered-character">
8714
- <xsl:text>&#xae;</xsl:text>
8715
- </xsl:template>
8716
-
8717
- <!-- Trademark symbol -->
8718
- <xsl:template name="trademark-character">
8719
- <xsl:text>&#x2122;</xsl:text>
8720
- </xsl:template>
8721
-
8722
- <!-- Servicemark symbol -->
8723
- <xsl:template name="servicemark-character">
8724
- <xsl:text>&#x2120;</xsl:text>
8725
- </xsl:template>
8726
-
8727
- <!-- Degree -->
8728
- <xsl:template name="degree-character">
8729
- <xsl:text>&#xb0;</xsl:text>
8730
- </xsl:template>
8731
-
8732
- <!-- Prime -->
8733
- <xsl:template name="prime-character">
8734
- <xsl:text>&#x2032;</xsl:text>
8735
- </xsl:template>
8736
-
8737
- <xsl:template name="dblprime-character">
8738
- <xsl:text>&#x2033;</xsl:text>
8739
- </xsl:template>
8740
-
8741
8852
  <!-- Characters for Tagging Equations -->
8742
8853
 
8743
8854
  <!-- 'SIX POINTED BLACK STAR' (U+2736) -->
@@ -9033,110 +9144,9 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
9033
9144
  </xsl:apply-templates>
9034
9145
  </xsl:template>
9035
9146
 
9036
- <!-- Left Double Bracket -->
9037
- <!-- MATHEMATICAL LEFT WHITE SQUARE BRACKET -->
9038
- <xsl:template name="ldblbracket-character">
9039
- <xsl:text>&#x27e6;</xsl:text>
9040
- </xsl:template>
9041
-
9042
- <!-- Right Double Bracket -->
9043
- <!-- MATHEMATICAL RIGHT WHITE SQUARE BRACKET -->
9044
- <xsl:template name="rdblbracket-character">
9045
- <xsl:text>&#x27e7;</xsl:text>
9046
- </xsl:template>
9047
-
9048
- <!-- Left Angle Bracket -->
9049
- <!-- LEFT ANGLE BRACKET -->
9050
- <!-- U+2329 was once used and caused a validator warning -->
9051
- <!-- "Text run is not in Unicode Normalization Form C" (NFC) -->
9052
- <xsl:template name="langle-character">
9053
- <xsl:text>&#x3008;</xsl:text>
9054
- </xsl:template>
9055
-
9056
- <!-- Right Angle Bracket -->
9057
- <!-- RIGHT ANGLE BRACKET -->
9058
- <!-- U+232A was once used and caused a validator warning -->
9059
- <!-- "Text run is not in Unicode Normalization Form C" (NFC) -->
9060
- <xsl:template name="rangle-character">
9061
- <xsl:text>&#x3009;</xsl:text>
9062
- </xsl:template>
9063
-
9064
9147
 
9065
9148
  <!-- Other Miscellaneous Symbols, Constructions -->
9066
9149
 
9067
- <!-- Ellipsis (dots), for text, not math -->
9068
- <xsl:template name="ellipsis-character">
9069
- <xsl:text>&#x2026;</xsl:text>
9070
- </xsl:template>
9071
-
9072
- <!-- Midpoint -->
9073
- <!-- A centered dot used sometimes like a decorative dash -->
9074
- <!-- Bringhurst: Not Unicode +387, "GREEK ANO TELEIA" -->
9075
- <xsl:template name="midpoint-character">
9076
- <xsl:text>&#xb7;</xsl:text>
9077
- </xsl:template>
9078
-
9079
- <!-- Swung Dash -->
9080
- <!-- A decorative dash, like a tilde, but bigger, and centered -->
9081
- <xsl:template name="swungdash-character">
9082
- <xsl:text>&#x2053;</xsl:text>
9083
- </xsl:template>
9084
-
9085
- <!-- Per Mille -->
9086
- <!-- Or, per thousand, like a percent sign -->
9087
- <xsl:template name="permille-character">
9088
- <xsl:text>&#x2030;</xsl:text>
9089
- </xsl:template>
9090
-
9091
- <!-- Pilcrow -->
9092
- <!-- Often used to mark the start of a paragraph -->
9093
- <xsl:template name="pilcrow-character">
9094
- <xsl:text>&#xb6;</xsl:text>
9095
- </xsl:template>
9096
-
9097
- <!-- Section Mark -->
9098
- <!-- The stylized double-S to indicate section numbers -->
9099
- <xsl:template name="section-mark-character">
9100
- <xsl:text>&#xa7;</xsl:text>
9101
- </xsl:template>
9102
-
9103
- <!-- Minus -->
9104
- <!-- A hyphen/dash for use in text as subtraction or negation-->
9105
- <xsl:template name="minus-character">
9106
- <xsl:text>&#x2212;</xsl:text>
9107
- </xsl:template>
9108
-
9109
- <!-- Times -->
9110
- <!-- A "multiplication sign" symbol for use in text -->
9111
- <!-- Styled to enhance, consensus at Google Group was -->
9112
- <!-- font-size: larger; vertical-align: -.2ex; -->
9113
- <xsl:template name="times-character">
9114
- <xsl:element name="span">
9115
- <xsl:attribute name="class">
9116
- <xsl:text>times-sign</xsl:text>
9117
- </xsl:attribute>
9118
- <xsl:text>&#xd7;</xsl:text>
9119
- </xsl:element>
9120
- </xsl:template>
9121
-
9122
- <!-- Solidus -->
9123
- <!-- Fraction bar, not as steep as a forward slash -->
9124
- <xsl:template name="solidus-character">
9125
- <xsl:text>&#x2044;</xsl:text>
9126
- </xsl:template>
9127
-
9128
- <!-- Obelus -->
9129
- <!-- A "division" symbol for use in text -->
9130
- <xsl:template name="obelus-character">
9131
- <xsl:text>&#xf7;</xsl:text>
9132
- </xsl:template>
9133
-
9134
- <!-- Plus/Minus -->
9135
- <!-- The combined symbol -->
9136
- <xsl:template name="plusminus-character">
9137
- <xsl:text>&#xb1;</xsl:text>
9138
- </xsl:template>
9139
-
9140
9150
  <!-- Foreign words/idioms -->
9141
9151
  <!-- Rutter, Web Typography, p.50 advocates a "span" with -->
9142
9152
  <!-- a "lang" attribute for foreign words so screen readers -->
@@ -9331,35 +9341,34 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
9331
9341
  <!-- Special Characters -->
9332
9342
  <!-- ################## -->
9333
9343
 
9334
- <!-- These are specific instances of abstract templates -->
9335
- <!-- See the similar section of pretext-common.xsl for more -->
9336
-
9337
- <!-- Non-breaking space, which "joins" two words as a unit -->
9338
- <!-- Using &nbsp; does not travel well into node-set() in common file -->
9339
- <!-- http://stackoverflow.com/questions/31870 -->
9340
- <!-- /using-a-html-entity-in-xslt-e-g-nbsp -->
9341
- <!-- Should create UTF-8 anyway: -->
9342
- <!-- https://html.spec.whatwg.org/multipage/semantics.html#charset -->
9343
-
9344
- <xsl:template name="nbsp-character">
9345
- <xsl:text>&#xa0;</xsl:text>
9346
- </xsl:template>
9347
-
9348
- <xsl:template name="ndash-character">
9349
- <xsl:text>&#8211;</xsl:text>
9350
- </xsl:template>
9344
+ <!-- Each character is the bare Unicode code point, read from the -->
9345
+ <!-- representation table in pretext-common.xsl; an exception -->
9346
+ <!-- needing markup overrides the modal template, per character -->
9351
9347
 
9352
- <xsl:template name="mdash-character">
9353
- <xsl:text>&#8212;</xsl:text>
9348
+ <xsl:template match="char" mode="character">
9349
+ <xsl:choose>
9350
+ <xsl:when test="@unicode">
9351
+ <xsl:value-of select="@unicode"/>
9352
+ </xsl:when>
9353
+ <xsl:otherwise>
9354
+ <xsl:call-template name="warn-unimplemented-character">
9355
+ <xsl:with-param name="char-name" select="@name"/>
9356
+ </xsl:call-template>
9357
+ </xsl:otherwise>
9358
+ </xsl:choose>
9354
9359
  </xsl:template>
9355
9360
 
9356
- <!-- The abstract template for "mdash" consults a publisher option -->
9357
- <!-- for thin space, or no space, surrounding an em-dash. So the -->
9358
- <!-- "thin-space-character" is needed for that purpose, and does -->
9359
- <!-- not have an associated empty PTX element. -->
9360
-
9361
- <xsl:template name="thin-space-character">
9362
- <xsl:text>&#8201;</xsl:text>
9361
+ <!-- Times -->
9362
+ <!-- A "multiplication sign" symbol for use in text -->
9363
+ <!-- Styled to enhance, consensus at Google Group was -->
9364
+ <!-- font-size: larger; vertical-align: -.2ex; -->
9365
+ <xsl:template match="char[@name = 'times']" mode="character">
9366
+ <xsl:element name="span">
9367
+ <xsl:attribute name="class">
9368
+ <xsl:text>times-sign</xsl:text>
9369
+ </xsl:attribute>
9370
+ <xsl:text>&#xd7;</xsl:text>
9371
+ </xsl:element>
9363
9372
  </xsl:template>
9364
9373
 
9365
9374
  <!-- -->
@@ -9464,7 +9473,9 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
9464
9473
  <xsl:template match="fragref">
9465
9474
  <xsl:variable name="target" select="id(@ref)"/>
9466
9475
  <span>
9467
- <xsl:call-template name="langle-character"/>
9476
+ <xsl:call-template name="character">
9477
+ <xsl:with-param name="name" select="'langle'"/>
9478
+ </xsl:call-template>
9468
9479
  <xsl:apply-templates select="." mode="xref-link">
9469
9480
  <xsl:with-param name="target" select="$target" />
9470
9481
  <!-- "fragref" is isomorpic to "xref" as a link -->
@@ -9475,7 +9486,9 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
9475
9486
  </xsl:apply-templates>
9476
9487
  <xsl:text> </xsl:text>
9477
9488
  <xsl:apply-templates select="$target" mode="number"/>
9478
- <xsl:call-template name="rangle-character"/>
9489
+ <xsl:call-template name="character">
9490
+ <xsl:with-param name="name" select="'rangle'"/>
9491
+ </xsl:call-template>
9479
9492
  </span>
9480
9493
  <br/>
9481
9494
  </xsl:template>
@@ -9836,14 +9849,12 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
9836
9849
  </xsl:apply-templates>
9837
9850
  <!-- (2) Identical content, but now isolated on a reader-friendly page -->
9838
9851
  <!-- (we skip this for portable html) -->
9839
- <!-- The standalone page has its own masthead h1, so headings inside -->
9840
- <!-- start fresh at h2. -->
9841
9852
  <xsl:if test="not($b-portable-html)">
9842
9853
  <xsl:apply-templates select="." mode="standalone-page" >
9843
9854
  <xsl:with-param name="content">
9844
9855
  <xsl:apply-templates select="." mode="interactive-core">
9845
9856
  <xsl:with-param name="is-standalone" select="true()"/>
9846
- <xsl:with-param name="heading-level" select="2"/>
9857
+ <xsl:with-param name="heading-level" select="1"/>
9847
9858
  </xsl:apply-templates>
9848
9859
  </xsl:with-param>
9849
9860
  </xsl:apply-templates>
@@ -10462,7 +10473,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
10462
10473
  <xsl:text>",&#xa;</xsl:text>
10463
10474
  </xsl:when>
10464
10475
  <xsl:when test="@geogebra">
10465
- <xsl:message>PTX Warning: "geogebra" attribute on "slate" element is deprecated; use "material" attribute</xsl:message>
10476
+ <xsl:message>PTX:DEPRECATE: "geogebra" attribute on "slate" element is deprecated; use "material" attribute</xsl:message>
10466
10477
  <xsl:text>material_id:"</xsl:text>
10467
10478
  <xsl:value-of select="@geogebra" />
10468
10479
  <xsl:text>",&#xa;</xsl:text>
@@ -11523,11 +11534,15 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11523
11534
  <!-- this *must* be first for maximum utility -->
11524
11535
  <xsl:call-template name="skip-to-content-link" />
11525
11536
  <!-- HTML5 body/header will be a "banner" landmark automatically -->
11526
- <header id="ptx-masthead" class="ptx-masthead">
11537
+ <header id="ptx-masthead" class="ptx-masthead" role="banner">
11527
11538
  <div class="ptx-banner">
11528
11539
  <xsl:call-template name="brand-logo" />
11529
11540
  <div class="title-container">
11530
- <h1 class="heading">
11541
+ <xsl:variable name="banner-heading-element-type">
11542
+ <xsl:apply-templates select="." mode="banner-heading-element-type"/>
11543
+ </xsl:variable>
11544
+ <xsl:element name="{$banner-heading-element-type}">
11545
+ <xsl:attribute name="class">heading ptx-banner-heading</xsl:attribute>
11531
11546
  <xsl:variable name="root-filename">
11532
11547
  <xsl:apply-templates select="$document-root" mode="containing-filename" />
11533
11548
  </xsl:variable>
@@ -11545,7 +11560,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11545
11560
  </span>
11546
11561
  </xsl:if>
11547
11562
  </a>
11548
- </h1>
11563
+ </xsl:element>
11549
11564
  <!-- Serial list of authors/editors -->
11550
11565
  <xsl:if test="$b-html-banner-byline">
11551
11566
  <p class="byline">
@@ -11554,7 +11569,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11554
11569
  </p>
11555
11570
  </xsl:if>
11556
11571
  </div> <!-- title-container -->
11557
- </div> <!-- banner -->
11572
+ </div> <!-- banner -->
11558
11573
  </header> <!-- masthead -->
11559
11574
  <xsl:apply-templates select="." mode="primary-navigation"/>
11560
11575
  <xsl:apply-templates select="." mode="latex-macros"/>
@@ -11618,6 +11633,24 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11618
11633
  </exsl:document>
11619
11634
  </xsl:template>
11620
11635
 
11636
+ <!-- Most pages get a plain div for the banner title element as content will have an h1 -->
11637
+ <xsl:template match="*" mode="banner-heading-element-type">
11638
+ <xsl:text>div</xsl:text>
11639
+ </xsl:template>
11640
+
11641
+ <!-- Root page for a single page document needs h1 as the banner title element -->
11642
+ <!-- as there will not be on in page contents. -->
11643
+ <xsl:template match="book|article" mode="banner-heading-element-type">
11644
+ <xsl:choose>
11645
+ <xsl:when test="$b-is-single-page">
11646
+ <xsl:text>h1</xsl:text>
11647
+ </xsl:when>
11648
+ <xsl:otherwise>
11649
+ <xsl:text>div</xsl:text>
11650
+ </xsl:otherwise>
11651
+ </xsl:choose>
11652
+ </xsl:template>
11653
+
11621
11654
  <!-- Templates that can be overriden to inject into various -->
11622
11655
  <!-- points in the HTML page. See file-wrap above for locations. -->
11623
11656
  <xsl:template match="*" mode="file-wrap-head-pre"/>
@@ -11906,15 +11939,25 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11906
11939
 
11907
11940
  <!-- TODO: perhaps isolate logic to return nodes and put into "common" -->
11908
11941
 
11942
+ <!-- Is a node a unit of the linear page order? The structural -->
11943
+ <!-- nodes are; so is a division companion realized as a page -->
11944
+ <xsl:template match="*" mode="is-linear-unit">
11945
+ <xsl:apply-templates select="." mode="is-structural"/>
11946
+ </xsl:template>
11947
+
11948
+ <xsl:template match="&DIVISION-COMPANION;" mode="is-linear-unit">
11949
+ <xsl:apply-templates select="." mode="is-chunk"/>
11950
+ </xsl:template>
11951
+
11909
11952
  <!-- Check if the XML tree has a preceding/following/parent node -->
11910
- <!-- Then check if it is a document node (structural) -->
11953
+ <!-- Then check if it is a page of the reading order -->
11911
11954
  <!-- If so, compute the URL for the node -->
11912
11955
  <!-- NB: tree urls maybe enabled as a processing option -->
11913
11956
  <xsl:template match="*" mode="previous-tree-url">
11914
11957
  <xsl:if test="preceding-sibling::*">
11915
11958
  <xsl:variable name="preceding" select="preceding-sibling::*[1]" />
11916
11959
  <xsl:variable name="structural">
11917
- <xsl:apply-templates select="$preceding" mode="is-structural" />
11960
+ <xsl:apply-templates select="$preceding" mode="is-linear-unit" />
11918
11961
  </xsl:variable>
11919
11962
  <xsl:if test="$structural='true'">
11920
11963
  <xsl:apply-templates select="$preceding" mode="url" />
@@ -11927,7 +11970,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11927
11970
  <xsl:if test="following-sibling::*">
11928
11971
  <xsl:variable name="following" select="following-sibling::*[1]" />
11929
11972
  <xsl:variable name="structural">
11930
- <xsl:apply-templates select="$following" mode="is-structural" />
11973
+ <xsl:apply-templates select="$following" mode="is-linear-unit" />
11931
11974
  </xsl:variable>
11932
11975
  <xsl:if test="$structural='true'">
11933
11976
  <xsl:apply-templates select="$following" mode="url" />
@@ -11965,11 +12008,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11965
12008
  <xsl:choose>
11966
12009
  <xsl:when test="$intermediate='true'">
11967
12010
  <!-- Descend once, will always have a child that is structural -->
11968
- <xsl:variable name="first-structural-child" select="*[&STRUCTURAL-FILTER;][1]" />
12011
+ <xsl:variable name="first-structural-child" select="*[&STRUCTURAL-FILTER; or ($b-division-companion-chunks and (&DIVISION-COMPANION-FILTER;))][1]" />
11969
12012
  <xsl:apply-templates select="$first-structural-child" mode="url" />
11970
12013
  <!-- remainder is a basic check, could be removed -->
11971
12014
  <xsl:variable name="structural">
11972
- <xsl:apply-templates select="$first-structural-child" mode="is-structural" />
12015
+ <xsl:apply-templates select="$first-structural-child" mode="is-linear-unit" />
11973
12016
  </xsl:variable>
11974
12017
  <xsl:if test="$structural='false'">
11975
12018
  <xsl:message>PTX:ERROR: descending into first node of an intermediate page (<xsl:value-of select="local-name($first-structural-child)" />) that is non-structural; maybe your source has incorrect structure</xsl:message>
@@ -11990,7 +12033,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
11990
12033
  <xsl:if test="following-sibling::*">
11991
12034
  <xsl:variable name="following" select="following-sibling::*[1]" />
11992
12035
  <xsl:variable name="structural">
11993
- <xsl:apply-templates select="$following" mode="is-structural" />
12036
+ <xsl:apply-templates select="$following" mode="is-linear-unit" />
11994
12037
  </xsl:variable>
11995
12038
  <xsl:if test="$structural='true'">
11996
12039
  <!-- A normal sibling following -->
@@ -12024,7 +12067,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
12024
12067
  <xsl:if test="preceding-sibling::*">
12025
12068
  <xsl:variable name="preceding" select="preceding-sibling::*[1]" />
12026
12069
  <xsl:variable name="structural">
12027
- <xsl:apply-templates select="$preceding" mode="is-structural" />
12070
+ <xsl:apply-templates select="$preceding" mode="is-linear-unit" />
12028
12071
  </xsl:variable>
12029
12072
  <xsl:if test="$structural='true'">
12030
12073
  <!-- A normal sibling precedin, result is just a sentinel-->
@@ -12064,11 +12107,11 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
12064
12107
  <xsl:apply-templates select="." mode="url" />
12065
12108
  </xsl:when>
12066
12109
  <xsl:otherwise>
12067
- <xsl:variable name="last-structural-child" select="*[&STRUCTURAL-FILTER;][last()]" />
12110
+ <xsl:variable name="last-structural-child" select="*[&STRUCTURAL-FILTER; or ($b-division-companion-chunks and (&DIVISION-COMPANION-FILTER;))][last()]" />
12068
12111
  <xsl:apply-templates select="$last-structural-child" mode="previous-descent-url" />
12069
12112
  <!-- remainder is a basic check, could be removed -->
12070
12113
  <xsl:variable name="structural">
12071
- <xsl:apply-templates select="$last-structural-child" mode="is-structural" />
12114
+ <xsl:apply-templates select="$last-structural-child" mode="is-linear-unit" />
12072
12115
  </xsl:variable>
12073
12116
  <xsl:if test="$structural='false'">
12074
12117
  <xsl:message>PTX:ERROR: descending into last node of an intermediate page (<xsl:value-of select="local-name($last-structural-child)" />) that is non-structural</xsl:message>
@@ -12926,6 +12969,35 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
12926
12969
  </li>
12927
12970
  </xsl:template>
12928
12971
 
12972
+ <!-- A division companion earns a ToC entry when it is a page -->
12973
+ <xsl:template match="&DIVISION-COMPANION;" mode="toc-item">
12974
+ <xsl:variable name="chunk">
12975
+ <xsl:apply-templates select="." mode="is-chunk"/>
12976
+ </xsl:variable>
12977
+ <xsl:if test="$chunk = 'true'">
12978
+ <xsl:variable name="the-url">
12979
+ <xsl:apply-templates select="." mode="url"/>
12980
+ </xsl:variable>
12981
+ <li>
12982
+ <xsl:attribute name="class">
12983
+ <xsl:text>toc-item toc-</xsl:text>
12984
+ <xsl:value-of select="local-name()"/>
12985
+ </xsl:attribute>
12986
+ <!-- copy id of this li for use in customization pass -->
12987
+ <xsl:attribute name="uid">
12988
+ <xsl:value-of select="@unique-id"/>
12989
+ </xsl:attribute>
12990
+ <div class="toc-title-box">
12991
+ <a href="{$the-url}" class="internal">
12992
+ <span class="title">
12993
+ <xsl:apply-templates select="." mode="division-companion-text"/>
12994
+ </span>
12995
+ </a>
12996
+ </div>
12997
+ </li>
12998
+ </xsl:if>
12999
+ </xsl:template>
13000
+
12929
13001
  <!-- Recurse through un-interesting elements -->
12930
13002
  <!-- NB: pass along current page -->
12931
13003
  <!-- Will pickup blocks, etc on unstructured divisions while picking up specialized divisions -->