diff options
author | murphy <murphy@rubychan.de> | 2011-06-22 07:22:23 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-06-22 07:22:23 +0000 |
commit | d6fe4e777a4f543c8828dbf77e955ab38e6c2803 (patch) | |
tree | 7f2a155c7645718f8936e649aee05574cd3d1b54 /lib/coderay/scanners/ruby.rb | |
parent | 90f70ee61e87e137aa192c5db97c382e1ec7d24b (diff) | |
download | coderay-d6fe4e777a4f543c8828dbf77e955ab38e6c2803.tar.gz |
#309 Improved highlighting of Ruby inside diffs
Diffstat (limited to 'lib/coderay/scanners/ruby.rb')
-rw-r--r-- | lib/coderay/scanners/ruby.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index 299accc..b3c7de1 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -23,8 +23,9 @@ module Scanners end def scan_tokens encoder, options + state, heredocs = @state + heredocs = heredocs.dup if heredocs.is_a?(Array) - state = @state if state && state.instance_of?(self.class::StringState) encoder.begin_group state.type end @@ -34,10 +35,15 @@ module Scanners method_call_expected = false value_expected = true - heredocs = nil inline_block_stack = nil inline_block_curly_depth = 0 + if heredocs + state = heredocs.shift + encoder.begin_group state.type + heredocs = nil if heredocs.empty? + end + # def_object_stack = nil # def_object_paren_depth = 0 @@ -421,11 +427,14 @@ module Scanners # cleaning up if options[:keep_state] - @state = state + heredocs = nil if heredocs && heredocs.empty? + @state = state, heredocs end + if state.is_a? self.class::StringState encoder.end_group state.type end + if inline_block_stack until inline_block_stack.empty? state, = *inline_block_stack.pop |