Copy purify.fvwm2rc to /tmp - add instructions in README.
[fvwm.git] / doc / docbook-xsl / manpages / lists.xsl
blob6ac82b2048b1361826abbae3683a9118f17808ec
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version='1.0'>
5 <!-- ********************************************************************
6 $Id: lists.xsl,v 1.1 2007/03/10 05:15:34 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://docbook.sf.net/release/xsl/current/ for
11 copyright and other information.
13 ******************************************************************** -->
15 <xsl:variable name="list-indent">
16 <xsl:choose>
17 <xsl:when test="not($man.indent.lists = 0)">
18 <xsl:value-of select="$man.indent.width"/>
19 </xsl:when>
20 <xsl:when test="not($man.indent.refsect = 0)">
21 <!-- * "zq" is the name of a register we set for -->
22 <!-- * preserving the original default indent value -->
23 <!-- * when $man.indent.refsect is non-zero; -->
24 <!-- * "u" is a roff unit specifier -->
25 <xsl:text>\n(zqu</xsl:text>
26 </xsl:when>
27 <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
28 </xsl:choose>
29 </xsl:variable>
31 <!-- ================================================================== -->
33 <xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
34 simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
35 remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
36 <xsl:call-template name="mixed-block"/>
37 <xsl:text>&#10;</xsl:text>
38 <xsl:if test="following-sibling::*[1][
39 self::para or
40 self::simpara or
41 self::remark
42 ]">
43 <!-- * Make sure multiple paragraphs within a list item don't -->
44 <!-- * merge together. -->
45 <xsl:text>.sp&#10;</xsl:text>
46 </xsl:if>
47 </xsl:template>
49 <xsl:template match="variablelist|glosslist">
50 <xsl:if test="title">
51 <xsl:text>.PP&#10;</xsl:text>
52 <xsl:apply-templates mode="bold" select="title"/>
53 <xsl:text>&#10;</xsl:text>
54 </xsl:if>
55 <xsl:apply-templates/>
56 </xsl:template>
58 <xsl:template match="varlistentry|glossentry">
59 <xsl:text>.PP&#10;</xsl:text>
60 <xsl:for-each select="term|glossterm">
61 <xsl:variable name="content">
62 <xsl:apply-templates/>
63 </xsl:variable>
64 <xsl:value-of select="normalize-space($content)"/>
65 <xsl:choose>
66 <xsl:when test="position() = last()"/> <!-- do nothing -->
67 <xsl:otherwise>
68 <!-- * if we have multiple terms in the same varlistentry, generate -->
69 <!-- * a separator (", " by default) and/or an additional line -->
70 <!-- * break after each one except the last -->
71 <!-- * -->
72 <!-- * note that it is not valid to have multiple glossterms -->
73 <!-- * within a glossentry, so this logic never gets exercised -->
74 <!-- * for glossterms (every glossterm is always the last in -->
75 <!-- * its parent glossentry) -->
76 <xsl:value-of select="$variablelist.term.separator"/>
77 <xsl:if test="not($variablelist.term.break.after = '0')">
78 <xsl:text>&#10;</xsl:text>
79 <xsl:text>.br&#10;</xsl:text>
80 </xsl:if>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:for-each>
84 <xsl:text>&#10;</xsl:text>
85 <xsl:text>.RS</xsl:text>
86 <xsl:if test="not($list-indent = '')">
87 <xsl:text> </xsl:text>
88 <xsl:value-of select="$list-indent"/>
89 </xsl:if>
90 <xsl:text>&#10;</xsl:text>
91 <xsl:apply-templates/>
92 <xsl:text>.RE&#10;</xsl:text>
93 </xsl:template>
95 <xsl:template match="varlistentry/term"/>
96 <xsl:template match="glossentry/glossterm"/>
98 <xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
99 glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
100 <xsl:apply-templates/>
101 <xsl:if test="following-sibling::node() or
102 parent::para[following-sibling::node()] or
103 parent::simpara[following-sibling::node()] or
104 parent::remark[following-sibling::node()]">
105 <xsl:text>.sp</xsl:text>
106 <xsl:text>&#10;</xsl:text>
107 </xsl:if>
108 </xsl:template>
110 <xsl:template match="varlistentry/listitem|glossentry/glossdef">
111 <xsl:apply-templates/>
112 </xsl:template>
114 <xsl:template match="itemizedlist/listitem">
115 <!-- * We output a real bullet here (rather than, "\(bu", -->
116 <!-- * the roff bullet) because, when we do character-map -->
117 <!-- * processing before final output, the character-map will -->
118 <!-- * handle conversion of the &#x2022; to "\(bu" for us -->
119 <xsl:text>&#10;</xsl:text>
120 <xsl:text>.sp</xsl:text>
121 <xsl:text>&#10;</xsl:text>
122 <xsl:text>.RS</xsl:text>
123 <xsl:if test="not($list-indent = '')">
124 <xsl:text> </xsl:text>
125 <xsl:value-of select="$list-indent"/>
126 </xsl:if>
127 <xsl:text>&#10;</xsl:text>
128 <xsl:text>\h'-</xsl:text>
129 <xsl:if test="not($list-indent = '')">
130 <xsl:text>0</xsl:text>
131 <xsl:value-of select="$list-indent"/>
132 </xsl:if>
133 <xsl:text>'</xsl:text>
134 <xsl:text>&#x2022;</xsl:text>
135 <xsl:text>\h'+</xsl:text>
136 <xsl:if test="not($list-indent = '')">
137 <xsl:text>0</xsl:text>
138 <xsl:value-of select="$list-indent - 1"/>
139 <xsl:text>'</xsl:text>
140 </xsl:if>
141 <xsl:apply-templates/>
142 <xsl:text>.RE&#10;</xsl:text>
143 </xsl:template>
145 <xsl:template match="orderedlist/listitem|procedure/step">
146 <xsl:text>&#10;</xsl:text>
147 <xsl:text>.sp</xsl:text>
148 <xsl:text>&#10;</xsl:text>
149 <xsl:text>.RS</xsl:text>
150 <xsl:if test="not($list-indent = '')">
151 <xsl:text> </xsl:text>
152 <xsl:value-of select="$list-indent"/>
153 </xsl:if>
154 <xsl:text>&#10;</xsl:text>
155 <xsl:text>\h'-</xsl:text>
156 <xsl:if test="not($list-indent = '')">
157 <xsl:text>0</xsl:text>
158 <xsl:value-of select="$list-indent"/>
159 </xsl:if>
160 <xsl:text>'</xsl:text>
161 <xsl:if test="count(preceding-sibling::listitem) &lt; 9">
162 <xsl:text> </xsl:text>
163 </xsl:if>
164 <xsl:number format="1."/>
165 <xsl:text>\h'+</xsl:text>
166 <xsl:if test="not($list-indent = '')">
167 <xsl:text>0</xsl:text>
168 <xsl:value-of select="$list-indent - 2"/>
169 <xsl:text>'</xsl:text>
170 </xsl:if>
171 <xsl:apply-templates/>
172 <xsl:text>.RE&#10;</xsl:text>
173 <xsl:text>&#10;</xsl:text>
174 </xsl:template>
176 <xsl:template match="itemizedlist|orderedlist|procedure">
177 <xsl:if test="title">
178 <xsl:text>.PP&#10;</xsl:text>
179 <xsl:apply-templates mode="bold" select="title"/>
180 <xsl:text>&#10;</xsl:text>
181 </xsl:if>
182 <!-- * DocBook allows just about any block content to appear in -->
183 <!-- * lists before the actual list items, so we need to get that -->
184 <!-- * content (if any) before getting the list items -->
185 <xsl:apply-templates
186 select="*[not(self::listitem) and not(self::title)]"/>
187 <xsl:apply-templates select="listitem"/>
188 <!-- * If this list is a child of para and has content following -->
189 <!-- * it, within the same para, then add a blank line and move -->
190 <!-- * the left margin back to where it was -->
191 <xsl:if test="parent::para and following-sibling::node()">
192 <xsl:text>.sp&#10;</xsl:text>
193 <xsl:text>.RE&#10;</xsl:text>
194 </xsl:if>
195 </xsl:template>
197 <xsl:template match="itemizedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
198 orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
199 procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
200 <xsl:if test="title">
201 <xsl:text>.PP&#10;</xsl:text>
202 <xsl:apply-templates mode="bold" select="title"/>
203 <xsl:text>&#10;</xsl:text>
204 </xsl:if>
205 <xsl:apply-templates/>
206 <xsl:if test="following-sibling::node() or
207 parent::para[following-sibling::node()] or
208 parent::simpara[following-sibling::node()] or
209 parent::remark[following-sibling::node()]">
210 <xsl:text>.IP ""</xsl:text>
211 <xsl:if test="not($list-indent = '')">
212 <xsl:text> </xsl:text>
213 <xsl:value-of select="$list-indent"/>
214 </xsl:if>
215 <xsl:text>&#10;</xsl:text>
216 </xsl:if>
217 </xsl:template>
219 <!-- ================================================================== -->
221 <!-- * for simplelist type="inline", render it as a comma-separated list -->
222 <xsl:template match="simplelist[@type='inline']">
224 <!-- * if dbchoice PI exists, use that to determine the choice separator -->
225 <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
226 <!-- * value of "choice" otherwise -->
227 <xsl:variable name="localized-choice-separator">
228 <xsl:choose>
229 <xsl:when test="processing-instruction('dbchoice')">
230 <xsl:call-template name="select.choice.separator"/>
231 </xsl:when>
232 <xsl:otherwise>
233 <!-- * empty -->
234 </xsl:otherwise>
235 </xsl:choose>
236 </xsl:variable>
238 <xsl:for-each select="member">
239 <xsl:apply-templates/>
240 <xsl:choose>
241 <xsl:when test="position() = last()"/> <!-- do nothing -->
242 <xsl:otherwise>
243 <xsl:text>, </xsl:text>
244 <xsl:if test="position() = last() - 1">
245 <xsl:if test="$localized-choice-separator != ''">
246 <xsl:value-of select="$localized-choice-separator"/>
247 <xsl:text> </xsl:text>
248 </xsl:if>
249 </xsl:if>
250 </xsl:otherwise>
251 </xsl:choose>
252 </xsl:for-each>
253 <xsl:text>&#10;</xsl:text>
254 </xsl:template>
256 <!-- * if simplelist type is not inline, render it as a one-column vertical -->
257 <!-- * list (ignoring the values of the type and columns attributes) -->
258 <xsl:template match="simplelist">
259 <xsl:for-each select="member">
260 <xsl:text>.IP ""</xsl:text>
261 <xsl:if test="not($list-indent = '')">
262 <xsl:text> </xsl:text>
263 <xsl:value-of select="$list-indent"/>
264 </xsl:if>
265 <xsl:text>&#10;</xsl:text>
266 <xsl:apply-templates/>
267 <xsl:text>&#10;</xsl:text>
268 </xsl:for-each>
269 </xsl:template>
271 <!-- ================================================================== -->
273 <!-- * We output Segmentedlist as a table, using tbl(1) markup. There -->
274 <!-- * is no option for outputting it in manpages in "list" form. -->
275 <xsl:template match="segmentedlist">
276 <xsl:if test="title">
277 <xsl:text>.PP&#10;</xsl:text>
278 <xsl:apply-templates mode="bold" select="title"/>
279 <xsl:text>&#10;</xsl:text>
280 </xsl:if>
281 <xsl:text>.\" line length increase to cope w/ tbl weirdness&#10;</xsl:text>
282 <xsl:text>.ll +(\n(LLu * 62u / 100u)&#10;</xsl:text>
283 <!-- * .TS = "Table Start" -->
284 <xsl:text>.TS&#10;</xsl:text>
285 <!-- * first output the table "format" spec, which tells tbl(1) how -->
286 <!-- * how to format each row and column. -->
287 <xsl:for-each select=".//segtitle">
288 <!-- * l = "left", which hard-codes left-alignment for tabular -->
289 <!-- * output of all segmentedlist content -->
290 <xsl:text>l</xsl:text>
291 </xsl:for-each>
292 <!-- * last line of table format section must end with a dot -->
293 <xsl:text>.&#10;</xsl:text>
294 <!-- * optionally suppress output of segtitle -->
295 <xsl:choose>
296 <xsl:when test="$man.segtitle.suppress != 0">
297 <!-- * non-zero = "suppress", so do nothing -->
298 </xsl:when>
299 <xsl:otherwise>
300 <!-- * "0" = "do not suppress", so output the segtitle(s) -->
301 <xsl:apply-templates select=".//segtitle" mode="table-title"/>
302 <xsl:text>&#10;</xsl:text>
303 </xsl:otherwise>
304 </xsl:choose>
305 <xsl:apply-templates/>
306 <!-- * .TE = "Table End" -->
307 <xsl:text>.TE&#10;</xsl:text>
308 <xsl:text>.\" line length decrease back to previous value&#10;</xsl:text>
309 <xsl:text>.ll -(\n(LLu * 62u / 100u)&#10;</xsl:text>
310 <!-- * put a blank line of space below the table -->
311 <xsl:text>.sp&#10;</xsl:text>
312 </xsl:template>
314 <xsl:template match="segmentedlist/segtitle" mode="table-title">
315 <!-- * italic makes titles stand out more reliably than bold (because -->
316 <!-- * some consoles do not actually support rendering of bold -->
317 <xsl:apply-templates mode="italic" select="."/>
318 <xsl:choose>
319 <xsl:when test="position() = last()"/> <!-- do nothing -->
320 <xsl:otherwise>
321 <!-- * tbl(1) treats tab characters as delimiters between -->
322 <!-- * cells; so we need to output a tab after each except -->
323 <!-- * segtitle except the last one -->
324 <xsl:text>&#09;</xsl:text>
325 </xsl:otherwise>
326 </xsl:choose>
327 </xsl:template>
329 <xsl:template match="segmentedlist/seglistitem">
330 <xsl:apply-templates/>
331 <xsl:text>&#10;</xsl:text>
332 </xsl:template>
334 <xsl:template match="segmentedlist/seglistitem/seg">
335 <!-- * the “T{" and “T}” stuff are delimiters to tell tbl(1) that -->
336 <!-- * the delimited contents are "text blocks" that groff(1) -->
337 <!-- * needs to process -->
338 <xsl:text>T{&#10;</xsl:text>
339 <xsl:variable name="contents">
340 <xsl:apply-templates/>
341 </xsl:variable>
342 <xsl:value-of select="normalize-space($contents)"/>
343 <xsl:text>&#10;T}</xsl:text>
344 <xsl:choose>
345 <xsl:when test="position() = last()"/> <!-- do nothing -->
346 <xsl:otherwise>
347 <!-- * tbl(1) treats tab characters as delimiters between -->
348 <!-- * cells; so we need to output a tab after each except -->
349 <!-- * segtitle except the last one -->
350 <xsl:text>&#09;</xsl:text>
351 </xsl:otherwise>
352 </xsl:choose>
353 </xsl:template>
355 </xsl:stylesheet>