diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2013-07-21 16:44:00 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2013-07-21 16:44:00 +0200 |
commit | b266cb62e4fc08b31dfa1b9a2700e5d555d13afb (patch) | |
tree | 8e88175ab9bf9d63eb504ce666b0e0aca0c0f895 /lib/coderay | |
parent | 5c23a731ca55729fc65630eca3b37a5b1a71e5b1 (diff) | |
parent | ea107396fdd72cdbbaf4820d09a87bd879ba7e6c (diff) | |
download | coderay-b266cb62e4fc08b31dfa1b9a2700e5d555d13afb.tar.gz |
Merge branch 'master' into fix-cache-attack
Diffstat (limited to 'lib/coderay')
-rw-r--r-- | lib/coderay/encoders/debug_lint.rb | 3 | ||||
-rw-r--r-- | lib/coderay/encoders/lint.rb | 4 | ||||
-rwxr-xr-x | lib/coderay/token_kinds.rb | 5 |
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/coderay/encoders/debug_lint.rb b/lib/coderay/encoders/debug_lint.rb index 2c14186..a4eba2c 100644 --- a/lib/coderay/encoders/debug_lint.rb +++ b/lib/coderay/encoders/debug_lint.rb @@ -18,7 +18,8 @@ module Encoders register_for :debug_lint def text_token text, kind - raise Lint::EmptyToken, 'empty token' if text.empty? + raise Lint::EmptyToken, 'empty token for %p' % [kind] if text.empty? + raise Lint::UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind super end diff --git a/lib/coderay/encoders/lint.rb b/lib/coderay/encoders/lint.rb index 4601e90..88c8bd1 100644 --- a/lib/coderay/encoders/lint.rb +++ b/lib/coderay/encoders/lint.rb @@ -17,10 +17,12 @@ module Encoders InvalidTokenStream = Class.new StandardError EmptyToken = Class.new InvalidTokenStream + UnknownTokenKind = Class.new InvalidTokenStream IncorrectTokenGroupNesting = Class.new InvalidTokenStream def text_token text, kind - raise EmptyToken, 'empty token' if text.empty? + raise EmptyToken, 'empty token for %p' % [kind] if text.empty? + raise UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind end def begin_group kind diff --git a/lib/coderay/token_kinds.rb b/lib/coderay/token_kinds.rb index 9137a49..5f49d77 100755 --- a/lib/coderay/token_kinds.rb +++ b/lib/coderay/token_kinds.rb @@ -1,10 +1,7 @@ module CodeRay # A Hash of all known token kinds and their associated CSS classes. - TokenKinds = Hash.new do |h, k| - warn 'Undefined Token kind: %p' % [k] if $CODERAY_DEBUG - false - end + TokenKinds = Hash.new(false) # speedup TokenKinds.compare_by_identity if TokenKinds.respond_to? :compare_by_identity |