diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2011-11-02 16:42:04 +0100 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2011-11-02 16:42:04 +0100 |
commit | 97dc325bed86fc90068748f906b16f9366fe4341 (patch) | |
tree | 040f4ae4df7f469d0e0e6ab9eed791264233c7e0 /lib | |
parent | dde41ac3cbc6e62dda54bd0dde0f1caa1316f3c7 (diff) | |
download | coderay-97dc325bed86fc90068748f906b16f9366fe4341.tar.gz |
css scanner fixes; preparing 1.0.4
Diffstat (limited to 'lib')
-rw-r--r-- | lib/coderay/scanners/css.rb | 21 | ||||
-rw-r--r-- | lib/coderay/version.rb | 2 |
2 files changed, 15 insertions, 8 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 diff --git a/lib/coderay/version.rb b/lib/coderay/version.rb index 2f70f5a..9ffb7a9 100644 --- a/lib/coderay/version.rb +++ b/lib/coderay/version.rb @@ -1,3 +1,3 @@ module CodeRay - VERSION = '1.0.3' + VERSION = '1.0.4' end |