mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] [Convert] Convert comments to start with // or * in the indented syntax.
Closes gh-122
This commit is contained in:
parent
b7b3df8cdf
commit
29ffc39b8f
4 changed files with 28 additions and 20 deletions
|
@ -58,6 +58,13 @@ Note that since underscores may still be used in place of hyphens
|
||||||
when referring to mixins and variables,
|
when referring to mixins and variables,
|
||||||
this won't cause any backwards-incompatibilities.
|
this won't cause any backwards-incompatibilities.
|
||||||
|
|
||||||
|
#### Sass Comment Format
|
||||||
|
|
||||||
|
When converting to the indented syntax,
|
||||||
|
each line of comments past the first begins with either `//` (for Sass comments)
|
||||||
|
or ` *` (for CSS comments).
|
||||||
|
This prevents some whitespace errors.
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|
||||||
Indented-syntax `/*` comments may now include `*` on lines beyond the first,
|
Indented-syntax `/*` comments may now include `*` on lines beyond the first,
|
||||||
|
|
|
@ -59,10 +59,11 @@ module Sass::Tree
|
||||||
else
|
else
|
||||||
content.gsub!(/\n( \*|\/\/)/, "\n ")
|
content.gsub!(/\n( \*|\/\/)/, "\n ")
|
||||||
spaces = content.scan(/\n( *)/).map {|s| s.first.size}.min
|
spaces = content.scan(/\n( *)/).map {|s| s.first.size}.min
|
||||||
|
sep = silent ? "\n//" : "\n *"
|
||||||
if spaces >= 2
|
if spaces >= 2
|
||||||
content
|
content.gsub(/\n /, sep)
|
||||||
else
|
else
|
||||||
content.gsub(/\n#{' ' * spaces}/, "\n ")
|
content.gsub(/\n#{' ' * spaces}/, sep)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -251,9 +251,9 @@ SCSS
|
||||||
|
|
||||||
assert_renders <<SASS, <<SCSS
|
assert_renders <<SASS, <<SCSS
|
||||||
// foo
|
// foo
|
||||||
bar
|
// bar
|
||||||
baz
|
// baz
|
||||||
bang
|
// bang
|
||||||
|
|
||||||
foo bar
|
foo bar
|
||||||
a: b
|
a: b
|
||||||
|
@ -309,9 +309,9 @@ SCSS
|
||||||
|
|
||||||
assert_scss_to_sass <<SASS, <<SCSS
|
assert_scss_to_sass <<SASS, <<SCSS
|
||||||
/* foo
|
/* foo
|
||||||
bar
|
* bar
|
||||||
baz
|
* baz
|
||||||
bang
|
* bang
|
||||||
|
|
||||||
foo bar
|
foo bar
|
||||||
a: b
|
a: b
|
||||||
|
@ -337,9 +337,9 @@ SCSS
|
||||||
|
|
||||||
assert_renders <<SASS, <<SCSS
|
assert_renders <<SASS, <<SCSS
|
||||||
/* foo
|
/* foo
|
||||||
bar
|
* bar
|
||||||
baz
|
* baz
|
||||||
bang
|
* bang
|
||||||
|
|
||||||
foo bar
|
foo bar
|
||||||
a: b
|
a: b
|
||||||
|
@ -358,8 +358,8 @@ SCSS
|
||||||
assert_scss_to_sass <<SASS, <<SCSS
|
assert_scss_to_sass <<SASS, <<SCSS
|
||||||
foo
|
foo
|
||||||
/* foo
|
/* foo
|
||||||
bar
|
* bar
|
||||||
baz
|
* baz
|
||||||
a: b
|
a: b
|
||||||
SASS
|
SASS
|
||||||
foo {
|
foo {
|
||||||
|
@ -387,8 +387,8 @@ SASS
|
||||||
def test_immediately_preceding_comments
|
def test_immediately_preceding_comments
|
||||||
assert_renders <<SASS, <<SCSS
|
assert_renders <<SASS, <<SCSS
|
||||||
/* Foo
|
/* Foo
|
||||||
Bar
|
* Bar
|
||||||
Baz
|
* Baz
|
||||||
.foo#bar
|
.foo#bar
|
||||||
a: b
|
a: b
|
||||||
SASS
|
SASS
|
||||||
|
@ -401,8 +401,8 @@ SCSS
|
||||||
|
|
||||||
assert_renders <<SASS, <<SCSS
|
assert_renders <<SASS, <<SCSS
|
||||||
// Foo
|
// Foo
|
||||||
Bar
|
// Bar
|
||||||
Baz
|
// Baz
|
||||||
=foo
|
=foo
|
||||||
a: b
|
a: b
|
||||||
SASS
|
SASS
|
||||||
|
|
|
@ -105,20 +105,20 @@ elephant.rawr
|
||||||
rampages: excessively
|
rampages: excessively
|
||||||
|
|
||||||
/* actual multiline
|
/* actual multiline
|
||||||
comment
|
*comment
|
||||||
|
|
||||||
span.turkey
|
span.turkey
|
||||||
isdinner: true
|
isdinner: true
|
||||||
|
|
||||||
.turducken
|
.turducken
|
||||||
/* Sounds funny
|
/* Sounds funny
|
||||||
doesn't it
|
* doesn't it
|
||||||
chimera: not_really
|
chimera: not_really
|
||||||
|
|
||||||
#overhere
|
#overhere
|
||||||
bored: sorta
|
bored: sorta
|
||||||
/* it's for a good
|
/* it's for a good
|
||||||
cause
|
* cause
|
||||||
better_than: thread_pools
|
better_than: thread_pools
|
||||||
|
|
||||||
#one_more
|
#one_more
|
||||||
|
|
Loading…
Reference in a new issue