From 1105322aac9cc8e71eafbf5a5eea8e709c8c77ce Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 7 Oct 2018 13:42:09 +0200 Subject: [PATCH] Display tab-based line indentation in HTML Resolves: https://github.com/cweiske/grauphel/issues/60 --- lib/converter/html.php | 9 +++++++++ templates/html2tomboy.xsl | 26 ++++++++++++++++++++++++- tests/data/formattest.html | 11 +++++++++++ tests/data/formattest.tomboynotecontent | 11 +++++++++++ tests/data/full-formattest.html | 11 +++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/lib/converter/html.php b/lib/converter/html.php index 11cf105..c777cad 100644 --- a/lib/converter/html.php +++ b/lib/converter/html.php @@ -134,6 +134,15 @@ class Html extends Base if ($nesting[0] != 'monospace') { $text = nl2br($text); } + $text = preg_replace_callback( + "#^\t+#m", + function ($matches) { + return str_repeat( + ' ', strlen($matches[0]) * 8 + ); + }, + $text + ); $store .= $text; break; default: 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 @@ - + + + + + @@ -90,4 +94,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/formattest.html b/tests/data/formattest.html index a7dbe14..b704c22 100644 --- a/tests/data/formattest.html +++ b/tests/data/formattest.html @@ -33,4 +33,15 @@ Links:
  • http://cweiske.de/?foo#bar
  • /home/cweiske/fam.jpg

  • +Tabs:
    +a
    +        b
    +                c
    +        d
    +e
    +
    +Tabs in text:
    +a b c
    +ab cd ef
    +
    Ende.
    diff --git a/tests/data/formattest.tomboynotecontent b/tests/data/formattest.tomboynotecontent index 8f0b017..3e5dedb 100644 --- a/tests/data/formattest.tomboynotecontent +++ b/tests/data/formattest.tomboynotecontent @@ -33,4 +33,15 @@ Links: http://cweiske.de/?foo#bar /home/cweiske/fam.jpg +Tabs: +a + b + c + d +e + +Tabs in text: +a b c +ab cd ef + Ende. diff --git a/tests/data/full-formattest.html b/tests/data/full-formattest.html index 74d27c0..79ab51f 100644 --- a/tests/data/full-formattest.html +++ b/tests/data/full-formattest.html @@ -37,5 +37,16 @@ Links:
  • http://cweiske.de/?foo#bar
  • /home/cweiske/fam.jpg

  • +Tabs:
    +a
    +        b
    +                c
    +        d
    +e
    +
    +Tabs in text:
    +a b c
    +ab cd ef
    +
    Ende.
    -- 2.30.2