summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-18 06:24:16 +0000
committermurphy <murphy@rubychan.de>2010-05-18 06:24:16 +0000
commit591b2823d986bc877697e3bd485ffa9c9adff3ed (patch)
tree4ed11e333a3e3913402dc186d0e4b457baba9f0e
parent4437cd00c14540b7eaf75fd0681058f34569d621 (diff)
downloadcoderay-591b2823d986bc877697e3bd485ffa9c9adff3ed.tar.gz
Ruby scanner handles :keep_state option.
-rw-r--r--Changes.textile1
-rw-r--r--lib/coderay/scanners/ruby.rb13
2 files changed, 13 insertions, 1 deletions
diff --git a/Changes.textile b/Changes.textile
index dc9752e..aa0d640 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -164,6 +164,7 @@ h3. @Scanners::Ruby@
* *NEW*: Highlight buggy floats (like .5) as @:error@.
* *CLEANUP* of documentation, names of constants and variables, state handling.
* *NEW*: Complicated rule for recognition of @foo=@ style method names.
+* *NEW*: Handles @:keep_state@ option (a bit; experimental).
Actually, Ruby checks if there is @[~>=]@, but not @=>@ following the name.
diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb
index a2e5fed..923d681 100644
--- a/lib/coderay/scanners/ruby.rb
+++ b/lib/coderay/scanners/ruby.rb
@@ -28,11 +28,19 @@ module Scanners
protected
+ def setup
+ @state = :initial
+ end
+
def scan_tokens encoder, options
patterns = Patterns # avoid constant lookup
- state = :initial
+ state = @state
+ if state.instance_of? patterns::StringState
+ encoder.begin_group state.type
+ end
+
last_state = nil
method_call_expected = false
@@ -414,6 +422,9 @@ module Scanners
end
# cleaning up
+ if options[:keep_state]
+ @state = state
+ end
if state.is_a? patterns::StringState
encoder.end_group state.type
end