From 23d2a5f2c6b876ba31a52e927973cdd57e2b6ef4 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 15 Mar 2006 23:45:09 +0000 Subject: Fixed HTML encoder. Changed HTML::CSS.load_stylesheet behaviour. --- lib/coderay/encoders/html.rb | 25 ++++++++++++------------- lib/coderay/encoders/html/css.rb | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'lib/coderay/encoders') 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 '' % [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 -- cgit v1.2.1