From dd5563b1f99bf0239bbaf8d6f09ac22b0a90bd97 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Fri, 18 Dec 2015 20:56:15 +0100 Subject: [PATCH] Fix inconsistancy with final blank line per pre --- src/compress.liquid | 8 ++++++++ test/expected/blanklines/blanklines.html | 4 ++++ test/source/blanklines/blanklines.html | 13 +++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/compress.liquid b/src/compress.liquid index 3810470..3214cd6 100644 --- a/src/compress.liquid +++ b/src/compress.liquid @@ -85,9 +85,17 @@ {% if _pres.size != 0 %} {% if site.compress_html.blanklines %} {% assign _lines = _pres.last | split: _LINE_FEED %} + {% assign _lastchar = _pres.last | split: "" | last %} + {% assign _outerloop = forloop %} {% capture _pres_after %} {% for _line in _lines %} {% assign _trimmed = _line | split: " " | join: " " %} + {% if forloop.last and _lastchar == _LINE_FEED %} + {% unless _outerloop.last %} + {{ _LINE_FEED }} + {% endunless %} + {% continue %} + {% endif %} {% if _trimmed != empty or forloop.last %} {% unless forloop.first %} {{ _LINE_FEED }} diff --git a/test/expected/blanklines/blanklines.html b/test/expected/blanklines/blanklines.html index 5d60cd2..505a3f9 100644 --- a/test/expected/blanklines/blanklines.html +++ b/test/expected/blanklines/blanklines.html @@ -29,5 +29,9 @@
     
     
+
+    
+    
+
diff --git a/test/source/blanklines/blanklines.html b/test/source/blanklines/blanklines.html index ff9f81f..2f0020a 100644 --- a/test/source/blanklines/blanklines.html +++ b/test/source/blanklines/blanklines.html @@ -38,6 +38,19 @@ + + + +
+    
+    
+
+ + + + + +