Skip to content

Commit

Permalink
Merge pull request #68 from jnvsor/hrpre
Browse files Browse the repository at this point in the history
Fix inconsistancy with final blank line per pre
  • Loading branch information
Anatol Broder committed Dec 18, 2015
2 parents dab26c8 + dd5563b commit 180e541
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/compress.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions test/expected/blanklines/blanklines.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@
</pre><pre>

</pre>
<pre>


</pre>
</body>
</html>
13 changes: 13 additions & 0 deletions test/source/blanklines/blanklines.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@

</pre>




<pre>


</pre>

</body>

</html>





0 comments on commit 180e541

Please sign in to comment.