[yelp-xsl] Use HTML <h*> elements for block titles



commit 60042f1fbea136d24109fee5d310a0335a4db7d9
Author: Shaun McCance <shaunm gnome org>
Date:   Thu Jan 20 12:38:31 2011 -0500

    Use HTML <h*> elements for block titles
    
    Joanie asked for this so that titles of formal elements like
    steps list can be jumped to with header navigation in screen
    readers. We still keep them in div.title elements, and add
    some CSS so that the h elements don't affect styling.

 xslt/common/html.xsl                 |    6 ++++++
 xslt/docbook/html/db2html-block.xsl  |   23 ++++++++++++++++++++---
 xslt/mallard/html/mal2html-block.xsl |   19 ++++++++++++++++---
 3 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/xslt/common/html.xsl b/xslt/common/html.xsl
index c5e00cd..12a2d9e 100644
--- a/xslt/common/html.xsl
+++ b/xslt/common/html.xsl
@@ -684,6 +684,12 @@ div.title {
   font-weight: bold;
   color: </xsl:text><xsl:value-of select="$color.text_light"/><xsl:text>;
 }
+div.title h1, div.title h2, div.title h3, div.title h4, div.title h5, div.title h6 {
+  margin: 0;
+  font-size: inherit;
+  font-weight: inherit;
+  color: inherit;
+}
 div.desc { margin: 0 0 0.2em 0; }
 div.contents + div.desc { margin: 0.2em 0 0 0; }
 pre.contents {
diff --git a/xslt/docbook/html/db2html-block.xsl b/xslt/docbook/html/db2html-block.xsl
index 54d4242..1050846 100644
--- a/xslt/docbook/html/db2html-block.xsl
+++ b/xslt/docbook/html/db2html-block.xsl
@@ -148,6 +148,21 @@ element.  It is called by *{db2html.block} for formal block elements.
 	<xsl:param name="lang" select="$title/@lang|$title/@xml:lang"/>
   <xsl:param name="dir" select="false()"/>
   <xsl:param name="ltr" select="false()"/>
+  <xsl:variable name="depth">
+    <xsl:call-template name="db.chunk.depth-in-chunk">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:variable name="depth_">
+    <xsl:choose>
+      <xsl:when test="number($depth) &lt; 6">
+        <xsl:value-of select="number($depth) + 1"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="6"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
 
   <div class="block title title-formal">
     <xsl:choose>
@@ -172,9 +187,11 @@ element.  It is called by *{db2html.block} for formal block elements.
     <xsl:call-template name="db2html.anchor">
       <xsl:with-param name="node" select="$title"/>
     </xsl:call-template>
-    <span class="title">
-      <xsl:apply-templates select="$title/node()"/>
-    </span>
+    <xsl:element name="{concat('h', $depth_)}" namespace="{$html.namespace}">
+      <span class="title">
+        <xsl:apply-templates select="$title/node()"/>
+      </span>
+    </xsl:element>
   </div>
 </xsl:template>
 
diff --git a/xslt/mallard/html/mal2html-block.xsl b/xslt/mallard/html/mal2html-block.xsl
index 6555741..99660ac 100644
--- a/xslt/mallard/html/mal2html-block.xsl
+++ b/xslt/mallard/html/mal2html-block.xsl
@@ -417,11 +417,24 @@ in accordance with the Mallard specification on fallback block content.
 
 <!-- = title = -->
 <xsl:template mode="mal2html.block.mode" match="mal:title">
+  <xsl:variable name="depth" select="count(ancestor::mal:section) + 2"/>
+  <xsl:variable name="depth_">
+    <xsl:choose>
+      <xsl:when test="$depth &lt; 6">
+        <xsl:value-of select="$depth"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="6"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
   <div class="title title-{local-name(..)}">
     <xsl:call-template name="html.lang.attrs"/>
-    <span class="title">
-      <xsl:apply-templates mode="mal2html.inline.mode"/>
-    </span>
+    <xsl:element name="{concat('h', $depth_)}" namespace="{$html.namespace}">
+      <span class="title">
+        <xsl:apply-templates mode="mal2html.inline.mode"/>
+      </span>
+    </xsl:element>
   </div>
 </xsl:template>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]