./lib/coderay/encoders/html/numerization.rb in coderay-0.8.357 vs ./lib/coderay/encoders/html/numerization.rb in coderay-0.9.1

- old
+ new

@@ -30,13 +30,23 @@ #unless allowed_wrappings == :all or allowed_wrappings.include? options[:wrap] # raise ArgumentError, "Can't numerize, :wrap must be in %p, but is %p" % [NUMERIZABLE_WRAPPINGS, options[:wrap]] #end bold_every = options[:bold_every] + highlight_lines = options[:highlight_lines] bolding = - if bold_every == false + if bold_every == false && highlight_lines == nil proc { |line| line.to_s } + elsif highlight_lines.is_a? Enumerable + highlight_lines = highlight_lines.to_set + proc do |line| + if highlight_lines.include? line + "<strong class=\"highlighted\">#{line}</strong>" # highlighted line numbers in bold + else + line.to_s + end + end elsif bold_every.is_a? Integer raise ArgumentError, ":bolding can't be 0." if bold_every == 0 proc do |line| if line % bold_every == 0 "<strong>#{line}</strong>" # every bold_every-th number in bold @@ -63,10 +73,9 @@ when :table # This is really ugly. # Because even monospace fonts seem to have different heights when bold, # I make the newline bold, both in the code and the line numbers. # FIXME Still not working perfect for Mr. Internet Exploder - # FIXME Firefox struggles with very long codes (> 200 lines) line_numbers = (start ... start + line_count).to_a.map(&bolding).join("\n") line_numbers << "\n" # also for Mr. MS Internet Exploder :-/ line_numbers.gsub!(/\n/) { "<tt>\n</tt>" } line_numbers_table_tpl = TABLE.apply('LINE_NUMBERS', line_numbers)