Commit 1f1411e1 authored by bperraud's avatar bperraud

fix bugs with headers/toc

parent af314464
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
<xsl:template match="h6"> <xsl:template match="h6">
<xsl:variable name="level" select="count(ancestor::section) + 2"/> <xsl:variable name="level" select="count(ancestor::section) + 2"/>
<xsl:element name="h{$level}"> <xsl:element name="h{$level}">
<xsl:attribute name="id">
<xsl:value-of select="concat('h', $level, '-')"/>
<xsl:number level="any"/>
</xsl:attribute>
<xsl:value-of select="."/> <xsl:value-of select="."/>
</xsl:element> </xsl:element>
</xsl:template> </xsl:template>
......
...@@ -18,103 +18,93 @@ ...@@ -18,103 +18,93 @@
<body> <body>
<h1><xsl:value-of select="/html/head/title"/></h1> <h1><xsl:value-of select="/html/head/title"/></h1>
<p class="authors"><xsl:value-of select="/html/head/meta[@name='author']/@content"/></p> <p class="authors"><xsl:value-of select="/html/head/meta[@name='author']/@content"/></p>
<xsl:apply-templates select="node()|@*"/> <xsl:apply-templates select="node()|@*"/>
<xsl:call-template name="toc"/> <xsl:call-template name="toc"/>
</body> </body>
</xsl:template> </xsl:template>
<!-- Cleaning des footers vides --> <!-- Cleaning des footers vides -->
<xsl:template match="footer[not(node())]"/> <xsl:template match="footer[not(node())]"/>
<!-- Gestion de la table des matières --> <!-- Gestion de la table des matières -->
<xsl:template name="toc"> <xsl:template name="toc">
<xsl:if test="count(//h2) &gt; 0"> <xsl:if test="count(//h2) &gt; 0">
<h2 class="nocount toc-title">Table des matières</h2> <h2 class="nocount toc-title">Table des matières</h2>
<ul class="toc level2"> <ul class="toc level2">
<xsl:for-each select="//h2"> <xsl:for-each select="//h2">
<li> <li>
<xsl:call-template name="toc-a"/> <xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h3) &gt; 0"> <xsl:if test="count(..//h3) &gt; 0">
<ul class="toc level3"> <ul class="toc level3">
<xsl:for-each select="..//h3"> <xsl:for-each select="..//h3">
<li> <li>
<xsl:call-template name="toc-a"/> <xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h4) &gt; 0"> <xsl:if test="count(..//h4) &gt; 0">
<ul class="toc level4"> <ul class="toc level4">
<xsl:for-each select="..//h4"> <xsl:for-each select="..//h4">
<li> <li>
<xsl:call-template name="toc-a"/> <xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h5) &gt; 0"> <xsl:if test="count(..//h5) &gt; 0">
<ul class="toc level5"> <ul class="toc level5">
<xsl:for-each select="..//h5"> <xsl:for-each select="..//h5">
<li> <li>
<xsl:call-template name="toc-a"/> <xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h6) &gt; 0"> <xsl:if test="count(..//h6) &gt; 0">
<ul class="toc level6"> <ul class="toc level6">
<xsl:for-each select="..//h6"> <xsl:for-each select="..//h6">
<li> <li>
<xsl:call-template name="toc-a"/> <xsl:call-template name="toc-a"/>
</li> </li>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</li> </li>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</li> </li>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</li> </li>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
</li> </li>
</xsl:for-each> </xsl:for-each>
</ul> </ul>
</xsl:if> </xsl:if>
<!-- <li><a href="#">Introduction</a><span>1</span></li> -->
<!-- <li class="nested"> -->
<!-- <ul class="inner"> -->
<!-- <li><a href="#">Header 1</a><span>2</span> -->
<!-- </li> -->
<!-- <li><a href="#">Header 2</a><span>2</span> -->
<!-- </li> -->
<!-- </ul> -->
<!-- </li> -->
<!-- <li><a href="#">Header 2</a><span>3</span></li> -->
</xsl:template> </xsl:template>
<xsl:template name="toc-a"> <xsl:template name="toc-a">
...@@ -126,7 +116,7 @@ ...@@ -126,7 +116,7 @@
<xsl:value-of select="."/> <xsl:value-of select="."/>
</a> </a>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment