[yelp-xsl] dita2html: Implement shortcut and screen



commit 47034fd002184bd04c3f1341615d6e896fc8afcb
Author: Shaun McCance <shaunm gnome org>
Date:   Tue Nov 27 16:27:07 2012 -0500

    dita2html: Implement shortcut and screen
    
    Added an initial-newline-stripper to dita2html.pre,
    just like we have for DocBook and Mallard. Although
    neither DITA nor DocBook specify this behavior like
    Mallard does, it matches user expectation in every
    case I've ever seen.

 xslt/dita/common/dita-selectors.mod |    7 ++++++-
 xslt/dita/html/dita2html-block.xsl  |   22 +++++++++++++++++++++-
 xslt/dita/html/dita2html-inline.xsl |    7 +++++++
 xslt/dita/html/dita2html-topic.xsl  |    1 +
 4 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/xslt/dita/common/dita-selectors.mod b/xslt/dita/common/dita-selectors.mod
index f84f99c..49823a2 100644
--- a/xslt/dita/common/dita-selectors.mod
+++ b/xslt/dita/common/dita-selectors.mod
@@ -191,6 +191,8 @@ topic/keyword
   name(.) = 'cmdname' or contains(@class, ' topic/keyword sw-d/cmdname ')]">
 <!ENTITY topic_shape "*[
   name(.) = 'shape' or contains(@class, ' topic/keyword ut-d/shape ')]">
+<!ENTITY topic_shortcut "*[
+  name(.) = 'shortcut' or contains(@class, ' topic/keyword ui-d/shortcut ')]">
 <!ENTITY topic_varname "*[
   name(.) = 'varname' or contains(@class, ' topic/keyword sw-d/varname ')]">
 <!ENTITY topic_wintitle "*[
@@ -327,13 +329,16 @@ topic/pre
 -->
 <!ENTITY topic_codeblock "*[
   name(.) = 'codeblock' or contains(@class, ' topic/pre pr-d/codeblock ')]">
+<!ENTITY topic_screen "*[
+  name(.) = 'screen' or contains(@class, ' topic/pre ui-d/screen ')]">
 <!ENTITY topic_pre "*[
   name(.) = 'pre' or (
   contains(@class, ' topic/pre ')
   and not(contains(@class, ' topic/pre pr-d/codeblock '))
+  and not(contains(@class, ' topic/pre ui-d/screen '))
   )]">
 <!ENTITY topic_pre_all "*[
-  name(.) = 'pre' or name(.) = 'codeblock' or
+  name(.) = 'pre' or name(.) = 'codeblock' or name(.) = 'screen' or
   contains(@class, ' topic/pre ')
   ]">
 
diff --git a/xslt/dita/html/dita2html-block.xsl b/xslt/dita/html/dita2html-block.xsl
index f9e0531..ab77876 100644
--- a/xslt/dita/html/dita2html-block.xsl
+++ b/xslt/dita/html/dita2html-block.xsl
@@ -107,6 +107,7 @@ FIXME
   <xsl:param name="node" select="."/>
   <xsl:param name="class" select="''"/>
   <xsl:variable name="conref" select="yelp:dita.ref.conref($node)"/>
+  <xsl:variable name="children" select="$conref/node()"/>
   <div>
     <xsl:call-template name="dita.id">
       <xsl:with-param name="node" select="$node"/>
@@ -120,7 +121,19 @@ FIXME
       </xsl:attribute>
     </xsl:if>
     <pre class="contents">
-      <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
+      <!-- Strip off a leading newline -->
+      <xsl:if test="$children[1]/self::text()">
+        <xsl:choose>
+          <xsl:when test="starts-with($node/text()[1], '&#x000A;')">
+            <xsl:value-of select="substring-after($node/text()[1], '&#x000A;')"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$node/text()[1]"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:if>
+      <xsl:apply-templates mode="dita2html.topic.mdoe"
+                           select="$children[not(position() = 1 and self::text())]"/>
     </pre>
   </div>
 </xsl:template>
@@ -292,6 +305,13 @@ FIXME
   </xsl:call-template>
 </xsl:template>
 
+<!-- = screen = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_screen;">
+  <xsl:call-template name="dita2html.pre">
+    <xsl:with-param name="class" select="'screen'"/>
+  </xsl:call-template>
+</xsl:template>
+
 <!-- = section = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_section;">
   <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
diff --git a/xslt/dita/html/dita2html-inline.xsl b/xslt/dita/html/dita2html-inline.xsl
index 0435661..c95fc5d 100644
--- a/xslt/dita/html/dita2html-inline.xsl
+++ b/xslt/dita/html/dita2html-inline.xsl
@@ -133,6 +133,13 @@ FIXME
   </xsl:for-each>
 </xsl:template>
 
+<!-- = shortcut = -->
+<xsl:template mode="dita2html.topic.mode" match="&topic_shortcut;">
+  <xsl:call-template name="dita2html.span">
+    <xsl:with-param name="class" select="'shortcut'"/>
+  </xsl:call-template>
+</xsl:template>
+
 <!-- = systemoutput = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_systemoutput;">
   <xsl:call-template name="dita2html.span">
diff --git a/xslt/dita/html/dita2html-topic.xsl b/xslt/dita/html/dita2html-topic.xsl
index 89e4505..f2ee1df 100644
--- a/xslt/dita/html/dita2html-topic.xsl
+++ b/xslt/dita/html/dita2html-topic.xsl
@@ -481,6 +481,7 @@ span.b {
 }
 span.i { font-style: italic; }
 span.u { text-decoration: underline; }
+span.shortcut { text-decoration: underline; }
 li.stepsection {
   margin-</xsl:text><xsl:value-of select="$left"/><xsl:text>: 0;
   list-style-type: none;



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