diff --git a/lib/syntax_tree/erb/nodes.rb b/lib/syntax_tree/erb/nodes.rb index 6f671ba..b276631 100644 --- a/lib/syntax_tree/erb/nodes.rb +++ b/lib/syntax_tree/erb/nodes.rb @@ -249,7 +249,7 @@ def deconstruct_keys(keys) # The HTML-closing tag is responsible for new lines after the node. def new_line - closing&.new_line + closing.nil? ? opening.new_line : closing&.new_line end def accept(visitor) diff --git a/test/html_test.rb b/test/html_test.rb index f5c351a..561bd99 100644 --- a/test/html_test.rb +++ b/test/html_test.rb @@ -148,6 +148,13 @@ def test_append_newlines assert_formatting("
What
", "
What
\n") end + def test_self_closing_with_blank_line + source = + "\n\nTest\n" + + assert_formatting(source, source) + end + def test_tag_with_leading_spaces source = "
What
" expected = "
What
\n"