summaryrefslogtreecommitdiff
path: root/lib/coderay/encoder.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-01 02:58:17 +0000
committermurphy <murphy@rubychan.de>2010-05-01 02:58:17 +0000
commit7bf48ce6cf5c75a2278d6545f02781a79f53ebbb (patch)
treec0f87f427bf4d8b8a8c56ec1f722367949c8ff5b /lib/coderay/encoder.rb
parent6f1178b7fb8967dda865433ecb9e309f6cb733e1 (diff)
downloadcoderay-7bf48ce6cf5c75a2278d6545f02781a79f53ebbb.tar.gz
Got rid of the old streaming system (see #142).
Diffstat (limited to 'lib/coderay/encoder.rb')
-rw-r--r--lib/coderay/encoder.rb28
1 files changed, 7 insertions, 21 deletions
diff --git a/lib/coderay/encoder.rb b/lib/coderay/encoder.rb
index 82545c4..716f516 100644
--- a/lib/coderay/encoder.rb
+++ b/lib/coderay/encoder.rb
@@ -27,8 +27,6 @@ module CodeRay
extend Plugin
plugin_host Encoders
- attr_reader :token_stream
-
class << self
# If FILE_EXTENSION isn't defined, this method returns the
@@ -44,7 +42,7 @@ module CodeRay
end
# Subclasses are to store their default options in this constant.
- DEFAULT_OPTIONS = { :stream => false }
+ DEFAULT_OPTIONS = { }
# The options you gave the Encoder at creating.
attr_accessor :options
@@ -56,7 +54,6 @@ module CodeRay
# Encoder objects provide three encode methods:
# - encode simply takes a +code+ string and a +lang+
# - encode_tokens expects a +tokens+ object instead
- # - encode_stream is like encode, but uses streaming mode.
#
# Each method has an optional +options+ parameter. These are
# added to the options you passed at creation.
@@ -75,31 +72,20 @@ module CodeRay
finish options
end
- # Encode the given +code+ after tokenizing it using the Scanner
- # for +lang+.
+ # Encode the given +code+ using the Scanner for +lang+.
def encode code, lang, options = {}
options = @options.merge options
- scanner_options = CodeRay.get_scanner_options(options)
- tokens = CodeRay.scan code, lang, scanner_options
- encode_tokens tokens, options
- end
-
- # You can use highlight instead of encode, if that seems
- # more clear to you.
- alias highlight encode
-
- # Encode the given +code+ using the Scanner for +lang+ in
- # streaming mode.
- def encode_stream code, lang, options = {}
- options = @options.merge options
setup options
scanner_options = CodeRay.get_scanner_options options
scanner_options[:tokens] = self
- @token_stream =
- CodeRay.scan_stream code, lang, scanner_options
+ CodeRay.scan code, lang, scanner_options
finish options
end
+ # You can use highlight instead of encode, if that seems
+ # more clear to you.
+ alias highlight encode
+
# Return the default file extension for outputs of this encoder.
def file_extension
self.class::FILE_EXTENSION