| 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 6843 2007-06-20 12:21:13Z 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="nested-section-title"/> |
| 21 |
<xsl:apply-templates/> |
| 22 |
<xsl:text> </xsl:text> |
| 23 |
</xsl:template> |
| 24 |
|
| 25 |
<xsl:template match="formalpara"> |
| 26 |
<xsl:variable name="title.wrapper"> |
| 27 |
<xsl:value-of select="normalize-space(title[1])"/> |
| 28 |
</xsl:variable> |
| 29 |
<xsl:text>.PP </xsl:text> |
| 30 |
<!-- * don't put linebreak after head; instead render it as a "run in" --> |
| 31 |
<!-- * head, that is, inline, with a period and space following it --> |
| 32 |
<xsl:call-template name="bold"> |
| 33 |
<xsl:with-param name="node" select="exsl:node-set($title.wrapper)"/> |
| 34 |
<xsl:with-param name="context" select="."/> |
| 35 |
</xsl:call-template> |
| 36 |
<xsl:text>. </xsl:text> |
| 37 |
<xsl:apply-templates/> |
| 38 |
</xsl:template> |
| 39 |
|
| 40 |
<xsl:template match="formalpara/para"> |
| 41 |
<xsl:call-template name="mixed-block"/> |
| 42 |
<xsl:text> </xsl:text> |
| 43 |
</xsl:template> |
| 44 |
|
| 45 |
<xsl:template match="para"> |
| 46 |
<!-- * FIXME: Need to extract the ancestor::footnote, etc. checking and --> |
| 47 |
<!-- * move to named template so that we can call it from templates for --> |
| 48 |
<!-- * other block elements also --> |
| 49 |
<xsl:choose> |
| 50 |
<!-- * If a para is a descendant of a footnote, etc., then indent it --> |
| 51 |
<!-- * (unless it is the first child, in which case don't generate --> |
| 52 |
<!-- * anything at all to mark its start). --> |
| 53 |
<!-- * FIXME: *blurb checking should not be munged in here the way --> |
| 54 |
<!-- * it currently is; this probably breaks blurb indenting. --> |
| 55 |
<xsl:when test="ancestor::footnote or |
| 56 |
ancestor::annotation or |
| 57 |
ancestor::authorblurb or |
| 58 |
ancestor::personblurb"> |
| 59 |
<xsl:if test="preceding-sibling::*[not(name() ='')]"> |
| 60 |
<xsl:text>.sp</xsl:text> |
| 61 |
<xsl:text> </xsl:text> |
| 62 |
<xsl:text>.RS 4n</xsl:text> |
| 63 |
<xsl:text> </xsl:text> |
| 64 |
</xsl:if> |
| 65 |
</xsl:when> |
| 66 |
<xsl:otherwise> |
| 67 |
<xsl:text>.PP</xsl:text> |
| 68 |
<xsl:text> </xsl:text> |
| 69 |
</xsl:otherwise> |
| 70 |
</xsl:choose> |
| 71 |
<xsl:call-template name="mixed-block"/> |
| 72 |
<xsl:if test="ancestor::footnote or |
| 73 |
ancestor::annotation or |
| 74 |
ancestor::authorblurb or |
| 75 |
ancestor::personblurb"> |
| 76 |
<xsl:if test="preceding-sibling::*[not(name() ='')]"> |
| 77 |
<xsl:text> </xsl:text> |
| 78 |
<xsl:text>.RE</xsl:text> |
| 79 |
<xsl:text> </xsl:text> |
| 80 |
</xsl:if> |
| 81 |
</xsl:if> |
| 82 |
<xsl:text> </xsl:text> |
| 83 |
</xsl:template> |
| 84 |
|
| 85 |
<xsl:template match="simpara"> |
| 86 |
<xsl:variable name="content"> |
| 87 |
<xsl:apply-templates/> |
| 88 |
</xsl:variable> |
| 89 |
<xsl:value-of select="normalize-space($content)"/> |
| 90 |
<xsl:text> </xsl:text> |
| 91 |
<xsl:if test="not(ancestor::authorblurb) and |
| 92 |
not(ancestor::personblurb)"> |
| 93 |
<xsl:text>.sp </xsl:text> |
| 94 |
</xsl:if> |
| 95 |
</xsl:template> |
| 96 |
|
| 97 |
<!-- ==================================================================== --> |
| 98 |
|
| 99 |
<!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. --> |
| 100 |
<xsl:template match="literallayout|programlisting|screen| |
| 101 |
address|synopsis|funcsynopsisinfo"> |
| 102 |
<xsl:param name="indent"> |
| 103 |
<!-- * Only indent this verbatim if $man.indent.verbatims is --> |
| 104 |
<!-- * non-zero and it is not a child of a *synopsis element --> |
| 105 |
<xsl:if test="not($man.indent.verbatims = 0) and |
| 106 |
not(substring(local-name(..), |
| 107 |
string-length(local-name(..))-7) = 'synopsis')"> |
| 108 |
<xsl:text>Yes</xsl:text> |
| 109 |
</xsl:if> |
| 110 |
</xsl:param> |
| 111 |
|
| 112 |
<xsl:choose> |
| 113 |
<!-- * Check to see if this verbatim item is within a parent element that --> |
| 114 |
<!-- * allows mixed content. --> |
| 115 |
<!-- * --> |
| 116 |
<!-- * If it is within a mixed-content parent, then a line space is --> |
| 117 |
<!-- * already added before it by the mixed-block template, so we don't --> |
| 118 |
<!-- * need to add one here. --> |
| 119 |
<!-- * --> |
| 120 |
<!-- * If it is not within a mixed-content parent, then we need to add a --> |
| 121 |
<!-- * line space before it. --> |
| 122 |
<xsl:when test="parent::caption|parent::entry|parent::para| |
| 123 |
parent::td|parent::th" /> <!-- do nothing --> |
| 124 |
<xsl:otherwise> |
| 125 |
<xsl:text> </xsl:text> |
| 126 |
<xsl:text>.sp </xsl:text> |
| 127 |
</xsl:otherwise> |
| 128 |
</xsl:choose> |
| 129 |
<xsl:if test="$indent = 'Yes'"> |
| 130 |
<!-- * start indented section --> |
| 131 |
<xsl:text>.RS</xsl:text> |
| 132 |
<xsl:if test="not($man.indent.width = '')"> |
| 133 |
<xsl:text> </xsl:text> |
| 134 |
<xsl:value-of select="$man.indent.width"/> |
| 135 |
</xsl:if> |
| 136 |
<xsl:text> </xsl:text> |
| 137 |
</xsl:if> |
| 138 |
<xsl:choose> |
| 139 |
<xsl:when test="self::funcsynopsisinfo"> |
| 140 |
<!-- * All Funcsynopsisinfo content is by default rendered in bold, --> |
| 141 |
<!-- * because the man(7) man page says this: --> |
| 142 |
<!-- * --> |
| 143 |
<!-- * For functions, the arguments are always specified using --> |
| 144 |
<!-- * italics, even in the SYNOPSIS section, where the rest of --> |
| 145 |
<!-- * the function is specified in bold --> |
| 146 |
<!-- * --> |
| 147 |
<!-- * Look through the contents of the man/man2 and man3 directories --> |
| 148 |
<!-- * on your system, and you'll see that most existing pages do follow --> |
| 149 |
<!-- * this "bold everything in function synopsis" rule. --> |
| 150 |
<!-- * --> |
| 151 |
<!-- * Users who don't want the bold output can choose to adjust the --> |
| 152 |
<!-- * man.font.funcsynopsisinfo parameter on their own. So even if you --> |
| 153 |
<!-- * don't personally like the way it looks, please don't change the --> |
| 154 |
<!-- * default to be non-bold - because it's a convention that's --> |
| 155 |
<!-- * followed is the vast majority of existing man pages that document --> |
| 156 |
<!-- * functions, and we need to follow it by default, like it or no. --> |
| 157 |
<xsl:text>.ft </xsl:text> |
| 158 |
<xsl:value-of select="$man.font.funcsynopsisinfo"/> |
| 159 |
<xsl:text> </xsl:text> |
| 160 |
<xsl:text>.nf </xsl:text> |
| 161 |
<xsl:apply-templates/> |
| 162 |
<xsl:text> </xsl:text> |
| 163 |
<xsl:text>.fi </xsl:text> |
| 164 |
<xsl:text>.ft </xsl:text> |
| 165 |
</xsl:when> |
| 166 |
<xsl:otherwise> |
| 167 |
<!-- * Other verbatims do not need to get bolded --> |
| 168 |
<xsl:text>.nf </xsl:text> |
| 169 |
<xsl:apply-templates/> |
| 170 |
<xsl:text> </xsl:text> |
| 171 |
<xsl:text>.fi </xsl:text> |
| 172 |
</xsl:otherwise> |
| 173 |
</xsl:choose> |
| 174 |
<xsl:if test="$indent = 'Yes'"> |
| 175 |
<!-- * end indented section --> |
| 176 |
<xsl:text>.RE </xsl:text> |
| 177 |
</xsl:if> |
| 178 |
<!-- * if first following sibling node of this verbatim --> |
| 179 |
<!-- * environment is a text node, output a line of space before it --> |
| 180 |
<xsl:if test="following-sibling::node()[1][name(.) = '']"> |
| 181 |
<xsl:text>.sp </xsl:text> |
| 182 |
</xsl:if> |
| 183 |
</xsl:template> |
| 184 |
|
| 185 |
<!-- ==================================================================== --> |
| 186 |
|
| 187 |
<xsl:template match="table|informaltable"> |
| 188 |
<xsl:apply-templates select="." mode="to.tbl"> |
| 189 |
<!--* we call the to.tbl mode with the "source" param so that we can --> |
| 190 |
<!--* preserve the context information and pass it down to the --> |
| 191 |
<!--* named templates that do the actual table processing --> |
| 192 |
<xsl:with-param name="source" select="ancestor::refentry/refnamediv[1]/refname[1]"/> |
| 193 |
</xsl:apply-templates> |
| 194 |
</xsl:template> |
| 195 |
|
| 196 |
<!-- ==================================================================== --> |
| 197 |
|
| 198 |
<xsl:template match="informalexample"> |
| 199 |
<xsl:apply-templates/> |
| 200 |
</xsl:template> |
| 201 |
|
| 202 |
<!-- ==================================================================== --> |
| 203 |
|
| 204 |
<xsl:template match="figure|example"> |
| 205 |
<xsl:variable name="param.placement" |
| 206 |
select="substring-after(normalize-space($formal.title.placement), |
| 207 |
concat(local-name(.), ' '))"/> |
| 208 |
|
| 209 |
<xsl:variable name="placement"> |
| 210 |
<xsl:choose> |
| 211 |
<xsl:when test="contains($param.placement, ' ')"> |
| 212 |
<xsl:value-of select="substring-before($param.placement, ' ')"/> |
| 213 |
</xsl:when> |
| 214 |
<xsl:when test="$param.placement = ''">before</xsl:when> |
| 215 |
<xsl:otherwise> |
| 216 |
<xsl:value-of select="$param.placement"/> |
| 217 |
</xsl:otherwise> |
| 218 |
</xsl:choose> |
| 219 |
</xsl:variable> |
| 220 |
|
| 221 |
<xsl:text>.PP </xsl:text> |
| 222 |
<xsl:call-template name="formal.object"> |
| 223 |
<xsl:with-param name="placement" select="$placement"/> |
| 224 |
</xsl:call-template> |
| 225 |
<xsl:text> </xsl:text> |
| 226 |
</xsl:template> |
| 227 |
|
| 228 |
<!-- ==================================================================== --> |
| 229 |
|
| 230 |
<xsl:template match="mediaobject"> |
| 231 |
<xsl:text>.sp</xsl:text> |
| 232 |
<xsl:text> </xsl:text> |
| 233 |
<xsl:text>.RS</xsl:text> |
| 234 |
<xsl:if test="not($list-indent = '')"> |
| 235 |
<xsl:text> </xsl:text> |
| 236 |
<xsl:value-of select="$list-indent"/> |
| 237 |
</xsl:if> |
| 238 |
<xsl:text> </xsl:text> |
| 239 |
<xsl:apply-templates/> |
| 240 |
<xsl:text> </xsl:text> |
| 241 |
<xsl:text>.RE </xsl:text> |
| 242 |
</xsl:template> |
| 243 |
|
| 244 |
<xsl:template match="imageobject"> |
| 245 |
<xsl:text>[IMAGE]</xsl:text> |
| 246 |
<xsl:apply-templates/> |
| 247 |
<xsl:text> </xsl:text> |
| 248 |
</xsl:template> |
| 249 |
|
| 250 |
<xsl:template match="textobject[parent::inlinemediaobject]"> |
| 251 |
<xsl:text>[</xsl:text> |
| 252 |
<xsl:value-of select="."/> |
| 253 |
<xsl:text>]</xsl:text> |
| 254 |
</xsl:template> |
| 255 |
|
| 256 |
<xsl:template match="textobject"> |
| 257 |
<xsl:apply-templates/> |
| 258 |
</xsl:template> |
| 259 |
|
| 260 |
<!-- ==================================================================== --> |
| 261 |
|
| 262 |
<xsl:template name="formal.object"> |
| 263 |
<xsl:param name="placement" select="'before'"/> |
| 264 |
<xsl:param name="class" select="local-name(.)"/> |
| 265 |
|
| 266 |
<xsl:choose> |
| 267 |
<xsl:when test="$placement = 'before'"> |
| 268 |
<xsl:call-template name="formal.object.heading"/> |
| 269 |
<xsl:apply-templates/> |
| 270 |
</xsl:when> |
| 271 |
<xsl:otherwise> |
| 272 |
<xsl:apply-templates/> |
| 273 |
<xsl:call-template name="formal.object.heading"/> |
| 274 |
</xsl:otherwise> |
| 275 |
</xsl:choose> |
| 276 |
</xsl:template> |
| 277 |
|
| 278 |
<xsl:template name="formal.object.heading"> |
| 279 |
<xsl:param name="object" select="."/> |
| 280 |
<xsl:param name="title"> |
| 281 |
<xsl:apply-templates select="$object" mode="object.title.markup.textonly"/> |
| 282 |
</xsl:param> |
| 283 |
<xsl:call-template name="bold"> |
| 284 |
<xsl:with-param name="node" select="exsl:node-set($title)"/> |
| 285 |
<xsl:with-param name="context" select="."/> |
| 286 |
</xsl:call-template> |
| 287 |
|
| 288 |
<xsl:text> </xsl:text> |
| 289 |
</xsl:template> |
| 290 |
|
| 291 |
<!-- ==================================================================== --> |
| 292 |
|
| 293 |
<!-- * suppress abstract --> |
| 294 |
<xsl:template match="abstract"/> |
| 295 |
|
| 296 |
</xsl:stylesheet> |