./lib/coderay/scanners/css.rb in coderay-1.0.0.598.pre vs ./lib/coderay/scanners/css.rb in coderay-1.0.0.738.pre

- old
+ new

@@ -12,16 +12,15 @@ :key, :value, :operator, :color, :float, :error, :important, ] # :nodoc: module RE # :nodoc: - NonASCII = /[\x80-\xFF]/ Hex = /[0-9a-fA-F]/ Unicode = /\\#{Hex}{1,6}(?:\r\n|\s)?/ # differs from standard because it allows uppercase hex too Escape = /#{Unicode}|\\[^\r\n\f0-9a-fA-F]/ - NMChar = /[-_a-zA-Z0-9]|#{NonASCII}|#{Escape}/ - NMStart = /[_a-zA-Z]|#{NonASCII}|#{Escape}/ + NMChar = /[-_a-zA-Z0-9]|#{Escape}/ + NMStart = /[_a-zA-Z]|#{Escape}/ NL = /\r\n|\r|\n|\f/ String1 = /"(?:[^\n\r\f\\"]|\\#{NL}|#{Escape})*"?/ # FIXME: buggy regexp String2 = /'(?:[^\n\r\f\\']|\\#{NL}|#{Escape})*'?/ # FIXME: buggy regexp String = /#{String1}|#{String2}/ @@ -53,16 +52,16 @@ def scan_tokens encoder, options value_expected = nil states = [:initial] - + until eos? - + if match = scan(/\s+/) encoder.text_token match, :space - + elsif case states.last when :initial, :media if match = scan(/(?>#{RE::Ident})(?!\()|\*/ox) encoder.text_token match, :type elsif match = scan(RE::Class) @@ -100,27 +99,18 @@ if match = scan(/\{/) encoder.text_token match, :operator states[-1] = :media end - when :comment - if match = scan(/(?:[^*\s]|\*(?!\/))+/) - encoder.text_token match, :comment - elsif match = scan(/\*\//) - encoder.text_token match, :comment - states.pop - elsif match = scan(/\s+/) - encoder.text_token match, :space - end - else + #:nocov: raise_inspect 'Unknown state', encoder - + #:nocov: + end - - elsif match = scan(/\/\*/) + + elsif match = scan(/\/\*(?:.*?\*\/|\z)/m) encoder.text_token match, :comment - states.push :comment elsif match = scan(/\{/) value_expected = false encoder.text_token match, :operator states.push :block