Skip to content

Commit

Permalink
Handles newline after self-closing html node
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwessman committed Aug 10, 2023
1 parent 91515fe commit 4efc95a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/syntax_tree/erb/nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions test/html_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ def test_append_newlines
assert_formatting("<div>What</div>", "<div>What</div>\n")
end

def test_self_closing_with_blank_line
source =
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n\n<title>Test</title>\n"

assert_formatting(source, source)
end

def test_tag_with_leading_spaces
source = "<div> What</div>"
expected = "<div>What</div>\n"
Expand Down

0 comments on commit 4efc95a

Please sign in to comment.