Skip to content

Commit 439ae13

Browse files
author
Sanders Kleinfeld
committed
Merge pull request #145 from oreillymedia/toc-refactor
Tocgen template refactor
2 parents 55820a6 + a3f7777 commit 439ae13

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

htmlbook-xsl/tocgen.xsl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
<!-- Default rule for TOC generation -->
1515
<xsl:template match="*" mode="tocgen">
1616
<xsl:param name="toc.section.depth" select="$toc.section.depth"/>
17-
<xsl:apply-templates select="*" mode="tocgen"/>
17+
<xsl:apply-templates select="*" mode="tocgen">
18+
<xsl:with-param name="toc.section.depth" select="$toc.section.depth"/>
19+
</xsl:apply-templates>
1820
</xsl:template>
1921

2022
<xsl:template match="h:section[not(@data-type = 'dedication' or @data-type = 'titlepage' or @data-type = 'toc' or @data-type = 'colophon' or @data-type = 'copyright-page' or @data-type = 'halftitlepage')]|h:div[@data-type='part']" mode="tocgen">
@@ -48,7 +50,9 @@
4850
<!-- Make sure there are descendants that conform to $toc.section.depth restrictions before generating nested TOC <ol> -->
4951
<xsl:if test="descendant::h:section[not(contains(@data-type, 'sect')) or htmlbook:section-depth(.) &lt;= $toc.section.depth]|descendant::h:div[@data-type='part']">
5052
<ol>
51-
<xsl:apply-templates mode="tocgen"/>
53+
<xsl:apply-templates mode="tocgen">
54+
<xsl:with-param name="toc.section.depth" select="$toc.section.depth"/>
55+
</xsl:apply-templates>
5256
</ol>
5357
</xsl:if>
5458
</xsl:element>
@@ -61,6 +65,7 @@
6165
<xsl:param name="scope" select="/*"/>
6266
<xsl:param name="autogenerate-toc" select="$autogenerate-toc"/>
6367
<xsl:param name="toc-placeholder-overwrite-contents" select="$toc-placeholder-overwrite-contents"/>
68+
<xsl:param name="toc.section.depth" select="$toc.section.depth"/>
6469

6570
<!-- Just switch context to $toc.node, so we don't have to reference the variable in rest of template -->
6671
<xsl:for-each select="$toc.node">
@@ -80,7 +85,9 @@
8085
</h1>
8186
</xsl:if>
8287
<ol>
83-
<xsl:apply-templates select="$scope" mode="tocgen"/>
88+
<xsl:apply-templates select="$scope" mode="tocgen">
89+
<xsl:with-param name="toc.section.depth" select="$toc.section.depth"/>
90+
</xsl:apply-templates>
8491
</ol>
8592
</xsl:copy>
8693
</xsl:when>

0 commit comments

Comments
 (0)