aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2018-10-07 13:42:09 +0200
committerChristian Weiske <cweiske@cweiske.de>2018-10-07 13:42:09 +0200
commit1105322aac9cc8e71eafbf5a5eea8e709c8c77ce (patch)
treebb2026db2adb7e1b7ab7396a047f64bbc17d0210 /templates
parent076545376eb1ce47de2135373fb858db5a411e8c (diff)
downloadgrauphel-1105322aac9cc8e71eafbf5a5eea8e709c8c77ce.tar.gz
grauphel-1105322aac9cc8e71eafbf5a5eea8e709c8c77ce.zip
Display tab-based line indentation in HTML
Resolves: https://github.com/cweiske/grauphel/issues/60
Diffstat (limited to 'templates')
-rw-r--r--templates/html2tomboy.xsl26
1 files changed, 25 insertions, 1 deletions
diff --git a/templates/html2tomboy.xsl b/templates/html2tomboy.xsl
index a354000..f3da05e 100644
--- a/templates/html2tomboy.xsl
+++ b/templates/html2tomboy.xsl
@@ -21,7 +21,11 @@
<xsl:for-each select="child::node()">
<xsl:choose>
<xsl:when test="local-name(.) = ''">
- <xsl:value-of select="."/>
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text" select="string(.)" />
+ <xsl:with-param name="replace" select="'&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'" />
+ <xsl:with-param name="by" select="'&#09;'" />
+ </xsl:call-template>
</xsl:when>
<xsl:when test="local-name(.) = 'br'">
<!-- do nothing -->
@@ -90,4 +94,24 @@
</xsl:for-each>
</xsl:template>
+ <!-- http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx -->
+ <xsl:template name="string-replace-all">
+ <xsl:param name="text" />
+ <xsl:param name="replace" />
+ <xsl:param name="by" />
+ <xsl:choose>
+ <xsl:when test="contains($text, $replace)">
+ <xsl:value-of select="substring-before($text,$replace)" />
+ <xsl:value-of select="$by" />
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text" select="substring-after($text,$replace)" />
+ <xsl:with-param name="replace" select="$replace" />
+ <xsl:with-param name="by" select="$by" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
</xsl:stylesheet>