]> granicus.if.org Git - docbook-dsssl/commitdiff
Fix for enhancement/bug#1312: Support font size in verbatim elements
authorThomas Schraitle <tom_schr@web.de>
Mon, 9 Sep 2013 15:00:31 +0000 (15:00 +0000)
committerThomas Schraitle <tom_schr@web.de>
Mon, 9 Sep 2013 15:00:31 +0000 (15:00 +0000)
testdocs/tests/screen.002.xml [new file with mode: 0644]
xsl/fo/pi.xsl
xsl/fo/verbatim.xsl

diff --git a/testdocs/tests/screen.002.xml b/testdocs/tests/screen.002.xml
new file mode 100644 (file)
index 0000000..d615a70
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+          "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<article>
+<articleinfo>
+<title>Unit Test: screen.002</title>
+<releaseinfo role="CVS">$Id: $</releaseinfo>
+<author><firstname>Thomas</firstname><surname>Schraitle</surname>
+</author>
+</articleinfo>
+
+  <sect1>
+    <title>Change Font Size Directly</title>
+    <para>If you want to change the font size directly, insert a
+        <sgmltag class="xmlpi">dbfo font-size="SIZE"</sgmltag>
+      processing instruction into the respective verbatim
+      element:</para>
+    <screen><![CDATA[<screen><?dbfo font-size="8pt"?>Hello World</screen>]]></screen>
+    <para>This is used if you want to change the font size for only one
+      verbatim element, but leave the others intact.</para>
+  </sect1>
+  
+  <sect1>
+    <title>Change Font Size as Upper Element</title>
+    <para>If you want to change the font size for consecutive verbatim
+      elements, position the <sgmltag class="xmlpi">dbfo
+        font-size="SIZE"</sgmltag> processing instruction outside the
+      verbatim element:</para>
+    <screen><![CDATA[<?dbfo font-size="8pt"?>
+<screen>Hello World</screen>
+<screen>Hello Tux</screen>]]></screen>
+    <para>Any following verbatim elements will use the parent PI. This
+      is used if you want to change the font size for more than one
+      verbatim elements. To reset the font size, use <sgmltag
+        class="xmlpi">dbfo font-size=""</sgmltag>.</para>
+  </sect1>
+  
+  
+</article>
index 4637738055f22d5e753601baa444880646e6b1a3..28c0de3e0b45b72d6e4baffe260a81b9a716cd82 100644 (file)
   </xsl:call-template>
 </xsl:template>
 
+<doc:pi name="dbfo_font-size" xmlns="">
+  <refpurpose>Specifies “font-size” for block verbatim elements</refpurpose>
+  <refdescription>
+    <para>Use the <tag class="xmlpi">dbfo font-size</tag> PI as a child of a
+      verbatim element (<tag>screen</tag>, <tag>programlisting</tag>, or
+      <tag>synopsis</tag>) to specify the “font-size”.</para>
+  </refdescription>
+  <refsynopsisdiv>
+    <synopsis><tag class="xmlpi">dbfo font-size="SIZE"</tag></synopsis>
+  </refsynopsisdiv>
+  <refparameter>
+    <variablelist>
+      <varlistentry><term>font-size="SIZE"</term>
+        <listitem>
+          <para>Specifies the font size (usually in points)</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refparameter>
+  
+</doc:pi>
+<xsl:template name="pi.dbfo_font-size">
+  <xsl:param name="node" select="."/>
+  <xsl:call-template name="dbfo-attribute">
+    <xsl:with-param name="pis" select="$node/processing-instruction('dbfo')"/>
+    <xsl:with-param name="attribute" select="'font-size'"/>
+  </xsl:call-template>
+</xsl:template>
+
 <doc:pi name="dbfo_funcsynopsis-style" xmlns="">
   <refpurpose>Specifies presentation style for a funcsynopsis</refpurpose>
   <refdescription>
index 58f27c892cffb1c980774cb17f0096c518110b08..ee0d326769cdca9d93f3d7f5b6000998b3edd445 100644 (file)
   <xsl:variable name="keep.together">
     <xsl:call-template name="pi.dbfo_keep-together"/>
   </xsl:variable>
+  
+  <xsl:variable name="font.size">
+    <xsl:call-template name="pi.dbfo_font-size">
+      <xsl:with-param name="node"
+        select="(self::*[processing-instruction('dbfo')]|
+                 parent::*[processing-instruction('dbfo')])[last()]"/>
+    </xsl:call-template>
+  </xsl:variable>
 
   <xsl:variable name="block.content">
     <xsl:choose>
       <xsl:when test="$shade.verbatim != 0">
         <fo:block id="{$id}"
              xsl:use-attribute-sets="monospace.verbatim.properties shade.verbatim.style">
-         <xsl:if test="$keep.together != ''">
-           <xsl:attribute name="keep-together.within-column"><xsl:value-of
-           select="$keep.together"/></xsl:attribute>
-         </xsl:if>
+         <xsl:if test="$keep.together != ''">
+           <xsl:attribute name="keep-together.within-column"><xsl:value-of
+               select="$keep.together"/></xsl:attribute>
+         </xsl:if>
+         <xsl:if test="$font.size != ''">
+           <xsl:attribute name="font-size"><xsl:value-of select="$font.size"/></xsl:attribute>
+         </xsl:if>
           <xsl:choose>
             <xsl:when test="$hyphenate.verbatim != 0 and 
                             $exsl.node.set.available != 0">