diff --git a/lib/html2haml/html.rb b/lib/html2haml/html.rb index 80a651a..fdd68fd 100644 --- a/lib/html2haml/html.rb +++ b/lib/html2haml/html.rb @@ -350,11 +350,12 @@ def to_haml(tabs, options) self.previous.content =~ /\A\s*\Z/ && self.previous.previous.nil?) nuke_outer_whitespace = true else - output << "= succeed #{self.next.content.slice!(/\A[^\s]+/).dump} do\n" + next_content = self.next.content + output << "= succeed #{next_content.slice!(/\A[^\s]+/).dump} do\n" tabs += 1 output << tabulate(tabs) - #empty the text node since it was inserted into the block - self.next.content = "" + # Set the next content to whatever wasn't added to the succeed statement + self.next.content = next_content end end diff --git a/test/html2haml_test.rb b/test/html2haml_test.rb index c96a040..d01e16b 100644 --- a/test/html2haml_test.rb +++ b/test/html2haml_test.rb @@ -365,6 +365,21 @@ def test_comma_post_tag_with_text_before HTML end + def test_comma_doesnt_nuke_other_content_post_tag + assert_equal(< + Batch + Foo, and everything else that goes in here. + +HTML + end + def test_haml_tags_should_be_on_new_line_after_tag_with_blank_content xml = " \n102" haml = "%weight\n%pages 102"