2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 exclude-result-prefixes="exsl"
7 <!-- ********************************************************************
8 $Id: block.xsl 8235 2009-02-09 16:22:14Z xmldoc $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
19 <xsl:template match="caution|important|note|tip|warning">
20 <xsl:call-template name="roff-if-start">
21 <xsl:with-param name="condition">n</xsl:with-param>
23 <xsl:text>.sp </xsl:text>
24 <xsl:call-template name="roff-if-end"/>
25 <xsl:text>.RS 4 </xsl:text>
26 <xsl:if test="not($man.output.better.ps.enabled = 0)">
27 <xsl:text>.BM yellow </xsl:text>
29 <xsl:call-template name="pinch.together"/>
30 <xsl:text>.ps +1 </xsl:text>
31 <xsl:call-template name="make.bold.title"/>
32 <xsl:text>.ps -1 </xsl:text>
33 <xsl:text>.br </xsl:text>
34 <xsl:apply-templates/>
35 <xsl:text>.sp .5v </xsl:text>
36 <xsl:if test="not($man.output.better.ps.enabled = 0)">
37 <xsl:text>.EM yellow </xsl:text>
39 <xsl:text>.RE </xsl:text>
42 <xsl:template match="formalpara">
43 <xsl:variable name="title.wrapper">
44 <xsl:value-of select="normalize-space(title[1])"/>
46 <xsl:text>.PP </xsl:text>
47 <!-- * don't put linebreak after head; instead render it as a "run in" -->
48 <!-- * head, that is, inline, with a period and space following it -->
49 <xsl:call-template name="bold">
50 <xsl:with-param name="node" select="exsl:node-set($title.wrapper)"/>
51 <xsl:with-param name="context" select="."/>
53 <xsl:text>. </xsl:text>
54 <xsl:apply-templates/>
57 <xsl:template match="formalpara/para">
58 <xsl:call-template name="mixed-block"/>
59 <xsl:text> </xsl:text>
62 <xsl:template match="para">
63 <!-- * FIXME: Need to extract the ancestor::footnote, etc. checking and -->
64 <!-- * move to named template so that we can call it from templates for -->
65 <!-- * other block elements also -->
67 <!-- * If a para is a descendant of a footnote, etc., then indent it -->
68 <!-- * (unless it is the first child, in which case don't generate -->
69 <!-- * anything at all to mark its start). -->
70 <!-- * FIXME: *blurb checking should not be munged in here the way -->
71 <!-- * it currently is; this probably breaks blurb indenting. -->
72 <xsl:when test="ancestor::footnote or
73 ancestor::annotation or
74 ancestor::authorblurb or
75 ancestor::personblurb or
77 <xsl:if test="preceding-sibling::*[not(name() ='')]">
78 <xsl:text>.sp</xsl:text>
79 <xsl:text> </xsl:text>
80 <xsl:text>.RS 4n</xsl:text>
81 <xsl:text> </xsl:text>
85 <xsl:text>.PP</xsl:text>
86 <xsl:text> </xsl:text>
89 <xsl:call-template name="mixed-block"/>
90 <xsl:if test="ancestor::footnote or
91 ancestor::annotation or
92 ancestor::authorblurb or
93 ancestor::personblurb">
94 <xsl:if test="preceding-sibling::*[not(name() ='')]">
95 <xsl:text> </xsl:text>
96 <xsl:text>.RE</xsl:text>
97 <xsl:text> </xsl:text>
100 <xsl:text> </xsl:text>
103 <xsl:template match="simpara">
104 <xsl:if test="not(ancestor::authorblurb)
105 and not(ancestor::personblurb)
106 and not(ancestor::callout)"
108 <xsl:text>.sp </xsl:text>
110 <xsl:variable name="content">
111 <xsl:apply-templates/>
113 <xsl:value-of select="normalize-space($content)"/>
114 <xsl:text> </xsl:text>
117 <!-- ==================================================================== -->
119 <!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. -->
120 <xsl:template match="literallayout|programlisting|screen|
121 address|synopsis|funcsynopsisinfo">
122 <xsl:param name="indent">
123 <!-- * Only indent this verbatim if $man.indent.verbatims is -->
124 <!-- * non-zero and it is not a child of a *synopsis element or a -->
125 <!-- * descendant of a refsynopsisdiv -->
126 <xsl:if test="not($man.indent.verbatims = 0)
127 and not(substring(local-name(..),
128 string-length(local-name(..))-7) = 'synopsis')
129 and not(ancestor::*[local-name() = 'refsynopsisdiv'])
131 <xsl:text>Yes</xsl:text>
135 <!-- * if this verbatim environment starts with a newline/linebreak -->
136 <!-- * (that is, if there is a linebreak after the opening tag), that -->
137 <!-- * break would otherwise show up in output; that does not seem to -->
138 <!-- * be what most users would expect, so we check to see if it does -->
139 <!-- * indeed start with a leading newline. if so, later in this -->
140 <!-- * template, we adjust for the leading new line by doing some -->
141 <!-- * monkeyshines with "sp -1" vertical spacing -->
142 <xsl:variable name="adjust-for-leading-newline">
143 <xsl:if test="substring(., 1, 1) = ' '">Yes</xsl:if>
147 <!-- * Check to see if this verbatim item is within a parent element that -->
148 <!-- * allows mixed content. -->
150 <!-- * If it is within a mixed-content parent, then a line space is -->
151 <!-- * already added before it by the mixed-block template, so we don't -->
152 <!-- * need to add one here. -->
154 <!-- * If it is not within a mixed-content parent, then we need to add a -->
155 <!-- * line space before it. -->
156 <xsl:when test="parent::caption|parent::entry|parent::para|
157 parent::td|parent::th" /> <!-- do nothing -->
159 <xsl:text> </xsl:text>
160 <xsl:text>.sp </xsl:text>
163 <xsl:if test="$indent = 'Yes'">
164 <!-- * start indented section -->
165 <xsl:call-template name="roff-if-start"/>
166 <!-- * only indent in TTY output, not in non-TTY/PS -->
167 <xsl:text>.RS</xsl:text>
168 <xsl:if test="not($man.indent.width = '')">
169 <xsl:text> </xsl:text>
170 <xsl:value-of select="$man.indent.width"/>
172 <xsl:text> </xsl:text>
173 <xsl:call-template name="roff-if-end"/>
176 <xsl:when test="self::funcsynopsisinfo">
177 <!-- * All Funcsynopsisinfo content is by default rendered in bold, -->
178 <!-- * because the man(7) man page says this: -->
180 <!-- * For functions, the arguments are always specified using -->
181 <!-- * italics, even in the SYNOPSIS section, where the rest of -->
182 <!-- * the function is specified in bold -->
184 <!-- * Look through the contents of the man/man2 and man3 directories -->
185 <!-- * on your system, and you'll see that most existing pages do follow -->
186 <!-- * this "bold everything in function synopsis" rule. -->
188 <!-- * Users who don't want the bold output can choose to adjust the -->
189 <!-- * man.font.funcsynopsisinfo parameter on their own. So even if you -->
190 <!-- * don't personally like the way it looks, please don't change the -->
191 <!-- * default to be non-bold - because it's a convention that's -->
192 <!-- * followed is the vast majority of existing man pages that document -->
193 <!-- * functions, and we need to follow it by default, like it or no. -->
194 <xsl:text>.ft </xsl:text>
195 <xsl:value-of select="$man.font.funcsynopsisinfo"/>
196 <xsl:text> </xsl:text>
197 <xsl:call-template name="verbatim-block-start"/>
198 <xsl:text>.nf </xsl:text>
199 <xsl:apply-templates/>
200 <xsl:text> </xsl:text>
201 <xsl:text>.fi </xsl:text>
202 <xsl:call-template name="verbatim-block-end"/>
203 <xsl:text>.ft </xsl:text>
206 <!-- * Other verbatims do not need to get bolded -->
207 <xsl:call-template name="verbatim-block-start"/>
208 <xsl:text>.nf </xsl:text>
210 <xsl:when test="self::literallayout|self::programlisting|self::screen
211 and not(ancestor::*[local-name() = 'refsynopsisdiv'])
212 and not($man.output.better.ps.enabled = 0)
214 <!-- * if this is a literallayout|programlisting|screen, -->
215 <!-- * and user has set man.output.better.ps.enabled to non-zero, -->
216 <!-- * then we put a background behind it in non-TTY output; except -->
217 <!-- * if it’s a descendant of a refsynopsisdiv (as can be -->
218 <!-- * found in the git docs) -->
220 <!-- * if content has a leading newline, we need to back up -->
221 <!-- * one line vertically to get it boxed correctly -->
222 <xsl:when test="not($adjust-for-leading-newline = '')">
223 <xsl:call-template name="roff-if-start">
224 <xsl:with-param name="condition">t</xsl:with-param>
226 <xsl:text>.sp -1 </xsl:text>
227 <xsl:call-template name="roff-if-end"/>
228 <xsl:text>.BB lightgray</xsl:text>
229 <xsl:text> </xsl:text>
230 <xsl:text>adjust-for-leading-newline </xsl:text>
231 <!-- * in non-TTY output, for the case where we have a -->
232 <!-- * leading newline, we need to also back up one line -->
233 <!-- * vertically inside the background box -->
234 <xsl:text>.sp -1 </xsl:text>
237 <xsl:text>.BB lightgray </xsl:text>
240 <xsl:apply-templates/>
241 <xsl:text> </xsl:text>
243 <xsl:when test="not($adjust-for-leading-newline = '')">
244 <xsl:text>.EB lightgray</xsl:text>
245 <xsl:text> </xsl:text>
246 <xsl:text>adjust-for-leading-newline </xsl:text>
247 <xsl:call-template name="roff-if-start">
248 <xsl:with-param name="condition">t</xsl:with-param>
250 <!-- * in non-TTY output, for the case where we have a -->
251 <!-- * leading newline, we need to add back at the end of -->
252 <!-- * the content some of the vertical space we chopped -->
253 <!-- * off at the beginning -->
254 <xsl:text>.sp 1 </xsl:text>
255 <xsl:call-template name="roff-if-end"/>
258 <xsl:text>.EB lightgray </xsl:text>
263 <!-- * otherwise this is not a literallayout|programlisting|screen, -->
264 <!-- * so we don’t put a background behind -->
265 <xsl:apply-templates/>
266 <xsl:text> </xsl:text>
269 <xsl:text>.fi </xsl:text>
270 <xsl:call-template name="verbatim-block-end"/>
273 <xsl:if test="$indent = 'Yes'">
274 <!-- * end indented section -->
275 <xsl:call-template name="roff-if-start"/>
276 <xsl:text>.RE </xsl:text>
277 <xsl:call-template name="roff-if-end"/>
279 <!-- * if this verbatim environment has a following sibling node, -->
280 <!-- * output a line of space to separate the content -->
281 <xsl:if test="following-sibling::text()
282 |following-sibling::para
283 |following-sibling::simpara">
284 <xsl:text>.sp </xsl:text>
288 <!-- ==================================================================== -->
290 <xsl:template match="table|informaltable">
291 <xsl:apply-templates select="." mode="to.tbl">
292 <!--* we call the to.tbl mode with the "source" param so that we can -->
293 <!--* preserve the context information and pass it down to the -->
294 <!--* named templates that do the actual table processing -->
295 <xsl:with-param name="source" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
296 </xsl:apply-templates>
299 <!-- ==================================================================== -->
301 <xsl:template match="informalexample">
302 <xsl:apply-templates/>
305 <!-- ==================================================================== -->
307 <xsl:template match="figure|example">
308 <xsl:variable name="param.placement"
309 select="substring-after(normalize-space($formal.title.placement),
310 concat(local-name(.), ' '))"/>
312 <xsl:variable name="placement">
314 <xsl:when test="contains($param.placement, ' ')">
315 <xsl:value-of select="substring-before($param.placement, ' ')"/>
317 <xsl:when test="$param.placement = ''">before</xsl:when>
319 <xsl:value-of select="$param.placement"/>
324 <xsl:text>.PP </xsl:text>
325 <xsl:call-template name="formal.object">
326 <xsl:with-param name="placement" select="$placement"/>
328 <xsl:text> </xsl:text>
331 <!-- ==================================================================== -->
333 <xsl:template match="mediaobject">
334 <xsl:text>.sp</xsl:text>
335 <xsl:text> </xsl:text>
336 <xsl:text>.RS</xsl:text>
337 <xsl:if test="not($list-indent = '')">
338 <xsl:text> </xsl:text>
339 <xsl:value-of select="$list-indent"/>
341 <xsl:text> </xsl:text>
342 <xsl:apply-templates/>
343 <xsl:text> </xsl:text>
344 <xsl:text>.RE </xsl:text>
347 <xsl:template match="imageobject">
348 <xsl:text>[IMAGE]</xsl:text>
349 <xsl:apply-templates/>
350 <xsl:text> </xsl:text>
353 <xsl:template match="textobject[parent::inlinemediaobject]">
354 <xsl:text>[</xsl:text>
355 <xsl:value-of select="."/>
356 <xsl:text>]</xsl:text>
359 <xsl:template match="textobject">
360 <xsl:apply-templates/>
363 <!-- ==================================================================== -->
365 <xsl:template name="formal.object">
366 <xsl:param name="placement" select="'before'"/>
367 <xsl:param name="class" select="local-name(.)"/>
370 <xsl:when test="$placement = 'before'">
371 <xsl:call-template name="formal.object.heading"/>
372 <xsl:apply-templates/>
375 <xsl:apply-templates/>
376 <xsl:call-template name="formal.object.heading"/>
381 <xsl:template name="formal.object.heading">
382 <xsl:param name="object" select="."/>
383 <xsl:param name="title">
384 <xsl:apply-templates select="$object" mode="object.title.markup.textonly"/>
386 <xsl:call-template name="bold">
387 <xsl:with-param name="node" select="exsl:node-set($title)"/>
388 <xsl:with-param name="context" select="."/>
391 <xsl:text> </xsl:text>
394 <!-- ==================================================================== -->
396 <!-- * suppress abstract -->
397 <xsl:template match="abstract"/>