Allow comment indentation

This commit is contained in:
Takashi Kokubun 2015-10-15 22:35:07 +09:00
parent f8d8158792
commit 158866c94e
2 changed files with 11 additions and 6 deletions

View File

@ -5,21 +5,28 @@ module Hamlit
class PrettyCompiler < Compiler
def initialize(*)
super
@tag_indent = 0
@indent_level = 0
@whitespace_compiler = Whitespace::IndentedCompiler.new
end
private
def compile_children(node)
@whitespace_compiler.compile_children(node, @tag_indent) { |n| compile(n) }
@whitespace_compiler.compile_children(node, @indent_level) { |n| compile(n) }
end
def compile_comment(node)
@indent_level += 1
super
ensure
@indent_level -= 1
end
def compile_tag(node)
@tag_indent += 1
@indent_level += 1
super
ensure
@tag_indent -= 1
@indent_level -= 1
end
end
end

View File

@ -790,7 +790,6 @@ class PrettyTest < MiniTest::Test
end
def test_a_nested_markup_comment
skip
haml = %q{/
comment
comment2}
@ -808,7 +807,6 @@ class PrettyTest < MiniTest::Test
class Conditionalcomments < MiniTest::Test
def test_a_conditional_comment
skip
haml = %q{/[if IE]
%p a}
html = %q{<!--[if IE]>