]> granicus.if.org Git - docbook-dsssl/commitdiff
Changed handling of bold and italic/underline output in manpages
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 20 Jun 2007 12:21:13 +0000 (12:21 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 20 Jun 2007 12:21:13 +0000 (12:21 +0000)
output. Should be transparent to users, but...

This touches handling of all bold and italic/underline output. The
exact change is that the mode="bold" and mode="italic" utility
templates were changed to named templates. (I think maybe I've
changed it back and forth from mode to named before, so this is
maybe re-reverting it yet again).

Anyway, the reason for the change is that the templates are
sometimes call on dynamically node-sets, and using modes to format
those doesn't allow passing info about the current/real context
node from the source (not the node-set created by the stylesheet)
to that formatting stage.

The named templates allow the context to be passed in as a
parameter, so that the bold/ital formatting template can use
context-aware condition checking.

This was basically necessary in order to suppress bold formatting
in titles, which otherwise gets screwed up because of the numbnut
way that roff handles nested bold/ital.

Closes #1674534). Much thanks to Daniel Leidert, whose in his
docbook-xsl bug-finding kung-fu has achieved Grand Master status.

xsl/manpages/block.xsl
xsl/manpages/endnotes.xsl
xsl/manpages/info.xsl
xsl/manpages/inline.xsl
xsl/manpages/lists.xsl
xsl/manpages/synop.xsl
xsl/manpages/utility.xsl

index dc029d03df20a0740d6defdf399ddab905d692a3..968b69c565da433705b77da1ce78d55f550549db 100644 (file)
 
 <xsl:template match="formalpara">
   <xsl:variable name="title.wrapper">
-    <bold><xsl:value-of select="normalize-space(title[1])"/></bold>
+    <xsl:value-of select="normalize-space(title[1])"/>
   </xsl:variable>
   <xsl:text>.PP&#10;</xsl:text>
   <!-- * don't put linebreak after head; instead render it as a "run in" -->
   <!-- * head, that is, inline, with a period and space following it -->
-  <xsl:apply-templates mode="bold" select="exsl:node-set($title.wrapper)"/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="exsl:node-set($title.wrapper)"/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
   <xsl:text>. </xsl:text>
   <xsl:apply-templates/>
 </xsl:template>
 <xsl:template name="formal.object.heading">
   <xsl:param name="object" select="."/>
   <xsl:param name="title">
-    <bold><xsl:apply-templates select="$object" mode="object.title.markup.textonly"/></bold>
+    <xsl:apply-templates select="$object" mode="object.title.markup.textonly"/>
   </xsl:param>
-  <xsl:apply-templates mode="bold" select="exsl:node-set($title)"/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="exsl:node-set($title)"/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
+
   <xsl:text>&#10;</xsl:text>
 </xsl:template>
 
index 3c4e0f6788727f38a9ab7f9219eff483106f4157..23df405ef2ed8737cda66927123521a2151edd08 100644 (file)
       <!-- * if user wants links underlined, underline (ital) it -->
       <xsl:when test="$man.links.are.underlined != 0">
         <xsl:variable name="link.wrapper">
-          <italic><xsl:value-of select="$notesource.contents"/></italic>
+          <xsl:value-of select="$notesource.contents"/>
         </xsl:variable>
-        <xsl:apply-templates mode="italic"
-                             select="exsl:node-set($link.wrapper)"/>
+        <xsl:call-template name="italic">
+          <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
+          <xsl:with-param name="context" select="."/>
+        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
         <!-- * user doesn't want links underlined, so just display content -->
index 5bbe063f60fc9560a3730fae7f0add082de6540b..b11e50653e04210ca5192dfdcbde9024d7f08b2d 100644 (file)
     <!-- * output name and email or ulink content on the same line -->
     <xsl:choose>
       <xsl:when test="not($person-name = '') or .//email or address/otheraddr/ulink">
-        <!-- * Our mode="bold" mechanism doesn't work on text nodes; so we -->
-        <!-- * need to turn the person-name into an element node first. -->
-        <xsl:variable name="person-name-node">
-          <bold><xsl:value-of select="$person-name"/></bold>
-        </xsl:variable>
         <xsl:text>.PP&#10;</xsl:text>
         <!-- * Display person name in bold -->
-        <xsl:apply-templates mode="bold" select="exsl:node-set($person-name-node)"/>
+        <xsl:call-template name="bold">
+          <xsl:with-param name="node" select="exsl:node-set($person-name)"/>
+          <xsl:with-param name="context" select="."/>
+        </xsl:call-template>
         <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
         <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
         <xsl:text>&#10;</xsl:text>
 
   <xsl:template match="collab" mode="authorsect">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="collabname"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="collabname"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
     <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
     <xsl:text>&#10;</xsl:text>
 
   <xsl:template match="corpauthor|corpcredit|orgname|publishername" mode="authorsect">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="."/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="."/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
     <xsl:if test="self::publishername">
       <!-- * Display localized "Publisher" gentext -->
 
   <xsl:template match="publisher" mode="authorsect">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="publishername"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="publishername"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <!-- * Display e-mail address(es) and ulink(s) on same line as name -->
     <xsl:apply-templates select=".//email|address/otheraddr/ulink" mode="authorsect"/>
     <!-- * Display addresses on separate lines -->
index 5583ff975b0b1f3ebf46e5e0ad8392067e9f1394..e2dc55f51e980a2f15c06f5e9caba8da14457140 100644 (file)
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="italic" select="."/>
+  <xsl:call-template name="italic">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="option|userinput|envar|errorcode|constant|markup">
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="bold" select="."/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="classname">
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="bold" select="."/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="type[not(ancestor::cmdsynopsis) and
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="bold" select="."/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="function[not(ancestor::cmdsynopsis) and
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="bold" select="."/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="parameter[not(ancestor::cmdsynopsis) and
   <xsl:if test="$man.hyphenate.computer.inlines = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="italic" select="."/>
+  <xsl:call-template name="italic">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="filename">
                 $man.break.after.slash = 0">
     <xsl:call-template name="suppress.hyphenation"/>
   </xsl:if>
-  <xsl:apply-templates mode="italic" select="."/>
+  <xsl:call-template name="italic">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="emphasis">
   <xsl:choose>
-    <xsl:when test="@role = 'bold' or
-                    @role = 'strong' or
-                    @remap = 'B'">
-      <xsl:apply-templates mode="bold" select="."/>
+    <xsl:when test="
+      @role = 'bold' or
+      @role = 'strong' or
+      @remap = 'B'">
+      <xsl:call-template name="bold">
+        <xsl:with-param name="node" select="."/>
+        <xsl:with-param name="context" select="."/>
+      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
-      <xsl:apply-templates mode="italic" select="."/>
+      <xsl:call-template name="italic">
+        <xsl:with-param name="node" select="."/>
+        <xsl:with-param name="context" select="."/>
+      </xsl:call-template>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
   <xsl:param name="refentrytitle" select="''"/>
   <xsl:param name="manvolnum" select="''"/>
   <xsl:variable name="title">
-    <bold><xsl:value-of select="$refentrytitle"/></bold>
+    <xsl:value-of select="$refentrytitle"/>
   </xsl:variable>
-  <xsl:apply-templates mode="bold" select="exsl:node-set($title)"/>
+  <xsl:call-template name="bold">
+    <xsl:with-param name="node" select="exsl:node-set($title)"/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
   <xsl:text>(</xsl:text>
   <xsl:value-of select="$manvolnum"/>
   <xsl:text>)</xsl:text>
index 6b4fabcd54be5f3197564caf5feeca6670e982dd..9fc65bb41a960e64ee5588adc97ad8b7d275dd2e 100644 (file)
 <xsl:template match="variablelist|glosslist">
   <xsl:if test="title">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="title"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="title"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
   </xsl:if>
   <xsl:apply-templates/>
 <xsl:template match="itemizedlist|orderedlist|procedure">
   <xsl:if test="title">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="title"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="title"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
   </xsl:if>
   <!-- * DocBook allows just about any block content to appear in -->
                      procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
   <xsl:if test="title">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="title"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="title"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
   </xsl:if>
   <xsl:apply-templates/>
 <xsl:template match="segmentedlist">
   <xsl:if test="title">
     <xsl:text>.PP&#10;</xsl:text>
-    <xsl:apply-templates mode="bold" select="title"/>
+    <xsl:call-template name="bold">
+      <xsl:with-param name="node" select="title"/>
+      <xsl:with-param name="context" select="."/>
+    </xsl:call-template>
     <xsl:text>&#10;</xsl:text>
   </xsl:if>
   <xsl:text>.\" line length increase to cope w/ tbl weirdness&#10;</xsl:text>
 </xsl:template>
 
 <xsl:template match="segmentedlist/segtitle" mode="table-title">
-  <!-- * italic makes titles stand out more reliably than bold (because -->
-  <!-- * some consoles do not actually support rendering of bold -->
-  <xsl:apply-templates mode="italic" select="."/>
+  <xsl:call-template name="italic">
+    <xsl:with-param name="node" select="."/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
   <xsl:choose>
       <xsl:when test="position() = last()"/> <!-- do nothing -->
       <xsl:otherwise>
index 07678fc5ab9c4f9cc707c7891f5e1fef3368463f..080ce1421fa46ced15a066a24ee24904817e8907 100644 (file)
   <xsl:variable name="synopfragmentref">
     <FragRefContents><xsl:value-of select="normalize-space(.)"/></FragRefContents>
   </xsl:variable>
-  <xsl:apply-templates select="exsl:node-set($synopfragmentref)" mode="italic"/>
+  <xsl:call-template name="italic">
+    <xsl:with-param name="node" select="exsl:node-set($synopfragmentref)"/>
+    <xsl:with-param name="context" select="."/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="synopfragment" mode="synopfragment.number">
index 23bc7a2d99094a150905f51c3b7b0c477f15559f..93a75d3ab217dce54788ec35fb62aec85c0a3b3d 100644 (file)
@@ -24,9 +24,9 @@
 <!-- ==================================================================== -->
 
   <!-- * NOTE TO DEVELOPERS: For ease of maintenance, the current -->
-  <!-- * manpages stylesheets use the mode="bold" and mode="italic" -->
-  <!-- * templates for *anything and everything* that needs to get -->
-  <!-- * boldfaced or italicized.   -->
+  <!-- * manpages stylesheets use the "bold" and "italic" named -->
+  <!-- * templates for anything and everything that needs to get -->
+  <!-- * boldfaced or italicized. -->
   <!-- * -->
   <!-- * So if you add anything that needs bold or italic character -->
   <!-- * formatting, try to apply these templates to it rather than -->
   <!-- * cases, you need to turn it into element content before applying -->
   <!-- * the template; see examples of this in the existing code. -->
 
-  <xsl:template mode="bold" match="*">
-    <xsl:for-each select="node()">
-      <xsl:text>\fB</xsl:text>
-      <xsl:apply-templates select="."/>
-      <xsl:text>\fR</xsl:text>
-    </xsl:for-each>
+  <xsl:template name="bold">
+    <xsl:param name="node"/>
+    <xsl:param name="context"/>
+    <xsl:choose>
+      <xsl:when test="not($context[ancestor::title])">
+        <xsl:for-each select="$node/node()">
+          <xsl:text>\fB</xsl:text>
+          <xsl:apply-templates select="."/>
+          <xsl:text>\fR</xsl:text>
+        </xsl:for-each>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="$node/node()"/>
+      </xsl:otherwise>
+    </xsl:choose>
   </xsl:template>
 
-  <xsl:template mode="italic" match="*">
-    <xsl:for-each select="node()">
+  <xsl:template name="italic">
+    <xsl:param name="node"/>
+    <xsl:param name="context"/>
+    <xsl:for-each select="$node/node()">
       <xsl:text>\fI</xsl:text>
       <xsl:apply-templates select="."/>
       <xsl:text>\fR</xsl:text>
@@ -55,7 +66,7 @@
 
   <!-- * NOTE TO DEVELOPERS: For ease of maintenance, the current -->
   <!-- * manpages stylesheets use the mode="prevent.line.breaking" -->
-  <!-- * templates for *anything and everything* that needs to have -->
+  <!-- * templates for anything and everything that needs to have -->
   <!-- * embedded spaces turned into no-break spaces in output - in -->
   <!-- * order to prevent that output from getting broken across lines -->
   <!-- * -->