Skip to content

Commit

Permalink
Add manpage XSL from git and enhance with literallayout fixes
Browse files Browse the repository at this point in the history
It ensures that .sp tags will be properly output so they do not appear
in the rendered manpages. Grabed from git's Documentation/callouts.xsl
file. From the git's commit 7ef0435088f41165ece95b6f226d3c15438505a5:

    This is just a random hack to work around problems people seem
    to be seeing in manpage backend of xmlto (it appears we are
    getting ".sp" at the end of line without line break).

Additionally, output an empty line after literallayout blocks (.nf .fi)
so that any text following it will appear in a separate block.
  • Loading branch information
jonas committed May 31, 2007
1 parent 173d76e commit 738cb15
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -91,7 +91,7 @@ README.html: README
asciidoc -b docbook -d manpage $<

%.1 : %.1.xml
xmlto man $<
xmlto -m manpage.xsl man $<

%.5.html : %.5.txt
asciidoc -b xhtml11 -d manpage $<
Expand All @@ -100,7 +100,7 @@ README.html: README
asciidoc -b docbook -d manpage $<

%.5 : %.5.xml
xmlto man $<
xmlto -m manpage.xsl man $<

%.html : %.txt
asciidoc -b xhtml11 -d article -n $<
Expand Down
55 changes: 55 additions & 0 deletions manpage.xsl
@@ -0,0 +1,55 @@
<!-- manpage.xsl: various fixups to docbook -> manpage output
-
- For now converts it adds a newline after preformatted text enclosed
- in screen.
-
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="screen">
<xsl:text>.sp&#10;.nf&#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#10;.fi&#10;.sp&#10;</xsl:text>
</xsl:template>

<xsl:template match="simpara">
<xsl:variable name="content">
<xsl:apply-templates/>
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
<xsl:text>&#10;</xsl:text>
<xsl:text>.sp&#10;</xsl:text>
</xsl:template>

<xsl:template match="address|literallayout|programlisting|screen|synopsis">
<!-- * Yes, address and synopsis are verbatim environments. -->

<xsl:choose>
<!-- * Check to see if this verbatim item is within a parent element that -->
<!-- * allows mixed content. -->
<!-- * -->
<!-- * If it is within a mixed-content parent, then a line space is -->
<!-- * already added before it by the mixed-block template, so we don't -->
<!-- * need to add one here. -->
<!-- * -->
<!-- * If it is not within a mixed-content parent, then we need to add a -->
<!-- * line space before it. -->
<xsl:when test="parent::caption|parent::entry|parent::para|
parent::td|parent::th" /> <!-- do nothing -->
<xsl:otherwise>
<xsl:text>&#10;</xsl:text>
<xsl:text>.sp&#10;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>.nf&#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#10;&#10;.fi&#10;</xsl:text>
<!-- * 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(.) = '']">
<xsl:text>&#10;</xsl:text>
<xsl:text>.sp&#10;</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

0 comments on commit 738cb15

Please sign in to comment.