2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:d="http://docbook.org/ns/docbook"
4 xmlns:exsl="http://exslt.org/common"
5 exclude-result-prefixes="exsl d"
8 <!-- ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://cdn.docbook.org/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:template match="d:caution|d:important|d:note|d:tip|d:warning">
19 <xsl:call-template name="roff-if-start">
20 <xsl:with-param name="condition">n</xsl:with-param>
22 <xsl:text>.sp </xsl:text>
23 <xsl:call-template name="roff-if-end"/>
24 <xsl:text>.RS 4 </xsl:text>
25 <xsl:if test="not($man.output.better.ps.enabled = 0)">
26 <xsl:text>.BM yellow </xsl:text>
28 <xsl:call-template name="pinch.together"/>
29 <xsl:text>.ps +1 </xsl:text>
30 <xsl:call-template name="make.bold.title"/>
31 <xsl:text>.ps -1 </xsl:text>
32 <xsl:text>.br </xsl:text>
33 <xsl:apply-templates/>
34 <xsl:text>.sp .5v </xsl:text>
35 <xsl:if test="not($man.output.better.ps.enabled = 0)">
36 <xsl:text>.EM yellow </xsl:text>
38 <xsl:text>.RE </xsl:text>
41 <xsl:template match="d:formalpara">
42 <xsl:variable name="title.wrapper">
43 <xsl:value-of select="normalize-space(d:title[1])"/>
45 <xsl:text>.PP </xsl:text>
46 <!-- * don't put linebreak after head; instead render it as a "run in" -->
47 <!-- * head, that is, inline, with a period and space following it -->
48 <xsl:call-template name="bold">
49 <xsl:with-param name="node" select="exsl:node-set($title.wrapper)"/>
50 <xsl:with-param name="context" select="."/>
52 <xsl:text>. </xsl:text>
53 <xsl:apply-templates/>
56 <xsl:template match="d:formalpara/d:para">
57 <xsl:call-template name="mixed-block"/>
58 <xsl:text> </xsl:text>
61 <xsl:template match="d:para">
62 <!-- * FIXME: Need to extract the ancestor::footnote, etc. checking and -->
63 <!-- * move to named template so that we can call it from templates for -->
64 <!-- * other block elements also -->
66 <!-- * If a para is a descendant of a footnote, etc., then indent it -->
67 <!-- * (unless it is the first child, in which case don't generate -->
68 <!-- * anything at all to mark its start). -->
69 <!-- * FIXME: *blurb checking should not be munged in here the way -->
70 <!-- * it currently is; this probably breaks blurb indenting. -->
71 <xsl:when test="ancestor::d:footnote or
72 ancestor::d:annotation or
73 ancestor::d:authorblurb or
74 ancestor::d:personblurb or
76 <xsl:if test="preceding-sibling::*[not(name() ='')]">
77 <xsl:text>.sp</xsl:text>
78 <xsl:text> </xsl:text>
79 <xsl:text>.RS 4n</xsl:text>
80 <xsl:text> </xsl:text>
84 <xsl:text>.PP</xsl:text>
85 <xsl:text> </xsl:text>
88 <xsl:call-template name="mixed-block"/>
89 <xsl:if test="ancestor::d:footnote or
90 ancestor::d:annotation or
91 ancestor::d:authorblurb or
92 ancestor::d:personblurb">
93 <xsl:if test="preceding-sibling::*[not(name() ='')]">
94 <xsl:text> </xsl:text>
95 <xsl:text>.RE</xsl:text>
96 <xsl:text> </xsl:text>
99 <xsl:text> </xsl:text>
102 <xsl:template match="d:simpara">
104 <xsl:when test="ancestor::d:footnote or
105 ancestor::d:annotation or
106 ancestor::d:authorblurb or
107 ancestor::d:personblurb or
108 ancestor::d:callout">
109 <xsl:if test="preceding-sibling::*[not(name() ='')]">
110 <xsl:text>.sp</xsl:text>
111 <xsl:text> </xsl:text>
112 <xsl:text>.RS 4n</xsl:text>
113 <xsl:text> </xsl:text>
117 <xsl:text>.sp</xsl:text>
118 <xsl:text> </xsl:text>
121 <xsl:variable name="content">
122 <xsl:apply-templates/>
124 <xsl:value-of select="normalize-space($content)"/>
125 <xsl:text> </xsl:text>
128 <!-- ==================================================================== -->
130 <!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. -->
131 <xsl:template match="d:literallayout|d:programlisting|d:screen|
132 d:address|d:synopsis|d:funcsynopsisinfo">
133 <xsl:param name="indent">
134 <!-- * Only indent this verbatim if $man.indent.verbatims is -->
135 <!-- * non-zero and it is not a child of a *synopsis element or a -->
136 <!-- * descendant of a refsynopsisdiv -->
137 <xsl:if test="not($man.indent.verbatims = 0)
138 and not(substring(local-name(..),
139 string-length(local-name(..))-7) = 'synopsis')
140 and not(ancestor::*[local-name() = 'refsynopsisdiv'])
141 and not(ancestor::*[local-name() = 'term'])
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::d:caption|parent::d:entry|parent::d:para|
169 parent::d:td|parent::d: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::d: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::d:literallayout|self::d:programlisting|self::d: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::d:para
295 |following-sibling::d:simpara">
296 <xsl:text>.sp </xsl:text>
300 <!-- ==================================================================== -->
302 <xsl:template match="d:table|d: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::d:refentry/d:refnamediv[1]/d:refname[1]"/>
308 </xsl:apply-templates>
311 <!-- ==================================================================== -->
313 <xsl:template match="d:informalexample">
314 <xsl:apply-templates/>
317 <!-- ==================================================================== -->
319 <xsl:template match="d:figure|d: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="d: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="d:imageobject">
360 <xsl:text>[IMAGE]</xsl:text>
361 <xsl:apply-templates/>
362 <xsl:text> </xsl:text>
365 <xsl:template match="d:textobject[parent::d:inlinemediaobject]">
366 <xsl:text>[</xsl:text>
367 <xsl:value-of select="."/>
368 <xsl:text>]</xsl:text>
371 <xsl:template match="d: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="d:abstract"/>