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