summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2013-06-23 14:35:17 +0200
committerKornelius Kalnbach <murphy@rubychan.de>2013-06-23 14:35:17 +0200
commit9651f0b464b6540a1427ea8320abaa01caf197b3 (patch)
tree184c42f0fe01ddce26b7d4cc42c124b695a20b3e /lib/coderay/encoders
parent14f3a4f28341237503a51bfa0764c922bb02bdfa (diff)
parentd7f1669cdf1d48204f3e1b0078d467da448c31d2 (diff)
downloadcoderay-9651f0b464b6540a1427ea8320abaa01caf197b3.tar.gz
Merge branch 'master' into upstream
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r--lib/coderay/encoders/debug_lint.rb23
-rw-r--r--lib/coderay/encoders/html.rb1
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/coderay/encoders/debug_lint.rb b/lib/coderay/encoders/debug_lint.rb
index 0ac89ef..17a0795 100644
--- a/lib/coderay/encoders/debug_lint.rb
+++ b/lib/coderay/encoders/debug_lint.rb
@@ -19,11 +19,6 @@ module Encoders
EmptyToken = Class.new InvalidTokenStream
IncorrectTokenGroupNesting = Class.new InvalidTokenStream
- def initialize options = {}
- super
- @opened = []
- end
-
def text_token text, kind
raise EmptyToken, 'empty token' if text.empty?
super
@@ -35,7 +30,8 @@ module Encoders
end
def end_group kind
- raise IncorrectTokenGroupNesting, "We are inside #{@opened.inspect}, not #{kind} (end_group)" if @opened.pop != kind
+ raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
+ @opened.pop
super
end
@@ -45,7 +41,20 @@ module Encoders
end
def end_line kind
- raise IncorrectTokenGroupNesting, "We are inside #{@opened.inspect}, not #{kind} (end_line)" if @opened.pop != kind
+ raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
+ @opened.pop
+ super
+ end
+
+ protected
+
+ def setup options
+ super
+ @opened = []
+ end
+
+ def finish options
+ raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty?
super
end
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index b897f5e..20f2409 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -193,7 +193,6 @@ module Encoders
def finish options
unless @opened.empty?
- warn '%d tokens still open: %p' % [@opened.size, @opened] if $CODERAY_DEBUG
@out << '</span>' while @opened.pop
@last_opened = nil
end