Rearrange Github pages-related Makefile targets
[pipeglade.git] / www-template / index-toc.xsl
blob963311668eb9838bc034c396931e51394886ae9c
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <!-- Add a table of contents to index.html -->
5 <xsl:output method="html" doctype-system="about:legacy-compat"/>
7 <!-- Attach @id to headings -->
8 <xsl:template match="div[@class='subsection']/h2">
9 <h2>
10 <xsl:attribute name="id">
11 <xsl:value-of select="."/>
12 </xsl:attribute>
13 <xsl:value-of select="."/>
14 </h2>
15 </xsl:template>
17 <!-- Insert table of contents -->
18 <xsl:template match="div[@class='toc']">
19 <div class="toc">
20 <xsl:for-each select="//div[@class='subsection']/h2">
21 <i class="link-sec">
22 <a class="link-sec">
23 <xsl:attribute name="href">
24 #<xsl:value-of select="."/>
25 </xsl:attribute>
26 <xsl:value-of select="."/>
27 <xsl:value-of select="id(.)"/>
28 </a>
29 </i>
30 <xsl:if test="position() != last()">
31 <xsl:text> ยท </xsl:text>
32 </xsl:if>
33 </xsl:for-each>
34 </div>
35 </xsl:template>
37 <!-- Rebuild html with table of contents added -->
38 <xsl:template match="@*|node()">
39 <xsl:copy>
40 <xsl:apply-templates select="@*|node()">
41 </xsl:apply-templates>
42 </xsl:copy>
43 </xsl:template>
45 </xsl:stylesheet>