Support indexes pointing directo to varlist items
[exim-website.git] / templates / doc / chapter.xsl
index bb0a3374bfc41b1829ce4508aa30b6b0c31ee42d..be6990aa75d3e8949c16d0a4948bad0179bc6191 100644 (file)
@@ -32,7 +32,7 @@
       <xsl:variable name="html.body.outer.append">
          <div id="toc">
             <ul class="hidden"/>
-            <img src="../../../../doc/contents.png" width="16" height="155"/>
+            <img src="{$staticroot}/doc/contents.png" width="16" height="155"/>
          </div>
       </xsl:variable>
 
@@ -60,7 +60,7 @@
 
             <!-- Chapter Title -->
             <h2 id="{@id}" class="{@class}">
-               <a href="{toc_url}">
+               <a href="{this_url}">
                   <xsl:value-of select="concat('Chapter ',chapter_id,' - ',title)"/>
                </a>
             </h2>
@@ -72,7 +72,7 @@
 
          <!-- Navigation -->
             <a class="previous_page" href="{prev_url}"><![CDATA[<-previous]]></a>
-            <a class="toc_page"      href="{prev_url}"><![CDATA[Table of Contents]]></a>
+            <a class="toc_page"      href="{toc_url}"><![CDATA[Table of Contents]]></a>
             <xsl:if test="next_url">
                <a class="next_page"  href="{next_url}"><![CDATA[next->]]></a>
             </xsl:if>
       </xsl:template>
 
    <!-- Section -->
-      <xsl:template match="/chapter/section">
+      <xsl:template match="*/section">
+
+        <!-- Add 2 to the "level" attr for the html header level; default h3 -->
+        <xsl:variable name="hlevel">
+          <xsl:choose>
+             <xsl:when test="@level!=''"><xsl:value-of select="@level + 2"/></xsl:when>
+             <xsl:otherwise>3</xsl:otherwise>
+          </xsl:choose>
+        </xsl:variable>
+
+        <!-- Take the "sectprefix" attr, default position() -->
+        <xsl:variable name="sectprefix">
+          <xsl:choose>
+             <xsl:when test="@sectprefix!=''"> <xsl:value-of select="@sectprefix"/> </xsl:when>
+             <xsl:otherwise>                   <xsl:value-of select="position()"/>  </xsl:otherwise>
+          </xsl:choose>
+        </xsl:variable>
+
          <!-- Section Wrapper -->
          <div class="section{@class}">
 
                   </h3>
                </xsl:when>
                <xsl:otherwise>
-                  <h3 id="{@id}" class="{@class}">
-                     <xsl:value-of select="concat(position(),'. ',title)"/>
-                  </h3>
+                 <xsl:element name="h{$hlevel}">
+                   <xsl:attribute name="id">    <xsl:value-of select="@id"/>    </xsl:attribute>
+                   <xsl:attribute name="class"> <xsl:value-of select="@class"/> </xsl:attribute>
+                     <xsl:value-of select="concat($sectprefix,'. ',title)"/>
+                 </xsl:element>
                </xsl:otherwise>
             </xsl:choose>
 
          </p>
       </xsl:template>
 
+   <!-- Anchors on varlistitems -->
+      <xsl:template match="*/listitem[@anchorname]">
+         <a id="{@anchorname}"> </a>
+         <dd>
+           <xsl:apply-templates select="*"/>
+         </dd>
+      </xsl:template>
+
    <!-- Ignore -->
-      <xsl:template match="chapter_id|prev_url|next_url|toc_url|canonical_url|current_url|old_versions"/>
+      <xsl:template match="chapter_id|this_url|prev_url|next_url|toc_url|canonical_url|current_url|title_uri|old_versions"/>
 
 </xsl:stylesheet>