summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners/groovy.rb
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2016-02-13 16:12:48 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2016-02-13 16:12:48 +0100
commit0b8c69cfb7a65bec04c44e58e5776e323d2aa1af (patch)
treefd81bf6229bfc0d173f5b744534a76b5c70eb440 /lib/coderay/scanners/groovy.rb
parent916711c9983483c39f9a68c29e21a0ed40004bd2 (diff)
parent0a1f500d524ff0fb5eeafef051ccbb641954a87a (diff)
downloadcoderay-paint-integration.tar.gz
Merge branch 'master' into paint-integrationpaint-integration
Diffstat (limited to 'lib/coderay/scanners/groovy.rb')
-rw-r--r--lib/coderay/scanners/groovy.rb21
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