summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/debug.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/encoders/debug.rb
parent916711c9983483c39f9a68c29e21a0ed40004bd2 (diff)
parent0a1f500d524ff0fb5eeafef051ccbb641954a87a (diff)
downloadcoderay-0b8c69cfb7a65bec04c44e58e5776e323d2aa1af.tar.gz
Merge branch 'master' into paint-integrationpaint-integration
Diffstat (limited to 'lib/coderay/encoders/debug.rb')
-rw-r--r--lib/coderay/encoders/debug.rb23
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