]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/custom-html.xsl
test-execute: Add tests for new PassEnvironment= directive
[thirdparty/systemd.git] / man / custom-html.xsl
CommitLineData
76318284
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2
3<!--
4 This file is part of systemd.
5
6 Copyright 2011 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
76318284
LP
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 16 Lesser General Public License for more details.
76318284 17
5430f7f2 18 You should have received a copy of the GNU Lesser General Public License
76318284
LP
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20-->
21
22<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
23
24<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
d77c25b1
JO
25<!--
26 - The docbook stylesheet injects empty anchor tags into generated HTML, identified by an auto-generated ID.
27 - Ask the docbook stylesheet to generate reproducible output when generating (these) ID values.
28 - This makes the output of this stylesheet reproducible across identical invocations on the same input,
29 - which is an easy and significant win for achieving reproducible builds.
30 -
31 - It may be even better to strip the empty anchors from the document output in addition to turning on consistent IDs,
32 - for this stylesheet contains its own custom ID logic (for generating permalinks) already.
33 -->
34<xsl:param name="generate.consistent.ids" select="1"/>
76318284 35
ecca17f6 36<!-- translate man page references to links to html pages -->
5aded369 37<xsl:template match="citerefentry[not(@project)]">
ecca17f6
KS
38 <a>
39 <xsl:attribute name="href">
40 <xsl:value-of select="refentrytitle"/><xsl:text>.html</xsl:text>
41 </xsl:attribute>
42 <xsl:call-template name="inline.charseq"/>
43 </a>
44</xsl:template>
45
5aded369
ZJS
46<xsl:template match="citerefentry[@project='man-pages'] | citerefentry[manvolnum='2'] | citerefentry[manvolnum='4']">
47 <a>
48 <xsl:attribute name="href">
49 <xsl:text>http://man7.org/linux/man-pages/man</xsl:text>
50 <xsl:value-of select="manvolnum"/>
51 <xsl:text>/</xsl:text>
52 <xsl:value-of select="refentrytitle"/>
53 <xsl:text>.</xsl:text>
54 <xsl:value-of select="manvolnum"/>
55 <xsl:text>.html</xsl:text>
56 </xsl:attribute>
57 <xsl:call-template name="inline.charseq"/>
58 </a>
59</xsl:template>
60
61<xsl:template match="citerefentry[@project='die-net']">
62 <a>
63 <xsl:attribute name="href">
64 <xsl:text>http://linux.die.net/man/</xsl:text>
65 <xsl:value-of select="manvolnum"/>
66 <xsl:text>/</xsl:text>
67 <xsl:value-of select="refentrytitle"/>
68 </xsl:attribute>
69 <xsl:call-template name="inline.charseq"/>
70 </a>
71</xsl:template>
72
74a6d87d
ZJS
73<xsl:template match="citerefentry[@project='mankier']">
74 <a>
75 <xsl:attribute name="href">
76 <xsl:text>https://www.mankier.com/</xsl:text>
77 <xsl:value-of select="manvolnum"/>
78 <xsl:text>/</xsl:text>
79 <xsl:value-of select="refentrytitle"/>
80 </xsl:attribute>
81 <xsl:call-template name="inline.charseq"/>
82 </a>
83</xsl:template>
84
5aded369
ZJS
85<xsl:template match="citerefentry[@project='archlinux']">
86 <a>
87 <xsl:attribute name="href">
88 <xsl:text>https://www.archlinux.org/</xsl:text>
89 <xsl:value-of select="refentrytitle"/>
90 <xsl:text>/</xsl:text>
91 <xsl:value-of select="refentrytitle"/>
92 <xsl:text>.</xsl:text>
93 <xsl:value-of select="manvolnum"/>
94 <xsl:text>.html</xsl:text>
95 </xsl:attribute>
96 <xsl:call-template name="inline.charseq"/>
97 </a>
98</xsl:template>
99
b5c7d097
ZJS
100<xsl:template match="citerefentry[@project='freebsd']">
101 <a>
102 <xsl:attribute name="href">
103 <xsl:text>https://www.freebsd.org/cgi/man.cgi?</xsl:text>
104 <xsl:value-of select="refentrytitle"/>
105 <xsl:text>(</xsl:text>
106 <xsl:value-of select="manvolnum"/>
107 <xsl:text>)</xsl:text>
108 </xsl:attribute>
109 <xsl:call-template name="inline.charseq"/>
110 </a>
111</xsl:template>
112
3b5cfcdb
ZJS
113<xsl:template match="citerefentry[@project='dbus']">
114 <a>
115 <xsl:attribute name="href">
116 <xsl:text>http://dbus.freedesktop.org/doc/</xsl:text>
117 <xsl:value-of select="refentrytitle"/>
118 <xsl:text>.</xsl:text>
119 <xsl:value-of select="manvolnum"/>
120 <xsl:text>.html</xsl:text>
121 </xsl:attribute>
122 <xsl:call-template name="inline.charseq"/>
123 </a>
124</xsl:template>
125
aa116977
JO
126<!--
127 - helper template to do conflict resolution between various headings with the same inferred ID attribute/tag from the headerlink template
a8eaaee7 128 - this conflict resolution is necessary to prevent malformed HTML output (multiple ID attributes with the same value)
aa116977
JO
129 - and it fixes xsltproc warnings during compilation of HTML man pages
130 -
131 - A simple top-to-bottom numbering scheme is implemented for nodes with the same ID value to derive unique ID values for HTML output.
132 - It uses two parameters:
133 templateID the proposed ID string to use which must be checked for conflicts
134 keyNode the context node which 'produced' the given templateID.
135 -
136 - Conflicts are detected solely based on keyNode, templateID is not taken into account for that purpose.
137 -->
138<xsl:template name="generateID">
139 <!-- node which generatedID needs to assume as the 'source' of the ID -->
140 <xsl:param name="keyNode"/>
141 <!-- suggested value for generatedID output, a contextually meaningful ID string -->
142 <xsl:param name="templateID"/>
143 <xsl:variable name="conflictSource" select="preceding::refsect1/title|preceding::refsect1/info/title|
144 preceding::refsect2/title|preceding::refsect2/info/title|
145 preceding::varlistentry/term[1]"/>
146 <xsl:variable name="conflictCount" select="count($conflictSource[. = $keyNode])"/>
147 <xsl:choose>
148 <!-- special case conflictCount = 0 to preserve compatibility with URLs generated by previous versions of this XSL stylesheet where possible -->
149 <xsl:when test="$conflictCount = 0">
150 <xsl:value-of select="$templateID"/>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:value-of select="concat($templateID, $conflictCount)"/>
154 </xsl:otherwise>
155 </xsl:choose>
156</xsl:template>
157
158<!--
159 - a helper template to abstract over the structure of generated subheading + permalink HTML output
160 - It helps reduce tedious repetition and groups all actual markup output (as opposed to URL/ID logic) in a single location.
161 -->
162<xsl:template name="permalink">
163 <xsl:param name="nodeType"/> <!-- local name of the element node to generate, e.g. 'h2' for <h2></h2> -->
164 <xsl:param name="nodeContent"/> <!-- nodeset to apply further templates to obtain the content of the subheading/term -->
165 <xsl:param name="linkTitle"/> <!-- value for title attribute of generated permalink, e.g. 'this is a permalink' -->
166
167 <!-- parameters passed to generateID template, otherwise unused. -->
168 <xsl:param name="keyNode"/>
169 <xsl:param name="templateID"/>
170
171 <!--
172 - If stable URLs with fragment markers (references to the ID) turn out not to be important:
173 - generatedID could simply take the value of generate-id(), and various other helper templates may be dropped entirely.
b938cb90 174 - Alternatively, if xsltproc is patched to generate reproducible generate-id() output, the same simplifications can be
aa116977
JO
175 - applied at the cost of breaking compatibility with URLs generated from output of previous versions of this stylesheet.
176 -->
177 <xsl:variable name="generatedID">
178 <xsl:call-template name="generateID">
179 <xsl:with-param name="keyNode" select="$keyNode"/>
180 <xsl:with-param name="templateID" select="$templateID"/>
181 </xsl:call-template>
182 </xsl:variable>
183
184 <xsl:element name="{$nodeType}">
20089f95 185 <xsl:attribute name="id">
aa116977 186 <xsl:value-of select="$generatedID"/>
20089f95 187 </xsl:attribute>
aa116977
JO
188 <xsl:apply-templates select="$nodeContent"/>
189 <a class="headerlink" title="{$linkTitle}" href="#{$generatedID}">¶</a>
190 </xsl:element>
20089f95
ZJS
191</xsl:template>
192
aa116977
JO
193<!-- simple wrapper around permalink to avoid repeating common info for each level of subheading covered by the permalink logic (h2, h3) -->
194<xsl:template name="headerlink">
195 <xsl:param name="nodeType"/>
196 <xsl:call-template name="permalink">
197 <xsl:with-param name="nodeType" select="$nodeType"/>
198 <xsl:with-param name="linkTitle" select="'Permalink to this headline'"/>
199 <xsl:with-param name="nodeContent" select="node()"/>
200 <xsl:with-param name="keyNode" select="."/>
201 <!--
202 - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
203 - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
204 - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
205 -->
206 <xsl:with-param name="templateID">
fa13e4a7 207 <xsl:call-template name="inline.charseq"/>
aa116977
JO
208 </xsl:with-param>
209 </xsl:call-template>
210</xsl:template>
211
212<xsl:template match="refsect1/title|refsect1/info/title">
213 <!-- the ID is output in the block.object call for refsect1 -->
214 <xsl:call-template name="headerlink">
215 <xsl:with-param name="nodeType" select="'h2'"/>
216 </xsl:call-template>
217</xsl:template>
218
219<xsl:template match="refsect2/title|refsect2/info/title">
220 <xsl:call-template name="headerlink">
221 <xsl:with-param name="nodeType" select="'h3'"/>
222 </xsl:call-template>
fa13e4a7
ZJS
223</xsl:template>
224
20089f95 225<xsl:template match="varlistentry">
aa116977
JO
226 <xsl:call-template name="permalink">
227 <xsl:with-param name="nodeType" select="'dt'"/>
228 <xsl:with-param name="linkTitle" select="'Permalink to this term'"/>
229 <xsl:with-param name="nodeContent" select="term"/>
230 <xsl:with-param name="keyNode" select="term[1]"/>
231 <!--
232 - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
233 - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
234 - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
235 -->
236 <xsl:with-param name="templateID">
20089f95 237 <xsl:call-template name="inline.charseq">
aa116977 238 <xsl:with-param name="content" select="term[1]"/>
20089f95 239 </xsl:call-template>
aa116977
JO
240 </xsl:with-param>
241 </xsl:call-template>
20089f95
ZJS
242 <dd>
243 <xsl:apply-templates select="listitem"/>
244 </dd>
245</xsl:template>
246
247
ecca17f6
KS
248<!-- add Index link at top of page -->
249<xsl:template name="user.header.content">
20089f95
ZJS
250 <style>
251 a.headerlink {
252 color: #c60f0f;
253 font-size: 0.8em;
254 padding: 0 4px 0 4px;
255 text-decoration: none;
256 visibility: hidden;
257 }
258
259 a.headerlink:hover {
260 background-color: #c60f0f;
261 color: white;
262 }
263
264 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
265 visibility: visible;
266 }
267 </style>
268
ecca17f6
KS
269 <a>
270 <xsl:attribute name="href">
271 <xsl:text>index.html</xsl:text>
272 </xsl:attribute>
273 <xsl:text>Index </xsl:text>
2cc8d973
ZJS
274 </a>·
275 <a>
276 <xsl:attribute name="href">
277 <xsl:text>systemd.directives.html</xsl:text>
278 </xsl:attribute>
279 <xsl:text>Directives </xsl:text>
1f35347a 280 </a>
702f64b9
ZJS
281
282 <span style="float:right">
283 <xsl:text>systemd </xsl:text>
284 <xsl:value-of select="$systemd.version"/>
285 </span>
ecca17f6
KS
286 <hr/>
287</xsl:template>
288
909f413d
ZJS
289<xsl:template match="literal">
290 <xsl:text>"</xsl:text>
291 <xsl:call-template name="inline.monoseq"/>
292 <xsl:text>"</xsl:text>
293</xsl:template>
294
76318284
LP
295<!-- Switch things to UTF-8, ISO-8859-1 is soo yesteryear -->
296<xsl:output method="html" encoding="UTF-8" indent="no"/>
297
298</xsl:stylesheet>