]> granicus.if.org Git - docbook-dsssl/commitdiff
Fixed handling of lists with titles. Also reworked handling of
authorMichael Smith <xmldoc@users.sourceforge.net>
Sun, 24 Jul 2005 14:10:31 +0000 (14:10 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Sun, 24 Jul 2005 14:10:31 +0000 (14:10 +0000)
space around lists. (Closes #1243003 and 1241371).

Among other things, this change "normalizes" line space before and
after verbatims. For most cases, the stylesheet now attempts to
ensure each verbatim is preceded and followed by exactly one line
of space.

xsl/manpages/block.xsl
xsl/manpages/lists.xsl
xsl/manpages/utility.xsl
xsl/params/man.string.subst.map.xml

index d71e439c57846aa5c86e36e333f9c11fbf89b2a9..e32e2f6947173b4228a30e5810ddd863544cbcb0 100644 (file)
     <!-- * Check to see if this verbatim item is within a parent element that -->
     <!-- * allows mixed content. -->
     <!-- * -->
-    <!-- * If it is within a mixed-content parent, then a line break is -->
+    <!-- * If it is within a mixed-content parent, then a line space is -->
     <!-- * already added before it by the mixed-block template, so we don't -->
     <!-- * need to add one here. -->
     <!-- * -->
     <!-- * If it is not within a mixed-content parent, then we need to add a -->
-    <!-- * line break before it. -->
+    <!-- * line space before it. -->
     <xsl:when test="parent::caption|parent::entry|parent::para|
                     parent::td|parent::th" /> <!-- do nothing -->
     <xsl:otherwise>
-      <xsl:text>&#10;</xsl:text>
+      <xsl:text>.sp&#10;</xsl:text>
     </xsl:otherwise>
   </xsl:choose>
   <xsl:text>.nf&#10;</xsl:text>
index 88d275960db940397ac7c2d68ebc9ba152da2e5c..7d05578b4df29808d920a3f7bdb173cdc81f1ef0 100644 (file)
@@ -12,9 +12,9 @@
 
      ******************************************************************** -->
 
-<xsl:template match="para[ancestor::listitem or ancestor::step]|
-                    simpara[ancestor::listitem or ancestor::step]|
-                    remark[ancestor::listitem or ancestor::step]">
+<xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
+                    simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
+                    remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
   <xsl:call-template name="mixed-block"/>
   <xsl:text>&#10;</xsl:text>
 
   </xsl:if>
 </xsl:template>
 
+<xsl:template match="variablelist|glosslist">
+  <xsl:if test="title">
+    <xsl:text>.PP&#10;</xsl:text>
+    <xsl:apply-templates mode="bold" select="title"/>
+    <xsl:text>&#10;</xsl:text>
+  </xsl:if>
+  <xsl:apply-templates/>
+</xsl:template>
+
 <xsl:template match="varlistentry|glossentry">
   <xsl:text>.TP&#10;</xsl:text> 
   <!-- * read in contents of all terms or glossterms so that we can run -->
 <xsl:template match="varlistentry/term"/>
 <xsl:template match="glossentry/glossterm"/>
 
-<xsl:template match="variablelist[ancestor::listitem or ancestor::step]|
-                    glosslist[ancestor::listitem or ancestor::step]">
+<xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
+                    glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
   <xsl:text>.RS&#10;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>.RE&#10;</xsl:text>
-  <xsl:text>.IP&#10;</xsl:text>
+  <xsl:if test="following-sibling::node() or
+                parent::para[following-sibling::node()] or
+                parent::simpara[following-sibling::node()] or
+                parent::remark[following-sibling::node()]">
+    <xsl:text>.IP&#10;</xsl:text>
+  </xsl:if>
 </xsl:template>
 
-<xsl:template match="varlistentry/listitem|glossdef">
+<xsl:template match="varlistentry/listitem|glossentry/glossdef">
   <xsl:apply-templates/>
 </xsl:template>
 
   <xsl:apply-templates/>
 </xsl:template>
 
-<xsl:template match="itemizedlist[ancestor::listitem or ancestor::step]|
-                    orderedlist[ancestor::listitem or ancestor::step]|
-                    procedure[ancestor::listitem or ancestor::step]">
+<xsl:template match="itemizedlist[ancestor::listitem or ancestor::step  or ancestor::glossdef]|
+                    orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
+                    procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
   <xsl:text>.RS&#10;</xsl:text>
   <xsl:text>.TP 3&#10;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>.RE&#10;</xsl:text>
-  <xsl:text>.IP&#10;</xsl:text>
+  <xsl:if test="following-sibling::node() or
+                parent::para[following-sibling::node()] or
+                parent::simpara[following-sibling::node()] or
+                parent::remark[following-sibling::node()]">
+    <xsl:text>.IP&#10;</xsl:text>
+  </xsl:if>
 </xsl:template>
 
+<!-- ================================================================== -->
+  
 <!-- * for simplelist type="inline", render it as a comma-separated list -->
 <xsl:template match="simplelist[@type='inline']">
 
index 3d5dd6559ba8f6e7dc6e6d35640c63ae7cba97c2..585378126ef8e41f8698242467e811bc7692fabf 100644 (file)
     <xsl:text>&#10;</xsl:text>
     <xsl:call-template name="mark.subheading"/>
   </xsl:template>
-  
+
   <!-- ================================================================== -->
 
   <!-- * The mixed-block template jumps through a few hoops to deal with -->
   <xsl:template name="mixed-block">
     <xsl:for-each select="node()">
       <xsl:choose>
+        <!-- * Check to see if this node is a verbatim environment. -->
+        <!-- * If so, put a line of space before it. -->
+        <!-- * -->
+        <!-- * Yes, address and synopsis are vertabim environments. -->
+        <!-- * -->
+        <!-- * The code here previously also treated informaltable as a -->
+        <!-- * verbatim, presumably to support some kludge; I removed it -->
         <xsl:when test="self::address|self::literallayout|self::programlisting|
                         self::screen|self::synopsis">
-          <!-- * Check to see if this node is a verbatim environment. -->
-          <!-- * If so, put a line break before it. -->
-          <!-- * -->
-          <!-- * Yes, address and synopsis are vertabim environments. -->
-          <!-- * -->
-          <!-- * The code here previously also treated informaltable as a -->
-          <!-- * verbatim, presumably to support some kludge; I removed it -->
-          <xsl:text>&#10;</xsl:text>
+          <xsl:text>.sp&#10;</xsl:text>
           <xsl:apply-templates select="."/>
-          <!-- * we don't need an extra line break after verbatim environments -->
-          <!-- * <xsl:text> &#10;</xsl:text> -->
         </xsl:when>
-        <xsl:when test="self::itemizedlist|self::orderedlist|
-                        self::variablelist|self::simplelist[@type !='inline']">
-          <!-- * Check to see if this node is a list; if so, -->
-          <!-- * put a line break before it. -->
-          <xsl:text>&#10;</xsl:text>
+        <!-- * Check to see if this node is a list; if it is, we don't -->
+        <!-- * want to normalize-space(), so we just apply-templates -->
+        <xsl:when test="(self::itemizedlist|self::orderedlist|
+                        self::variablelist|self::glosslist|
+                        self::simplelist[@type !='inline'])">
           <xsl:apply-templates select="."/>
-          <!-- * we don't need an extra line break after lists -->
-          <!-- * <xsl:text> &#10;</xsl:text> -->
         </xsl:when>
         <xsl:when test="self::text()">
           <!-- * Check to see if this is a text node. -->
               test="starts-with(translate(.,'&#9;&#10;&#13; ','    '), ' ')
                     and preceding-sibling::node()[name(.)!='']
                     and normalize-space($content) != ''
+                    and not(
+                    preceding-sibling::variablelist[1] or
+                    preceding-sibling::glosslistlist[1] or
+                    preceding-sibling::itemizedlist[1] or
+                    preceding-sibling::orderededlist[1] or
+                    preceding-sibling::procedure[1]
+                    )
                     ">
             <xsl:text> &#10;</xsl:text>
           </xsl:if>
index aa6253b445eb5b5ab55313cc61aa6e604fd2deb8..79199950af7887c4d7d937ef64e1480fb0baa759 100644 (file)
   <substitution oldstring="-" newstring="\-"/>
   <!-- * now, we need to restore single-hypens in all roff requests -->
   <!-- * (because the substitution above added backslashes before them) -->
+  <substitution oldstring=".sp \-" newstring=".sp -"/>
   <substitution oldstring=".it 1 an\-trap" newstring=".it 1 an-trap"/>
   <substitution oldstring=".nr an\-no\-space\-flag 1" newstring=".nr an-no-space-flag 1"/>
   <substitution oldstring=".nr an\-break\-flag 1" newstring=".nr an-break-flag 1"/>
+  <!-- * squeeze multiple newlines before a roff request  -->
+  <substitution oldstring="&#10;&#10;." newstring="&#10;."/>
+  <!-- * squeeze multiple newlines after start of no-fill (verbatim) env. -->
+  <substitution oldstring=".nf&#10;&#10;" newstring=".nf&#10;"/>
   <!-- * an apostrophe at the beginning of a line gets interpreted as a -->
   <!-- * roff request (groff(7) says it is "the non-breaking control -->
   <!-- * character"); so we must add backslash before any apostrophe -->