Started a glossary implementation (initialized from the socket lib glossary) in Gloss...
[senf.git] / doclib / html-munge.xsl
index 3229bf7..8efc0f8 100644 (file)
 \r
   <!-- ====================================================================== -->\r
 \r
+  <!-- Hack Glossary menu highlight -->\r
+\r
+  <xsl:template match="div[@class='tabs menu']/ul[1]">\r
+    <xsl:choose>\r
+      <xsl:when test="//h1[.//text()='Glossary']">\r
+        <xsl:call-template name="add-class">\r
+          <xsl:with-param name="class">glossary</xsl:with-param>\r
+        </xsl:call-template>\r
+      </xsl:when>\r
+      <xsl:otherwise>\r
+        <xsl:copy>\r
+          <xsl:call-template name="copy-attributes"/>\r
+          <xsl:apply-templates/>\r
+        </xsl:copy>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <!-- Autogenerate table-of-contents for a page -->\r
+\r
+  <xsl:template match="div[@id='autotoc']">\r
+    <xsl:copy>\r
+      <xsl:call-template name="copy-attributes"/>\r
+      <h1>Contents</h1>\r
+      <ul>\r
+        <xsl:for-each select="following::h2|following::h3|following::h4">\r
+          <xsl:element name="li">\r
+            <xsl:attribute name="class"><xsl:value-of select="concat('level_',local-name())"/></xsl:attribute>\r
+            <b><xsl:call-template name="section-number"/></b>\r
+            <xsl:element name="a">\r
+              <xsl:attribute name="href"><xsl:value-of select="concat('#',a/@name)"/></xsl:attribute>\r
+              <xsl:value-of select="string(current())"/>\r
+            </xsl:element>\r
+          </xsl:element>\r
+        </xsl:for-each>\r
+      </ul>\r
+    </xsl:copy>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="section-number">\r
+    <xsl:number level="any" from="h1" count="h2"/>\r
+    <xsl:text>.</xsl:text>\r
+    <xsl:if test="self::h3|self::h4">\r
+      <xsl:number level="any" from="h2" count="h3"/>\r
+      <xsl:text>.</xsl:text>\r
+    </xsl:if>\r
+    <xsl:if test="self::h4">\r
+      <xsl:number level="any" from="h3" count="h4"/>\r
+      <xsl:text>.</xsl:text>\r
+    </xsl:if>\r
+    <xsl:text> </xsl:text>\r
+  </xsl:template>\r
+  \r
+  <xsl:template match="h2|h3|h4">\r
+    <xsl:copy>\r
+      <xsl:call-template name="copy-attributes"/>\r
+      <xsl:if test="preceding::div[@id='autotoc']">\r
+        <xsl:call-template name="section-number"/>\r
+      </xsl:if>\r
+      <xsl:apply-templates/>\r
+    </xsl:copy>\r
+  </xsl:template>\r
+\r
   <!-- Remove the automatically inserted search form (we build our own) -->\r
   <xsl:template match="li[form]"> \r
   </xsl:template>\r