summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/html
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2014-01-23 22:23:59 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2014-01-23 22:23:59 +0100
commitee76cc5df42af385743d81ec0810073b7c9ed465 (patch)
tree89387c694298768c2ea4766eff097cdd5006fbdf /lib/coderay/encoders/html
parent4131a5ff622e7c767dfd042c4c357906a2544c01 (diff)
parente93aae88985667189bb5b24ad0d5f54cb5fdba70 (diff)
downloadcoderay-ee76cc5df42af385743d81ec0810073b7c9ed465.tar.gz
Merge branch 'master' into bash-scanner
Conflicts: lib/coderay/helpers/file_type.rb
Diffstat (limited to 'lib/coderay/encoders/html')
-rw-r--r--lib/coderay/encoders/html/css.rb14
-rw-r--r--lib/coderay/encoders/html/numbering.rb4
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