summaryrefslogtreecommitdiff
path: root/docs-xml/xslt/man.xsl
blob: 99b2112cb3af7c7d63d748dc7334d9c9cb9b8ca0 (plain)
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
<?xml version='1.0'?>
<!-- vim:set sts=2 shiftwidth=2 syntax=xml: -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>

<xsl:param name="chunk.section.depth" select="0"/>
<xsl:param name="chunk.first.sections" select="1"/>
<xsl:param name="use.id.as.filename" select="1"/>

<!-- 
    Our ulink stylesheet omits @url part if content was specified
-->
<xsl:template match="ulink">
  <xsl:variable name="content">
    <xsl:apply-templates/>
  </xsl:variable>
  <xsl:if test="$content = ''">
    <xsl:text>: </xsl:text>
  </xsl:if>
  <xsl:if test="$content != ''">
    <xsl:value-of select="$content" />
  </xsl:if>
  <xsl:if test="$content = ''">
    <xsl:apply-templates mode="italic" select="@url" />
  </xsl:if>
</xsl:template>

<xsl:template match="itemizedlist/listitem">
  <!-- * We output a real bullet here (rather than, "\(bu", -->
  <!-- * the roff bullet) because, when we do character-map -->
  <!-- * processing before final output, the character-map will -->
  <!-- * handle conversion of the &#x2022; to "\(bu" for us -->
  <xsl:text>&#10;</xsl:text>
  <xsl:text>.sp</xsl:text>
  <xsl:text>&#10;</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>&#10;</xsl:text>
  <!-- * if "n" then we are using "nroff", which means the output is for -->
  <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
  <!-- * hanging indent (instead of using .IP, which has some -->
  <!-- * undesirable side effects under certain circumstances) -->
  <xsl:call-template name="roff-if-else-start"/>
  <xsl:text>\h'-</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>\n(INu</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'</xsl:text>
  <xsl:text>&#x2022;</xsl:text>
  <xsl:text>\h'+</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent - 1"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>\n(INu-1</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'\c&#10;</xsl:text>
  <!-- * else, we are not using for "nroff", but instead "troff" - which -->
  <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
  <!-- * fixed-width font, so use a real .IP instead -->
  <xsl:call-template name="roff-else"/>
  <!-- * .IP generates a blank like of space, so let’s go backwards one -->
  <!-- * line up to compensate for that -->
  <xsl:text>.sp -1&#10;</xsl:text>
  <xsl:text>.IP \(bu 2.3&#10;</xsl:text>
  <!-- * The value 2.3 is the amount of indentation; we use 2.3 instead -->
  <!-- * of 2 because when the font family is New Century Schoolbook it -->
  <!-- * seems to require the extra space. -->
  <xsl:call-template name="roff-if-end"/>
  <xsl:apply-templates/>
  <xsl:if test=" following-sibling::listitem">
	 <xsl:text>&#10;.RE&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="itemizedlist|orderedlist|procedure">
  <xsl:if test="title">
    <xsl:text>.PP&#10;</xsl:text>
    <xsl:call-template name="bold">
      <xsl:with-param name="node" select="title"/>
      <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <!-- * DocBook allows just about any block content to appear in -->
  <!-- * lists before the actual list items, so we need to get that -->
  <!-- * content (if any) before getting the list items -->
  <xsl:apply-templates
    select="*[not(self::listitem) and not(self::title)]"/>
  <xsl:apply-templates select="listitem"/>
  <xsl:if test="(parent::para or parent::listitem) or following-sibling::node()">
    <xsl:text>.sp&#10;</xsl:text>
    <xsl:text>.RE&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="refsect3">
  <xsl:text>&#10;.SS "</xsl:text>
  <xsl:value-of select="title[1]"/>
  <xsl:text>"&#10;</xsl:text>
  <xsl:apply-templates/>
</xsl:template>

  <!-- ================================================================== -->
  <!-- These macros are from Docbook manpages XSLT development tree       -->
  <!-- help to maintain manpage generation clean when difference between  -->
  <!-- roff processors is important to note.                              -->

  <xsl:template name="roff-if-else-start">
    <xsl:param name="condition">n</xsl:param>
    <xsl:text>.ie </xsl:text>
    <xsl:value-of select="$condition"/>
    <xsl:text> \{\&#10;</xsl:text>
  </xsl:template>

  <xsl:template name="roff-if-start">
    <xsl:param name="condition">n</xsl:param>
    <xsl:text>.if </xsl:text>
    <xsl:value-of select="$condition"/>
    <xsl:text> \{\&#10;</xsl:text>
  </xsl:template>

  <xsl:template name="roff-else">
    <xsl:text>.\}&#10;</xsl:text>
    <xsl:text>.el \{\&#10;</xsl:text>
  </xsl:template>

  <xsl:template name="roff-if-end">
    <xsl:text>.\}&#10;</xsl:text>
  </xsl:template>

</xsl:stylesheet>