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