Skip to content

Commit

Permalink
Preserve the bang in /*! comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed May 31, 2013
1 parent b575ad1 commit 0c52f5a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Expand Up @@ -10,6 +10,8 @@
* When printing a Sass error into a CSS comment, escape `*/` so the comment
doesn't end prematurely.

* Preserve the `!` in `/*! ... */`-style comments.

## 3.2.9

* Fix a bug where `@extend`s would occasionally cause a selector to be generated
Expand Down
1 change: 0 additions & 1 deletion lib/sass/engine.rb
Expand Up @@ -637,7 +637,6 @@ def parse_comment(line)
value = [line.text]
else
value = self.class.parse_interp(line.text, line.index, line.offset, :filename => @filename)
value[0].slice!(2) if loud # get rid of the "!"
end
value = with_extracted_values(value) do |str|
str = str.gsub(/^#{line.comment_tab_str}/m, '')[2..-1] # get rid of // or /*
Expand Down
1 change: 0 additions & 1 deletion lib/sass/scss/parser.rb
Expand Up @@ -120,7 +120,6 @@ def process_comment(text, node)
value = [text.sub(/^\s*\/\//, '/*').gsub(/^\s*\/\//, ' *') + ' */']
else
value = Sass::Engine.parse_interp(text, line, @scanner.pos - text.size, :filename => @filename)
value[0].slice!(2) if loud # get rid of the "!"
value.unshift(@scanner.
string[0...@scanner.pos].
reverse[/.*?\*\/(.*?)($|\Z)/, 1].
Expand Down
1 change: 0 additions & 1 deletion lib/sass/tree/visitors/convert.rb
Expand Up @@ -89,7 +89,6 @@ def visit_comment(node)
end.gsub(/^/, spaces) + "\n"
content
end
content.sub!(%r{^\s*(/\*)}, '/*!') if node.type == :loud #'
content
end

Expand Down
13 changes: 7 additions & 6 deletions test/sass/engine_test.rb
Expand Up @@ -1804,7 +1804,7 @@ def test_loud_comment_with_separate_line_close

def test_loud_comment_in_compressed_mode
assert_equal <<CSS, render(<<SASS, :style => :compressed)
foo{color:blue;/* foo
foo{color:blue;/*! foo
* bar
*/}
CSS
Expand All @@ -1818,7 +1818,8 @@ def test_loud_comment_in_compressed_mode

def test_loud_comment_is_evaluated
assert_equal <<CSS, render(<<SASS)
/* Hue: 327.21649deg */
/*!
* Hue: 327.21649deg */
CSS
/*!
Hue: \#{hue(#f836a0)}
Expand Down Expand Up @@ -2486,15 +2487,15 @@ def test_tricky_mixin_loop_exception

def test_interpolated_comment_in_mixin
assert_equal <<CSS, render(<<SASS)
/* color: red */
/*! color: red */
.foo {
color: red; }
/* color: blue */
/*! color: blue */
.foo {
color: blue; }
/* color: green */
/*! color: green */
.foo {
color: green; }
CSS
Expand Down Expand Up @@ -2789,7 +2790,7 @@ def test_loud_comment_interpolations_can_be_escaped
/* \\\#{foo}
SASS
assert_equal <<CSS, render(<<SASS)
/* \#{foo} */
/*! \#{foo} */
CSS
/*! \\\#{foo}
SASS
Expand Down
8 changes: 8 additions & 0 deletions test/sass/scss/scss_test.rb
Expand Up @@ -1711,6 +1711,14 @@ def test_no_lonely_else

# Regression

def test_loud_comment_in_compressed_mode
assert_equal(<<CSS, render(<<SCSS))
/*! foo */
CSS
/*! foo */
SCSS
end

def test_parsing_decimals_followed_by_comments_doesnt_take_forever
assert_equal(<<CSS, render(<<SCSS))
.foo {
Expand Down

0 comments on commit 0c52f5a

Please sign in to comment.