Skip to content

Commit 97dc325

Browse files
committed
css scanner fixes; preparing 1.0.4
1 parent dde41ac commit 97dc325

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

Changes.textile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ p=. _This files lists all changes in the CodeRay library since the 0.9.8 release
44

55
{{toc}}
66

7+
h2. Changes in 1.0.4
8+
9+
Fixes in the CSS scanner:
10+
11+
* understands the unit "s" (seconds)
12+
* ignores unexpected curly braces
13+
* code inside of diffs is highlighted correctly
14+
715
h2. Changes in 1.0.3
816

917
New:

lib/coderay/scanners/css.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module RE # :nodoc:
3535

3636
reldimensions = %w[em ex px]
3737
absdimensions = %w[in cm mm pt pc]
38-
Unit = Regexp.union(*(reldimensions + absdimensions))
38+
Unit = Regexp.union(*(reldimensions + absdimensions + %w[s]))
3939

4040
Dimension = /#{Num}#{Unit}/
4141

@@ -50,10 +50,14 @@ module RE # :nodoc:
5050

5151
protected
5252

53+
def setup
54+
@state = :initial
55+
@value_expected = nil
56+
end
57+
5358
def scan_tokens encoder, options
54-
55-
value_expected = nil
56-
states = [:initial]
59+
states = Array(options[:state] || @state)
60+
value_expected = @value_expected
5761

5862
until eos?
5963

@@ -127,11 +131,9 @@ def scan_tokens encoder, options
127131

128132
elsif match = scan(/\}/)
129133
value_expected = false
134+
encoder.text_token match, :operator
130135
if states.last == :block || states.last == :media
131-
encoder.text_token match, :operator
132136
states.pop
133-
else
134-
encoder.text_token match, :error
135137
end
136138

137139
elsif match = scan(/#{RE::String}/o)
@@ -183,6 +185,11 @@ def scan_tokens encoder, options
183185

184186
end
185187

188+
if options[:keep_state]
189+
@state = states
190+
@value_expected = value_expected
191+
end
192+
186193
encoder
187194
end
188195

lib/coderay/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CodeRay
2-
VERSION = '1.0.3'
2+
VERSION = '1.0.4'
33
end

0 commit comments

Comments
 (0)