diff --git a/lib/syntax_tree/haml/format.rb b/lib/syntax_tree/haml/format.rb index d3583f2..c3cf6cc 100644 --- a/lib/syntax_tree/haml/format.rb +++ b/lib/syntax_tree/haml/format.rb @@ -16,7 +16,7 @@ def initialize( .lines .each .with_index(1) do |line, index| - @literal_lines[index] = line.rstrip if line.start_with?("!") + @literal_lines[index] = line.strip if line.lstrip.start_with?("!") end super(source, *rest, options: options) diff --git a/test/script_test.rb b/test/script_test.rb index 8eeff62..2d88312 100644 --- a/test/script_test.rb +++ b/test/script_test.rb @@ -22,4 +22,11 @@ def test_preserve_escape_html def test_unescape assert_format("!= hello") end + + def test_child_unescape + assert_format(<<~HAML) + .container + != hello + HAML + end end