summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2006-03-15 23:45:09 +0000
committermurphy <murphy@rubychan.de>2006-03-15 23:45:09 +0000
commit23d2a5f2c6b876ba31a52e927973cdd57e2b6ef4 (patch)
treed200f63961cf23972beb2b52503175f087d1d884 /lib/coderay/encoders
parent052466e27f9d42c051e49177d5f132d16dde69eb (diff)
downloadcoderay-23d2a5f2c6b876ba31a52e927973cdd57e2b6ef4.tar.gz
Fixed HTML encoder.
Changed HTML::CSS.load_stylesheet behaviour.
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r--lib/coderay/encoders/html.rb25
-rw-r--r--lib/coderay/encoders/html/css.rb2
2 files changed, 13 insertions, 14 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index c57d20d..08390ad 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -120,18 +120,17 @@ module Encoders
end
def self.token_path_to_hint hint, classes
- if hint
- title = if hint == :debug
- k.inspect
- elsif hint == :info_long
- classes.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/')
- elsif hint == :info
+ return '' unless hint
+ title =
+ case hint
+ when :info
TOKEN_KIND_TO_INFO[classes.first]
+ when :info_long
+ classes.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/')
+ when :debug
+ k.inspect
end
- " title=\"#{title}\""
- else
- ''
- end
+ " title=\"#{title}\""
end
def setup options
@@ -176,12 +175,12 @@ module Encoders
styles = [k]
end
type = styles.first
- styles.map! { |c| ClassOfKind[c] }
- if styles.first == :NO_HIGHLIGHT and not hint
+ classes = styles.map { |c| ClassOfKind[c] }
+ if classes.first == :NO_HIGHLIGHT and not hint
h[k] = false
else
title = HTML.token_path_to_hint hint, styles
- style = @css[*styles]
+ style = @css[*classes]
h[k] =
if style
'<span%s style="%s">' % [title, style]
diff --git a/lib/coderay/encoders/html/css.rb b/lib/coderay/encoders/html/css.rb
index ef564ce..e938e07 100644
--- a/lib/coderay/encoders/html/css.rb
+++ b/lib/coderay/encoders/html/css.rb
@@ -7,7 +7,7 @@ module CodeRay module Encoders
attr :stylesheet
- def CSS.load_stylesheet style
+ def CSS.load_stylesheet style = :default
style = DEFAULT_STYLESHEET_ID if style == :default
CodeRay::Styles[style]
end