docs: add a permalink to html headers

Quite often, I need to cite URLs like
    http://libvirt.org/formatnetwork.html#elementQoS
but it is annoying to copy them from the table of contents or the html
source.

This patch borrows from the Python documentation in order to make it
easier to cite headers on libvirt's oneline documentation.
This commit is contained in:
Dan Kenigsberg 2013-12-08 14:05:46 +00:00 committed by Claudio Bley
parent 29ea437e40
commit 237a088ba4
2 changed files with 33 additions and 0 deletions

View File

@ -498,3 +498,16 @@ div.description pre.code {
padding: 5px 10px 5px 10px;
margin-left: 2.5em;
}
a.headerlink {
text-decoration: none!important;
visibility: hidden;
}
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink {
visibility: visible;
}

View File

@ -185,4 +185,24 @@
<xsl:apply-templates select="exsl:node-set($inchtml)/html:html/html:body/*" mode="content"/>
</xsl:template>
<xsl:template match="html:h2 | html:h3 | html:h4 | html:h5 | html:h6" mode="content">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:apply-templates mode="copy" />
<xsl:if test="./html:a/@name">
<a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline">&#xb6;</a>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template match="text()" mode="copy">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="node()" mode="copy">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select="./@*"/>
<xsl:apply-templates mode="copy" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>