commit:     ca88a7b371840409a3f3788da5365d968a55118e
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 22:02:43 2021 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Feb 25 19:06:13 2021 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=ca88a7b3

devbook.xsl, devmanual.css: Add permalinks to section headers

While we use empty fragments ("#") elsewhere for navigation within the
document (because they don't cause reloading of the page), we use an
empty href ("") for the chapter because it is meant to be copied as an
external link.

Closes: https://bugs.gentoo.org/772005
Suggested-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 devbook.xsl   |  6 +++++-
 devmanual.css | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/devbook.xsl b/devbook.xsl
index ec02aa4..49dc0c3 100644
--- a/devbook.xsl
+++ b/devbook.xsl
@@ -24,7 +24,10 @@
 </xsl:variable>
 
   <xsl:template match="chapter">
-    <h1 class="first-header"><xsl:apply-templates select="title"/></h1>
+    <h1 class="first-header">
+      <xsl:apply-templates select="title"/>
+      <a class="permalink" href=""><span class="fa fa-link"/></a>
+    </h1>
     <xsl:apply-templates select="*[not(self::title)]"/>
   </xsl:template>
 
@@ -42,6 +45,7 @@
       <xsl:element name="h{$level}">
         <xsl:attribute name="id"><xsl:value-of 
select="$anchor"/></xsl:attribute>
         <xsl:apply-templates select="title"/>
+        <a class="permalink" href="#{$anchor}"><span class="fa fa-link"/></a>
       </xsl:element>
       <xsl:apply-templates select="*[not(self::title)]"/>
     </div>

diff --git a/devmanual.css b/devmanual.css
index 288f81d..bba2a31 100644
--- a/devmanual.css
+++ b/devmanual.css
@@ -33,6 +33,20 @@ pre span.Constant { color: black; }
 pre span.Comment { color: red; }
 pre span.Statement { color: darkred; }
 
+a.permalink {
+    padding: 0 0.3em;
+    font-size: 90%;
+    text-decoration: none;
+    visibility: hidden;
+}
+
+h1:hover > a.permalink,
+h2:hover > a.permalink,
+h3:hover > a.permalink,
+h4:hover > a.permalink {
+    visibility: visible;
+}
+
 .truncated-text {
     white-space: nowrap;
     overflow: hidden;

Reply via email to