summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners/css.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2011-03-01 01:18:27 +0000
committermurphy <murphy@rubychan.de>2011-03-01 01:18:27 +0000
commitfc3fb2ed266bf01fdac54cd4abcc346559159cbe (patch)
tree661b3fa9b816ea4b6bbb6a1461ca895346058f82 /lib/coderay/scanners/css.rb
parent9e3818cb135954638afef4f11b9defa65d10963b (diff)
downloadcoderay-fc3fb2ed266bf01fdac54cd4abcc346559159cbe.tar.gz
Speedup comment matching in CSS scanner.
Diffstat (limited to 'lib/coderay/scanners/css.rb')
-rw-r--r--lib/coderay/scanners/css.rb25
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/coderay/scanners/css.rb b/lib/coderay/scanners/css.rb
index 5222c3c..ee76234 100644
--- a/lib/coderay/scanners/css.rb
+++ b/lib/coderay/scanners/css.rb
@@ -54,12 +54,12 @@ module Scanners
value_expected = nil
states = [:initial]
-
+
until eos?
-
+
if match = scan(/\s+/)
encoder.text_token match, :space
-
+
elsif case states.last
when :initial, :media
if match = scan(/(?>#{RE::Ident})(?!\()|\*/ox)
@@ -101,24 +101,15 @@ module Scanners
states[-1] = :media
end
- when :comment
- if match = scan(/(?:[^*\s]|\*(?!\/))+/)
- encoder.text_token match, :comment
- elsif match = scan(/\*\//)
- encoder.text_token match, :comment
- states.pop
- elsif match = scan(/\s+/)
- encoder.text_token match, :space
- end
-
else
+ #:nocov:
raise_inspect 'Unknown state', encoder
-
+ #:nocov:
+
end
-
- elsif match = scan(/\/\*/)
+
+ elsif match = scan(/\/\*(?:.*?\*\/|\z)/m)
encoder.text_token match, :comment
- states.push :comment
elsif match = scan(/\{/)
value_expected = false