diff options
Diffstat (limited to 'lib/coderay/encoders/html')
-rw-r--r-- | lib/coderay/encoders/html/css.rb | 14 | ||||
-rw-r--r-- | lib/coderay/encoders/html/numbering.rb | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/coderay/encoders/html/css.rb b/lib/coderay/encoders/html/css.rb index 6de4b46..164d7f8 100644 --- a/lib/coderay/encoders/html/css.rb +++ b/lib/coderay/encoders/html/css.rb @@ -11,7 +11,7 @@ module Encoders end def initialize style = :default - @classes = Hash.new + @styles = Hash.new style = CSS.load_stylesheet style @stylesheet = [ style::CSS_MAIN_STYLES, @@ -20,12 +20,12 @@ module Encoders parse style::TOKEN_COLORS end - def get_style styles - cl = @classes[styles.first] + def get_style_for_css_classes css_classes + cl = @styles[css_classes.first] return '' unless cl style = '' - 1.upto styles.size do |offset| - break if style = cl[styles[offset .. -1]] + 1.upto css_classes.size do |offset| + break if style = cl[css_classes[offset .. -1]] end # warn 'Style not found: %p' % [styles] if style.empty? return style @@ -52,8 +52,8 @@ module Encoders for selector in selectors.split(',') classes = selector.scan(/[-\w]+/) cl = classes.pop - @classes[cl] ||= Hash.new - @classes[cl][classes] = style.to_s.strip.delete(' ').chomp(';') + @styles[cl] ||= Hash.new + @styles[cl][classes] = style.to_s.strip.delete(' ').chomp(';') end end end diff --git a/lib/coderay/encoders/html/numbering.rb b/lib/coderay/encoders/html/numbering.rb index 332145b..a1b9c04 100644 --- a/lib/coderay/encoders/html/numbering.rb +++ b/lib/coderay/encoders/html/numbering.rb @@ -26,7 +26,7 @@ module Encoders "<a href=\"##{anchor}\" name=\"#{anchor}\">#{line}</a>" end else - proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+ + :to_s.to_proc end bold_every = options[:bold_every] @@ -75,7 +75,7 @@ module Encoders line_number = start output.gsub!(/^.*$\n?/) do |line| line_number_text = bolding.call line_number - indent = ' ' * (max_width - line_number.to_s.size) # TODO: Optimize (10^x) + indent = ' ' * (max_width - line_number.to_s.size) line_number += 1 "<span class=\"line-numbers\">#{indent}#{line_number_text}</span>#{line}" end |