custom-html.xsl revision d77c25b1164f55fe3f9b5ad00c47c0e01243ad53
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<?xml version='1.0'?> <!--*-nxml-*-->
2d0611ffc9f91c5fc2ddccb93f9a3d17791ae650takashi
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<!--
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend This file is part of systemd.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
7ec4d5cc4aa574e3191bc5a612e68fd8f25ab7earpluem Copyright 2011 Lennart Poettering
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend systemd is free software; you can redistribute it and/or modify it
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend under the terms of the GNU Lesser General Public License as published by
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend the Free Software Foundation; either version 2.1 of the License, or
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend (at your option) any later version.
d9b843d090f14405079b4a61a493316cd3f1e5b9minfrin
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend systemd is distributed in the hope that it will be useful, but
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes WITHOUT ANY WARRANTY; without even the implied warranty of
909ce17e2bd0faef7b1c294f2307f009793fd493nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend Lesser General Public License for more details.
0ce5630695a7aa568811a9dd0aceedd685f040dend
42af92a661a06b3cebc88d585aad75064a309d51nd You should have received a copy of the GNU Lesser General Public License
367d146f245f3b1c9f77c18e6ec591b52e0b344cbnicholes along with systemd; If not, see <http://www.gnu.org/licenses/>.
6fe26506780e73be2a412d758af77fafdf03291and-->
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<!--
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend - The docbook stylesheet injects empty anchor tags into generated HTML, identified by an auto-generated ID.
43f6cc6aa3312619633538b8978619a48c0ce52eminfrin - Ask the docbook stylesheet to generate reproducible output when generating (these) ID values.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend - This makes the output of this stylesheet reproducible across identical invocations on the same input,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend - which is an easy and significant win for achieving reproducible builds.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend -
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend - It may be even better to strip the empty anchors from the document output in addition to turning on consistent IDs,
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend - for this stylesheet contains its own custom ID logic (for generating permalinks) already.
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend -->
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:param name="generate.consistent.ids" select="1"/>
05ede5110427cb9dc071cc671d5aaba5d3b88c79nd
e8b603fa9ccf7b17b11b42df6d8916fd97c2331dnd<!-- translate man page references to links to html pages -->
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:template match="citerefentry[not(@project)]">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:attribute name="href">
d6ce05b6521a82cc93da69f7c2116c4a5bc54f8cjim <xsl:value-of select="refentrytitle"/><xsl:text>.html</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </xsl:attribute>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:call-template name="inline.charseq"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend</xsl:template>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:template match="citerefentry[@project='man-pages'] | citerefentry[manvolnum='2'] | citerefentry[manvolnum='4']">
03a4ff9ac4c9b8009249010e7c53bb86ff05915and <a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:attribute name="href">
1e367a83311e5243e04d68857d007d04765a48f9chrisd <xsl:text>http://man7.org/linux/man-pages/man</xsl:text>
1e367a83311e5243e04d68857d007d04765a48f9chrisd <xsl:value-of select="manvolnum"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>/</xsl:text>
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna <xsl:value-of select="refentrytitle"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>.</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:value-of select="manvolnum"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>.html</xsl:text>
2704de98885368683621b01c8f8f4e4b01557611takashi </xsl:attribute>
2704de98885368683621b01c8f8f4e4b01557611takashi <xsl:call-template name="inline.charseq"/>
2704de98885368683621b01c8f8f4e4b01557611takashi </a>
1e367a83311e5243e04d68857d007d04765a48f9chrisd</xsl:template>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:template match="citerefentry[@project='die-net']">
d2b809e5d72658bff23819d8b77f20e4939af541nd <a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:attribute name="href">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>http://linux.die.net/man/</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:value-of select="manvolnum"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>/</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:value-of select="refentrytitle"/>
27d778df0b517e1578f907d2e51eb961cd8ee5fbjim </xsl:attribute>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:call-template name="inline.charseq"/>
6b0fe1f447ba35827cd5cf1d2a703bd8517f33ffmturk </a>
6b0fe1f447ba35827cd5cf1d2a703bd8517f33ffmturk</xsl:template>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend
e5ce3ac0e9b720c0fa23782e29168a0810697fdetakashi<xsl:template match="citerefentry[@project='mankier']">
f73390048b37c973a8016ffd22108d7a73c6cc22pquerna <a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:attribute name="href">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>https://www.mankier.com/</xsl:text>
0a69d9bb491d9810892a9949c01403a1de3c7ac2nd <xsl:value-of select="manvolnum"/>
5f4e50966b2b9b58436a1651cbe588d1b595657ewrowe <xsl:text>/</xsl:text>
623eebe956d9c2d6d073ed3eae855b56030b40e9noodl <xsl:value-of select="refentrytitle"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </xsl:attribute>
79b024b81f6bb3c44dce77a7552191daf8b522d2jim <xsl:call-template name="inline.charseq"/>
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin </a>
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin</xsl:template>
4277c95b5a9454a5c25f8d8762634fcff37aa840minfrin
f195a136dcd90148b116fdae8ce95b41ba92b87eminfrin<xsl:template match="citerefentry[@project='archlinux']">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <a>
1de1266f0ea387d6373be8415745dfd2ab876341jim <xsl:attribute name="href">
1de1266f0ea387d6373be8415745dfd2ab876341jim <xsl:text>https://www.archlinux.org/</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:value-of select="refentrytitle"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>/</xsl:text>
0ce5630695a7aa568811a9dd0aceedd685f040dend <xsl:value-of select="refentrytitle"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>.</xsl:text>
10eed2803538d660048f6e733602e82a75ef6885noodl <xsl:value-of select="manvolnum"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>.html</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </xsl:attribute>
4db28ee269aa06f7c6232e11cd01f58c3349af23noodl <xsl:call-template name="inline.charseq"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend </a>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend</xsl:template>
03c25fb6f628ac81f2ecb637d1e7502dcee783f3nd
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend<xsl:template match="citerefentry[@project='freebsd']">
0ce5630695a7aa568811a9dd0aceedd685f040dend <a>
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna <xsl:attribute name="href">
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>https://www.freebsd.org/cgi/man.cgi?</xsl:text>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:value-of select="refentrytitle"/>
0ce5630695a7aa568811a9dd0aceedd685f040dend <xsl:text>(</xsl:text>
0ce5630695a7aa568811a9dd0aceedd685f040dend <xsl:value-of select="manvolnum"/>
f73f2c2fae0ded6c8273c28d025ba8aa8136a0fend <xsl:text>)</xsl:text>
</xsl:attribute>
<xsl:call-template name="inline.charseq"/>
</a>
</xsl:template>
<xsl:template match="citerefentry[@project='dbus']">
<a>
<xsl:attribute name="href">
<xsl:text>http://dbus.freedesktop.org/doc/</xsl:text>
<xsl:value-of select="refentrytitle"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="manvolnum"/>
<xsl:text>.html</xsl:text>
</xsl:attribute>
<xsl:call-template name="inline.charseq"/>
</a>
</xsl:template>
<!--
- helper template to do conflict resolution between various headings with the same inferred ID attribute/tag from the headerlink template
- this conflict resolution is necessary to prevent malformed HTML ouput (multiple id attributes with the same value)
- and it fixes xsltproc warnings during compilation of HTML man pages
-
- A simple top-to-bottom numbering scheme is implemented for nodes with the same ID value to derive unique ID values for HTML output.
- It uses two parameters:
templateID the proposed ID string to use which must be checked for conflicts
keyNode the context node which 'produced' the given templateID.
-
- Conflicts are detected solely based on keyNode, templateID is not taken into account for that purpose.
-->
<xsl:template name="generateID">
<!-- node which generatedID needs to assume as the 'source' of the ID -->
<xsl:param name="keyNode"/>
<!-- suggested value for generatedID output, a contextually meaningful ID string -->
<xsl:param name="templateID"/>
<xsl:variable name="conflictSource" select="preceding::refsect1/title|preceding::refsect1/info/title|
preceding::refsect2/title|preceding::refsect2/info/title|
preceding::varlistentry/term[1]"/>
<xsl:variable name="conflictCount" select="count($conflictSource[. = $keyNode])"/>
<xsl:choose>
<!-- special case conflictCount = 0 to preserve compatibility with URLs generated by previous versions of this XSL stylesheet where possible -->
<xsl:when test="$conflictCount = 0">
<xsl:value-of select="$templateID"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($templateID, $conflictCount)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
- a helper template to abstract over the structure of generated subheading + permalink HTML output
- It helps reduce tedious repetition and groups all actual markup output (as opposed to URL/ID logic) in a single location.
-->
<xsl:template name="permalink">
<xsl:param name="nodeType"/> <!-- local name of the element node to generate, e.g. 'h2' for <h2></h2> -->
<xsl:param name="nodeContent"/> <!-- nodeset to apply further templates to obtain the content of the subheading/term -->
<xsl:param name="linkTitle"/> <!-- value for title attribute of generated permalink, e.g. 'this is a permalink' -->
<!-- parameters passed to generateID template, otherwise unused. -->
<xsl:param name="keyNode"/>
<xsl:param name="templateID"/>
<!--
- If stable URLs with fragment markers (references to the ID) turn out not to be important:
- generatedID could simply take the value of generate-id(), and various other helper templates may be dropped entirely.
- Alternatively if xsltproc is patched to generate reproducible generate-id() output the same simplifications can be
- applied at the cost of breaking compatibility with URLs generated from output of previous versions of this stylesheet.
-->
<xsl:variable name="generatedID">
<xsl:call-template name="generateID">
<xsl:with-param name="keyNode" select="$keyNode"/>
<xsl:with-param name="templateID" select="$templateID"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="{$nodeType}">
<xsl:attribute name="id">
<xsl:value-of select="$generatedID"/>
</xsl:attribute>
<xsl:apply-templates select="$nodeContent"/>
<a class="headerlink" title="{$linkTitle}" href="#{$generatedID}">¶</a>
</xsl:element>
</xsl:template>
<!-- simple wrapper around permalink to avoid repeating common info for each level of subheading covered by the permalink logic (h2, h3) -->
<xsl:template name="headerlink">
<xsl:param name="nodeType"/>
<xsl:call-template name="permalink">
<xsl:with-param name="nodeType" select="$nodeType"/>
<xsl:with-param name="linkTitle" select="'Permalink to this headline'"/>
<xsl:with-param name="nodeContent" select="node()"/>
<xsl:with-param name="keyNode" select="."/>
<!--
- To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
- The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
- The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
-->
<xsl:with-param name="templateID">
<xsl:call-template name="inline.charseq"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="refsect1/title|refsect1/info/title">
<!-- the ID is output in the block.object call for refsect1 -->
<xsl:call-template name="headerlink">
<xsl:with-param name="nodeType" select="'h2'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="refsect2/title|refsect2/info/title">
<xsl:call-template name="headerlink">
<xsl:with-param name="nodeType" select="'h3'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="varlistentry">
<xsl:call-template name="permalink">
<xsl:with-param name="nodeType" select="'dt'"/>
<xsl:with-param name="linkTitle" select="'Permalink to this term'"/>
<xsl:with-param name="nodeContent" select="term"/>
<xsl:with-param name="keyNode" select="term[1]"/>
<!--
- To retain compatibility with IDs generated by previous versions of the template, inline.charseq must be called.
- The purpose of that template is to generate markup (according to docbook documentation its purpose is to mark/format something as plain text).
- The only reason to call this template is to get the auto-generated text such as brackets ([]) before flattening it.
-->
<xsl:with-param name="templateID">
<xsl:call-template name="inline.charseq">
<xsl:with-param name="content" select="term[1]"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
<dd>
<xsl:apply-templates select="listitem"/>
</dd>
</xsl:template>
<!-- add Index link at top of page -->
<xsl:template name="user.header.content">
<style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style>
<a>
<xsl:attribute name="href">
<xsl:text>index.html</xsl:text>
</xsl:attribute>
<xsl:text>Index </xsl:text>
</a
<a>
<xsl:attribute name="href">
<xsl:text>systemd.directives.html</xsl:text>
</xsl:attribute>
<xsl:text>Directives </xsl:text>
</a>
<span style="float:right">
<xsl:text>systemd </xsl:text>
<xsl:value-of select="$systemd.version"/>
</span>
<hr/>
</xsl:template>
<xsl:template match="literal">
<xsl:text>"</xsl:text>
<xsl:call-template name="inline.monoseq"/>
<xsl:text>"</xsl:text>
</xsl:template>
<!-- Switch things to UTF-8, ISO-8859-1 is soo yesteryear -->
<xsl:output method="html" encoding="UTF-8" indent="no"/>
</xsl:stylesheet>