diff options
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r-- | lib/coderay/encoders/html.rb | 25 | ||||
-rw-r--r-- | lib/coderay/encoders/html/css.rb | 2 |
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
|