<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="."/>
+ <xsl:value-of select="$content"/>
<xsl:text>\fR</xsl:text>
</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="."/>
+ <xsl:value-of select="$content"/>
<xsl:text>\fR</xsl:text>
</xsl:template>
</xsl:template>
<xsl:template match="copyright">
- <xsl:text>Copyright </xsl:text>
+ <xsl:text>Copyright \(co </xsl:text>
<xsl:apply-templates select="./year" />
<xsl:text> .Sp </xsl:text>
</xsl:template>
<xsl:template match="email">
- <xsl:text> <</xsl:text>
+ <xsl:text> <</xsl:text>
<xsl:apply-templates/>
<xsl:text>></xsl:text>
</xsl:template>
</xsl:choose>
</xsl:template>
+<xsl:template name="replace-dash">
+ <xsl:param name="content" select="''"/>
+ <xsl:call-template name="replace-string">
+ <xsl:with-param name="content" select="$content"/>
+ <xsl:with-param name="replace" select="'-'"/>
+ <xsl:with-param name="with" select="'\-'"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="replace-ndash">
+ <xsl:param name="content" select="''"/>
+ <xsl:call-template name="replace-string">
+ <xsl:with-param name="content" select="$content"/>
+ <xsl:with-param name="replace" select="'–'"/>
+ <xsl:with-param name="with" select="'-'"/>
+ </xsl:call-template>
+</xsl:template>
+
<xsl:template name="replace-mdash">
<xsl:param name="content" select="''"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="content">
<xsl:call-template name="replace-mdash">
<xsl:with-param name="content">
- <xsl:call-template name="replace-setmn">
+ <xsl:call-template name="replace-ndash">
<xsl:with-param name="content">
- <xsl:call-template name="replace-period">
+ <xsl:call-template name="replace-dash">
<xsl:with-param name="content">
- <xsl:call-template name="replace-backslash">
- <xsl:with-param name="content" select="$content"/>
+ <xsl:call-template name="replace-setmn">
+ <xsl:with-param name="content">
+ <xsl:call-template name="replace-period">
+ <xsl:with-param name="content">
+ <xsl:call-template name="replace-backslash">
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
<xsl:variable name="arg">
<xsl:apply-templates/>
</xsl:variable>
+ <xsl:choose>
+ <xsl:when test="local-name(.) = 'arg'">
+ <!-- Prevent breaking up an argument by wrapping it -->
+ <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:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space($arg)"/>
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:value-of select="normalize-space($arg)"/>
<xsl:choose>
<xsl:when test="$rep='repeat'">
<xsl:apply-templates mode="italic" select="."/>
</xsl:template>
-<xsl:template match="sbr">
- <xsl:variable name="cmd" select="ancestor::cmdsynopsis/command"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="translate($cmd,$cmd,' ')"/>
-</xsl:template>
-
-<xsl:template name="wrap-cmd">
- <xsl:param name="indent" select="''"/>
- <xsl:param name="text" select="''"/>
- <xsl:param name="allow" select="75"/>
- <xsl:param name="width" select="$allow - string-length($indent)"/>
- <xsl:variable name="total" select="string-length($text)"/>
- <xsl:variable name="split"
- select="substring($text,$width+1,$total - $width)"/>
- <xsl:variable name="fragment" select="substring-before($split,' ')"/>
- <xsl:variable name="line">
- <xsl:value-of select="substring($text,1,$width)"/>
- <xsl:choose>
- <xsl:when test="$fragment!=''">
- <xsl:value-of select="$fragment"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$split"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$split=''">
- <xsl:value-of select="$line"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$line"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$indent"/>
- <xsl:variable name="done" select="string-length($line)"/>
- <xsl:variable name="remaining" select="$total - $done + 1"/>
- <xsl:call-template name="wrap-cmd">
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="text"
- select="substring($text,1+$done,$remaining)"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
+<xsl:template match="sbr" />
<xsl:template match="cmdsynopsis">
- <xsl:text> .nf </xsl:text>
- <xsl:choose>
- <xsl:when test=".//sbr">
- <!-- The author has put explicit formatting hints in for us. -->
- <xsl:apply-templates/>
- </xsl:when>
- <xsl:otherwise>
- <!-- Try to do some smart formatting. -->
- <xsl:variable name="cmdsynopsis">
- <xsl:apply-templates/>
- </xsl:variable>
- <xsl:variable name="cmd" select="command"/>
- <xsl:variable name="indent"
- select="translate($cmd,$cmd,' ')"/>
- <xsl:text>\fB</xsl:text>
- <xsl:value-of select="$cmd"/><xsl:text>\fR </xsl:text>
- <xsl:call-template name="wrap-cmd">
- <xsl:with-param name="indent" select="$indent"/>
- <xsl:with-param name="text" select="substring-after($cmdsynopsis,' ')"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> .fi </xsl:text>
+ <xsl:text>.ad l .hy 0 </xsl:text>
+ <xsl:text>.HP </xsl:text>
+ <xsl:value-of select="string-length (normalize-space (command)) + 1"/>
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text> .ad .hy </xsl:text>
</xsl:template>
<xsl:template match="synopsis">