lib/css_parser/parser.rb in css_parser-1.3.6 vs lib/css_parser/parser.rb in css_parser-1.3.7
- old
+ new
@@ -12,11 +12,11 @@
# When calling Parser#new there are some configuaration options:
# [<tt>absolute_paths</tt>] Convert relative paths to absolute paths (<tt>href</tt>, <tt>src</tt> and <tt>url('')</tt>. Boolean, default is <tt>false</tt>.
# [<tt>import</tt>] Follow <tt>@import</tt> rules. Boolean, default is <tt>true</tt>.
# [<tt>io_exceptions</tt>] Throw an exception if a link can not be found. Boolean, default is <tt>true</tt>.
class Parser
- USER_AGENT = "Ruby CSS Parser/#{CssParser::VERSION} (http://github.com/alexdunae/css_parser)"
+ USER_AGENT = "Ruby CSS Parser/#{CssParser::VERSION} (https://github.com/premailer/css_parser)"
STRIP_CSS_COMMENTS_RX = /\/\*.*?\*\//m
STRIP_HTML_COMMENTS_RX = /\<\!\-\-|\-\-\>/m
# Initial parsing
@@ -261,11 +261,11 @@
current_selectors = ''
current_media_query = ''
current_declarations = ''
- block.scan(/([\\]?[{}\s"]|(.[^\s"{}\\]*))/).each do |matches|
+ block.scan(/(([\\]{2,})|([\\]?[{}\s"])|(.[^\s"{}\\]*))/).each do |matches|
token = matches[0]
if token =~ /\A"/ # found un-escaped double quote
in_string = !in_string
end
@@ -275,10 +275,10 @@
if in_declarations > 1
in_declarations -= 1 if token =~ /\}/
next
end
- if token =~ /\{/
+ if token =~ /\{/ and not in_string
in_declarations += 1
next
end
current_declarations += token