Skip to content

Commit e099e73

Browse files
committed
fix whitespace changes
1 parent 5750b1c commit e099e73

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

lib/coderay/scanners/css.rb

+38-38
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ module CodeRay
22
module Scanners
33

44
class CSS < Scanner
5-
5+
66
register_for :css
7-
7+
88
KINDS_NOT_LOC = [
99
:comment,
1010
:class, :pseudo_class, :type,
1111
:constant, :directive,
1212
:key, :value, :operator, :color, :float, :string,
1313
:error, :important,
1414
] # :nodoc:
15-
15+
1616
module RE # :nodoc:
1717
Hex = /[0-9a-fA-F]/
1818
Unicode = /\\#{Hex}{1,6}(?:\r\n|\s)?/ # differs from standard because it allows uppercase hex too
@@ -23,47 +23,47 @@ module RE # :nodoc:
2323
String1 = /"(?:[^\n\r\f\\"]|\\#{NL}|#{Escape})*"?/ # TODO: buggy regexp
2424
String2 = /'(?:[^\n\r\f\\']|\\#{NL}|#{Escape})*'?/ # TODO: buggy regexp
2525
String = /#{String1}|#{String2}/
26-
26+
2727
HexColor = /#(?:#{Hex}{6}|#{Hex}{3})/
2828
Color = /#{HexColor}/
29-
29+
3030
Num = /-?(?:[0-9]+|[0-9]*\.[0-9]+)/
3131
Name = /#{NMChar}+/
3232
Ident = /-?#{NMStart}#{NMChar}*/
3333
AtKeyword = /@#{Ident}/
3434
Percentage = /#{Num}%/
35-
35+
3636
reldimensions = %w[em ex px]
3737
absdimensions = %w[in cm mm pt pc]
3838
Unit = Regexp.union(*(reldimensions + absdimensions + %w[s]))
39-
39+
4040
Dimension = /#{Num}#{Unit}/
41-
41+
4242
Comment = %r! /\* (?: .*? \*/ | .* ) !mx
4343
Function = /(?:url|alpha|attr|counters?)\((?:[^)\n\r\f]|\\\))*\)?/
44-
44+
4545
Id = /##{Name}/
4646
Class = /\.#{Name}/
4747
PseudoClass = /:#{Name}/
4848
AttributeSelector = /\[[^\]]*\]?/
4949
end
50-
50+
5151
protected
52-
52+
5353
def setup
5454
@state = :initial
5555
@value_expected = nil
5656
end
57-
57+
5858
def scan_tokens encoder, options
5959
states = Array(options[:state] || @state)
6060
value_expected = @value_expected
61-
61+
6262
until eos?
63-
63+
6464
if match = scan(/\s+/)
6565
encoder.text_token match, :space
66-
66+
6767
elsif case states.last
6868
when :initial, :media
6969
if match = scan(/(?>#{RE::Ident})(?!\()|\*/ox)
@@ -89,7 +89,7 @@ def scan_tokens encoder, options
8989
states.push :media_before_name
9090
next
9191
end
92-
92+
9393
when :block
9494
if match = scan(/(?>#{RE::Ident})(?!\()/ox)
9595
if value_expected
@@ -99,50 +99,50 @@ def scan_tokens encoder, options
9999
end
100100
next
101101
end
102-
102+
103103
when :media_before_name
104104
if match = scan(RE::Ident)
105105
encoder.text_token match, :type
106106
states[-1] = :media_after_name
107107
next
108108
end
109-
109+
110110
when :media_after_name
111111
if match = scan(/\{/)
112112
encoder.text_token match, :operator
113113
states[-1] = :media
114114
next
115115
end
116-
116+
117117
else
118118
#:nocov:
119119
raise_inspect 'Unknown state', encoder
120120
#:nocov:
121-
121+
122122
end
123-
123+
124124
elsif match = scan(/\/\*(?:.*?\*\/|\z)/m)
125125
encoder.text_token match, :comment
126-
126+
127127
elsif match = scan(/\{/)
128128
value_expected = false
129129
encoder.text_token match, :operator
130130
states.push :block
131-
131+
132132
elsif match = scan(/\}/)
133133
value_expected = false
134134
encoder.text_token match, :operator
135135
if states.last == :block || states.last == :media
136136
states.pop
137137
end
138-
138+
139139
elsif match = scan(/#{RE::String}/o)
140140
encoder.begin_group :string
141141
encoder.text_token match[0, 1], :delimiter
142142
encoder.text_token match[1..-2], :content if match.size > 2
143143
encoder.text_token match[-1, 1], :delimiter if match.size >= 2
144144
encoder.end_group :string
145-
145+
146146
elsif match = scan(/#{RE::Function}/o)
147147
encoder.begin_group :function
148148
start = match[/^\w+\(/]
@@ -154,46 +154,46 @@ def scan_tokens encoder, options
154154
encoder.text_token match[start.size..-1], :content
155155
end
156156
encoder.end_group :function
157-
157+
158158
elsif match = scan(/(?: #{RE::Dimension} | #{RE::Percentage} | #{RE::Num} )/ox)
159159
encoder.text_token match, :float
160-
160+
161161
elsif match = scan(/#{RE::Color}/o)
162162
encoder.text_token match, :color
163-
163+
164164
elsif match = scan(/! *important/)
165165
encoder.text_token match, :important
166-
166+
167167
elsif match = scan(/(?:rgb|hsl)a?\([^()\n]*\)?/)
168168
encoder.text_token match, :color
169-
169+
170170
elsif match = scan(RE::AtKeyword)
171171
encoder.text_token match, :directive
172-
172+
173173
elsif match = scan(/ [+>:;,.=()\/] /x)
174174
if match == ':'
175175
value_expected = true
176176
elsif match == ';'
177177
value_expected = false
178178
end
179179
encoder.text_token match, :operator
180-
180+
181181
else
182182
encoder.text_token getch, :error
183-
183+
184184
end
185-
185+
186186
end
187-
187+
188188
if options[:keep_state]
189189
@state = states
190190
@value_expected = value_expected
191191
end
192-
192+
193193
encoder
194194
end
195-
195+
196196
end
197-
197+
198198
end
199199
end

0 commit comments

Comments
 (0)