Skip to content

Commit

Permalink
Handle explicitly loud comments in sass/scss conversions.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed Mar 11, 2011
1 parent a6b940d commit 3af2ab3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/sass/tree/visitors/convert.rb
Expand Up @@ -49,7 +49,7 @@ def visit_charset(node)
end

def visit_comment(node)
if @format == :sass
content = if @format == :sass
content = node.value.gsub(/\*\/$/, '').rstrip
if content =~ /\A[ \t]/
# Re-indent SCSS comments like this:
Expand Down Expand Up @@ -79,12 +79,22 @@ def visit_comment(node)
content.rstrip + "\n"
else
spaces = (' ' * [@tabs - node.value[/^ */].size, 0].max)
if node.silent
content = if node.silent
node.value.gsub(/^[\/ ]\*/, '//').gsub(/ *\*\/$/, '')
else
node.value
end.gsub(/^/, spaces) + "\n"
content
end
if node.loud
if node.silent
(require 'ruby-debug'; debugger if content =~ /!/)
content.gsub!(%r{^\s*(//!?)}, '//!')
else
content.sub!(%r{^\s*(/\*)}, '/*!')
end
end
content
end

def visit_debug(node)
Expand Down
21 changes: 21 additions & 0 deletions test/sass/conversion_test.rb
Expand Up @@ -1131,6 +1131,27 @@ def test_dasherize
SASS
end

def test_loud_comment_conversion
assert_renders(<<SASS, <<SCSS)
/*! \#{"interpolated"}
/*!
* \#{"also interpolated"}
SASS
/*! \#{"interpolated"} */
/*!
* \#{"also interpolated"} */
SCSS
assert_renders(<<SASS, <<SCSS)
//! \#{"interpolated"}
//!
//! \#{"also interpolated"}
SASS
//! \#{"interpolated"}
//!
//! \#{"also interpolated"}
SCSS
end

private

def assert_sass_to_sass(sass, options = {})
Expand Down

0 comments on commit 3af2ab3

Please sign in to comment.