From 09920bca2e44373fd932c42cc3850d303489168a Mon Sep 17 00:00:00 2001 From: Clara Beyer Date: Mon, 18 Dec 2017 11:24:18 -0500 Subject: [PATCH] Prevent this from eating content after punctuation --- lib/html2haml/html.rb | 7 ++++--- test/html2haml_test.rb | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) 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"