summaryrefslogtreecommitdiff
path: root/lib/coderay/tokens_proxy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/coderay/tokens_proxy.rb')
-rw-r--r--lib/coderay/tokens_proxy.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/coderay/tokens_proxy.rb b/lib/coderay/tokens_proxy.rb
index 598ad2e..b333e57 100644
--- a/lib/coderay/tokens_proxy.rb
+++ b/lib/coderay/tokens_proxy.rb
@@ -1,13 +1,15 @@
module CodeRay
- class TokensProxy < Struct.new :code, :lang, :options, :block
+ class TokensProxy < Struct.new :input, :lang, :options, :block
def method_missing method, *args, &blk
+ encode method, *args
+ rescue PluginHost::PluginNotFound
tokens.send(method, *args, &blk)
end
def tokens
- @tokens ||= scanner.tokenize(code)
+ @tokens ||= scanner.tokenize(input)
end
def each *args, &blk
@@ -22,6 +24,14 @@ module CodeRay
@scanner ||= CodeRay.scanner(lang, options, &block)
end
+ def encode encoder, options = {}
+ if encoder.respond_to? :to_sym
+ CodeRay.encode(input, lang, encoder, options)
+ else
+ encoder.encode_tokens tokens, options
+ end
+ end
+
end
end