diff options
author | murphy <murphy@rubychan.de> | 2005-10-04 04:04:07 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2005-10-04 04:04:07 +0000 |
commit | 48e144a20829faaeca9a7db8fbc6128f1f5d7297 (patch) | |
tree | 24326041ae8a5cc12a87ab96b8cdc67dba1e585e /lib/coderay/encoders/debug.rb | |
parent | 0ae9f844faf25d3be9f6fe5f8157f6bfebb30942 (diff) | |
download | coderay-48e144a20829faaeca9a7db8fbc6128f1f5d7297.tar.gz |
Two new encoders: debug and xml.
encoder.rb: new token handling
encoders/statistic.rb: using new handling
ruby_helper.rb: small improvements
ruby.rb:
- escapes in subtoken
- Float detection changed
- some multi-char operators are now scanned as one token
- def and module definition handling changed
bin/coderay: improved, new interface (still in progress)
plugin.rb: more expressive load error message
Diffstat (limited to 'lib/coderay/encoders/debug.rb')
-rw-r--r-- | lib/coderay/encoders/debug.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/coderay/encoders/debug.rb b/lib/coderay/encoders/debug.rb new file mode 100644 index 0000000..b084733 --- /dev/null +++ b/lib/coderay/encoders/debug.rb @@ -0,0 +1,38 @@ +module CodeRay
+ module Encoders
+
+ # = Debug Encoder
+ class Debug < Encoder
+
+ include Streamable
+ register_for :debug
+
+ FILE_EXTENSION = 'debug'
+
+ protected
+ def text_token text, kind
+ @out <<
+ if kind == :space
+ text
+ else
+ text = text.gsub(/[)\\]/, '\\\\\0')
+ "#{kind}(#{text})"
+ end
+ end
+
+ def block_token action, kind
+ @out << super
+ end
+
+ def open_token kind
+ "#{kind}<"
+ end
+
+ def close_token kind
+ ">"
+ end
+
+ end
+
+ end
+end
|