summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-12-14 16:40:54 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-12-14 16:40:54 -0600
commit304c8ff0bc1eb43934ad794dbde589e11a2f3902 (patch)
tree356b7b99d6630efe3801289a519771fff3affeb3
parenteb188b3e7208d57931873d2ca61620ec92e81138 (diff)
downloaddocs-304c8ff0bc1eb43934ad794dbde589e11a2f3902.tar.gz
docs-304c8ff0bc1eb43934ad794dbde589e11a2f3902.tar.bz2
docs-304c8ff0bc1eb43934ad794dbde589e11a2f3902.tar.xz
docs-304c8ff0bc1eb43934ad794dbde589e11a2f3902.zip
XSL: add permalinks to every section header
-rw-r--r--master.xsl2
-rw-r--r--src/pretty.css12
-rw-r--r--xsl/LICENSE1
-rw-r--r--xsl/permalinks.xsl26
-rw-r--r--xsl/section.title.xsl55
5 files changed, 95 insertions, 1 deletions
diff --git a/master.xsl b/master.xsl
index 1ca9851..56aa37b 100644
--- a/master.xsl
+++ b/master.xsl
@@ -22,6 +22,8 @@
<xsl:variable name="adelie.book.title">
<xsl:call-template name="get.doc.title"/>
</xsl:variable>
+ <xsl:include href="xsl/permalinks.xsl"/>
+ <xsl:include href="xsl/section.title.xsl"/>
<xsl:template name="head.content">
<xsl:param name="node" select="."/>
<xsl:param name="title">
diff --git a/src/pretty.css b/src/pretty.css
index 2066874..8895690 100644
--- a/src/pretty.css
+++ b/src/pretty.css
@@ -25,6 +25,16 @@ div.othercredit {
font-size: smaller;
}
+span.permalink {
+ font-size: smaller;
+ margin-left: 0.5em;
+}
+
+span.permalink>a {
+ color: #444;
+ text-decoration: none;
+}
+
h2 {
margin-top: 2.5em;
}
@@ -47,7 +57,7 @@ h5 {
}
/* normalise size with command */
-code {
+p>code {
font-size: 14px;
}
diff --git a/xsl/LICENSE b/xsl/LICENSE
new file mode 100644
index 0000000..08339a9
--- /dev/null
+++ b/xsl/LICENSE
@@ -0,0 +1 @@
+Taken from http://doccookbook.sourceforge.net/html/en/ which is licensed CC BY-NC-SA 3.0.
diff --git a/xsl/permalinks.xsl b/xsl/permalinks.xsl
new file mode 100644
index 0000000..f6a74fc
--- /dev/null
+++ b/xsl/permalinks.xsl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- SPDX-Identifier: CC-BY-NC-SA-3.0 -->
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="generate.permalink" select="1"/>
+ <xsl:param name="permalink.text">¶</xsl:param>
+
+ <xsl:template name="permalink">
+ <xsl:param name="node" select="."/>
+
+ <xsl:if test="$generate.permalink != '0'">
+ <span class="permalink">
+ <a alt="Permalink" title="Permalink">
+ <xsl:attribute name="href">
+ <xsl:call-template name="href.target">
+ <xsl:with-param name="object" select="$node"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <xsl:copy-of select="$permalink.text"/>
+ </a>
+ </span>
+ </xsl:if>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/xsl/section.title.xsl b/xsl/section.title.xsl
new file mode 100644
index 0000000..8edfb6e
--- /dev/null
+++ b/xsl/section.title.xsl
@@ -0,0 +1,55 @@
+<!-- SPDX-Identifier: CC-BY-NC-SA-3.0 -->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:d="http://docbook.org/ns/docbook"
+ xmlns="http://www.w3.org/1999/xhtml">
+
+ <xsl:template name="section.title">
+ <xsl:variable name="section"
+ select="(ancestor::section |
+ ancestor::simplesect|
+ ancestor::sect1|
+ ancestor::sect2|
+ ancestor::sect3|
+ ancestor::sect4|
+ ancestor::sect5)[last()]"/>
+
+ <xsl:variable name="renderas">
+ <xsl:choose>
+ <xsl:when test="$section/@renderas = 'sect1'">1</xsl:when>
+ <xsl:when test="$section/@renderas = 'sect2'">2</xsl:when>
+ <xsl:when test="$section/@renderas = 'sect3'">3</xsl:when>
+ <xsl:when test="$section/@renderas = 'sect4'">4</xsl:when>
+ <xsl:when test="$section/@renderas = 'sect5'">5</xsl:when>
+ <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="level">
+ <xsl:choose>
+ <xsl:when test="$renderas != ''">
+ <xsl:value-of select="$renderas"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="section.level">
+ <xsl:with-param name="node" select="$section"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:call-template name="section.heading">
+ <xsl:with-param name="section" select="$section"/>
+ <xsl:with-param name="level" select="$level"/>
+ <xsl:with-param name="title">
+ <xsl:apply-templates select="$section" mode="object.title.markup">
+ <xsl:with-param name="allow-anchors" select="1"/>
+ </xsl:apply-templates>
+ <xsl:if test="$level = 1">
+ <xsl:call-template name="permalink">
+ <xsl:with-param name="node" select="$section"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+</xsl:stylesheet>