summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners/ruby.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2011-05-21 03:37:50 +0000
committermurphy <murphy@rubychan.de>2011-05-21 03:37:50 +0000
commit32ee1838a598a9a9c196acb2a78ab7062a63aaaa (patch)
treea5dc9de04fc5a7955b81de6ff05b172f421d19ae /lib/coderay/scanners/ruby.rb
parent10cd06d76d284d613c7a59a72522d50de090fba3 (diff)
downloadcoderay-32ee1838a598a9a9c196acb2a78ab7062a63aaaa.tar.gz
new method Scanner#scan_rest (upported from 0.9.8), and Scanner::ScanError is now a StandardError
Diffstat (limited to 'lib/coderay/scanners/ruby.rb')
-rw-r--r--lib/coderay/scanners/ruby.rb15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb
index 79e1e91..549ae87 100644
--- a/lib/coderay/scanners/ruby.rb
+++ b/lib/coderay/scanners/ruby.rb
@@ -8,13 +8,6 @@ module Scanners
#
# It is optimized for HTML highlighting, and is not very useful for
# parsing or pretty printing.
- #
- # For now, I think it's better than the scanners in VIM or Syntax, or
- # any highlighter I was able to find, except Caleb's RubyLexer.
- #
- # I hope it's also better than the rdoc/irb lexer.
- #
- # Alias: +irb+
class Ruby < Scanner
register_for :ruby
@@ -31,10 +24,8 @@ module Scanners
def scan_tokens encoder, options
- patterns = Patterns # avoid constant lookup
-
state = @state
- if state.instance_of? self.class::StringState
+ if state && state.instance_of?(self.class::StringState)
encoder.begin_group state.type
end
@@ -50,6 +41,8 @@ module Scanners
# def_object_stack = nil
# def_object_paren_depth = 0
+ patterns = Patterns # avoid constant lookup
+
unicode = string.respond_to?(:encoding) && string.encoding.name == 'UTF-8'
until eos?
@@ -339,7 +332,7 @@ module Scanners
else # StringState
- match = scan_until(state.pattern) || scan_until(/\z/)
+ match = scan_until(state.pattern) || scan_rest
unless match.empty?
encoder.text_token match, :content
break if eos?