diff options
Diffstat (limited to 'lib/coderay/scanners')
-rw-r--r-- | lib/coderay/scanners/css.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/coderay/scanners/css.rb b/lib/coderay/scanners/css.rb index e5f03f5..34eaecb 100644 --- a/lib/coderay/scanners/css.rb +++ b/lib/coderay/scanners/css.rb @@ -35,7 +35,7 @@ module Scanners reldimensions = %w[em ex px] absdimensions = %w[in cm mm pt pc] - Unit = Regexp.union(*(reldimensions + absdimensions)) + Unit = Regexp.union(*(reldimensions + absdimensions + %w[s])) Dimension = /#{Num}#{Unit}/ @@ -50,10 +50,14 @@ module Scanners protected + def setup + @state = :initial + @value_expected = nil + end + def scan_tokens encoder, options - - value_expected = nil - states = [:initial] + states = Array(options[:state] || @state) + value_expected = @value_expected until eos? @@ -127,11 +131,9 @@ module Scanners elsif match = scan(/\}/) value_expected = false + encoder.text_token match, :operator if states.last == :block || states.last == :media - encoder.text_token match, :operator states.pop - else - encoder.text_token match, :error end elsif match = scan(/#{RE::String}/o) @@ -183,6 +185,11 @@ module Scanners end + if options[:keep_state] + @state = states + @value_expected = value_expected + end + encoder end |