@@ -1356,9 +1356,15 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
13561356<!-- calls the "duplicate-heading" modal template. -->
13571357
13581358<xsl:template match="*" mode="duplicate-heading">
1359+ <!-- If we default b-make-link to true() we could make -->
1360+ <!-- section headings that appear in solutions into -->
1361+ <!-- backlinks to the corresponding sections. As it is -->
1362+ <!-- only exercises etc become backlinks. -->
1363+ <xsl:param name="b-make-link" select="false()"/>
13591364 <xsl:param name="heading-level"/>
13601365 <xsl:param name="heading-stack" select="."/>
13611366 <xsl:apply-templates select="." mode="heading-generic">
1367+ <xsl:with-param name="b-make-link" select="$b-make-link"/>
13621368 <xsl:with-param name="heading-level" select="$heading-level"/>
13631369 <xsl:with-param name="extra-heading-classes">
13641370 <xsl:if test="not(self::chapter) or ($numbering-maxlevel = 0)">
@@ -1993,8 +1999,10 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
19931999<!-- REMARK-LIKE, COMPUTATION-LIKE, DEFINITION-LIKE, SOLUTION-LIKE, objectives (xref-content), outcomes (xref-content), EXAMPLE-LIKE, PROJECT-LIKE, OPENPROBLEM-LIKE, exercise (inline), task (xref-content), fn (xref-content), biblio/note (xref-content)-->
19942000<!-- E.g. Corollary 4.1 (Leibniz, Newton). The fundamental theorem of calculus. -->
19952001<xsl:template match="*" mode="heading-full">
2002+ <xsl:param name="b-make-link" select="false()"/>
19962003 <xsl:param name="heading-level"/>
19972004 <xsl:apply-templates select="." mode="heading-generic">
2005+ <xsl:with-param name="b-make-link" select="$b-make-link"/>
19982006 <xsl:with-param name="heading-level" select="$heading-level"/>
19992007 <xsl:with-param name="heading-title">
20002008 <span class="type">
@@ -2082,11 +2090,13 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
20822090<!-- heading-title: The actual text, including any numbering -->
20832091<!-- heading-attr-title: If provided, a title attribute will be created on the hN tag -->
20842092<!-- extra-heading-classes: Added to the default "heading" class on the hN tag -->
2093+ <!-- b-make-link: Whether to turn the heading into a link to its origin. Used in solutions sections -->
20852094<xsl:template match="*" mode="heading-generic">
20862095 <xsl:param name="heading-level"/>
20872096 <xsl:param name="heading-title"/>
20882097 <xsl:param name="heading-attr-title"/>
20892098 <xsl:param name="extra-heading-classes"/>
2099+ <xsl:param name="b-make-link" select="false()" />
20902100 <xsl:variable name="hN">
20912101 <xsl:apply-templates select="." mode="hN">
20922102 <xsl:with-param name="heading-level" select="$heading-level" />
@@ -2102,16 +2112,30 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
21022112 <xsl:value-of select="$heading-attr-title"/>
21032113 </xsl:attribute>
21042114 </xsl:if>
2105- <xsl:copy-of select="$heading-title"/>
2115+ <xsl:choose>
2116+ <xsl:when test="$b-make-link">
2117+ <xsl:element name="a">
2118+ <xsl:attribute name="href">
2119+ <xsl:apply-templates select="." mode="url"/>
2120+ </xsl:attribute>
2121+ <xsl:copy-of select="$heading-title"/>
2122+ </xsl:element>
2123+ </xsl:when>
2124+ <xsl:otherwise>
2125+ <xsl:copy-of select="$heading-title"/>
2126+ </xsl:otherwise>
2127+ </xsl:choose>
21062128 </xsl:element>
21072129</xsl:template>
21082130
21092131
21102132<!-- hN, no type name, full number, title (if exists) -->
21112133<!-- divisional exercise, principally for solution list -->
21122134<xsl:template match="*" mode="heading-divisional-exercise">
2135+ <xsl:param name="b-make-link" select="false()" />
21132136 <xsl:param name="heading-level"/>
21142137 <xsl:apply-templates select="." mode="heading-generic">
2138+ <xsl:with-param name="b-make-link" select="$b-make-link" />
21152139 <xsl:with-param name="heading-level" select="$heading-level"/>
21162140 <xsl:with-param name="heading-title">
21172141 <span class="codenumber">
@@ -3582,6 +3606,22 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
35823606 </xsl:apply-templates>
35833607</xsl:template>
35843608
3609+ <!-- Used when headings are created in solutions sections, to make them backlinks -->
3610+ <xsl:template match="exercise[boolean(&INLINE-EXERCISE-FILTER;)]" mode="heading-solutions">
3611+ <xsl:param name="heading-level"/>
3612+ <xsl:apply-templates select="." mode="heading-full">
3613+ <xsl:with-param name="heading-level" select="$heading-level"/>
3614+ <xsl:with-param name="b-make-link" select="true()"/>
3615+ </xsl:apply-templates>
3616+ </xsl:template>
3617+ <xsl:template match="exercises//exercise|worksheet//exercise|reading-questions//exercise" mode="heading-solutions">
3618+ <xsl:param name="heading-level"/>
3619+ <xsl:apply-templates select="." mode="heading-divisional-exercise">
3620+ <xsl:with-param name="heading-level" select="$heading-level"/>
3621+ <xsl:with-param name="b-make-link" select="true()"/>
3622+ </xsl:apply-templates>
3623+ </xsl:template>
3624+
35853625<!-- Heading for interior of xref-knowl content -->
35863626<!-- Note match first on inline, then divisional -->
35873627<xsl:template match="exercise[boolean(&INLINE-EXERCISE-FILTER;)]" mode="heading-xref-knowl">
@@ -3748,6 +3788,15 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
37483788 </xsl:apply-templates>
37493789</xsl:template>
37503790
3791+ <!-- When used in solutions -->
3792+ <xsl:template match="&PROJECT-LIKE;" mode="heading-solutions">
3793+ <xsl:param name="heading-level"/>
3794+ <xsl:apply-templates select="." mode="heading-full">
3795+ <xsl:with-param name="heading-level" select="$heading-level"/>
3796+ <xsl:with-param name="b-make-link" select="true()"/>
3797+ </xsl:apply-templates>
3798+ </xsl:template>
3799+
37513800<!-- Heading for interior of xref-knowl content -->
37523801<xsl:template match="&PROJECT-LIKE;" mode="heading-xref-knowl">
37533802 <xsl:apply-templates select="." mode="heading-full" />
@@ -3843,27 +3892,10 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
38433892 </xsl:choose>
38443893 </xsl:attribute>
38453894 <!-- A variety of headings -->
3846- <xsl:choose>
3847- <!-- inline can go with generic, which is switched on inline/divisional -->
3848- <xsl:when test="boolean(&INLINE-EXERCISE-FILTER;)">
3849- <xsl:apply-templates select="." mode="heading-birth">
3850- <xsl:with-param name="heading-level" select="$heading-level"/>
3851- </xsl:apply-templates>
3852- </xsl:when>
3853- <!-- with full number just for solution list -->
3854- <!-- "exercise" must be divisional now -->
3855- <xsl:when test="self::exercise">
3856- <xsl:apply-templates select="." mode="heading-divisional-exercise">
3857- <xsl:with-param name="heading-level" select="$heading-level"/>
3858- </xsl:apply-templates>
3859- </xsl:when>
3860- <!-- now PROJECT-LIKE -->
3861- <xsl:otherwise>
3862- <xsl:apply-templates select="." mode="heading-birth">
3863- <xsl:with-param name="heading-level" select="$heading-level"/>
3864- </xsl:apply-templates>
3865- </xsl:otherwise>
3866- </xsl:choose>
3895+ <xsl:apply-templates select="." mode="heading-solutions">
3896+ <xsl:with-param name="heading-level" select="$heading-level"/>
3897+ </xsl:apply-templates>
3898+
38673899 <xsl:choose>
38683900 <!-- structured version -->
38693901 <xsl:when test="task">
@@ -4093,6 +4125,7 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
40934125 <article class="exercise-like">
40944126 <xsl:apply-templates select="." mode="duplicate-heading">
40954127 <xsl:with-param name="heading-level" select="$heading-level"/>
4128+ <xsl:with-param name="b-make-link" select="true()"/>
40964129 </xsl:apply-templates>
40974130
40984131 <xsl:choose>
0 commit comments