1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Make sure empty lines in comments are included in the output.

Closes gh-12
This commit is contained in:
Nathan Weizenbaum 2009-06-21 16:12:04 -07:00
parent 98d1f7465b
commit 91c6cf0cf9
3 changed files with 23 additions and 3 deletions

View file

@ -170,7 +170,10 @@ module Sass
lines = []
string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/).each_with_index do |line, index|
index += (@options[:line] || 1)
next if line.strip.empty?
if line.strip.empty?
lines.last.text << "\n" if lines.last && lines.last.comment?
next
end
line_tab_str = line[/^\s*/]
unless line_tab_str.empty?

View file

@ -50,9 +50,13 @@ module Sass::Tree
def to_s(tabs = 0, _ = nil)
return if invisible?
content = (value.split("\n") + lines.map {|l| l.text})
content.map! {|l| (l.empty? ? "" : " ") + l}
content.first.gsub!(/^ /, '')
content.last.gsub!(%r{ ?\*/ *$}, '')
spaces = ' ' * (tabs - 1)
spaces + "/* " + (value.split("\n") + lines.map {|l| l.text}).
map{|l| l.sub(%r{ ?\*/ *$},'')}.join(style == :compact ? ' ' : "\n#{spaces} * ") + " */"
spaces + "/* " + content.join(style == :compact ? '' : "\n#{spaces} *") + " */"
end
# Returns `true` if this is a silent comment

View file

@ -770,6 +770,19 @@ a
SASS
end
def test_empty_line_comment
assert_equal(<<CSS, render(<<SASS))
/* Foo
*
* Bar */
CSS
/*
Foo
Bar
SASS
end
private
def render(sass, options = {})