File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed
Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,14 @@ class Parser < Parslet::Parser
1919
2020 rule ( :blank_attribute ) { str ( ";" ) >> space? }
2121
22- rule ( :attribute_value ) { ( str ( '/*' ) . absent? >> match [ "^;}" ] ) | raw_comment }
22+ rule ( :attribute_value ) { ( str ( '"' ) >> any >> str ( '"' ) ) | ( str ( ' /*') . absent? >> match [ "^;}" ] ) | raw_comment }
2323
2424 rule ( :attribute ) {
2525 match [ "^:{}" ] . repeat ( 1 ) . as ( :property ) >>
2626 str ( ":" ) >>
2727 (
2828 ( stri ( "data:" ) . absent? >> attribute_value ) |
29- ( stri ( "data:" ) . present? >> attribute_value . repeat ( 1 ) >> str ( ";" ) >> attribute_value . repeat ( 1 ) )
29+ ( stri ( "data:" ) . present? >> attribute_value . repeat ( 1 ) >> str ( ";" ) >> attribute_value . repeat ( 1 ) )
3030 ) . repeat ( 1 ) . as ( :value ) >>
3131 str ( ";" ) . maybe >>
3232 space?
Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ class CommonTest
139139 @parser . url . must_parse "url(data:image/svg+xml;base64,IMGDATAGOESHERE4/5/h/1+==)"
140140 @parser . url . must_parse "url('data:image/svg+xml;base64,IMGDATAGOESHERE4/5/h/1+==')"
141141 end
142+
143+ it "parses specials characters" do
144+ @parser . between ( '"' , '"' ) { @parser . symbol ( "{" ) } . must_parse '"{"'
145+ @parser . between ( '"' , '"' ) { @parser . symbol ( "}" ) } . must_parse '"}"'
146+ @parser . between ( '"' , '"' ) { @parser . symbol ( "%" ) } . must_parse '"%"'
147+ end
142148 end
143149 end
144150end
Original file line number Diff line number Diff line change @@ -212,6 +212,39 @@ module Css
212212 dec ( "display" , "block" ) ] )
213213 ] )
214214 end
215+
216+ it "parses attributes with special characters" do
217+ css = %$
218+
219+ #menu a::before {
220+ content: "{";
221+ left: -6px;
222+ }
223+
224+ #menu a::after {
225+ content: "}";
226+ right: -6px;
227+ }
228+
229+ #menu a::weird {
230+ content: "@";
231+ up: -2px;
232+ }
233+
234+ $
235+
236+ trans ( css ) . must_equal ( [
237+ rs ( sel ( "#menu a::before" ) , [ dec ( "content" , '"{"' ) ,
238+ dec ( "left" , "-6px" )
239+ ] ) ,
240+ rs ( sel ( "#menu a::after" ) , [ dec ( "content" , '"}"' ) ,
241+ dec ( "right" , "-6px" )
242+ ] ) ,
243+ rs ( sel ( "#menu a::weird" ) , [ dec ( "content" , '"@"' ) ,
244+ dec ( "up" , "-2px" )
245+ ] )
246+ ] )
247+ end
215248 end
216249 end
217250end
You can’t perform that action at this time.
0 commit comments