nroff .fi and .nf directive need to be at the beginning of a line.
[Samba/bjacke.git] / docs / xslt / man.xsl
blob00d0948de5fc3732868cc787566bc9ac8d2f35f4
1 <?xml version='1.0'?>
2 <!-- vim:set sts=2 shiftwidth=2 syntax=xml: -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version='1.0'>
6 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
8 <xsl:param name="chunk.section.depth" select="0"/>
9 <xsl:param name="chunk.first.sections" select="1"/>
10 <xsl:param name="use.id.as.filename" select="1"/>
12 <!--
13 Our ulink stylesheet omits @url part if content was specified
14 -->
15 <xsl:template match="ulink">
16 <xsl:variable name="content">
17 <xsl:apply-templates/>
18 </xsl:variable>
19 <xsl:if test="$content = ''">
20 <xsl:text>: </xsl:text>
21 </xsl:if>
22 <xsl:if test="$content != ''">
23 <xsl:value-of select="$content" />
24 </xsl:if>
25 <xsl:if test="$content = ''">
26 <xsl:apply-templates mode="italic" select="@url" />
27 </xsl:if>
28 </xsl:template>
30 <xsl:template match="refentry">
32 <xsl:variable name="section" select="refmeta/manvolnum"/>
33 <xsl:variable name="name" select="refnamediv/refname[1]"/>
34 <xsl:variable name="base.dir" select="$base.dir"/>
35 <!-- standard man page width is 64 chars; 6 chars needed for the two
36 (x) volume numbers, and 2 spaces, leaves 56 -->
37 <xsl:variable name="twidth" select="(74 - string-length(refmeta/refentrytitle)) div 2"/>
39 <xsl:variable name="reftitle"
40 select="substring(refmeta/refentrytitle, 1, $twidth)"/>
42 <xsl:variable name="title">
43 <xsl:choose>
44 <xsl:when test="refentryinfo/title">
45 <xsl:value-of select="refentryinfo/title"/>
46 </xsl:when>
47 <xsl:when test="../referenceinfo/title">
48 <xsl:value-of select="../referenceinfo/title"/>
49 </xsl:when>
50 </xsl:choose>
51 </xsl:variable>
53 <xsl:variable name="date">
54 <xsl:choose>
55 <xsl:when test="refentryinfo/date">
56 <xsl:value-of select="refentryinfo/date"/>
57 </xsl:when>
58 <xsl:when test="../referenceinfo/date">
59 <xsl:value-of select="../referenceinfo/date"/>
60 </xsl:when>
61 </xsl:choose>
62 </xsl:variable>
64 <xsl:variable name="productname">
65 <xsl:choose>
66 <xsl:when test="refentryinfo/productname">
67 <xsl:value-of select="refentryinfo/productname"/>
68 </xsl:when>
69 <xsl:when test="../referenceinfo/productname">
70 <xsl:value-of select="../referenceinfo/productname"/>
71 </xsl:when>
72 </xsl:choose>
73 </xsl:variable>
75 <xsl:call-template name="write.text.chunk">
76 <xsl:with-param name="filename"
77 select="concat($base.dir, normalize-space ($name), '.', $section)"/>
78 <xsl:with-param name="content">
79 <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
80 .de Sh \" Subsection
81 .br
82 .if t .Sp
83 .ne 5
84 .PP
85 \fB\\$1\fR
86 .PP
88 .de Sp \" Vertical space (when we can't use .PP)
89 .if t .sp .5v
90 .if n .sp
92 .de Ip \" List item
93 .br
94 .ie \\n(.$>=3 .ne \\$3
95 .el .ne 3
96 .IP "\\$1" \\$2
98 .TH "</xsl:text>
99 <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
100 <xsl:text>" </xsl:text>
101 <xsl:value-of select="refmeta/manvolnum[1]"/>
102 <xsl:text> "</xsl:text>
103 <xsl:value-of select="normalize-space($date)"/>
104 <xsl:text>" "</xsl:text>
105 <xsl:value-of select="normalize-space($productname)"/>
106 <xsl:text>" "</xsl:text>
107 <xsl:value-of select="$title"/>
108 <xsl:text>"
109 </xsl:text>
110 <xsl:apply-templates/>
111 <xsl:text>&#10;</xsl:text>
113 <!-- Author section -->
114 <xsl:choose>
115 <xsl:when test="refentryinfo//author">
116 <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
117 </xsl:when>
118 </xsl:choose>
119 </xsl:with-param>
120 </xsl:call-template>
121 </xsl:template>
123 <xsl:template match="informalexample|screen|programlisting">
124 <xsl:text>
125 .nf&#10;
126 </xsl:text>
127 <xsl:apply-templates/>
128 <xsl:text>
129 .fi&#10;
130 </xsl:text>
131 </xsl:template>
133 <xsl:template match="//emphasis">
134 <xsl:text>\fB</xsl:text>
135 <xsl:apply-templates/>
136 <xsl:text>\fR</xsl:text>
137 </xsl:template>
139 <xsl:template match="para|simpara|remark" mode="list">
140 <xsl:variable name="foo">
141 <xsl:apply-templates/>
142 </xsl:variable>
143 <xsl:choose match="node()">
144 <!-- Don't normalize-space() for verbatim paragraphs -->
145 <xsl:when test="informalexample|screen|programlisting">
146 <xsl:value-of select="$foo"/>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:value-of select="normalize-space($foo)"/>
150 <xsl:text>&#10;</xsl:text>
151 </xsl:otherwise>
152 </xsl:choose>
153 <xsl:text>&#10;</xsl:text>
154 <xsl:if test="following-sibling::para or following-sibling::simpara or
155 following-sibling::remark">
156 <!-- Make sure multiple paragraphs within a list item don't -->
157 <!-- merge together. -->
158 <xsl:text>&#10;</xsl:text>
159 </xsl:if>
160 </xsl:template>
162 <xsl:template match="refsect3">
163 <xsl:text>&#10;.SS "</xsl:text>
164 <xsl:value-of select="title[1]"/>
165 <xsl:text>"&#10;</xsl:text>
166 <xsl:apply-templates/>
167 </xsl:template>
170 </xsl:stylesheet>