1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/hamlit/parsers/comment.rb
2015-03-29 20:02:40 +09:00

22 lines
563 B
Ruby

module Hamlit
module Parsers
module Comment
def parse_comment(scanner)
raise SyntaxError unless scanner.scan(/\//)
ast = [:html, :comment]
text = (scanner.scan(/.+/) || '').strip
if text.empty?
content = with_indented { parse_lines }
return ast << [:multi, [:static, "\n"], *content]
elsif !text.match(/\[.*\]/)
return ast << [:static, " #{text} "]
end
content = with_indented { parse_lines }
[:haml, :comment, text, content]
end
end
end
end