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 8703 2010-07-06 20:57:06Z nwalsh $
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">
105 <xsl:when test="ancestor::footnote or
106 ancestor::annotation or
107 ancestor::authorblurb or
108 ancestor::personblurb or
110 <xsl:if test="preceding-sibling::*[not(name() ='')]">
111 <xsl:text>.sp</xsl:text>
112 <xsl:text> </xsl:text>
113 <xsl:text>.RS 4n</xsl:text>
114 <xsl:text> </xsl:text>
118 <xsl:text>.sp</xsl:text>
119 <xsl:text> </xsl:text>
122 <xsl:variable name="content">
123 <xsl:apply-templates/>
125 <xsl:value-of select="normalize-space($content)"/>
126 <xsl:text> </xsl:text>
129 <!-- ==================================================================== -->
131 <!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. -->
132 <xsl:template match="literallayout|programlisting|screen|
133 address|synopsis|funcsynopsisinfo">
134 <xsl:param name="indent">
135 <!-- * Only indent this verbatim if $man.indent.verbatims is -->
136 <!-- * non-zero and it is not a child of a *synopsis element or a -->
137 <!-- * descendant of a refsynopsisdiv -->
138 <xsl:if test="not($man.indent.verbatims = 0)
139 and not(substring(local-name(..),
140 string-length(local-name(..))-7) = 'synopsis')
141 and not(ancestor::*[local-name() = 'refsynopsisdiv'])
143 <xsl:text>Yes</xsl:text>
147 <!-- * if this verbatim environment starts with a newline/linebreak -->
148 <!-- * (that is, if there is a linebreak after the opening tag), that -->
149 <!-- * break would otherwise show up in output; that does not seem to -->
150 <!-- * be what most users would expect, so we check to see if it does -->
151 <!-- * indeed start with a leading newline. if so, later in this -->
152 <!-- * template, we adjust for the leading new line by doing some -->
153 <!-- * monkeyshines with "sp -1" vertical spacing -->
154 <xsl:variable name="adjust-for-leading-newline">
155 <xsl:if test="substring(., 1, 1) = ' '">Yes</xsl:if>
159 <!-- * Check to see if this verbatim item is within a parent element that -->
160 <!-- * allows mixed content. -->
162 <!-- * If it is within a mixed-content parent, then a line space is -->
163 <!-- * already added before it by the mixed-block template, so we don't -->
164 <!-- * need to add one here. -->
166 <!-- * If it is not within a mixed-content parent, then we need to add a -->
167 <!-- * line space before it. -->
168 <xsl:when test="parent::caption|parent::entry|parent::para|
169 parent::td|parent::th" /> <!-- do nothing -->
171 <xsl:text> </xsl:text>
172 <xsl:text>.sp </xsl:text>
175 <xsl:if test="$indent = 'Yes'">
176 <!-- * start indented section -->
177 <xsl:call-template name="roff-if-start"/>
178 <!-- * only indent in TTY output, not in non-TTY/PS -->
179 <xsl:text>.RS</xsl:text>
180 <xsl:if test="not($man.indent.width = '')">
181 <xsl:text> </xsl:text>
182 <xsl:value-of select="$man.indent.width"/>
184 <xsl:text> </xsl:text>
185 <xsl:call-template name="roff-if-end"/>
188 <xsl:when test="self::funcsynopsisinfo">
189 <!-- * All Funcsynopsisinfo content is by default rendered in bold, -->
190 <!-- * because the man(7) man page says this: -->
192 <!-- * For functions, the arguments are always specified using -->
193 <!-- * italics, even in the SYNOPSIS section, where the rest of -->
194 <!-- * the function is specified in bold -->
196 <!-- * Look through the contents of the man/man2 and man3 directories -->
197 <!-- * on your system, and you'll see that most existing pages do follow -->
198 <!-- * this "bold everything in function synopsis" rule. -->
200 <!-- * Users who don't want the bold output can choose to adjust the -->
201 <!-- * man.font.funcsynopsisinfo parameter on their own. So even if you -->
202 <!-- * don't personally like the way it looks, please don't change the -->
203 <!-- * default to be non-bold - because it's a convention that's -->
204 <!-- * followed is the vast majority of existing man pages that document -->
205 <!-- * functions, and we need to follow it by default, like it or no. -->
206 <xsl:text>.ft </xsl:text>
207 <xsl:value-of select="$man.font.funcsynopsisinfo"/>
208 <xsl:text> </xsl:text>
209 <xsl:call-template name="verbatim-block-start"/>
210 <xsl:text>.nf </xsl:text>
211 <xsl:apply-templates/>
212 <xsl:text> </xsl:text>
213 <xsl:text>.fi </xsl:text>
214 <xsl:call-template name="verbatim-block-end"/>
215 <xsl:text>.ft </xsl:text>
218 <!-- * Other verbatims do not need to get bolded -->
219 <xsl:call-template name="verbatim-block-start"/>
220 <xsl:text>.nf </xsl:text>
222 <xsl:when test="self::literallayout|self::programlisting|self::screen
223 and not(ancestor::*[local-name() = 'refsynopsisdiv'])
224 and not($man.output.better.ps.enabled = 0)
226 <!-- * if this is a literallayout|programlisting|screen, -->
227 <!-- * and user has set man.output.better.ps.enabled to non-zero, -->
228 <!-- * then we put a background behind it in non-TTY output; except -->
229 <!-- * if it’s a descendant of a refsynopsisdiv (as can be -->
230 <!-- * found in the git docs) -->
232 <!-- * if content has a leading newline, we need to back up -->
233 <!-- * one line vertically to get it boxed correctly -->
234 <xsl:when test="not($adjust-for-leading-newline = '')">
235 <xsl:call-template name="roff-if-start">
236 <xsl:with-param name="condition">t</xsl:with-param>
238 <xsl:text>.sp -1 </xsl:text>
239 <xsl:call-template name="roff-if-end"/>
240 <xsl:text>.BB lightgray</xsl:text>
241 <xsl:text> </xsl:text>
242 <xsl:text>adjust-for-leading-newline </xsl:text>
243 <!-- * in non-TTY output, for the case where we have a -->
244 <!-- * leading newline, we need to also back up one line -->
245 <!-- * vertically inside the background box -->
246 <xsl:text>.sp -1 </xsl:text>
249 <xsl:text>.BB lightgray </xsl:text>
252 <xsl:apply-templates/>
253 <xsl:text> </xsl:text>
255 <xsl:when test="not($adjust-for-leading-newline = '')">
256 <xsl:text>.EB lightgray</xsl:text>
257 <xsl:text> </xsl:text>
258 <xsl:text>adjust-for-leading-newline </xsl:text>
259 <xsl:call-template name="roff-if-start">
260 <xsl:with-param name="condition">t</xsl:with-param>
262 <!-- * in non-TTY output, for the case where we have a -->
263 <!-- * leading newline, we need to add back at the end of -->
264 <!-- * the content some of the vertical space we chopped -->
265 <!-- * off at the beginning -->
266 <xsl:text>.sp 1 </xsl:text>
267 <xsl:call-template name="roff-if-end"/>
270 <xsl:text>.EB lightgray </xsl:text>
275 <!-- * otherwise this is not a literallayout|programlisting|screen, -->
276 <!-- * so we don’t put a background behind -->
277 <xsl:apply-templates/>
278 <xsl:text> </xsl:text>
281 <xsl:text>.fi </xsl:text>
282 <xsl:call-template name="verbatim-block-end"/>
285 <xsl:if test="$indent = 'Yes'">
286 <!-- * end indented section -->
287 <xsl:call-template name="roff-if-start"/>
288 <xsl:text>.RE </xsl:text>
289 <xsl:call-template name="roff-if-end"/>
291 <!-- * if this verbatim environment has a following sibling node, -->
292 <!-- * output a line of space to separate the content -->
293 <xsl:if test="following-sibling::text()
294 |following-sibling::para
295 |following-sibling::simpara">
296 <xsl:text>.sp </xsl:text>
300 <!-- ==================================================================== -->
302 <xsl:template match="table|informaltable">
303 <xsl:apply-templates select="." mode="to.tbl">
304 <!--* we call the to.tbl mode with the "source" param so that we can -->
305 <!--* preserve the context information and pass it down to the -->
306 <!--* named templates that do the actual table processing -->
307 <xsl:with-param name="source" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
308 </xsl:apply-templates>
311 <!-- ==================================================================== -->
313 <xsl:template match="informalexample">
314 <xsl:apply-templates/>
317 <!-- ==================================================================== -->
319 <xsl:template match="figure|example">
320 <xsl:variable name="param.placement"
321 select="substring-after(normalize-space($formal.title.placement),
322 concat(local-name(.), ' '))"/>
324 <xsl:variable name="placement">
326 <xsl:when test="contains($param.placement, ' ')">
327 <xsl:value-of select="substring-before($param.placement, ' ')"/>
329 <xsl:when test="$param.placement = ''">before</xsl:when>
331 <xsl:value-of select="$param.placement"/>
336 <xsl:text>.PP </xsl:text>
337 <xsl:call-template name="formal.object">
338 <xsl:with-param name="placement" select="$placement"/>
340 <xsl:text> </xsl:text>
343 <!-- ==================================================================== -->
345 <xsl:template match="mediaobject">
346 <xsl:text>.sp</xsl:text>
347 <xsl:text> </xsl:text>
348 <xsl:text>.RS</xsl:text>
349 <xsl:if test="not($list-indent = '')">
350 <xsl:text> </xsl:text>
351 <xsl:value-of select="$list-indent"/>
353 <xsl:text> </xsl:text>
354 <xsl:apply-templates/>
355 <xsl:text> </xsl:text>
356 <xsl:text>.RE </xsl:text>
359 <xsl:template match="imageobject">
360 <xsl:text>[IMAGE]</xsl:text>
361 <xsl:apply-templates/>
362 <xsl:text> </xsl:text>
365 <xsl:template match="textobject[parent::inlinemediaobject]">
366 <xsl:text>[</xsl:text>
367 <xsl:value-of select="."/>
368 <xsl:text>]</xsl:text>
371 <xsl:template match="textobject">
372 <xsl:apply-templates/>
375 <!-- ==================================================================== -->
377 <xsl:template name="formal.object">
378 <xsl:param name="placement" select="'before'"/>
379 <xsl:param name="class" select="local-name(.)"/>
382 <xsl:when test="$placement = 'before'">
383 <xsl:call-template name="formal.object.heading"/>
384 <xsl:apply-templates/>
387 <xsl:apply-templates/>
388 <xsl:call-template name="formal.object.heading"/>
393 <xsl:template name="formal.object.heading">
394 <xsl:param name="object" select="."/>
395 <xsl:param name="title">
396 <xsl:apply-templates select="$object" mode="object.title.markup.textonly"/>
398 <xsl:call-template name="bold">
399 <xsl:with-param name="node" select="exsl:node-set($title)"/>
400 <xsl:with-param name="context" select="."/>
403 <xsl:text> </xsl:text>
406 <!-- ==================================================================== -->
408 <!-- * suppress abstract -->
409 <xsl:template match="abstract"/>