From f626caaa29f259bd5b628dade5821ad26a8efe9f Mon Sep 17 00:00:00 2001 From: Michael Smith <xmldoc@users.sourceforge.net> Date: Fri, 10 Mar 2006 12:13:03 +0000 Subject: [PATCH] Funcsynopsisinfo must be handled as a verbatim. Problem:: Existing code was not preserving breaks and whitespace in Funcsynopsisinfo. Cause:: Lack of awareness that Funcsynopsisinfo is a verbatim environment. Fix:: Handle in Funcsynopsisinfo in the same way as other verbatims (that is, wrap in .nf/.fi requests. Additional problem: According to man(7) man page and existing man2/ pages, all parts of a funcsynopsis that are not args must be in bold. But because Funcsynopsisinfo is a verbatim, it needs different roff bold markup than other stuff. So wrapped it in ".ft B"/ft pair. (Perhaps it might make sense to wrap the whole funcsynopsis in ".ft B"/ft instead of trying to bold/unbold at the word level, as we are doing now. Or perhaps not.) Closes bug #1447121. Thanks to Joe Orton for reporting. --- xsl/manpages/block.xsl | 39 +++++++++++++++++++++++++++++++++------ xsl/manpages/synop.xsl | 18 +++++++++--------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/xsl/manpages/block.xsl b/xsl/manpages/block.xsl index b1471f2ef..5e8b2197d 100644 --- a/xsl/manpages/block.xsl +++ b/xsl/manpages/block.xsl @@ -40,8 +40,9 @@ <xsl:text>.sp </xsl:text> </xsl:template> -<xsl:template match="address|literallayout|programlisting|screen|synopsis"> - <!-- * Yes, address and synopsis are verbatim environments. --> +<xsl:template match="literallayout|programlisting|screen| + address|synopsis|funcsynopsisinfo"> + <!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. --> <xsl:choose> <!-- * Check to see if this verbatim item is within a parent element that --> @@ -59,10 +60,36 @@ <xsl:text>.sp </xsl:text> </xsl:otherwise> </xsl:choose> - <xsl:text>.nf </xsl:text> - <xsl:apply-templates/> - <xsl:text> </xsl:text> - <xsl:text>.fi </xsl:text> + <xsl:choose> + <xsl:when test="self::funcsynopsisinfo"> + <!-- * All funcsynopsisinfo content must be rendered in bold --> + <!-- * The man(7) man page says this: --> + <!-- * --> + <!-- * For functions, the arguments are always specified using --> + <!-- * italics, even in the SYNOPSIS section, where the rest of --> + <!-- * the function is specified in bold. --> + <!-- * --> + <!-- * If you take a look through the contents of the man/man2 --> + <!-- * directory on your system, you'll see that most existing pages --> + <!-- * do follow that "bold everything in function synopsis " rule. --> + <!-- * --> + <xsl:text>.\" bold on </xsl:text> + <xsl:text>.ft B </xsl:text> + <xsl:text>.nf </xsl:text> + <xsl:apply-templates/> + <xsl:text> </xsl:text> + <xsl:text>.fi </xsl:text> + <xsl:text>.\" bold off </xsl:text> + <xsl:text>.ft </xsl:text> + </xsl:when> + <xsl:otherwise> + <!-- * Other verbatims do not need to get bolded --> + <xsl:text>.nf </xsl:text> + <xsl:apply-templates/> + <xsl:text> </xsl:text> + <xsl:text>.fi </xsl:text> + </xsl:otherwise> + </xsl:choose> <!-- * if first following sibling node of this verbatim --> <!-- * environment is a text node, output a line of space before it --> <xsl:if test="following-sibling::node()[1][name(.) = '']"> diff --git a/xsl/manpages/synop.xsl b/xsl/manpages/synop.xsl index 656481b4f..4026ca5ca 100644 --- a/xsl/manpages/synop.xsl +++ b/xsl/manpages/synop.xsl @@ -16,9 +16,9 @@ <xsl:variable name="arg.or.sep"> |</xsl:variable> -<!-- * Note: If you are looking for the <synopsis> element, you won't --> -<!-- * find any code here for handling it. It is a _verbatim_ --> -<!-- * environment; check the block.xsl file instead. --> +<!-- * Note: If you're looking for the *Synopsis* element, you won't --> +<!-- * find any code here for handling it. It's a "verbatim" --> +<!-- * environment; see the block.xsl file instead. --> <xsl:template match="synopfragmentref"> <xsl:variable name="target" select="key('id',@linkend)"/> @@ -194,6 +194,12 @@ </xsl:template> <!-- ==================================================================== --> +<!-- * Funcsynopis hierarchy starts here --> +<!-- ==================================================================== --> + +<!-- * Note: If you're looking for the *Funcsynopsisinfo* element, --> +<!-- * you won't find any code here for handling it. It's a "verbatim" --> +<!-- * environment; see the block.xsl file instead. --> <!-- * Within funcsynopis output, disable hyphenation, and use --> <!-- * left-aligned filling for the duration of the synopsis, so that --> @@ -241,12 +247,6 @@ <!-- * that document functions, and there's no good reason for us to --> <!-- * be following it. --> -<xsl:template match="funcsynopsisinfo"> - <xsl:text>.PP </xsl:text> - <xsl:apply-templates mode="bold" select="."/> - <xsl:text> </xsl:text> -</xsl:template> - <xsl:template match="funcprototype"> <xsl:variable name="funcprototype.string.value"> <xsl:value-of select="funcdef"/> -- 2.40.0