File tree Expand file tree Collapse file tree 3 files changed +19
-17
lines changed
Expand file tree Collapse file tree 3 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 1+ ## (Unreleased) ##
2+
3+ * Fixes attribute parsing bug that includes comments with braces
4+
15## 1.3.1 - 4/20/2013 ##
26
37* Fixes --ignore-sass-mixins bug with @importing
Original file line number Diff line number Diff line change @@ -12,26 +12,22 @@ def parse(source)
1212 class Parser < Parslet ::Parser
1313 include Common
1414
15- rule ( :comment ) {
16- ( space? >> str ( '/*' ) >> ( str ( '*/' ) . absent? >> any ) . repeat >> str ( '*/' ) >> space? ) . as ( :comment )
17- }
18-
19- rule ( :css_space? ) {
20- comment . repeat ( 1 ) | space?
15+ rule ( :raw_comment ) {
16+ space? >> str ( '/*' ) >> ( str ( '*/' ) . absent? >> any ) . repeat >> str ( '*/' ) >> space?
2117 }
18+ rule ( :comment ) { raw_comment . as ( :comment ) }
2219
2320 rule ( :blank_attribute ) { str ( ";" ) >> space? }
2421
22+ rule ( :attribute_value ) { ( str ( '/*' ) . absent? >> match [ "^;}" ] ) | raw_comment }
23+
2524 rule ( :attribute ) {
2625 match [ "^:{}" ] . repeat ( 1 ) . as ( :property ) >>
2726 str ( ":" ) >>
28- ( match [ "^;}" ] . repeat ( 1 ) . capture ( :stuff ) >> dynamic { |source , context |
29- if context . captures [ :stuff ] . to_s =~ /data:/
30- str ( ";" ) >> match [ "^;}" ] . repeat ( 1 )
31- else
32- any . present?
33- end
34- } ) . as ( :value ) >>
27+ (
28+ ( stri ( "data:" ) . absent? >> attribute_value ) |
29+ ( stri ( "data:" ) . present? >> attribute_value . repeat ( 1 ) >> str ( ";" ) >> attribute_value . repeat ( 1 ) )
30+ ) . repeat ( 1 ) . as ( :value ) >>
3531 str ( ";" ) . maybe >>
3632 space?
3733 }
Original file line number Diff line number Diff line change @@ -23,14 +23,14 @@ module Css
2323 end
2424
2525 it "parses comments" do
26- @parser . css_space? . must_parse "/* foo */"
27- @parser . css_space? . must_parse %$
26+ @parser . comment . must_parse "/* foo */"
27+ @parser . comment . must_parse %$
2828 /* foo
2929 * bar
3030 */
3131 $
3232
33- @parser . css_space? . must_parse %$
33+ @parser . comment . repeat ( 1 ) . must_parse %$
3434 /* foo */
3535 /* bar */
3636 $
@@ -63,11 +63,13 @@ module Css
6363 */
6464 .bar { border: 1px solid black /* sdflk */ }
6565 .baz { background: white /* sdflk */ }
66+ .baz2 { background: white /* {sdflk} */ }
6667 $
6768
6869 trans ( css ) . must_equal ( [
6970 rs ( sel ( ".bar" ) , [ dec ( "border" , "1px solid black /* sdflk */" ) ] ) ,
70- rs ( sel ( ".baz" ) , [ dec ( "background" , "white /* sdflk */" ) ] )
71+ rs ( sel ( ".baz" ) , [ dec ( "background" , "white /* sdflk */" ) ] ) ,
72+ rs ( sel ( ".baz2" ) , [ dec ( "background" , "white /* {sdflk} */" ) ] )
7173 ] )
7274 end
7375
You can’t perform that action at this time.
0 commit comments