diff options
-rw-r--r-- | Changes.textile | 1 | ||||
-rw-r--r-- | lib/coderay/scanners/ruby.rb | 13 |
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 |