]>
Commit | Line | Data |
---|---|---|
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"> | |
958caa58 ZJS |
40 | <xsl:value-of select="refentrytitle"/><xsl:text>.html#</xsl:text> |
41 | <xsl:value-of select="refentrytitle/@target"/> | |
ecca17f6 KS |
42 | </xsl:attribute> |
43 | <xsl:call-template name="inline.charseq"/> | |
44 | </a> | |
45 | </xsl:template> | |
46 | ||
5aded369 ZJS |
47 | <xsl:template match="citerefentry[@project='man-pages'] | citerefentry[manvolnum='2'] | citerefentry[manvolnum='4']"> |
48 | <a> | |
49 | <xsl:attribute name="href"> | |
50 | <xsl:text>http://man7.org/linux/man-pages/man</xsl:text> | |
51 | <xsl:value-of select="manvolnum"/> | |
52 | <xsl:text>/</xsl:text> | |
53 | <xsl:value-of select="refentrytitle"/> | |
54 | <xsl:text>.</xsl:text> | |
55 | <xsl:value-of select="manvolnum"/> | |
56 | <xsl:text>.html</xsl:text> | |
57 | </xsl:attribute> | |
58 | <xsl:call-template name="inline.charseq"/> | |
59 | </a> | |
60 | </xsl:template> | |
61 | ||
62 | <xsl:template match="citerefentry[@project='die-net']"> | |
63 | <a> | |
64 | <xsl:attribute name="href"> | |
65 | <xsl:text>http://linux.die.net/man/</xsl:text> | |
66 | <xsl:value-of select="manvolnum"/> | |
67 | <xsl:text>/</xsl:text> | |
68 | <xsl:value-of select="refentrytitle"/> | |
69 | </xsl:attribute> | |
70 | <xsl:call-template name="inline.charseq"/> | |
71 | </a> | |
72 | </xsl:template> | |
73 | ||
74a6d87d ZJS |
74 | <xsl:template match="citerefentry[@project='mankier']"> |
75 | <a> | |
76 | <xsl:attribute name="href"> | |
77 | <xsl:text>https://www.mankier.com/</xsl:text> | |
78 | <xsl:value-of select="manvolnum"/> | |
79 | <xsl:text>/</xsl:text> | |
80 | <xsl:value-of select="refentrytitle"/> | |
81 | </xsl:attribute> | |
82 | <xsl:call-template name="inline.charseq"/> | |
83 | </a> | |
84 | </xsl:template> | |
85 | ||
5aded369 ZJS |
86 | <xsl:template match="citerefentry[@project='archlinux']"> |
87 | <a> | |
88 | <xsl:attribute name="href"> | |
89 | <xsl:text>https://www.archlinux.org/</xsl:text> | |
90 | <xsl:value-of select="refentrytitle"/> | |
91 | <xsl:text>/</xsl:text> | |
92 | <xsl:value-of select="refentrytitle"/> | |
93 | <xsl:text>.</xsl:text> | |
94 | <xsl:value-of select="manvolnum"/> | |
95 | <xsl:text>.html</xsl:text> | |
96 | </xsl:attribute> | |
97 | <xsl:call-template name="inline.charseq"/> | |
98 | </a> | |
99 | </xsl:template> | |
100 | ||
b5c7d097 ZJS |
101 | <xsl:template match="citerefentry[@project='freebsd']"> |
102 | <a> | |
103 | <xsl:attribute name="href"> | |
104 | <xsl:text>https://www.freebsd.org/cgi/man.cgi?</xsl:text> | |
105 | <xsl:value-of select="refentrytitle"/> | |
106 | <xsl:text>(</xsl:text> | |
107 | <xsl:value-of select="manvolnum"/> | |
108 | <xsl:text>)</xsl:text> | |
109 | </xsl:attribute> | |
110 | <xsl:call-template name="inline.charseq"/> | |
111 | </a> | |
112 | </xsl:template> | |
113 | ||
3b5cfcdb ZJS |
114 | <xsl:template match="citerefentry[@project='dbus']"> |
115 | <a> | |
116 | <xsl:attribute name="href"> | |
117 | <xsl:text>http://dbus.freedesktop.org/doc/</xsl:text> | |
118 | <xsl:value-of select="refentrytitle"/> | |
119 | <xsl:text>.</xsl:text> | |
120 | <xsl:value-of select="manvolnum"/> | |
121 | <xsl:text>.html</xsl:text> | |
122 | </xsl:attribute> | |
123 | <xsl:call-template name="inline.charseq"/> | |
124 | </a> | |
125 | </xsl:template> | |
126 | ||
aa116977 JO |
127 | <!-- |
128 | - helper template to do conflict resolution between various headings with the same inferred ID attribute/tag from the headerlink template | |
a8eaaee7 | 129 | - this conflict resolution is necessary to prevent malformed HTML output (multiple ID attributes with the same value) |
aa116977 JO |
130 | - and it fixes xsltproc warnings during compilation of HTML man pages |
131 | - | |
132 | - A simple top-to-bottom numbering scheme is implemented for nodes with the same ID value to derive unique ID values for HTML output. | |
133 | - It uses two parameters: | |
134 | templateID the proposed ID string to use which must be checked for conflicts | |
135 | keyNode the context node which 'produced' the given templateID. | |
136 | - | |
137 | - Conflicts are detected solely based on keyNode, templateID is not taken into account for that purpose. | |
138 | --> | |
139 | <xsl:template name="generateID"> | |
140 | <!-- node which generatedID needs to assume as the 'source' of the ID --> | |
141 | <xsl:param name="keyNode"/> | |
142 | <!-- suggested value for generatedID output, a contextually meaningful ID string --> | |
143 | <xsl:param name="templateID"/> | |
144 | <xsl:variable name="conflictSource" select="preceding::refsect1/title|preceding::refsect1/info/title| | |
145 | preceding::refsect2/title|preceding::refsect2/info/title| | |
146 | preceding::varlistentry/term[1]"/> | |
147 | <xsl:variable name="conflictCount" select="count($conflictSource[. = $keyNode])"/> | |
148 | <xsl:choose> | |
149 | <!-- special case conflictCount = 0 to preserve compatibility with URLs generated by previous versions of this XSL stylesheet where possible --> | |
150 | <xsl:when test="$conflictCount = 0"> | |
151 | <xsl:value-of select="$templateID"/> | |
152 | </xsl:when> | |
153 | <xsl:otherwise> | |
154 | <xsl:value-of select="concat($templateID, $conflictCount)"/> | |
155 | </xsl:otherwise> | |
156 | </xsl:choose> | |
157 | </xsl:template> | |
158 | ||
159 | <!-- | |
160 | - a helper template to abstract over the structure of generated subheading + permalink HTML output | |
161 | - It helps reduce tedious repetition and groups all actual markup output (as opposed to URL/ID logic) in a single location. | |
162 | --> | |
163 | <xsl:template name="permalink"> | |
164 | <xsl:param name="nodeType"/> <!-- local name of the element node to generate, e.g. 'h2' for <h2></h2> --> | |
165 | <xsl:param name="nodeContent"/> <!-- nodeset to apply further templates to obtain the content of the subheading/term --> | |
166 | <xsl:param name="linkTitle"/> <!-- value for title attribute of generated permalink, e.g. 'this is a permalink' --> | |
167 | ||
168 | <!-- parameters passed to generateID template, otherwise unused. --> | |
169 | <xsl:param name="keyNode"/> | |
170 | <xsl:param name="templateID"/> | |
171 | ||
172 | <!-- | |
173 | - If stable URLs with fragment markers (references to the ID) turn out not to be important: | |
174 | - generatedID could simply take the value of generate-id(), and various other helper templates may be dropped entirely. | |
b938cb90 | 175 | - Alternatively, if xsltproc is patched to generate reproducible generate-id() output, the same simplifications can be |
aa116977 JO |
176 | - applied at the cost of breaking compatibility with URLs generated from output of previous versions of this stylesheet. |
177 | --> | |
178 | <xsl:variable name="generatedID"> | |
179 | <xsl:call-template name="generateID"> | |
180 | <xsl:with-param name="keyNode" select="$keyNode"/> | |
181 | <xsl:with-param name="templateID" select="$templateID"/> | |
182 | </xsl:call-template> | |
183 | </xsl:variable> | |
184 | ||
185 | <xsl:element name="{$nodeType}"> | |
20089f95 | 186 | <xsl:attribute name="id"> |
aa116977 | 187 | <xsl:value-of select="$generatedID"/> |
20089f95 | 188 | </xsl:attribute> |
aa116977 JO |
189 | <xsl:apply-templates select="$nodeContent"/> |
190 | <a class="headerlink" title="{$linkTitle}" href="#{$generatedID}">¶</a> | |
191 | </xsl:element> | |
20089f95 ZJS |
192 | </xsl:template> |
193 | ||
aa116977 JO |
194 | <!-- simple wrapper around permalink to avoid repeating common info for each level of subheading covered by the permalink logic (h2, h3) --> |
195 | <xsl:template name="headerlink"> | |
196 | <xsl:param name="nodeType"/> | |
197 | <xsl:call-template name="permalink"> | |
198 | <xsl:with-param name="nodeType" select="$nodeType"/> | |
199 | <xsl:with-param name="linkTitle" select="'Permalink to this headline'"/> | |
200 | <xsl:with-param name="nodeContent" select="node()"/> | |
201 | <xsl:with-param name="keyNode" select="."/> | |
202 | <!-- | |
203 | - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called. | |
204 | - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text). | |
205 | - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it. | |
206 | --> | |
207 | <xsl:with-param name="templateID"> | |
fa13e4a7 | 208 | <xsl:call-template name="inline.charseq"/> |
aa116977 JO |
209 | </xsl:with-param> |
210 | </xsl:call-template> | |
211 | </xsl:template> | |
212 | ||
213 | <xsl:template match="refsect1/title|refsect1/info/title"> | |
214 | <!-- the ID is output in the block.object call for refsect1 --> | |
215 | <xsl:call-template name="headerlink"> | |
216 | <xsl:with-param name="nodeType" select="'h2'"/> | |
217 | </xsl:call-template> | |
218 | </xsl:template> | |
219 | ||
220 | <xsl:template match="refsect2/title|refsect2/info/title"> | |
221 | <xsl:call-template name="headerlink"> | |
222 | <xsl:with-param name="nodeType" select="'h3'"/> | |
223 | </xsl:call-template> | |
fa13e4a7 ZJS |
224 | </xsl:template> |
225 | ||
20089f95 | 226 | <xsl:template match="varlistentry"> |
aa116977 JO |
227 | <xsl:call-template name="permalink"> |
228 | <xsl:with-param name="nodeType" select="'dt'"/> | |
229 | <xsl:with-param name="linkTitle" select="'Permalink to this term'"/> | |
230 | <xsl:with-param name="nodeContent" select="term"/> | |
231 | <xsl:with-param name="keyNode" select="term[1]"/> | |
232 | <!-- | |
233 | - To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called. | |
234 | - The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text). | |
235 | - The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it. | |
236 | --> | |
237 | <xsl:with-param name="templateID"> | |
20089f95 | 238 | <xsl:call-template name="inline.charseq"> |
aa116977 | 239 | <xsl:with-param name="content" select="term[1]"/> |
20089f95 | 240 | </xsl:call-template> |
aa116977 JO |
241 | </xsl:with-param> |
242 | </xsl:call-template> | |
20089f95 ZJS |
243 | <dd> |
244 | <xsl:apply-templates select="listitem"/> | |
245 | </dd> | |
246 | </xsl:template> | |
247 | ||
248 | ||
ecca17f6 KS |
249 | <!-- add Index link at top of page --> |
250 | <xsl:template name="user.header.content"> | |
20089f95 ZJS |
251 | <style> |
252 | a.headerlink { | |
253 | color: #c60f0f; | |
254 | font-size: 0.8em; | |
255 | padding: 0 4px 0 4px; | |
256 | text-decoration: none; | |
257 | visibility: hidden; | |
258 | } | |
259 | ||
260 | a.headerlink:hover { | |
261 | background-color: #c60f0f; | |
262 | color: white; | |
263 | } | |
264 | ||
265 | h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink { | |
266 | visibility: visible; | |
267 | } | |
268 | </style> | |
269 | ||
ecca17f6 KS |
270 | <a> |
271 | <xsl:attribute name="href"> | |
272 | <xsl:text>index.html</xsl:text> | |
273 | </xsl:attribute> | |
274 | <xsl:text>Index </xsl:text> | |
2cc8d973 ZJS |
275 | </a>· |
276 | <a> | |
277 | <xsl:attribute name="href"> | |
278 | <xsl:text>systemd.directives.html</xsl:text> | |
279 | </xsl:attribute> | |
280 | <xsl:text>Directives </xsl:text> | |
1f35347a | 281 | </a> |
702f64b9 ZJS |
282 | |
283 | <span style="float:right"> | |
284 | <xsl:text>systemd </xsl:text> | |
285 | <xsl:value-of select="$systemd.version"/> | |
286 | </span> | |
ecca17f6 KS |
287 | <hr/> |
288 | </xsl:template> | |
289 | ||
909f413d ZJS |
290 | <xsl:template match="literal"> |
291 | <xsl:text>"</xsl:text> | |
292 | <xsl:call-template name="inline.monoseq"/> | |
293 | <xsl:text>"</xsl:text> | |
294 | </xsl:template> | |
295 | ||
76318284 LP |
296 | <!-- Switch things to UTF-8, ISO-8859-1 is soo yesteryear --> |
297 | <xsl:output method="html" encoding="UTF-8" indent="no"/> | |
298 | ||
299 | </xsl:stylesheet> |