2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
3 xmlns:
exsl=
"http://exslt.org/common"
4 xmlns:
ng=
"http://docbook.org/docbook-ng"
5 xmlns:
db=
"http://docbook.org/ns/docbook"
6 exclude-result-prefixes=
"exsl"
9 <xsl:import href=
"docbook-xsl/html/docbook.xsl"/>
10 <xsl:import href=
"docbook-xsl/html/manifest.xsl"/>
11 <!-- * html-synop.xsl file is generated by build -->
12 <xsl:import href=
"docbook-xsl/manpages/html-synop.xsl"/>
13 <xsl:import href=
"docbook-xsl/manpages/synop.xsl"/>
14 <xsl:import href=
"docbook-xsl/manpages/lists.xsl"/>
15 <!-- we need to overrade apostroph escapment defined in other.xsl -->
16 <xsl:import href=
"docbook-xsl/manpages/other.xsl"/>
18 <xsl:output method=
"text"
21 <!-- ********************************************************************
22 $Id: fvwm-man.xsl,v 1.12 2007/08/17 17:02:03 griph Exp $
23 ********************************************************************
25 This file is part of the XSL DocBook Stylesheet distribution.
26 See ../README or http://docbook.sf.net/release/xsl/current/ for
27 copyright and other information.
29 ******************************************************************** -->
31 <!-- ==================================================================== -->
33 <xsl:include href=
"docbook-xsl/common/refentry.xsl"/>
34 <xsl:include href=
"docbook-xsl/manpages/param.xsl"/>
35 <xsl:include href=
"docbook-xsl/manpages/utility.xsl"/>
36 <xsl:include href=
"docbook-xsl/manpages/info.xsl"/>
37 <xsl:include href=
"docbook-xsl/manpages/refentry.xsl"/>
38 <xsl:include href=
"docbook-xsl/manpages/block.xsl"/>
39 <xsl:include href=
"docbook-xsl/manpages/inline.xsl"/>
40 <xsl:include href=
"docbook-xsl/manpages/endnotes.xsl"/>
41 <xsl:include href=
"docbook-xsl/manpages/table.xsl"/>
43 <!-- * we rename the following just to avoid using params with "man" -->
44 <!-- * prefixes in the table.xsl stylesheet (because that stylesheet -->
45 <!-- * can potentially be reused for more than just man output) -->
46 <xsl:param name=
"tbl.font.headings" select=
"$man.font.table.headings"/>
47 <xsl:param name=
"tbl.font.title" select=
"$man.font.table.title"/>
49 <!-- ==================================================================== -->
51 <!--xsl:variable name="arg.or.sep">|</xsl:variable-->
52 <xsl:variable name="arg.choice.plain.close.str"></xsl:variable>
53 <xsl:variable name="arg.rep.repeat.str"> ...</xsl:variable>
55 <xsl:template match="section">
56 <xsl:apply-templates/>
59 <!-- don't escape apostrophs, but put them on the previous line if they start
61 <xsl:template name=
"escape.apostrophe">
62 <xsl:param name=
"content"/>
63 <xsl:call-template name=
"string.subst">
64 <xsl:with-param name=
"string" select=
"$content"/>
65 <xsl:with-param name=
"target"> '
</xsl:with-param>
66 <xsl:with-param name=
"replacement"> '
</xsl:with-param>
71 <xsl:template match=
"section/title">
72 <xsl:text>.SH
</xsl:text>
73 <xsl:call-template name=
"string.upper">
74 <xsl:with-param name=
"string">
75 <xsl:apply-templates/>
78 <xsl:text> </xsl:text>
81 <xsl:template match=
"section/section/title">
82 <xsl:text>.SS
</xsl:text>
83 <xsl:apply-templates/>
84 <xsl:text> </xsl:text>
87 <xsl:template match=
"section/section/section/title">
90 <xsl:when test=
"parent::section//cmdsynopsis/@command = text()">
92 <xsl:when test=
"parent::section//cmdsynopsis/command/text() = text()">
93 <!-- this is no good when there are multiple cmdsynopsis children -->
94 <!--xsl:apply-templates select="parent::section//cmdsynopsis/*"/-->
97 <xsl:text>.TP
</xsl:text>
98 <xsl:text>.B
</xsl:text>
99 <xsl:apply-templates/>
100 <xsl:text> .RS
</xsl:text>
101 <!-- We don't want .PP from following paras, this is a hack for that -->
102 <xsl:text>.\
"</xsl:text>
107 <xsl:template match=
"section/section/section">
108 <xsl:apply-templates/>
109 <xsl:text>.RE
</xsl:text>
112 <xsl:template match=
"section/section/section//cmdsynopsis">
114 <xsl:when test=
"parent::section/title/text() = command/text() or @command = parent::section/title/text()">
115 <xsl:if test=
"preceding-sibling::cmdsynopsis/command/text() = command/text()">
116 <xsl:text>.RE
</xsl:text>
118 <xsl:text>.TP
</xsl:text>
119 <xsl:apply-templates select=
"*"/>
120 <xsl:text> .RS
</xsl:text>
121 <!-- We don't want .PP from following paras, this is a hack for that -->
122 <xsl:text>.\
"</xsl:text>
126 <!--xsl:text> </xsl:text-->
131 <xsl:template match="simplelist">
132 <xsl:text>.nf </xsl:text>
133 <xsl:text>.IP ""</xsl:text>
134 <xsl:if test="not($list-indent = '')">
135 <xsl:text> </xsl:text>
136 <xsl:value-of select="$list-indent"/>
138 <xsl:text> </xsl:text>
139 <xsl:for-each select="member">
140 <xsl:variable name="content">
141 <xsl:apply-templates/>
143 <xsl:value-of select="normalize-space($content)"/>
144 <xsl:text> </xsl:text>
146 <xsl:text>.fi </xsl:text>
149 <xsl:template mode="small" match="*">
150 <xsl:for-each select="node()">
151 <xsl:text> .SM </xsl:text>
152 <xsl:value-of select="normalize-space(.)"/>
153 <xsl:text> </xsl:text>
157 <xsl:template match="keysym">
158 <xsl:apply-templates mode="small" select="."/>
161 <xsl:template match="envar">
162 <xsl:apply-templates mode="italic" select="."/>
166 <xsl:template match=
"fvwmopt">
167 <xsl:text>\fI
</xsl:text>
168 <xsl:value-of select=
"@opt"/>
169 <xsl:text>\fR
</xsl:text>
172 <!-- * paragraphs starting with a blank line adds extra space in some
173 * cases were we don't want it. Work around that, and make sentenses
174 * have two spaces inbetween in the same time. -->
176 <xsl:template name=
"normalize-paragraph">
177 <xsl:param name=
"content"/>
179 <xsl:when test=
"starts-with($content,' ') or starts-with($content,' ')">
180 <xsl:call-template name=
"normalize-paragraph">
181 <xsl:with-param name=
"content" select=
"substring($content,2)"/>
184 <xsl:when test=
"contains($content,' ')">
185 <xsl:variable name='pcontent'
>
186 <xsl:value-of select=
"substring-before($content,' ')"/>
189 <xsl:when test=
"contains($pcontent,'. ') or contains($pcontent,' ')">
190 <xsl:call-template name=
"normalize-paragraph">
191 <xsl:with-param name=
"content" select=
"$pcontent"/>
195 <xsl:value-of select=
"$pcontent"/>
198 <xsl:text> </xsl:text>
199 <xsl:variable name=
"rcontent">
200 <xsl:value-of select=
"substring-after($content,' ')"/>
203 <xsl:when test=
"starts-with($rcontent,' ') or starts-with($rcontent,' ')">
204 <xsl:call-template name=
"normalize-paragraph">
205 <xsl:with-param name=
"content" select=
"substring($rcontent,2)"/>
208 <xsl:when test=
"contains($rcontent,' ') or contains($rcontent,'. ')">
209 <xsl:call-template name=
"normalize-paragraph">
210 <xsl:with-param name=
"content" select=
"$rcontent"/>
214 <xsl:value-of select=
"$rcontent"/>
218 <!-- spaces at the start of lines must be removed -->
219 <xsl:when test=
"contains($content,' ')">
220 <xsl:variable name='pcontent'
>
221 <xsl:value-of select=
"substring-before($content,' ')"/>
224 <xsl:when test=
"contains($pcontent,'. ')">
225 <xsl:call-template name=
"normalize-paragraph">
226 <xsl:with-param name=
"content" select=
"$pcontent"/>
230 <xsl:value-of select=
"$pcontent"/>
233 <xsl:text> </xsl:text>
234 <xsl:variable name=
"rcontent">
235 <xsl:value-of select=
"substring-after($content,' ')"/>
238 <xsl:when test=
"starts-with($rcontent,' ') or starts-with($rcontent,' ')">
239 <xsl:call-template name=
"normalize-paragraph">
240 <xsl:with-param name=
"content" select=
"substring($rcontent,2)"/>
243 <xsl:when test=
"contains($rcontent,' ') or contains($rcontent,' ') or contains($rcontent,'. ')">
244 <xsl:call-template name=
"normalize-paragraph">
245 <xsl:with-param name=
"content" select=
"$rcontent"/>
249 <xsl:value-of select=
"$rcontent"/>
253 <xsl:when test=
"contains($content,'. ')">
254 <xsl:variable name='pcontent'
>
255 <xsl:value-of select=
"substring-before($content,'. ')"/>
257 <xsl:variable name='spcontent'
>
258 <xsl:value-of select=
"substring($pcontent,string-length($pcontent)-3)"/>
260 <xsl:value-of select=
"$pcontent"/>
261 <xsl:text>.
</xsl:text>
262 <xsl:if test=
"not(contains($spcontent,'.')) or contains('0123456789)',substring($spcontent,3,1))">
263 <xsl:text> </xsl:text>
265 <xsl:call-template name=
"normalize-paragraph">
266 <xsl:with-param name=
"content" select=
"substring-after($content,'. ')"/>
270 <xsl:value-of select=
"$content"/>
275 <xsl:template match=
"para[ancestor::listitem]">
276 <xsl:call-template name=
"normalize-paragraph">
277 <xsl:with-param name=
"content">
283 <xsl:template match=
"para">
284 <!-- just is enough for most cases, and make less need for .RS
285 in all places, however it reduces spaces in some less desireable
287 <xsl:text>.PP
</xsl:text>
288 <xsl:variable name=
"rawcontent">
289 <xsl:apply-templates/>
291 <xsl:variable name=
"content">
292 <!-- normalize spaces, but not newlisnes -->
293 <xsl:value-of select=
"translate(normalize-space(translate($rawcontent,' ','')),'',' ')"/>
295 <!-- * Add some check to remove double newlines within the paragraph
296 * but keep single newlines since there might be formatting -->
298 <xsl:when test=
"contains($content,' ') or contains($content,' ') or starts-with($content,' ') or contains($content,'. ')">
299 <xsl:call-template name=
"normalize-paragraph">
300 <xsl:with-param name=
"content" select=
"$content"/>
304 <xsl:value-of select=
"$content"/>
307 <!-- <xsl:apply-templates/> -->
308 <xsl:text> </xsl:text>
313 <xsl:template match=
"fvwmref">
315 <xsl:when test=
"@sect">
316 <xsl:text>\fB
</xsl:text>
317 <xsl:value-of select=
"@name"/>
318 <xsl:text>\fR
</xsl:text>
320 <xsl:when test=
"@opt">
321 <xsl:text>\fI
</xsl:text>
322 <xsl:value-of select=
"@opt"/>
323 <xsl:text>\fR
</xsl:text>
326 <xsl:text>\fB
</xsl:text>
328 <xsl:when test=
"@cmd">
329 <xsl:value-of select=
"@cmd"/>
331 <xsl:when test=
"@mod">
332 <xsl:value-of select=
"@mod"/>
334 <!-- anything else should be an error -->
336 <xsl:text>\fR
</xsl:text>
342 <xsl:template match=
"section/command">
343 <xsl:text> </xsl:text>
344 <xsl:text>.sp
</xsl:text>
345 <xsl:text>.RS
</xsl:text>
346 <xsl:text> </xsl:text>
347 <xsl:value-of select=
"$man.indent.width"/>
348 <xsl:text> </xsl:text>
349 <xsl:text>.nf
</xsl:text>
350 <xsl:apply-templates/>
351 <xsl:text> </xsl:text>
352 <xsl:text>.fi
</xsl:text>
353 <xsl:text>.RE
</xsl:text>
354 <xsl:text>.PP
</xsl:text>
358 <xsl:template name=
"get.fvwm.metadata">
360 <xsl:value-of select=
"artheader/titleabbrev"/>
363 <xsl:text>1</xsl:text>
366 <xsl:value-of select=
"artheader/date"/>
371 <xsl:value-of select=
"artheader/title"/>
375 <!-- escape special characters (as for <refentry>) -->
376 <xsl:template match=
"//article//text()">
377 <xsl:call-template name=
"escape.roff.specials">
378 <xsl:with-param name=
"content">
379 <xsl:value-of select=
"."/>
385 <!-- ==================================================================== -->
387 <xsl:template match=
"/">
389 <xsl:when test=
"//article">
390 <!-- * Check to see if we have any refentry children in this -->
391 <!-- * document; if so, process them. -->
392 <xsl:apply-templates select=
"//article"/>
393 <!-- * if $man.output.manifest.enabled is non-zero, -->
394 <!-- * generate a manifest file -->
395 <xsl:if test=
"not($man.output.manifest.enabled = 0)">
396 <xsl:call-template name=
"generate.manifest">
397 <xsl:with-param name=
"filename">
399 <xsl:when test=
"not($man.output.manifest.filename = '')">
400 <!-- * If a name for the manifest file is specified, -->
401 <!-- * use that name. -->
402 <xsl:value-of select=
"$man.output.manifest.filename"/>
405 <!-- * Otherwise, if user has unset -->
406 <!-- * $man.output.manifest.filename, default to -->
407 <!-- * using "MAN.MANIFEST" as the filename. Because -->
408 <!-- * $man.output.manifest.enabled is non-zero and -->
409 <!-- * so we must have a filename in order to -->
410 <!-- * generate the manifest. -->
411 <xsl:text>MAN.MANIFEST
</xsl:text>
419 <!-- * Otherwise, the document does not contain any -->
420 <!-- * refentry elements, so emit message and stop. -->
421 <xsl:variable name=
"title">
422 <!-- * Get a title so that we let the user know what -->
423 <!-- * document we are processing at this point. -->
425 <xsl:when test=
"title">
426 <xsl:value-of select=
"title[1]"/>
428 <xsl:when test=
"substring(local-name(*[1]),
429 string-length(local-name(*[1])-3) = 'info')
431 <xsl:value-of select=
"*[1]/title[1]"/>
436 <xsl:text>Note: No article elements found in
"</xsl:text>
437 <xsl:value-of select="local-name(.)
"/>
438 <xsl:if test="$title != ''
">
440 <xsl:when test="string-length($title)
> 30">
441 <xsl:value-of select="substring($title,
1,
30)
"/>
442 <xsl:text>...</xsl:text>
445 <xsl:value-of select="$title
"/>
449 <xsl:text>"</xsl:text>
455 <!-- ============================================================== -->
457 <xsl:template match=
"article">
458 <xsl:param name=
"lang">
459 <xsl:call-template name=
"l10n.language"/>
461 <!-- * Just use the first refname found as the "name" of the man -->
462 <!-- * page (which may different from the "title"...) -->
464 <xsl:variable name="first.refname" select="refnamediv[1]/refname[1]"/>
466 <xsl:variable name=
"first.refname" select=
"artheader/titleabbrev"/>
468 <xsl:call-template name=
"root.messages">
469 <xsl:with-param name=
"refname" select=
"$first.refname"/>
472 <!-- * Because there are several times when we need to check *info of -->
473 <!-- * each refentry and its ancestors, we get those and store the -->
474 <!-- * data from them as a node-set in memory. -->
476 <!-- * Make a node-set with contents of *info -->
477 <xsl:variable name=
"get.info"
478 select=
"ancestor-or-self::*/*[substring(local-name(),
479 string-length(local-name()) - 3) = 'info']"
481 <xsl:variable name=
"info" select=
"exsl:node-set($get.info)"/>
483 <!-- * The get.refentry.metadata template is in -->
484 <!-- * ../common/refentry.xsl. It looks for metadata in $info -->
485 <!-- * and in various other places and then puts it into a form -->
486 <!-- * that's easier for us to digest. -->
488 <xsl:variable name=
"get.refentry.metadata">
489 <xsl:call-template name=
"get.fvwm.metadata">
490 <xsl:with-param name=
"refname" select=
"$first.refname"/>
491 <xsl:with-param name=
"info" select=
"$info"/>
492 <xsl:with-param name=
"prefs" select=
"$refentry.metadata.prefs"/>
495 <xsl:variable name=
"refentry.metadata" select=
"exsl:node-set($get.refentry.metadata)"/>
498 <!-- * Assemble the various parts into a complete page, then store into -->
499 <!-- * $manpage.contents so that we can manipluate them further. -->
500 <xsl:variable name=
"manpage.contents">
501 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
502 <!-- * top.comment = commented-out section at top of roff source -->
503 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
504 <xsl:call-template name=
"top.comment">
505 <xsl:with-param name=
"info" select=
"$info"/>
506 <xsl:with-param name=
"date" select=
"$refentry.metadata/date"/>
507 <xsl:with-param name=
"title" select=
"$refentry.metadata/title"/>
508 <xsl:with-param name=
"manual" select=
"$refentry.metadata/manual"/>
509 <xsl:with-param name=
"source" select=
"$refentry.metadata/source"/>
511 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
512 <!-- * TH.title.line = title line in header/footer of man page -->
513 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
514 <xsl:call-template name=
"TH.title.line">
515 <!-- * .TH TITLE section extra1 extra2 extra3 -->
517 <!-- * According to the man(7) man page: -->
519 <!-- * extra1 = date, "the date of the last revision" -->
520 <!-- * extra2 = source, "the source of the command" -->
521 <!-- * extra3 = manual, "the title of the manual -->
522 <!-- * (e.g., Linux Programmer's Manual)" -->
524 <!-- * So, we end up with: -->
526 <!-- * .TH TITLE section date source manual -->
528 <xsl:with-param name=
"title" select=
"$refentry.metadata/title"/>
529 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
530 <xsl:with-param name=
"extra1" select=
"$refentry.metadata/date"/>
531 <xsl:with-param name=
"extra2" select=
"$refentry.metadata/source"/>
532 <xsl:with-param name=
"extra3" select=
"$refentry.metadata/manual"/>
534 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
535 <!-- * Set default hyphenation, justification, indentation, and -->
536 <!-- * line-breaking -->
537 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
538 <xsl:call-template name=
"set.default.formatting"/>
539 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
540 <!-- * Main body of man page -->
541 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
542 <xsl:apply-templates/>
543 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
544 <!-- * AUTHOR section -->
545 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
546 <xsl:call-template name=
"author.section">
547 <xsl:with-param name=
"info" select=
"$info"/>
549 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
550 <!-- * COPYRIGHT section -->
551 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
552 <xsl:call-template name=
"copyright.section">
553 <xsl:with-param name=
"info" select=
"$info"/>
555 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
556 <!-- * NOTES list (only if user wants endnotes numbered and/or listed) -->
557 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
558 <xsl:if test=
"$man.endnotes.list.enabled != 0 or
559 $man.endnotes.are.numbered != 0">
560 <xsl:call-template name=
"endnotes.list"/>
562 </xsl:variable> <!-- * end of manpage.contents -->
564 <!-- * Prepare the page contents for final output, then store in -->
565 <!-- * $manpage.contents.prepared so the we can pass it on to the -->
566 <!-- * write.text.chunk() function -->
567 <xsl:variable name=
"manpage.contents.prepared">
568 <!-- * "Preparing" the page contents involves, at a minimum, -->
569 <!-- * doubling any backslashes found (so they aren't interpreted -->
570 <!-- * as roff escapes). -->
572 <!-- * If $charmap.enabled is true, "preparing" the page contents also -->
573 <!-- * involves applying a character map to convert Unicode symbols and -->
574 <!-- * special characters into corresponding roff escape sequences. -->
575 <xsl:call-template name=
"prepare.manpage.contents">
576 <xsl:with-param name=
"content" select=
"$manpage.contents"/>
580 <!-- * Write the prepared page contents to disk to create -->
581 <!-- * the final man page. -->
582 <xsl:call-template name=
"write.man.file">
583 <xsl:with-param name=
"name" select=
"$first.refname"/>
584 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
585 <xsl:with-param name=
"lang" select=
"$lang"/>
586 <xsl:with-param name=
"content" select=
"$manpage.contents.prepared"/>
589 <!-- * Generate "stub" (alias) pages (if any needed) -->
590 <xsl:call-template name=
"write.stubs">
591 <xsl:with-param name=
"first.refname" select=
"$first.refname"/>
592 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
593 <xsl:with-param name=
"lang" select=
"$lang"/>