1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
|
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
exclude-result-prefixes="exsl"
version='1.0'>
<!-- ********************************************************************
This file is part of the XSL DocBook Stylesheet distribution.
See ../README or http://cdn.docbook.org/release/xsl/current/ for
copyright and other information.
******************************************************************** -->
<!-- ==================================================================== -->
<xsl:template match="caution|important|note|tip|warning">
<xsl:call-template name="roff-if-start">
<xsl:with-param name="condition">n</xsl:with-param>
</xsl:call-template>
<xsl:text>.sp </xsl:text>
<xsl:call-template name="roff-if-end"/>
<xsl:text>.RS 4 </xsl:text>
<xsl:if test="not($man.output.better.ps.enabled = 0)">
<xsl:text>.BM yellow </xsl:text>
</xsl:if>
<xsl:call-template name="pinch.together"/>
<xsl:text>.ps +1 </xsl:text>
<xsl:call-template name="make.bold.title"/>
<xsl:text>.ps -1 </xsl:text>
<xsl:text>.br </xsl:text>
<xsl:apply-templates/>
<xsl:text>.sp .5v </xsl:text>
<xsl:if test="not($man.output.better.ps.enabled = 0)">
<xsl:text>.EM yellow </xsl:text>
</xsl:if>
<xsl:text>.RE </xsl:text>
</xsl:template>
<xsl:template match="formalpara">
<xsl:variable name="title.wrapper">
<xsl:value-of select="normalize-space(title[1])"/>
</xsl:variable>
<xsl:text>.PP </xsl:text>
<!-- * don't put linebreak after head; instead render it as a "run in" -->
<!-- * head, that is, inline, with a period and space following it -->
<xsl:call-template name="bold">
<xsl:with-param name="node" select="exsl:node-set($title.wrapper)"/>
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:text>. </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="formalpara/para">
<xsl:call-template name="mixed-block"/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="para">
<!-- * FIXME: Need to extract the ancestor::footnote, etc. checking and -->
<!-- * move to named template so that we can call it from templates for -->
<!-- * other block elements also -->
<xsl:choose>
<!-- * If a para is a descendant of a footnote, etc., then indent it -->
<!-- * (unless it is the first child, in which case don't generate -->
<!-- * anything at all to mark its start). -->
<!-- * FIXME: *blurb checking should not be munged in here the way -->
<!-- * it currently is; this probably breaks blurb indenting. -->
<xsl:when test="ancestor::footnote or
ancestor::annotation or
ancestor::authorblurb or
ancestor::personblurb or
ancestor::callout">
<xsl:if test="preceding-sibling::*[not(name() ='')]">
<xsl:text>.sp</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>.RS 4n</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>.PP</xsl:text>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="mixed-block"/>
<xsl:if test="ancestor::footnote or
ancestor::annotation or
ancestor::authorblurb or
ancestor::personblurb">
<xsl:if test="preceding-sibling::*[not(name() ='')]">
<xsl:text> </xsl:text>
<xsl:text>.RE</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:if>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="simpara">
<xsl:choose>
<xsl:when test="ancestor::footnote or
ancestor::annotation or
ancestor::authorblurb or
ancestor::personblurb or
ancestor::callout">
<xsl:if test="preceding-sibling::*[not(name() ='')]">
<xsl:text>.sp</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>.RS 4n</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:text>.sp</xsl:text>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="content">
<xsl:apply-templates/>
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
<xsl:text> </xsl:text>
</xsl:template>
<!-- ==================================================================== -->
<!-- * Yes, address, synopsis, and funcsynopsisinfo are verbatim environments. -->
<xsl:template match="literallayout|programlisting|screen|
address|synopsis|funcsynopsisinfo">
<xsl:param name="indent">
<!-- * Only indent this verbatim if $man.indent.verbatims is -->
<!-- * non-zero and it is not a child of a *synopsis element or a -->
<!-- * descendant of a refsynopsisdiv -->
<xsl:if test="not($man.indent.verbatims = 0)
and not(substring(local-name(..),
string-length(local-name(..))-7) = 'synopsis')
and not(ancestor::*[local-name() = 'refsynopsisdiv'])
and not(ancestor::*[local-name() = 'term'])
">
<xsl:text>Yes</xsl:text>
</xsl:if>
</xsl:param>
<!-- * if this verbatim environment starts with a newline/linebreak -->
<!-- * (that is, if there is a linebreak after the opening tag), that -->
<!-- * break would otherwise show up in output; that does not seem to -->
<!-- * be what most users would expect, so we check to see if it does -->
<!-- * indeed start with a leading newline. if so, later in this -->
<!-- * template, we adjust for the leading new line by doing some -->
<!-- * monkeyshines with "sp -1" vertical spacing -->
<xsl:variable name="adjust-for-leading-newline">
<xsl:if test="substring(., 1, 1) = ' '">Yes</xsl:if>
</xsl:variable>
<xsl:choose>
<!-- * Check to see if this verbatim item is within a parent element that -->
<!-- * allows mixed content. -->
<!-- * -->
<!-- * If it is within a mixed-content parent, then a line space is -->
<!-- * already added before it by the mixed-block template, so we don't -->
<!-- * need to add one here. -->
<!-- * -->
<!-- * If it is not within a mixed-content parent, then we need to add a -->
<!-- * line space before it. -->
<xsl:when test="parent::caption|parent::entry|parent::para|
parent::td|parent::th" /> <!-- do nothing -->
<xsl:otherwise>
<xsl:text> </xsl:text>
<xsl:text>.sp </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$indent = 'Yes'">
<!-- * start indented section -->
<xsl:call-template name="roff-if-start"/>
<!-- * only indent in TTY output, not in non-TTY/PS -->
<xsl:text>.RS</xsl:text>
<xsl:if test="not($man.indent.width = '')">
<xsl:text> </xsl:text>
<xsl:value-of select="$man.indent.width"/>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:call-template name="roff-if-end"/>
</xsl:if>
<xsl:choose>
<xsl:when test="self::funcsynopsisinfo">
<!-- * All Funcsynopsisinfo content is by default rendered in bold, -->
<!-- * because the man(7) man page says this: -->
<!-- * -->
<!-- * For functions, the arguments are always specified using -->
<!-- * italics, even in the SYNOPSIS section, where the rest of -->
<!-- * the function is specified in bold -->
<!-- * -->
<!-- * Look through the contents of the man/man2 and man3 directories -->
<!-- * on your system, and you'll see that most existing pages do follow -->
<!-- * this "bold everything in function synopsis" rule. -->
<!-- * -->
<!-- * Users who don't want the bold output can choose to adjust the -->
<!-- * man.font.funcsynopsisinfo parameter on their own. So even if you -->
<!-- * don't personally like the way it looks, please don't change the -->
<!-- * default to be non-bold - because it's a convention that's -->
<!-- * followed is the vast majority of existing man pages that document -->
<!-- * functions, and we need to follow it by default, like it or no. -->
<xsl:text>.ft </xsl:text>
<xsl:value-of select="$man.font.funcsynopsisinfo"/>
<xsl:text> </xsl:text>
<xsl:call-template name="verbatim-block-start"/>
<xsl:text>.nf </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
<xsl:text>.fi </xsl:text>
<xsl:call-template name="verbatim-block-end"/>
<xsl:text>.ft </xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- * Other verbatims do not need to get bolded -->
<xsl:call-template name="verbatim-block-start"/>
<xsl:text>.nf </xsl:text>
<xsl:choose>
<xsl:when test="self::literallayout|self::programlisting|self::screen
and not(ancestor::*[local-name() = 'refsynopsisdiv'])
and not($man.output.better.ps.enabled = 0)
">
<!-- * if this is a literallayout|programlisting|screen, -->
<!-- * and user has set man.output.better.ps.enabled to non-zero, -->
<!-- * then we put a background behind it in non-TTY output; except -->
<!-- * if it’s a descendant of a refsynopsisdiv (as can be -->
<!-- * found in the git docs) -->
<xsl:choose>
<!-- * if content has a leading newline, we need to back up -->
<!-- * one line vertically to get it boxed correctly -->
<xsl:when test="not($adjust-for-leading-newline = '')">
<xsl:call-template name="roff-if-start">
<xsl:with-param name="condition">t</xsl:with-param>
</xsl:call-template>
<xsl:text>.sp -1 </xsl:text>
<xsl:call-template name="roff-if-end"/>
<xsl:text>.BB lightgray</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>adjust-for-leading-newline </xsl:text>
<!-- * in non-TTY output, for the case where we have a -->
<!-- * leading newline, we need to also back up one line -->
<!-- * vertically inside the background box -->
<xsl:text>.sp -1 </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>.BB lightgray </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="not($adjust-for-leading-newline = '')">
<xsl:text>.EB lightgray</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>adjust-for-leading-newline </xsl:text>
<xsl:call-template name="roff-if-start">
<xsl:with-param name="condition">t</xsl:with-param>
</xsl:call-template>
<!-- * in non-TTY output, for the case where we have a -->
<!-- * leading newline, we need to add back at the end of -->
<!-- * the content some of the vertical space we chopped -->
<!-- * off at the beginning -->
<xsl:text>.sp 1 </xsl:text>
<xsl:call-template name="roff-if-end"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>.EB lightgray </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- * otherwise this is not a literallayout|programlisting|screen, -->
<!-- * so we don’t put a background behind -->
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>.fi </xsl:text>
<xsl:call-template name="verbatim-block-end"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$indent = 'Yes'">
<!-- * end indented section -->
<xsl:call-template name="roff-if-start"/>
<xsl:text>.RE </xsl:text>
<xsl:call-template name="roff-if-end"/>
</xsl:if>
<!-- * if this verbatim environment has a following sibling node, -->
<!-- * output a line of space to separate the content -->
<xsl:if test="following-sibling::text()
|following-sibling::para
|following-sibling::simpara">
<xsl:text>.sp </xsl:text>
</xsl:if>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="table|informaltable">
<xsl:apply-templates select="." mode="to.tbl">
<!--* we call the to.tbl mode with the "source" param so that we can -->
<!--* preserve the context information and pass it down to the -->
<!--* named templates that do the actual table processing -->
<xsl:with-param name="source" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
</xsl:apply-templates>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="informalexample">
<xsl:apply-templates/>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="figure|example">
<xsl:variable name="param.placement"
select="substring-after(normalize-space($formal.title.placement),
concat(local-name(.), ' '))"/>
<xsl:variable name="placement">
<xsl:choose>
<xsl:when test="contains($param.placement, ' ')">
<xsl:value-of select="substring-before($param.placement, ' ')"/>
</xsl:when>
<xsl:when test="$param.placement = ''">before</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$param.placement"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text>.PP </xsl:text>
<xsl:call-template name="formal.object">
<xsl:with-param name="placement" select="$placement"/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template match="mediaobject">
<xsl:text>.sp</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>.RS</xsl:text>
<xsl:if test="not($list-indent = '')">
<xsl:text> </xsl:text>
<xsl:value-of select="$list-indent"/>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
<xsl:text>.RE </xsl:text>
</xsl:template>
<xsl:template match="imageobject">
<xsl:text>[IMAGE]</xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="textobject[parent::inlinemediaobject]">
<xsl:text>[</xsl:text>
<xsl:value-of select="."/>
<xsl:text>]</xsl:text>
</xsl:template>
<xsl:template match="textobject">
<xsl:apply-templates/>
</xsl:template>
<!-- ==================================================================== -->
<xsl:template name="formal.object">
<xsl:param name="placement" select="'before'"/>
<xsl:param name="class" select="local-name(.)"/>
<xsl:choose>
<xsl:when test="$placement = 'before'">
<xsl:call-template name="formal.object.heading"/>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:call-template name="formal.object.heading"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="formal.object.heading">
<xsl:param name="object" select="."/>
<xsl:param name="title">
<xsl:apply-templates select="$object" mode="object.title.markup.textonly"/>
</xsl:param>
<xsl:call-template name="bold">
<xsl:with-param name="node" select="exsl:node-set($title)"/>
<xsl:with-param name="context" select="."/>
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:template>
<!-- ==================================================================== -->
<!-- * suppress abstract -->
<xsl:template match="abstract"/>
</xsl:stylesheet>
|