]> granicus.if.org Git - docbook-dsssl/commitdiff
Improved display of programlistings (language attribute is shown as a label)
authorJirka Kosek <jirka@kosek.cz>
Tue, 16 May 2006 20:23:58 +0000 (20:23 +0000)
committerJirka Kosek <jirka@kosek.cz>
Tue, 16 May 2006 20:23:58 +0000 (20:23 +0000)
docbook/relaxng/docbook/howto/howto.css
docbook/relaxng/docbook/howto/stylesheets/fo.xsl
docbook/relaxng/docbook/howto/stylesheets/html.xsl

index 902d03c09e396ff714ef6418139d1f753b39515b..06311c5117bb5ddd45fb9bfee79f42bd051ee042 100644 (file)
@@ -36,3 +36,21 @@ dl            { margin-left: 3em;
 .screen, .programlisting { background-color: silver; padding: 4px; }
 .menuchoice, .guimenu, .guisubmenu, .guimenuitem { font-weight: bold; }
 .guibutton { background-color: silver; padding: 2px; }
+
+/* programlisting types */
+.programlisting, 
+.programlistingco, 
+.screen { padding-left: 14pt; }
+          
+.rolelabel {
+       position: absolute; 
+       margin-left: -14pt; 
+       background-color: #606060; 
+       color: white;
+       line-height: 1; 
+       font-family: sans-serif; 
+       font-weight: bold; 
+       text-align: center; 
+       padding: 1px; 
+       font-size: smaller; 
+       text-transform: uppercase }
index 43761b39720a52dc90b9ba38474844e30c1d076a..d45beb2ca29fb1ba92538d01ab6371b4a68c4b43 100644 (file)
@@ -3,7 +3,9 @@
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
                 version="1.0">
 
-<xsl:import href="../../../../../xsl/fo/docbook.xsl"/>
+<xsl:import href="../../../../../xsl/fo/profile-docbook.xsl"/>
+
+<xsl:param name="profile.status">final</xsl:param>
 
 <xsl:param name="body.start.indent" select="'0pt'"/>
 <xsl:param name="title.margin.left" select="'0pt'"/>
 
 <xsl:param name="ulink.footnotes" select="1"/>
 
+<xsl:template match="programlisting[@language]">
+  <fo:block clear="left"/>
+  <fo:float float="start">
+    <fo:block width="0.4cm" text-align="end" font-family="Helvetica" font-size="7pt" font-weight="bold" 
+              margin-left="-0.4cm">
+      <xsl:if test="not(preceding-sibling::*[1]/self::programlisting)">
+        <xsl:attribute name="margin-top">1.5em</xsl:attribute>
+      </xsl:if>
+      <fo:block-container reference-orientation="90" width="0.8cm">
+        <fo:block color="white" background-color="#808080" text-align="center">
+          <xsl:value-of select="translate(@language,'rngc','RNGC')"/>
+        </fo:block>
+      </fo:block-container>
+    </fo:block>
+  </fo:float>
+  <xsl:apply-imports/>
+</xsl:template>
+
 </xsl:stylesheet>
index 92ca454facf94533aa28e20afcf96506367a65fe..3ea9edfc56834c86f17b1f99efd49f7a3826f7eb 100644 (file)
@@ -2,7 +2,9 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">
 
-<xsl:import href="../../../../../xsl/html/docbook.xsl"/>
+<xsl:import href="../../../../../xsl/html/profile-docbook.xsl"/>
+
+<xsl:param name="profile.status">final</xsl:param>
 
 <xsl:template name="user.head.content">
   <xsl:param name="node" select="."/>
   </a>
 </xsl:template>
 
+<!-- Support for labels identifying programlisting syntax used -->
+<xsl:template match="programlisting[@language]">
+  <xsl:param name="suppress-numbers" select="'0'"/>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:call-template name="anchor"/>
+
+  <xsl:if test="$shade.verbatim != 0">
+    <xsl:message>
+      <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
+      <xsl:text>Use CSS instead,</xsl:text>
+    </xsl:message>
+    <xsl:message>
+      <xsl:text>for example: pre.</xsl:text>
+      <xsl:value-of select="local-name(.)"/>
+      <xsl:text> { background-color: #E0E0E0; }</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <xsl:choose>
+    <xsl:when test="$suppress-numbers = '0'
+                   and @linenumbering = 'numbered'
+                   and $use.extensions != '0'
+                   and $linenumbering.extension != '0'">
+      <xsl:variable name="rtf">
+       <xsl:apply-templates/>
+      </xsl:variable>
+      <pre class="{name(.)}">
+        <xsl:call-template name="role.label"/>
+       <xsl:call-template name="number.rtf.lines">
+         <xsl:with-param name="rtf" select="$rtf"/>
+       </xsl:call-template>
+      </pre>
+    </xsl:when>
+    <xsl:otherwise>
+      <pre class="{name(.)}">
+        <xsl:call-template name="role.label"/>
+       <xsl:apply-templates/>
+      </pre>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="role.label">
+  <span class="rolelabel">
+    <xsl:call-template name="brealize">
+      <xsl:with-param name="text" select="@language"/>
+    </xsl:call-template>
+  </span>
+</xsl:template>
+
+<xsl:template name="brealize">
+  <xsl:param name="text"/>
+  <xsl:variable name="head" select="substring($text, 1, 1)"/>
+  <xsl:variable name="tail" select="substring($text, 2)"/>
+
+  <xsl:if test="$head != ''">
+    <xsl:value-of select="$head"/>
+  </xsl:if>
+  
+  <xsl:if test="$tail != ''">
+    <br/>
+    <xsl:call-template name="brealize">
+      <xsl:with-param name="text" select="$tail"/>
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
 </xsl:stylesheet>