summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2019-06-02 12:41:28 +0300
committerdefanor <defanor@uberspace.net>2019-06-02 12:41:28 +0300
commit5bd02d6b80fe7825f7ece3f5a80dbfec62b2de87 (patch)
tree3d2d2b11bfc0777a1186c6ce8b33e1c5a5ac81cc
parent6fefc86f51256423cde778555213cf5ed6373086 (diff)
downloadhomepage-5bd02d6b80fe7825f7ece3f5a80dbfec62b2de87.zip
homepage-5bd02d6b80fe7825f7ece3f5a80dbfec62b2de87.tar.gz
homepage-5bd02d6b80fe7825f7ece3f5a80dbfec62b2de87.tar.bz2
Add heading IDs
-rw-r--r--tools/xml-to-html.xsl12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/xml-to-html.xsl b/tools/xml-to-html.xsl
index 918cc49..261397f 100644
--- a/tools/xml-to-html.xsl
+++ b/tools/xml-to-html.xsl
@@ -2,7 +2,9 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns:str="http://exslt.org/strings"
xmlns="http://www.w3.org/1999/xhtml"
+ extension-element-prefixes="str"
version="1.0">
<xsl:output method="xml" indent="yes"/>
@@ -127,6 +129,16 @@
</dd>
</xsl:template>
+ <xsl:template mode="body" match="xhtml:h1|xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5">
+ <xsl:copy>
+ <xsl:attribute name="id">
+ <xsl:value-of select="str:replace(text(),' ','_')"/>
+ </xsl:attribute>
+ <xsl:copy-of select="@*" />
+ <xsl:apply-templates mode="body" />
+ </xsl:copy>
+ </xsl:template>
+
<xsl:template mode="body" match="node()" priority="0">
<xsl:copy>
<xsl:copy-of select="@*" />