diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-23 14:36:53 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-23 14:36:53 +0200 |
commit | 8c3c0c49a98eb8daceb69d0b233d054fbbccc49e (patch) | |
tree | 52dfc1b4abe110580a51ec0c0d056d1044c44151 /lib/coderay/scanners/groovy.rb | |
parent | 7ada74c8f0f77815393e887db83e1d2c36ce7235 (diff) | |
parent | 9651f0b464b6540a1427ea8320abaa01caf197b3 (diff) | |
download | coderay-8c3c0c49a98eb8daceb69d0b233d054fbbccc49e.tar.gz |
Merge branch 'master' into css-in-html
Diffstat (limited to 'lib/coderay/scanners/groovy.rb')
-rw-r--r-- | lib/coderay/scanners/groovy.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/coderay/scanners/groovy.rb b/lib/coderay/scanners/groovy.rb index cf55daf..c64454f 100644 --- a/lib/coderay/scanners/groovy.rb +++ b/lib/coderay/scanners/groovy.rb @@ -36,9 +36,12 @@ module Scanners protected + def setup + @state = :initial + end + def scan_tokens encoder, options - - state = :initial + state = options[:state] || @state inline_block_stack = [] inline_block_paren_depth = nil string_delimiter = nil @@ -223,7 +226,7 @@ module Scanners encoder.text_token match, :content # TODO: Shouldn't this be :error? elsif match = scan(/ \\ | \n /x) - encoder.end_group state + encoder.end_group state == :regexp ? :regexp : :string encoder.text_token match, :error after_def = value_expected = false state = :initial @@ -243,7 +246,17 @@ module Scanners end if [:multiline_string, :string, :regexp].include? state - encoder.end_group state + encoder.end_group state == :regexp ? :regexp : :string + end + + if options[:keep_state] + @state = state + end + + until inline_block_stack.empty? + state, = *inline_block_stack.pop + encoder.end_group :inline + encoder.end_group state == :regexp ? :regexp : :string end encoder |