diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2014-01-23 22:23:59 +0100 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2014-01-23 22:23:59 +0100 |
commit | ee76cc5df42af385743d81ec0810073b7c9ed465 (patch) | |
tree | 89387c694298768c2ea4766eff097cdd5006fbdf /lib/coderay/encoders/debug.rb | |
parent | 4131a5ff622e7c767dfd042c4c357906a2544c01 (diff) | |
parent | e93aae88985667189bb5b24ad0d5f54cb5fdba70 (diff) | |
download | coderay-ee76cc5df42af385743d81ec0810073b7c9ed465.tar.gz |
Merge branch 'master' into bash-scanner
Conflicts:
lib/coderay/helpers/file_type.rb
Diffstat (limited to 'lib/coderay/encoders/debug.rb')
-rw-r--r-- | lib/coderay/encoders/debug.rb | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/coderay/encoders/debug.rb b/lib/coderay/encoders/debug.rb index c03d3fb..f4db330 100644 --- a/lib/coderay/encoders/debug.rb +++ b/lib/coderay/encoders/debug.rb @@ -9,7 +9,6 @@ module Encoders # # You cannot fully restore the tokens information from the # output, because consecutive :space tokens are merged. - # Use Tokens#dump for caching purposes. # # See also: Scanners::Debug class Debug < Encoder @@ -18,38 +17,26 @@ module Encoders FILE_EXTENSION = 'raydebug' - def initialize options = {} - super - @opened = [] - end - def text_token text, kind - raise 'empty token' if $CODERAY_DEBUG && text.empty? if kind == :space @out << text else - # TODO: Escape ( - text = text.gsub(/[)\\]/, '\\\\\0') if text.index(/[)\\]/) - @out << kind.to_s << '(' << text << ')' + text = text.gsub('\\', '\\\\\\\\') if text.index('\\') + text = text.gsub(')', '\\\\)') if text.index(')') + @out << "#{kind}(#{text})" end end def begin_group kind - @opened << kind - @out << kind.to_s << '<' + @out << "#{kind}<" end def end_group kind - if @opened.last != kind - puts @out - raise "we are inside #{@opened.inspect}, not #{kind}" - end - @opened.pop @out << '>' end def begin_line kind - @out << kind.to_s << '[' + @out << "#{kind}[" end def end_line kind |