diff options
-rw-r--r-- | Changes.textile | 8 | ||||
-rw-r--r-- | lib/coderay/scanners/css.rb | 21 | ||||
-rw-r--r-- | lib/coderay/version.rb | 2 |
3 files changed, 23 insertions, 8 deletions
diff --git a/Changes.textile b/Changes.textile index 84cf31e..9b93fa4 100644 --- a/Changes.textile +++ b/Changes.textile @@ -4,6 +4,14 @@ p=. _This files lists all changes in the CodeRay library since the 0.9.8 release {{toc}} +h2. Changes in 1.0.4 + +Fixes in the CSS scanner: + +* understands the unit "s" (seconds) +* ignores unexpected curly braces +* code inside of diffs is highlighted correctly + h2. Changes in 1.0.3 New: 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 |