blob: 7eebfdb5a142673ab433dfb338e346a3fc2220b6 [file] [log] [blame]
Lennart Poettering76318282011-12-19 20:25:52 +01001<?xml version='1.0'?> <!--*-nxml-*-->
Zbigniew Jędrzejewski-Szmek42ecca22020-04-20 09:20:01 +02002<!-- SPDX-License-Identifier: LGPL-2.1+ -->
Lennart Poettering76318282011-12-19 20:25:52 +01003
4<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
5
6<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
Johan Ouwerkerkd77c25b2015-07-13 10:39:09 +02007<!--
8 - The docbook stylesheet injects empty anchor tags into generated HTML, identified by an auto-generated ID.
9 - Ask the docbook stylesheet to generate reproducible output when generating (these) ID values.
10 - This makes the output of this stylesheet reproducible across identical invocations on the same input,
11 - which is an easy and significant win for achieving reproducible builds.
12 -
13 - It may be even better to strip the empty anchors from the document output in addition to turning on consistent IDs,
14 - for this stylesheet contains its own custom ID logic (for generating permalinks) already.
15 -->
16<xsl:param name="generate.consistent.ids" select="1"/>
Lennart Poettering76318282011-12-19 20:25:52 +010017
Kay Sieversecca17f2012-07-17 23:04:48 +020018<!-- translate man page references to links to html pages -->
Zbigniew Jędrzejewski-Szmek5aded362014-07-07 18:25:54 -040019<xsl:template match="citerefentry[not(@project)]">
Kay Sieversecca17f2012-07-17 23:04:48 +020020 <a>
21 <xsl:attribute name="href">
Zbigniew Jędrzejewski-Szmek958caa52015-11-22 23:43:36 -050022 <xsl:value-of select="refentrytitle"/><xsl:text>.html#</xsl:text>
23 <xsl:value-of select="refentrytitle/@target"/>
Kay Sieversecca17f2012-07-17 23:04:48 +020024 </xsl:attribute>
25 <xsl:call-template name="inline.charseq"/>
26 </a>
27</xsl:template>
28
Zbigniew Jędrzejewski-Szmek5aded362014-07-07 18:25:54 -040029<xsl:template match="citerefentry[@project='man-pages'] | citerefentry[manvolnum='2'] | citerefentry[manvolnum='4']">
30 <a>
31 <xsl:attribute name="href">
32 <xsl:text>http://man7.org/linux/man-pages/man</xsl:text>
33 <xsl:value-of select="manvolnum"/>
34 <xsl:text>/</xsl:text>
35 <xsl:value-of select="refentrytitle"/>
36 <xsl:text>.</xsl:text>
37 <xsl:value-of select="manvolnum"/>
38 <xsl:text>.html</xsl:text>
39 </xsl:attribute>
40 <xsl:call-template name="inline.charseq"/>
41 </a>
42</xsl:template>
43
44<xsl:template match="citerefentry[@project='die-net']">
45 <a>
46 <xsl:attribute name="href">
47 <xsl:text>http://linux.die.net/man/</xsl:text>
48 <xsl:value-of select="manvolnum"/>
49 <xsl:text>/</xsl:text>
50 <xsl:value-of select="refentrytitle"/>
51 </xsl:attribute>
52 <xsl:call-template name="inline.charseq"/>
53 </a>
54</xsl:template>
55
Jörg Thalheime5719362017-12-18 15:20:34 +010056<xsl:template match="citerefentry[@project='wireguard']">
57 <a>
58 <xsl:attribute name="href">
59 <xsl:text>https://git.zx2c4.com/WireGuard/about/src/tools/</xsl:text>
60 <xsl:value-of select="refentrytitle"/>
61 <xsl:text>.</xsl:text>
62 <xsl:value-of select="manvolnum"/>
63 </xsl:attribute>
64 <xsl:call-template name="inline.charseq"/>
65 </a>
66</xsl:template>
67
Zbigniew Jędrzejewski-Szmek74a6d872015-02-01 16:05:56 -050068<xsl:template match="citerefentry[@project='mankier']">
69 <a>
70 <xsl:attribute name="href">
71 <xsl:text>https://www.mankier.com/</xsl:text>
72 <xsl:value-of select="manvolnum"/>
73 <xsl:text>/</xsl:text>
74 <xsl:value-of select="refentrytitle"/>
75 </xsl:attribute>
76 <xsl:call-template name="inline.charseq"/>
77 </a>
78</xsl:template>
79
Zbigniew Jędrzejewski-Szmek5aded362014-07-07 18:25:54 -040080<xsl:template match="citerefentry[@project='archlinux']">
81 <a>
82 <xsl:attribute name="href">
83 <xsl:text>https://www.archlinux.org/</xsl:text>
84 <xsl:value-of select="refentrytitle"/>
85 <xsl:text>/</xsl:text>
86 <xsl:value-of select="refentrytitle"/>
87 <xsl:text>.</xsl:text>
88 <xsl:value-of select="manvolnum"/>
89 <xsl:text>.html</xsl:text>
90 </xsl:attribute>
91 <xsl:call-template name="inline.charseq"/>
92 </a>
93</xsl:template>
94
Zbigniew Jędrzejewski-Szmek42ecca22020-04-20 09:20:01 +020095<xsl:template match="citerefentry[@project='debian']">
96 <a>
97 <xsl:attribute name="href">
98 <xsl:text>https://manpages.debian.org/unstable/</xsl:text>
99 <xsl:value-of select="refentrytitle"/>
100 <xsl:text>/</xsl:text>
101 <xsl:value-of select="refentrytitle"/>
102 <xsl:text>.</xsl:text>
103 <xsl:value-of select="manvolnum"/>
104 <xsl:text>.en.html</xsl:text>
105 </xsl:attribute>
106 <xsl:call-template name="inline.charseq"/>
107 </a>
108</xsl:template>
109
Zbigniew Jędrzejewski-Szmekb5c7d092015-03-13 21:23:24 -0500110<xsl:template match="citerefentry[@project='freebsd']">
111 <a>
112 <xsl:attribute name="href">
113 <xsl:text>https://www.freebsd.org/cgi/man.cgi?</xsl:text>
114 <xsl:value-of select="refentrytitle"/>
115 <xsl:text>(</xsl:text>
116 <xsl:value-of select="manvolnum"/>
117 <xsl:text>)</xsl:text>
118 </xsl:attribute>
119 <xsl:call-template name="inline.charseq"/>
120 </a>
121</xsl:template>
122
Zbigniew Jędrzejewski-Szmek3b5cfcd2015-03-13 21:24:30 -0500123<xsl:template match="citerefentry[@project='dbus']">
124 <a>
125 <xsl:attribute name="href">
126 <xsl:text>http://dbus.freedesktop.org/doc/</xsl:text>
127 <xsl:value-of select="refentrytitle"/>
128 <xsl:text>.</xsl:text>
129 <xsl:value-of select="manvolnum"/>
130 <xsl:text>.html</xsl:text>
131 </xsl:attribute>
132 <xsl:call-template name="inline.charseq"/>
133 </a>
134</xsl:template>
135
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200136<!--
137 - helper template to do conflict resolution between various headings with the same inferred ID attribute/tag from the headerlink template
Jan Engelhardta8eaaee2014-08-03 07:11:37 +0200138 - this conflict resolution is necessary to prevent malformed HTML output (multiple ID attributes with the same value)
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200139 - and it fixes xsltproc warnings during compilation of HTML man pages
140 -
141 - A simple top-to-bottom numbering scheme is implemented for nodes with the same ID value to derive unique ID values for HTML output.
142 - It uses two parameters:
143 templateID the proposed ID string to use which must be checked for conflicts
144 keyNode the context node which 'produced' the given templateID.
145 -
146 - Conflicts are detected solely based on keyNode, templateID is not taken into account for that purpose.
147 -->
148<xsl:template name="generateID">
149 <!-- node which generatedID needs to assume as the 'source' of the ID -->
150 <xsl:param name="keyNode"/>
151 <!-- suggested value for generatedID output, a contextually meaningful ID string -->
152 <xsl:param name="templateID"/>
153 <xsl:variable name="conflictSource" select="preceding::refsect1/title|preceding::refsect1/info/title|
154 preceding::refsect2/title|preceding::refsect2/info/title|
155 preceding::varlistentry/term[1]"/>
156 <xsl:variable name="conflictCount" select="count($conflictSource[. = $keyNode])"/>
157 <xsl:choose>
158 <!-- special case conflictCount = 0 to preserve compatibility with URLs generated by previous versions of this XSL stylesheet where possible -->
159 <xsl:when test="$conflictCount = 0">
160 <xsl:value-of select="$templateID"/>
161 </xsl:when>
162 <xsl:otherwise>
163 <xsl:value-of select="concat($templateID, $conflictCount)"/>
164 </xsl:otherwise>
165 </xsl:choose>
166</xsl:template>
167
168<!--
169 - a helper template to abstract over the structure of generated subheading + permalink HTML output
170 - It helps reduce tedious repetition and groups all actual markup output (as opposed to URL/ID logic) in a single location.
171 -->
172<xsl:template name="permalink">
173 <xsl:param name="nodeType"/> <!-- local name of the element node to generate, e.g. 'h2' for <h2></h2> -->
174 <xsl:param name="nodeContent"/> <!-- nodeset to apply further templates to obtain the content of the subheading/term -->
175 <xsl:param name="linkTitle"/> <!-- value for title attribute of generated permalink, e.g. 'this is a permalink' -->
176
177 <!-- parameters passed to generateID template, otherwise unused. -->
178 <xsl:param name="keyNode"/>
179 <xsl:param name="templateID"/>
180
181 <!--
182 - If stable URLs with fragment markers (references to the ID) turn out not to be important:
183 - generatedID could simply take the value of generate-id(), and various other helper templates may be dropped entirely.
Jan Engelhardtb938cb92014-08-03 07:11:12 +0200184 - Alternatively, if xsltproc is patched to generate reproducible generate-id() output, the same simplifications can be
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200185 - applied at the cost of breaking compatibility with URLs generated from output of previous versions of this stylesheet.
186 -->
187 <xsl:variable name="generatedID">
188 <xsl:call-template name="generateID">
189 <xsl:with-param name="keyNode" select="$keyNode"/>
190 <xsl:with-param name="templateID" select="$templateID"/>
191 </xsl:call-template>
192 </xsl:variable>
193
194 <xsl:element name="{$nodeType}">
195 <xsl:attribute name="id">
196 <xsl:value-of select="$generatedID"/>
197 </xsl:attribute>
198 <xsl:apply-templates select="$nodeContent"/>
199 <a class="headerlink" title="{$linkTitle}" href="#{$generatedID}"></a>
200 </xsl:element>
201</xsl:template>
202
203<!-- simple wrapper around permalink to avoid repeating common info for each level of subheading covered by the permalink logic (h2, h3) -->
204<xsl:template name="headerlink">
205 <xsl:param name="nodeType"/>
206 <xsl:call-template name="permalink">
207 <xsl:with-param name="nodeType" select="$nodeType"/>
208 <xsl:with-param name="linkTitle" select="'Permalink to this headline'"/>
209 <xsl:with-param name="nodeContent" select="node()"/>
210 <xsl:with-param name="keyNode" select="."/>
211 <!--
212 - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
213 - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
214 - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
215 -->
216 <xsl:with-param name="templateID">
217 <xsl:call-template name="inline.charseq"/>
218 </xsl:with-param>
219 </xsl:call-template>
220</xsl:template>
221
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400222<xsl:template match="refsect1/title|refsect1/info/title">
223 <!-- the ID is output in the block.object call for refsect1 -->
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200224 <xsl:call-template name="headerlink">
225 <xsl:with-param name="nodeType" select="'h2'"/>
226 </xsl:call-template>
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400227</xsl:template>
228
Zbigniew Jędrzejewski-Szmekfa13e4a2013-05-06 20:00:16 -0400229<xsl:template match="refsect2/title|refsect2/info/title">
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200230 <xsl:call-template name="headerlink">
231 <xsl:with-param name="nodeType" select="'h3'"/>
232 </xsl:call-template>
Zbigniew Jędrzejewski-Szmekfa13e4a2013-05-06 20:00:16 -0400233</xsl:template>
234
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400235<xsl:template match="varlistentry">
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200236 <xsl:call-template name="permalink">
237 <xsl:with-param name="nodeType" select="'dt'"/>
238 <xsl:with-param name="linkTitle" select="'Permalink to this term'"/>
239 <xsl:with-param name="nodeContent" select="term"/>
240 <xsl:with-param name="keyNode" select="term[1]"/>
241 <!--
242 - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
243 - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
244 - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
245 -->
246 <xsl:with-param name="templateID">
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400247 <xsl:call-template name="inline.charseq">
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200248 <xsl:with-param name="content" select="term[1]"/>
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400249 </xsl:call-template>
Johan Ouwerkerkaa116972015-07-12 03:07:24 +0200250 </xsl:with-param>
251 </xsl:call-template>
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400252 <dd>
253 <xsl:apply-templates select="listitem"/>
254 </dd>
255</xsl:template>
256
257
Kay Sieversecca17f2012-07-17 23:04:48 +0200258<!-- add Index link at top of page -->
259<xsl:template name="user.header.content">
Zbigniew Jędrzejewski-Szmek20089f92013-05-03 20:25:57 -0400260 <style>
261 a.headerlink {
262 color: #c60f0f;
263 font-size: 0.8em;
264 padding: 0 4px 0 4px;
265 text-decoration: none;
266 visibility: hidden;
267 }
268
269 a.headerlink:hover {
270 background-color: #c60f0f;
271 color: white;
272 }
273
274 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
275 visibility: visible;
276 }
277 </style>
278
Kay Sieversecca17f2012-07-17 23:04:48 +0200279 <a>
280 <xsl:attribute name="href">
281 <xsl:text>index.html</xsl:text>
282 </xsl:attribute>
283 <xsl:text>Index </xsl:text>
Zbigniew Jędrzejewski-Szmek2cc8d972013-03-07 13:13:44 -0500284 </a>·
285 <a>
286 <xsl:attribute name="href">
287 <xsl:text>systemd.directives.html</xsl:text>
288 </xsl:attribute>
289 <xsl:text>Directives </xsl:text>
Kay Sievers1f353472015-06-22 19:54:52 +0200290 </a>
Zbigniew Jędrzejewski-Szmek702f64b2013-03-12 23:57:09 -0400291
292 <span style="float:right">
293 <xsl:text>systemd </xsl:text>
294 <xsl:value-of select="$systemd.version"/>
295 </span>
Kay Sieversecca17f2012-07-17 23:04:48 +0200296 <hr/>
297</xsl:template>
298
Zbigniew Jędrzejewski-Szmek909f4132013-06-26 08:03:53 -0400299<xsl:template match="literal">
300 <xsl:text>"</xsl:text>
301 <xsl:call-template name="inline.monoseq"/>
302 <xsl:text>"</xsl:text>
303</xsl:template>
304
Lennart Poettering76318282011-12-19 20:25:52 +0100305<!-- Switch things to UTF-8, ISO-8859-1 is soo yesteryear -->
306<xsl:output method="html" encoding="UTF-8" indent="no"/>
307
308</xsl:stylesheet>