</xsl:template>
<xsl:template match="refsect2">
- <xsl:text> .Sh "</xsl:text>
+ <xsl:text> .SS "</xsl:text>
<xsl:value-of select="title[1]"/>
<xsl:text>" </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="void">
- <xsl:text> (void</xsl:text>
+ <xsl:text>void</xsl:text>
</xsl:template>
<xsl:template match="varargs">
- <xsl:text> (...</xsl:text>
+ <xsl:text>...</xsl:text>
</xsl:template>
<xsl:template match="funcsynopsisinfo">
<xsl:text> .sp </xsl:text>
</xsl:template>
+<!-- disable hyphenation, and use left-aligned filling for the duration
+ of the synopsis, so that line breaks only occur between
+ separate paramdefs. -->
<xsl:template match="funcsynopsis">
- <xsl:text>.nf </xsl:text>
+ <xsl:text>.ad l .hy 0 </xsl:text>
<xsl:apply-templates/>
- <xsl:text>.fi </xsl:text>
+ <xsl:text>.ad .hy </xsl:text>
</xsl:template>
<!-- TODO: Handle K&R-style parameter lists
is now obsolete and thus deleted
-->
+<!-- evaluates to parameter string with all space characters converted
+ to non-breaking spaces. -->
+<xsl:template name="nbspace">
+ <xsl:param name="string" select="''"/>
+ <xsl:choose>
+ <xsl:when test="contains($string, ' ')">
+ <xsl:value-of select="substring-before($string, ' ')"/>
+ <xsl:text>\ </xsl:text>
+ <xsl:call-template name="nbspace">
+ <xsl:with-param name="string" select="substring-after($string, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- replaces all spaces within the funcdef/paramdef with non-breaking
+ spaces -->
+<xsl:template match="paramdef|funcdef">
+ <xsl:variable name="content">
+ <xsl:apply-templates select="*|./*|text()"/>
+ </xsl:variable>
+ <xsl:call-template name="nbspace">
+ <xsl:with-param name="string" select="$content"/>
+ </xsl:call-template>
+ <xsl:if test="local-name(.) = 'paramdef' and
+ (following-sibling::paramdef or following-sibling::varargs)">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+</xsl:template>
+
<xsl:template match="funcprototype">
<xsl:variable name="funcprototype">
<xsl:apply-templates select="funcdef"/>
</xsl:variable>
- <xsl:text>.sp </xsl:text>
+ <xsl:text>.HP </xsl:text>
+ <xsl:value-of select="string-length (normalize-space ($funcprototype)) - 5"/>
+ <xsl:text> </xsl:text>
<xsl:value-of select="normalize-space ($funcprototype)"/>
- <xsl:text> (</xsl:text>
- <xsl:for-each select="paramdef">
- <xsl:variable name="param">
- <xsl:apply-templates select="." />
- </xsl:variable>
- <xsl:value-of select="normalize-space ($param)" />
- <xsl:choose>
- <xsl:when test="following-sibling::paramdef">
- <xsl:text>, </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>); .RE </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="not (preceding-sibling::paramdef)">
- <xsl:text>.RS </xsl:text>
- <xsl:value-of
- select="string-length(normalize-space ($funcprototype)) - 4" />
- <xsl:text> </xsl:text>
- </xsl:if>
- </xsl:for-each>
+ <xsl:text>\ (</xsl:text>
+ <xsl:apply-templates select="void|paramdef|varargs"/>
+ <xsl:text>); </xsl:text>
</xsl:template>
</xsl:stylesheet>
</xsl:template>
<xsl:template match="refsect2">
- <xsl:text> .Sh "</xsl:text>
+ <xsl:text> .SS "</xsl:text>
<xsl:value-of select="title[1]"/>
<xsl:text>" </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="void">
- <xsl:text> (void</xsl:text>
+ <xsl:text>void</xsl:text>
</xsl:template>
<xsl:template match="varargs">
- <xsl:text> (...</xsl:text>
+ <xsl:text>...</xsl:text>
</xsl:template>
<xsl:template match="funcsynopsisinfo">
<xsl:text> .sp </xsl:text>
</xsl:template>
+<!-- disable hyphenation, and use left-aligned filling for the duration
+ of the synopsis, so that line breaks only occur between
+ separate paramdefs. -->
<xsl:template match="funcsynopsis">
- <xsl:text>.nf </xsl:text>
+ <xsl:text>.ad l .hy 0 </xsl:text>
<xsl:apply-templates/>
- <xsl:text>.fi </xsl:text>
+ <xsl:text>.ad .hy </xsl:text>
</xsl:template>
<!-- TODO: Handle K&R-style parameter lists
is now obsolete and thus deleted
-->
+<!-- evaluates to parameter string with all space characters converted
+ to non-breaking spaces. -->
+<xsl:template name="nbspace">
+ <xsl:param name="string" select="''"/>
+ <xsl:choose>
+ <xsl:when test="contains($string, ' ')">
+ <xsl:value-of select="substring-before($string, ' ')"/>
+ <xsl:text>\ </xsl:text>
+ <xsl:call-template name="nbspace">
+ <xsl:with-param name="string" select="substring-after($string, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- replaces all spaces within the funcdef/paramdef with non-breaking
+ spaces -->
+<xsl:template match="paramdef|funcdef">
+ <xsl:variable name="content">
+ <xsl:apply-templates select="*|./*|text()"/>
+ </xsl:variable>
+ <xsl:call-template name="nbspace">
+ <xsl:with-param name="string" select="$content"/>
+ </xsl:call-template>
+ <xsl:if test="local-name(.) = 'paramdef' and
+ (following-sibling::paramdef or following-sibling::varargs)">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+</xsl:template>
+
<xsl:template match="funcprototype">
<xsl:variable name="funcprototype">
<xsl:apply-templates select="funcdef"/>
</xsl:variable>
- <xsl:text>.sp </xsl:text>
+ <xsl:text>.HP </xsl:text>
+ <xsl:value-of select="string-length (normalize-space ($funcprototype)) - 5"/>
+ <xsl:text> </xsl:text>
<xsl:value-of select="normalize-space ($funcprototype)"/>
- <xsl:text> (</xsl:text>
- <xsl:for-each select="paramdef">
- <xsl:variable name="param">
- <xsl:apply-templates select="." />
- </xsl:variable>
- <xsl:value-of select="normalize-space ($param)" />
- <xsl:choose>
- <xsl:when test="following-sibling::paramdef">
- <xsl:text>, </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>); .RE </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="not (preceding-sibling::paramdef)">
- <xsl:text>.RS </xsl:text>
- <xsl:value-of
- select="string-length(normalize-space ($funcprototype)) - 4" />
- <xsl:text> </xsl:text>
- </xsl:if>
- </xsl:for-each>
+ <xsl:text>\ (</xsl:text>
+ <xsl:apply-templates select="void|paramdef|varargs"/>
+ <xsl:text>); </xsl:text>
</xsl:template>
</xsl:stylesheet>