[libvirt] [PATCH] 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. --- docs/libvirt.css | 13 +++++++++++++ docs/page.xsl | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/docs/libvirt.css b/docs/libvirt.css index b324ac8..1d27873 100644 --- a/docs/libvirt.css +++ b/docs/libvirt.css @@ -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; +} diff --git a/docs/page.xsl b/docs/page.xsl index a2da854..107f6e2 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -185,4 +185,11 @@ <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:copy> + <xsl:copy-of select="./*"/> + <a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline">¶</a> + </xsl:copy> + </xsl:template> </xsl:stylesheet> -- 1.8.3.1

Note to reviewers: this patch is too naive and has devastating effect of headers that lack a named anchor element. Still, I'd love to hear your opinion about the idea. On Sun, Dec 08, 2013 at 02:05:46PM +0000, Dan Kenigsberg wrote:
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. --- docs/libvirt.css | 13 +++++++++++++ docs/page.xsl | 7 +++++++ 2 files changed, 20 insertions(+)
diff --git a/docs/libvirt.css b/docs/libvirt.css index b324ac8..1d27873 100644 --- a/docs/libvirt.css +++ b/docs/libvirt.css @@ -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; +} diff --git a/docs/page.xsl b/docs/page.xsl index a2da854..107f6e2 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -185,4 +185,11 @@
<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:copy> + <xsl:copy-of select="./*"/> + <a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline">¶</a> + </xsl:copy> + </xsl:template> </xsl:stylesheet> -- 1.8.3.1

On 08.12.2013 23:57, Dan Kenigsberg wrote:
Note to reviewers: this patch is too naive and has devastating effect of headers that lack a named anchor element. Still, I'd love to hear your opinion about the idea.
On Sun, Dec 08, 2013 at 02:05:46PM +0000, Dan Kenigsberg wrote:
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. --- docs/libvirt.css | 13 +++++++++++++ docs/page.xsl | 7 +++++++ 2 files changed, 20 insertions(+)
I like the idea - I often find myself in the same situation, but if we decide to merge this, we need to fix some issues: Validating internals/command.html ./html/libvirt-libvirt.html:6: element a: validity error : No declaration for attribute xmlns:html of element a ne">blah</a></h2><h3><a xmlns:html="http://www.w3.org/1999/xhtml" href="#macros" ^ (line repeats over and over) Moreover, going with '¶' turns out to be not cool: Generating logging.html.tmp ../docs/page.xsl:192: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xB6 0x3C 0x2F 0x61 <a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline"> Michal

At Tue, 10 Dec 2013 13:45:05 +0100, Michal Privoznik wrote:
On 08.12.2013 23:57, Dan Kenigsberg wrote:
Note to reviewers: this patch is too naive and has devastating effect of headers that lack a named anchor element. Still, I'd love to hear your opinion about the idea.
On Sun, Dec 08, 2013 at 02:05:46PM +0000, Dan Kenigsberg wrote:
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. --- docs/libvirt.css | 13 +++++++++++++ docs/page.xsl | 7 +++++++ 2 files changed, 20 insertions(+)
I like the idea - I often find myself in the same situation, but if we decide to merge this, we need to fix some issues:
Validating internals/command.html ./html/libvirt-libvirt.html:6: element a: validity error : No declaration for attribute xmlns:html of element a ne">blah</a></h2><h3><a xmlns:html="http://www.w3.org/1999/xhtml" href="#macros" ^
(line repeats over and over)
Moreover, going with '¶' turns out to be not cool:
Generating logging.html.tmp ../docs/page.xsl:192: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xB6 0x3C 0x2F 0x61 <a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline">
Hi. I like the idea too. Works for me if you squash this in: ------------ >8 ------- 8< ------------------------------- diff --git a/docs/page.xsl b/docs/page.xsl index 7f6f2af..d560c09 100644 --- a/docs/page.xsl +++ b/docs/page.xsl @@ -187,9 +187,22 @@ </xsl:template> <xsl:template match="html:h2 | html:h3 | html:h4 | html:h5 | html:h6" mode="content"> - <xsl:copy> - <xsl:copy-of select="./*"/> - <a class="headerlink" href="#{html:a/@name}" title="Permalink to this headline"><B6></a> - </xsl:copy> + <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">¶</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 ------------ >8 ------- 8< ------------------------------- Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On 01/23/2014 08:24 AM, Claudio Bley wrote:
At Tue, 10 Dec 2013 13:45:05 +0100, Michal Privoznik wrote:
On 08.12.2013 23:57, Dan Kenigsberg wrote:
Note to reviewers: this patch is too naive and has devastating effect of headers that lack a named anchor element. Still, I'd love to hear your opinion about the idea.
I like the idea - I often find myself in the same situation, but if we decide to merge this, we need to fix some issues:
I like the idea too.
Works for me if you squash this in:
ACK; Claudio, since you have the adjustment required in your local tree, can you push the overall patch? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

At Fri, 24 Jan 2014 10:54:13 -0700, Eric Blake wrote:
On 01/23/2014 08:24 AM, Claudio Bley wrote:
At Tue, 10 Dec 2013 13:45:05 +0100, Michal Privoznik wrote:
On 08.12.2013 23:57, Dan Kenigsberg wrote:
Note to reviewers: this patch is too naive and has devastating effect of headers that lack a named anchor element. Still, I'd love to hear your opinion about the idea.
I like the idea - I often find myself in the same situation, but if we decide to merge this, we need to fix some issues:
I like the idea too.
Works for me if you squash this in:
ACK; Claudio, since you have the adjustment required in your local tree, can you push the overall patch?
Sure, I can do it on Monday, if nobody else did it until then. Claudio --

At Sat, 25 Jan 2014 13:50:02 +0100, Claudio Bley wrote:
ACK; Claudio, since you have the adjustment required in your local tree, can you push the overall patch?
Sure, I can do it on Monday, if nobody else did it until then.
Pushed. Claudio -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern
participants (4)
-
Claudio Bley
-
Dan Kenigsberg
-
Eric Blake
-
Michal Privoznik