[yelp-xsl] dita2html-block: Support fig, pre, steps-informal



commit eb4944df12c14b236c69e38fc8a7bd74b885d9a9
Author: Shaun McCance <shaunm gnome org>
Date:   Fri Oct 5 18:07:30 2012 -0400

    dita2html-block: Support fig, pre, steps-informal

 xslt/dita/common/dita-selectors.mod |   29 ++++++++++++-
 xslt/dita/html/dita2html-block.xsl  |   83 +++++++++++++++++++++++++++++++---
 2 files changed, 103 insertions(+), 9 deletions(-)
---
diff --git a/xslt/dita/common/dita-selectors.mod b/xslt/dita/common/dita-selectors.mod
index 6671ec7..400ba5d 100644
--- a/xslt/dita/common/dita-selectors.mod
+++ b/xslt/dita/common/dita-selectors.mod
@@ -45,6 +45,16 @@ topic/desc
 <!ENTITY topic_desc "*[name(.) = 'desc' or starts-with(@class, '- topic/desc ')]">
 
 <!-- ===========================================================================
+topic/fig
+-->
+<!ENTITY topic_fig "*[name(.) = 'fig' or starts-with(@class, '- topic/fig ')]">
+
+<!-- ===========================================================================
+topic/image
+-->
+<!ENTITY topic_image "*[name(.) = 'image' or starts-with(@class, '- topic/image ')]">
+
+<!-- ===========================================================================
 topic/itemgroup
 -->
 <!ENTITY topic_info "*[
@@ -118,6 +128,11 @@ topic/note
 <!ENTITY topic_note "*[name(.) = 'note' or starts-with(@class, '- topic/note ')]">
 
 <!-- ===========================================================================
+topic/object
+-->
+<!ENTITY topic_object "*[name(.) = 'object' or starts-with(@class, '- topic/object ')]">
+
+<!-- ===========================================================================
 topic/ol
 -->
 <!ENTITY topic_steps "*[
@@ -174,6 +189,15 @@ topic/pre
 -->
 <!ENTITY topic_codeblock "*[
   name(.) = 'codeblock' or starts-with(@class, '- topic/pre pr-d/codeblock ')]">
+<!ENTITY topic_pre "*[
+  name(.) = 'pre' or (
+  starts-with(@class, '- topic/pre ')
+  and not(starts-with(@class, '- topic/pre pr-d/codeblock '))
+  )]">
+<!ENTITY topic_pre_all "*[
+  name(.) = 'pre' or name(.) = 'codeblock' or
+  starts-with(@class, '- topic/pre ')
+  ]">
 
 <!-- ===========================================================================
 topic/prolog
@@ -196,6 +220,8 @@ topic/section
   name(.) = 'prereq'  or starts-with(@class, '- topic/section task/prereq ')]">
 <!ENTITY topic_result  "*[
   name(.) = 'result'  or starts-with(@class, '- topic/section task/result ')]">
+<!ENTITY topic_steps-informal "*[
+  name(.) = 'steps-informal'  or starts-with(@class, '- topic/section task/steps-informal ')]">
 <!ENTITY topic_section "*[
   name(.) = 'section'  or (
   starts-with(@class, '- topic/section ')
@@ -203,10 +229,11 @@ topic/section
   and not(starts-with(@class, '- topic/section task/postreq '))
   and not(starts-with(@class, '- topic/section task/prereq '))
   and not(starts-with(@class, '- topic/section task/result '))
+  and not(starts-with(@class, '- topic/section task/steps-informal '))
   )]">
 <!ENTITY topic_section_all "*[
   name(.) = 'section' or name(.) = 'context' or name(.) = 'prereq' or
-  name(.) = 'postreq' or name(.) = 'result'  or
+  name(.) = 'postreq' or name(.) = 'result'  or name(.) = 'steps-informal' or
   starts-with(@class, '- topic/section ')
   ]">
 
diff --git a/xslt/dita/html/dita2html-block.xsl b/xslt/dita/html/dita2html-block.xsl
index 1407616..54ddc06 100644
--- a/xslt/dita/html/dita2html-block.xsl
+++ b/xslt/dita/html/dita2html-block.xsl
@@ -88,6 +88,30 @@ FIXME
   </p>
 </xsl:template>
 
+<!--**==========================================================================
+dita2html.pre
+Output an HTML #{pre} element.
+:Revision:version="3.8" date="2012-10-05" status="incomplete"
+$node: The source element to output a #{pre} for.
+$class: The value of the HTML #{class} attribute.
+
+FIXME
+-->
+<xsl:template name="dita2html.pre">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="class" select="''"/>
+  <xsl:variable name="conref" select="yelp:dita.ref.conref($node)"/>
+  <div class="code">
+    <xsl:copy-of select="$node/@id"/>
+    <xsl:call-template name="html.lang.attrs">
+      <xsl:with-param name="node" select="$node"/>
+    </xsl:call-template>
+    <pre class="contents">
+      <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
+    </pre>
+  </div>
+</xsl:template>
+
 
 <!-- == Matched Templates == -->
 
@@ -98,14 +122,9 @@ FIXME
 
 <!-- = codeblock = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_codeblock;">
-  <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
-  <div class="code">
-    <xsl:copy-of select="@id"/>
-    <xsl:call-template name="html.lang.attrs"/>
-    <pre class="contents">
-      <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
-    </pre>
-  </div>
+  <xsl:call-template name="dita2html.pre">
+    <xsl:with-param name="class" select="'code'"/>
+  </xsl:call-template>
 </xsl:template>
 
 <!-- = context = -->
@@ -122,6 +141,42 @@ FIXME
   </xsl:call-template>
 </xsl:template>
 
+<!-- = fig = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_fig;">
+  <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
+  <!-- If there's images or video, treat it like a Mallard figure.
+       Otherwise, treat it like a Mallard listing. -->
+  <xsl:variable name="style">
+    <xsl:choose>
+      <xsl:when test="$conref/&topic_image; or $conref/&topic_object;">
+        <xsl:text>figure</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:text>listing</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <div class="{$style}">
+    <xsl:copy-of select="@id"/>
+    <xsl:call-template name="html.lang.attrs"/>
+    <div class="inner">
+      <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_title;"/>
+      <div class="region">
+        <xsl:if test="$style = 'listing'">
+          <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_desc;"/>
+        </xsl:if>
+        <div class="contents">
+          <xsl:apply-templates mode="dita2html.topic.mode"
+                               select="$conref/node()[not(self::&topic_title; or self::&topic_desc;)]"/>
+        </div>
+        <xsl:if test="$style = 'figure'">
+          <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/&topic_desc;"/>
+        </xsl:if>
+      </div>
+    </div>
+  </div>
+</xsl:template>
+
 <!-- = info = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_info;">
   <xsl:call-template name="dita2html.p"/>
@@ -184,6 +239,11 @@ FIXME
   </xsl:call-template>
 </xsl:template>
 
+<!-- = pre = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_pre;">
+  <xsl:call-template name="dita2html.pre"/>
+</xsl:template>
+
 <!-- = prereq = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_prereq;">
   <xsl:call-template name="dita2html.div">
@@ -227,6 +287,13 @@ FIXME
   <xsl:call-template name="dita2html.p"/>
 </xsl:template>
 
+<!-- = steps-informal = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_steps-informal;">
+  <xsl:call-template name="dita2html.div">
+    <xsl:with-param name="class" select="'steps-informal'"/>
+  </xsl:call-template>
+</xsl:template>
+
 <!-- = stepxmp = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_stepxmp;">
   <xsl:call-template name="dita2html.div">



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