]> granicus.if.org Git - docbook-dsssl/commitdiff
Prevent "sticky" fonts changes. (closes #956070; thanks to Sam
authorMichael Smith <xmldoc@users.sourceforge.net>
Tue, 24 May 2005 09:40:55 +0000 (09:40 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Tue, 24 May 2005 09:40:55 +0000 (09:40 +0000)
Steingold for reporting the problem, and for his patience...)

::Problem:
  Sometimes a bold or italic font change inadvertently ends up
  becoming "sticky" such that a following chunk of text that
  should just be rendered as plain text instead gets
  boldfaced/italicized.

::Cause:
  Font changes were simply being nested, as they are in HTML.
  While that works for HTML, it doesn't work for roff, where
  font-change instructions aren't actually intended to nest.

::Fix:
  Attempted to un-nest bold/italic font changes. When the manpages
  stylesheets encounter node sets that need to be boldfaced or
  italicized, they now put the \fBfoo\fR \fIbar\fR groff
  bold/italic instructions separately around each node in the set.

  This may not be a complete fix for the problem. In fact, it may
  cause other problems. Please test :^)

xsl/manpages/docbook.xsl
xsl/manpages/sect23.xsl
xsl/manpages/synop.xsl

index 25d07a5f56190fb9915122acda728cb2a8ed8192..9b5b44499598f4255e53572a8073d26b14da1e5b 100644 (file)
   <xsl:apply-templates mode="bold" select="node-you-want" />
 -->
 <xsl:template mode="bold" match="*">
-  <xsl:variable name="content">
-    <xsl:apply-templates/>
-  </xsl:variable>
-  <xsl:text>\fB</xsl:text>
-  <xsl:value-of select="$content"/>
-  <xsl:text>\fR</xsl:text>
+  <xsl:for-each select="child::node()">
+    <xsl:text>\fB</xsl:text>
+    <xsl:apply-templates select="."/>
+    <xsl:text>\fR</xsl:text>
+  </xsl:for-each>
 </xsl:template>
 
 <xsl:template mode="italic" match="*">
-  <xsl:variable name="content">
-    <xsl:apply-templates/>
-  </xsl:variable>
-  <xsl:text>\fI</xsl:text>
-  <xsl:value-of select="$content"/>
-  <xsl:text>\fR</xsl:text>
+  <xsl:for-each select="node()">
+    <xsl:text>\fI</xsl:text>
+    <xsl:apply-templates select="."/>
+    <xsl:text>\fR</xsl:text>
+  </xsl:for-each>
 </xsl:template>
 
 <xsl:template match="caution|important|note|tip|warning">
        -->
       </xsl:when>
       <xsl:when test="self::itemizedlist|self::orderedlist|
-                     self::variablelist|self::simplelist">
+                     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>
 </xsl:template>
 
 <xsl:template match="filename|replaceable|varname">
-  <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+  <xsl:apply-templates mode="italic" select="."/>
 </xsl:template>
 
 <xsl:template match="option|userinput|envar|errorcode|constant|type">
-  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+  <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
 <xsl:template match="emphasis">
   <xsl:choose>
     <xsl:when test="@role = 'bold' or @role = 'strong'">
-      <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+      <xsl:apply-templates mode="bold" select="."/>
     </xsl:when>
     <xsl:otherwise>
-      <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+      <xsl:apply-templates mode="italic" select="."/>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
index 23079bf28ce7448399cb9053144a7b725e006c05..b9c1766edd8f3704dd481463e838a33f9595ed6d 100644 (file)
 <xsl:template match="article/articleinfo/*"></xsl:template>
 
 <xsl:template match="term/option">
-  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+  <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
 <xsl:template match="varlistentry">
 </xsl:template>
 
 <xsl:template match="envar">
-  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+  <xsl:apply-templates mode="bold" select="."/>
 </xsl:template>
 
 <xsl:template match="filename">
-  <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+  <xsl:apply-templates mode="italic" select="."/>
 </xsl:template>
 
 </xsl:stylesheet>
index d4562810a24dce12784396451cb8c07b8ff9e357..dc3aefb5b8a1c292f4e17b3ea23a54b9d4b9d084 100644 (file)
@@ -1,5 +1,7 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:exsl="http://exslt.org/common"
+                exclude-result-prefixes="exsl"
                 version='1.0'>
 
   <!-- the synopsis element is a verbatim environment; you won't find any -->
   <xsl:if test="position()>1">
     <xsl:value-of select="$arg.or.sep"/>
   </xsl:if>
-  <!-- Don't use the 'bold' named template here since there may be -->
-  <!-- child elements that require different markup (such as       -->
-  <!-- <replaceable>).                                             -->
-  <xsl:text>\fB</xsl:text>
   <xsl:variable name="arg">
     <xsl:apply-templates/>
   </xsl:variable>
-  <xsl:call-template name="replace-string">
-    <xsl:with-param name="content" select="normalize-space($arg)"/>
-    <xsl:with-param name="replace" select="' '"/>
-    <xsl:with-param name="with" select="'\ '"/>
-  </xsl:call-template>
-  <xsl:text>\fR</xsl:text>
+  <xsl:variable name="space-escaped-arg">
+    <xsl:call-template name="replace-string">
+      <xsl:with-param name="content" select="normalize-space($arg)"/>
+      <xsl:with-param name="replace" select="' '"/>
+      <xsl:with-param name="with" select="'\ '"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:apply-templates mode="bold" select="exsl:node-set($space-escaped-arg)"/>
 </xsl:template>
 
 <xsl:template match="command">