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: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 </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> </xsl:text>
</xsl:template>
<!-- * 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 -->
<!-- * 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 </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> </xsl:text>
<xsl:template match="collab" mode="authorsect">
<xsl:text>.PP </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> </xsl:text>
<xsl:template match="corpauthor|corpcredit|orgname|publishername" mode="authorsect">
<xsl:text>.PP </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> </xsl:text>
<xsl:if test="self::publishername">
<!-- * Display localized "Publisher" gentext -->
<xsl:template match="publisher" mode="authorsect">
<xsl:text>.PP </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 -->
<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>
<xsl:template match="variablelist|glosslist">
<xsl:if test="title">
<xsl:text>.PP </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> </xsl:text>
</xsl:if>
<xsl:apply-templates/>
<xsl:template match="itemizedlist|orderedlist|procedure">
<xsl:if test="title">
<xsl:text>.PP </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> </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 </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> </xsl:text>
</xsl:if>
<xsl:apply-templates/>
<xsl:template match="segmentedlist">
<xsl:if test="title">
<xsl:text>.PP </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> </xsl:text>
</xsl:if>
<xsl:text>.\" line length increase to cope w/ tbl weirdness </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>
<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">
<!-- ==================================================================== -->
<!-- * 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>
<!-- * 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 -->
<!-- * -->