summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2005-10-29 14:41:32 +0000
committermurphy <murphy@rubychan.de>2005-10-29 14:41:32 +0000
commit84199b89843d0eca9a85b66dbeae9fd10fdc7d63 (patch)
tree5d947d894f1d0ac49b20ee7aa172e23e236aeb8b /lib/coderay/encoders
parent18ece3991f1ed26a086bc919648bcec0f090c13d (diff)
downloadcoderay-84199b89843d0eca9a85b66dbeae9fd10fdc7d63.tar.gz
encoders/html.rb: Improved Info hints; better error messages; fixed tab bug!
test/ruby: added new targets
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r--lib/coderay/encoders/html.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index a722f18..3c969d4 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -105,7 +105,7 @@ module Encoders
ansi_chars = Array(0x7f..0xff)
ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '&#%d;' % i }
# \x9 (\t) and \xA (\n) not included
- HTML_ESCAPE_PATTERN = /[&"><\0-\x8\xB-\x1f\x7f-\xff]/
+ HTML_ESCAPE_PATTERN = /[\t&"><\xB-\x1f\x7f-\xff\0-\x8]/
def setup options
super
@@ -119,7 +119,9 @@ module Encoders
@css = CSS.new
hint = options[:hint]
- raise ArgumentError if hint and not [:debug, :info].include? hint
+ if hint and not [:debug, :info].include? hint
+ raise ArgumentError, "Unknown value %p for :hint; expected :info, :debug, false or nil." % hint
+ end
case options[:css]
@@ -137,8 +139,9 @@ module Encoders
title = if hint
if hint == :debug
' title="%p"' % [ k ]
- elsif hint == :info and k.size == 1
- " title=\"#{type.to_s.gsub(/_/, " ").capitalize}\""
+ elsif hint == :info
+ path = (k[1..-1] << k.first).map { |kind| kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } }
+ " title=\"#{path.join('/')}\""
end
else
''
@@ -179,7 +182,7 @@ module Encoders
end
else
- raise "Unknown value %p for :css." % options[:css]
+ raise ArgumentError, "Unknown value %p for :css." % options[:css]
end
end