]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/styleguide/docbook-xsl-1.75.2/manpages/block.xsl
stylesheet changes.
[working/Evergreen.git] / stylesheets / styleguide / docbook-xsl-1.75.2 / manpages / block.xsl
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 8235 2009-02-09 16:22:14Z xmldoc $
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:if test="not(ancestor::authorblurb)
105     and not(ancestor::personblurb)
106     and not(ancestor::callout)"
107     >
108     <xsl:text>.sp&#10;</xsl:text>
109   </xsl:if>
110   <xsl:variable name="content">
111     <xsl:apply-templates/>
112   </xsl:variable>
113   <xsl:value-of select="normalize-space($content)"/>
114   <xsl:text>&#10;</xsl:text>
115 </xsl:template>
116
117 <!-- ==================================================================== -->
118
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'])
130       ">
131       <xsl:text>Yes</xsl:text>
132     </xsl:if>
133   </xsl:param>
134
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) = '&#10;'">Yes</xsl:if>
144   </xsl:variable>
145
146   <xsl:choose>
147     <!-- * Check to see if this verbatim item is within a parent element that -->
148     <!-- * allows mixed content. -->
149     <!-- * -->
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. -->
153     <!-- * -->
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 -->
158     <xsl:otherwise>
159       <xsl:text>&#10;</xsl:text>
160       <xsl:text>.sp&#10;</xsl:text>
161     </xsl:otherwise>
162   </xsl:choose>
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"/>
171     </xsl:if>
172     <xsl:text>&#10;</xsl:text>
173     <xsl:call-template name="roff-if-end"/>
174   </xsl:if>
175   <xsl:choose>
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: -->
179       <!-- * -->
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 -->
183       <!-- * -->
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. -->
187       <!-- * -->
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>&#10;</xsl:text>
197       <xsl:call-template name="verbatim-block-start"/>
198       <xsl:text>.nf&#10;</xsl:text>
199       <xsl:apply-templates/>
200       <xsl:text>&#10;</xsl:text>
201       <xsl:text>.fi&#10;</xsl:text>
202       <xsl:call-template name="verbatim-block-end"/>
203       <xsl:text>.ft&#10;</xsl:text>
204     </xsl:when>
205     <xsl:otherwise>
206       <!-- * Other verbatims do not need to get bolded -->
207       <xsl:call-template name="verbatim-block-start"/>
208       <xsl:text>.nf&#10;</xsl:text>
209       <xsl:choose>
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)
213           ">
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) -->
219           <xsl:choose>
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>
225               </xsl:call-template>
226               <xsl:text>.sp -1&#10;</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&#10;</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&#10;</xsl:text>
235             </xsl:when>
236             <xsl:otherwise>
237               <xsl:text>.BB lightgray&#10;</xsl:text>
238             </xsl:otherwise>
239           </xsl:choose>
240           <xsl:apply-templates/>
241           <xsl:text>&#10;</xsl:text>
242           <xsl:choose>
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&#10;</xsl:text>
247               <xsl:call-template name="roff-if-start">
248                 <xsl:with-param name="condition">t</xsl:with-param>
249               </xsl:call-template>
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&#10;</xsl:text>
255               <xsl:call-template name="roff-if-end"/>
256             </xsl:when>
257             <xsl:otherwise>
258               <xsl:text>.EB lightgray&#10;</xsl:text>
259             </xsl:otherwise>
260           </xsl:choose>
261         </xsl:when>
262         <xsl:otherwise>
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>&#10;</xsl:text>
267         </xsl:otherwise>
268       </xsl:choose>
269       <xsl:text>.fi&#10;</xsl:text>
270       <xsl:call-template name="verbatim-block-end"/>
271     </xsl:otherwise>
272   </xsl:choose>
273   <xsl:if test="$indent = 'Yes'">
274     <!-- * end indented section -->
275     <xsl:call-template name="roff-if-start"/>
276     <xsl:text>.RE&#10;</xsl:text> 
277     <xsl:call-template name="roff-if-end"/>
278   </xsl:if>
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&#10;</xsl:text>
285   </xsl:if>
286 </xsl:template>
287
288 <!-- ==================================================================== -->
289
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>
297 </xsl:template>
298
299 <!-- ==================================================================== -->
300
301 <xsl:template match="informalexample">
302   <xsl:apply-templates/>
303 </xsl:template>
304
305 <!-- ==================================================================== -->
306
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(.), ' '))"/>
311
312   <xsl:variable name="placement">
313     <xsl:choose>
314       <xsl:when test="contains($param.placement, ' ')">
315         <xsl:value-of select="substring-before($param.placement, ' ')"/>
316       </xsl:when>
317       <xsl:when test="$param.placement = ''">before</xsl:when>
318       <xsl:otherwise>
319         <xsl:value-of select="$param.placement"/>
320       </xsl:otherwise>
321     </xsl:choose>
322   </xsl:variable>
323
324   <xsl:text>.PP&#10;</xsl:text>
325   <xsl:call-template name="formal.object">
326     <xsl:with-param name="placement" select="$placement"/>
327   </xsl:call-template>
328   <xsl:text>&#10;</xsl:text>
329 </xsl:template>
330
331 <!-- ==================================================================== -->
332
333 <xsl:template match="mediaobject">
334   <xsl:text>.sp</xsl:text>
335   <xsl:text>&#10;</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"/>
340   </xsl:if>
341   <xsl:text>&#10;</xsl:text>
342   <xsl:apply-templates/>
343   <xsl:text>&#10;</xsl:text>
344   <xsl:text>.RE&#10;</xsl:text>
345 </xsl:template>
346
347 <xsl:template match="imageobject">
348   <xsl:text>[IMAGE]</xsl:text>
349   <xsl:apply-templates/>
350   <xsl:text>&#10;</xsl:text>
351 </xsl:template>
352
353 <xsl:template match="textobject[parent::inlinemediaobject]">
354   <xsl:text>[</xsl:text>
355   <xsl:value-of select="."/>
356   <xsl:text>]</xsl:text>
357 </xsl:template>
358
359 <xsl:template match="textobject">
360   <xsl:apply-templates/>
361 </xsl:template>
362
363 <!-- ==================================================================== -->
364
365 <xsl:template name="formal.object">
366   <xsl:param name="placement" select="'before'"/>
367   <xsl:param name="class" select="local-name(.)"/>
368
369   <xsl:choose>
370     <xsl:when test="$placement = 'before'">
371       <xsl:call-template name="formal.object.heading"/>
372       <xsl:apply-templates/>
373     </xsl:when>
374     <xsl:otherwise>
375       <xsl:apply-templates/>
376       <xsl:call-template name="formal.object.heading"/>
377     </xsl:otherwise>
378   </xsl:choose>
379 </xsl:template>
380
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"/>
385   </xsl:param>
386   <xsl:call-template name="bold">
387     <xsl:with-param name="node" select="exsl:node-set($title)"/>
388     <xsl:with-param name="context" select="."/>
389   </xsl:call-template>
390
391   <xsl:text>&#10;</xsl:text>
392 </xsl:template>
393
394 <!-- ==================================================================== -->
395
396 <!-- * suppress abstract -->
397 <xsl:template match="abstract"/>
398
399 </xsl:stylesheet>