source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/manpages/block.xsl@ c158fe6

7.5-systemd 7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since c158fe6 was b1a51ac1, checked in by Krejzi <krejzi@…>, 11 years ago

Import new branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10389 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 15.7 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 exclude-result-prefixes="exsl"
5 version='1.0'>
6
7<!-- ********************************************************************
8 $Id: block.xsl 8703 2010-07-06 20:57:06Z nwalsh $
9 ********************************************************************
10
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.
14
15 ******************************************************************** -->
16
17<!-- ==================================================================== -->
18
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>
22 </xsl:call-template>
23 <xsl:text>.sp&#10;</xsl:text>
24 <xsl:call-template name="roff-if-end"/>
25 <xsl:text>.RS 4&#10;</xsl:text>
26 <xsl:if test="not($man.output.better.ps.enabled = 0)">
27 <xsl:text>.BM yellow&#10;</xsl:text>
28 </xsl:if>
29 <xsl:call-template name="pinch.together"/>
30 <xsl:text>.ps +1&#10;</xsl:text>
31 <xsl:call-template name="make.bold.title"/>
32 <xsl:text>.ps -1&#10;</xsl:text>
33 <xsl:text>.br&#10;</xsl:text>
34 <xsl:apply-templates/>
35 <xsl:text>.sp .5v&#10;</xsl:text>
36 <xsl:if test="not($man.output.better.ps.enabled = 0)">
37 <xsl:text>.EM yellow&#10;</xsl:text>
38 </xsl:if>
39 <xsl:text>.RE&#10;</xsl:text>
40</xsl:template>
41
42<xsl:template match="formalpara">
43 <xsl:variable name="title.wrapper">
44 <xsl:value-of select="normalize-space(title[1])"/>
45 </xsl:variable>
46 <xsl:text>.PP&#10;</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="."/>
52 </xsl:call-template>
53 <xsl:text>. </xsl:text>
54 <xsl:apply-templates/>
55</xsl:template>
56
57<xsl:template match="formalpara/para">
58 <xsl:call-template name="mixed-block"/>
59 <xsl:text>&#10;</xsl:text>
60</xsl:template>
61
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 -->
66 <xsl:choose>
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
76 ancestor::callout">
77 <xsl:if test="preceding-sibling::*[not(name() ='')]">
78 <xsl:text>.sp</xsl:text>
79 <xsl:text>&#10;</xsl:text>
80 <xsl:text>.RS 4n</xsl:text>
81 <xsl:text>&#10;</xsl:text>
82 </xsl:if>
83 </xsl:when>
84 <xsl:otherwise>
85 <xsl:text>.PP</xsl:text>
86 <xsl:text>&#10;</xsl:text>
87 </xsl:otherwise>
88 </xsl:choose>
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>&#10;</xsl:text>
96 <xsl:text>.RE</xsl:text>
97 <xsl:text>&#10;</xsl:text>
98 </xsl:if>
99 </xsl:if>
100 <xsl:text>&#10;</xsl:text>
101</xsl:template>
102
103<xsl:template match="simpara">
104 <xsl:choose>
105 <xsl:when test="ancestor::footnote or
106 ancestor::annotation or
107 ancestor::authorblurb or
108 ancestor::personblurb or
109 ancestor::callout">
110 <xsl:if test="preceding-sibling::*[not(name() ='')]">
111 <xsl:text>.sp</xsl:text>
112 <xsl:text>&#10;</xsl:text>
113 <xsl:text>.RS 4n</xsl:text>
114 <xsl:text>&#10;</xsl:text>
115 </xsl:if>
116 </xsl:when>
117 <xsl:otherwise>
118 <xsl:text>.sp</xsl:text>
119 <xsl:text>&#10;</xsl:text>
120 </xsl:otherwise>
121 </xsl:choose>
122 <xsl:variable name="content">
123 <xsl:apply-templates/>
124 </xsl:variable>
125 <xsl:value-of select="normalize-space($content)"/>
126 <xsl:text>&#10;</xsl:text>
127</xsl:template>
128
129<!-- ==================================================================== -->
130
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'])
142 ">
143 <xsl:text>Yes</xsl:text>
144 </xsl:if>
145 </xsl:param>
146
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) = '&#10;'">Yes</xsl:if>
156 </xsl:variable>
157
158 <xsl:choose>
159 <!-- * Check to see if this verbatim item is within a parent element that -->
160 <!-- * allows mixed content. -->
161 <!-- * -->
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. -->
165 <!-- * -->
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 -->
170 <xsl:otherwise>
171 <xsl:text>&#10;</xsl:text>
172 <xsl:text>.sp&#10;</xsl:text>
173 </xsl:otherwise>
174 </xsl:choose>
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"/>
183 </xsl:if>
184 <xsl:text>&#10;</xsl:text>
185 <xsl:call-template name="roff-if-end"/>
186 </xsl:if>
187 <xsl:choose>
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: -->
191 <!-- * -->
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 -->
195 <!-- * -->
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. -->
199 <!-- * -->
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>&#10;</xsl:text>
209 <xsl:call-template name="verbatim-block-start"/>
210 <xsl:text>.nf&#10;</xsl:text>
211 <xsl:apply-templates/>
212 <xsl:text>&#10;</xsl:text>
213 <xsl:text>.fi&#10;</xsl:text>
214 <xsl:call-template name="verbatim-block-end"/>
215 <xsl:text>.ft&#10;</xsl:text>
216 </xsl:when>
217 <xsl:otherwise>
218 <!-- * Other verbatims do not need to get bolded -->
219 <xsl:call-template name="verbatim-block-start"/>
220 <xsl:text>.nf&#10;</xsl:text>
221 <xsl:choose>
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)
225 ">
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) -->
231 <xsl:choose>
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>
237 </xsl:call-template>
238 <xsl:text>.sp -1&#10;</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&#10;</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&#10;</xsl:text>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:text>.BB lightgray&#10;</xsl:text>
250 </xsl:otherwise>
251 </xsl:choose>
252 <xsl:apply-templates/>
253 <xsl:text>&#10;</xsl:text>
254 <xsl:choose>
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&#10;</xsl:text>
259 <xsl:call-template name="roff-if-start">
260 <xsl:with-param name="condition">t</xsl:with-param>
261 </xsl:call-template>
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&#10;</xsl:text>
267 <xsl:call-template name="roff-if-end"/>
268 </xsl:when>
269 <xsl:otherwise>
270 <xsl:text>.EB lightgray&#10;</xsl:text>
271 </xsl:otherwise>
272 </xsl:choose>
273 </xsl:when>
274 <xsl:otherwise>
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>&#10;</xsl:text>
279 </xsl:otherwise>
280 </xsl:choose>
281 <xsl:text>.fi&#10;</xsl:text>
282 <xsl:call-template name="verbatim-block-end"/>
283 </xsl:otherwise>
284 </xsl:choose>
285 <xsl:if test="$indent = 'Yes'">
286 <!-- * end indented section -->
287 <xsl:call-template name="roff-if-start"/>
288 <xsl:text>.RE&#10;</xsl:text>
289 <xsl:call-template name="roff-if-end"/>
290 </xsl:if>
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&#10;</xsl:text>
297 </xsl:if>
298</xsl:template>
299
300<!-- ==================================================================== -->
301
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>
309</xsl:template>
310
311<!-- ==================================================================== -->
312
313<xsl:template match="informalexample">
314 <xsl:apply-templates/>
315</xsl:template>
316
317<!-- ==================================================================== -->
318
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(.), ' '))"/>
323
324 <xsl:variable name="placement">
325 <xsl:choose>
326 <xsl:when test="contains($param.placement, ' ')">
327 <xsl:value-of select="substring-before($param.placement, ' ')"/>
328 </xsl:when>
329 <xsl:when test="$param.placement = ''">before</xsl:when>
330 <xsl:otherwise>
331 <xsl:value-of select="$param.placement"/>
332 </xsl:otherwise>
333 </xsl:choose>
334 </xsl:variable>
335
336 <xsl:text>.PP&#10;</xsl:text>
337 <xsl:call-template name="formal.object">
338 <xsl:with-param name="placement" select="$placement"/>
339 </xsl:call-template>
340 <xsl:text>&#10;</xsl:text>
341</xsl:template>
342
343<!-- ==================================================================== -->
344
345<xsl:template match="mediaobject">
346 <xsl:text>.sp</xsl:text>
347 <xsl:text>&#10;</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"/>
352 </xsl:if>
353 <xsl:text>&#10;</xsl:text>
354 <xsl:apply-templates/>
355 <xsl:text>&#10;</xsl:text>
356 <xsl:text>.RE&#10;</xsl:text>
357</xsl:template>
358
359<xsl:template match="imageobject">
360 <xsl:text>[IMAGE]</xsl:text>
361 <xsl:apply-templates/>
362 <xsl:text>&#10;</xsl:text>
363</xsl:template>
364
365<xsl:template match="textobject[parent::inlinemediaobject]">
366 <xsl:text>[</xsl:text>
367 <xsl:value-of select="."/>
368 <xsl:text>]</xsl:text>
369</xsl:template>
370
371<xsl:template match="textobject">
372 <xsl:apply-templates/>
373</xsl:template>
374
375<!-- ==================================================================== -->
376
377<xsl:template name="formal.object">
378 <xsl:param name="placement" select="'before'"/>
379 <xsl:param name="class" select="local-name(.)"/>
380
381 <xsl:choose>
382 <xsl:when test="$placement = 'before'">
383 <xsl:call-template name="formal.object.heading"/>
384 <xsl:apply-templates/>
385 </xsl:when>
386 <xsl:otherwise>
387 <xsl:apply-templates/>
388 <xsl:call-template name="formal.object.heading"/>
389 </xsl:otherwise>
390 </xsl:choose>
391</xsl:template>
392
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"/>
397 </xsl:param>
398 <xsl:call-template name="bold">
399 <xsl:with-param name="node" select="exsl:node-set($title)"/>
400 <xsl:with-param name="context" select="."/>
401 </xsl:call-template>
402
403 <xsl:text>&#10;</xsl:text>
404</xsl:template>
405
406<!-- ==================================================================== -->
407
408<!-- * suppress abstract -->
409<xsl:template match="abstract"/>
410
411</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.