aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-08-06 23:49:20 +0200
committerAdrian Kummerlaender2014-08-06 23:49:20 +0200
commit4ba35f4999514043d2ff420779cb07cedb8b0d96 (patch)
tree1310c032fc24df6d80d164db95205fde5c6d4f38
parent96895b711b282e914d064273ef9f74b2c5f0c920 (diff)
downloadblog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar.gz
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar.bz2
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar.lz
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar.xz
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.tar.zst
blog.kummerlaender.eu-4ba35f4999514043d2ff420779cb07cedb8b0d96.zip
Improved automatic source code highlighting
* disable indentation in both the page and datasource master stylesheets ** indentation was interfering with correct output of formatted code * simplified call to formatter helper template
-rw-r--r--source/02_data/articles.xsl32
-rw-r--r--source/99_result/article/article.xsl2
-rw-r--r--utility/datasource.xsl2
-rw-r--r--utility/formatter.xsl2
-rw-r--r--utility/master.xsl2
5 files changed, 18 insertions, 22 deletions
diff --git a/source/02_data/articles.xsl b/source/02_data/articles.xsl
index bbe6f40..b3ac0df 100644
--- a/source/02_data/articles.xsl
+++ b/source/02_data/articles.xsl
@@ -15,6 +15,19 @@
<target mode="plain" value="articles.xml"/>
</xsl:variable>
+<xsl:template match="@*|node()" mode="embellish">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" mode="embellish"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="pre" mode="embellish">
+ <xsl:call-template name="formatter">
+ <xsl:with-param name="format">/usr/bin/highlight.sh</xsl:with-param>
+ <xsl:with-param name="source" select="code/text()"/>
+ </xsl:call-template>
+</xsl:template>
+
<xsl:template name="list_tags">
<xsl:param name="path"/>
@@ -29,23 +42,6 @@
</xsl:apply-templates>
</xsl:template>
-<xsl:template match="@*|node()" mode="content_transform">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" mode="content_transform"/>
- </xsl:copy>
-</xsl:template>
-
-<xsl:template match="pre/code" mode="content_transform">
- <xsl:variable name="formatted_code">
- <xsl:call-template name="formatter">
- <xsl:with-param name="format">/usr/bin/highlight.sh</xsl:with-param>
- <xsl:with-param name="source" select="text()"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:copy-of select="xalan:nodeset($formatted_code)/pre/node()"/>
-</xsl:template>
-
<xsl:template match="files/articles/file[./extension = '.md']">
<xsl:variable name="content">
<xsl:call-template name="formatter">
@@ -72,7 +68,7 @@
</xsl:call-template>
</tags>
<content>
- <xsl:apply-templates mode="content_transform" select="xalan:nodeset($content)/*[name() != 'h1']"/>
+ <xsl:apply-templates select="xalan:nodeset($content)/*[name() != 'h1']" mode="embellish"/>
</content>
</entry>
</xsl:template>
diff --git a/source/99_result/article/article.xsl b/source/99_result/article/article.xsl
index a82dcb1..bd7ed14 100644
--- a/source/99_result/article/article.xsl
+++ b/source/99_result/article/article.xsl
@@ -34,7 +34,7 @@
</xsl:for-each>
| Adrian Kummerländer
</p>
- <xsl:copy-of select="content/*"/>
+ <xsl:copy-of select="content/node()"/>
</div>
</xsl:template>
diff --git a/utility/datasource.xsl b/utility/datasource.xsl
index ce31d41..411086a 100644
--- a/utility/datasource.xsl
+++ b/utility/datasource.xsl
@@ -8,7 +8,7 @@
method="xml"
omit-xml-declaration="no"
encoding="UTF-8"
- indent="yes"
+ indent="no"
/>
<xsl:variable name="root" select="/datasource"/>
diff --git a/utility/formatter.xsl b/utility/formatter.xsl
index 49d8630..0f7643e 100644
--- a/utility/formatter.xsl
+++ b/utility/formatter.xsl
@@ -14,7 +14,7 @@
<xsl:copy-of select="InputXSLT:external-text-formatter(
$format,
$source
- )/self::output/*"/>
+ )/self::output/node()"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/utility/master.xsl b/utility/master.xsl
index c682072..66cfdb3 100644
--- a/utility/master.xsl
+++ b/utility/master.xsl
@@ -10,7 +10,7 @@
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
- indent="yes"
+ indent="no"
/>
<xsl:variable name="root" select="/datasource"/>