summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders
diff options
context:
space:
mode:
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r--lib/coderay/encoders/html.rb4
-rw-r--r--lib/coderay/encoders/terminal.rb24
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index d43805d..56857dc 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -262,7 +262,7 @@ module Encoders
@out << (@css_style[@opened] || '<span>')
@opened << type
when :close
- if $CODERAY_DEBUG and @opened.last != type
+ if $CODERAY_DEBUG and (@opened.size == 1 or @opened.last != type)
warn 'Malformed token stream: Trying to close a token (%p) ' \
'that is not open. Open are: %p.' % [type, @opened[1..-1]]
end
@@ -283,7 +283,7 @@ module Encoders
end
@opened << type
when :end_line
- if $CODERAY_DEBUG and @opened.last != type
+ if $CODERAY_DEBUG and (@opened.size == 1 or @opened.last != type)
warn 'Malformed token stream: Trying to close a line (%p) ' \
'that is not open. Open are: %p.' % [type, @opened[1..-1]]
end
diff --git a/lib/coderay/encoders/terminal.rb b/lib/coderay/encoders/terminal.rb
index 782147a..7224218 100644
--- a/lib/coderay/encoders/terminal.rb
+++ b/lib/coderay/encoders/terminal.rb
@@ -19,6 +19,7 @@ module CodeRay
register_for :terminal
TOKEN_COLORS = {
+ :annotation => '35',
:attribute_name => '33',
:attribute_value => '31',
:bin => '1;35',
@@ -29,10 +30,13 @@ module CodeRay
:class_variable => '36',
:color => '32',
:comment => '37',
+ :complex => '34',
:constant => ['34', '4'],
+ :decoration => '35',
:definition => '1;32',
:directive => ['32', '4'],
:doc => '46',
+ :doctype => '1;30',
:doc_string => ['31', '4'],
:entity => '33',
:error => ['1;33', '41'],
@@ -44,6 +48,7 @@ module CodeRay
:include => '33',
:integer => '1;34',
:interpreted => '1;35',
+ :key => '35',
:label => '1;15',
:local_variable => '33',
:oct => '1;35',
@@ -52,6 +57,7 @@ module CodeRay
:pre_type => '1;30',
:predefined => ['4', '1;34'],
:preprocessor => '36',
+ :pseudo_class => '34',
:regexp => {
:self => '31',
:content => '31',
@@ -60,20 +66,32 @@ module CodeRay
:function => '1;29'
},
:reserved => '1;31',
- :shell => {:self => '42', :content => '1;29'},
- :string => '32',
+ :shell => {
+ :self => '42',
+ :content => '1;29',
+ :delimiter => '37',
+ },
+ :string => {
+ :self => '32',
+ :modifier => '1;32',
+ :escape => '1;36',
+ :delimiter => '1;32',
+ },
:symbol => '1;32',
:tag => '34',
:tag_special => ['34', '4'],
:type => '1;34',
+ :value => '36',
:variable => '34',
:insert => '42',
:delete => '41',
:change => '44',
- :head => '41'
+ :head => '45'
}
+ TOKEN_COLORS[:keyword] = TOKEN_COLORS[:reserved]
TOKEN_COLORS[:method] = TOKEN_COLORS[:function]
+ TOKEN_COLORS[:imaginary] = TOKEN_COLORS[:complex]
TOKEN_COLORS[:open] = TOKEN_COLORS[:close] = TOKEN_COLORS[:nesting_delimiter] = TOKEN_COLORS[:escape] = TOKEN_COLORS[:delimiter]
protected