summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/html
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2009-01-22 14:13:43 +0000
committermurphy <murphy@rubychan.de>2009-01-22 14:13:43 +0000
commit70dcba4428281407ff0b92a417c3d6d6939390a4 (patch)
treeb8e467002cd75e7a1694bc7e403218806e915c7d /lib/coderay/encoders/html
parent4c64867ce924aca00fc40849e83acbfe2fcc3b29 (diff)
downloadcoderay-70dcba4428281407ff0b92a417c3d6d6939390a4.tar.gz
New feature: HTML encode option :highlight_lines. See documentation.
* The scanner test suite uses it and highlights the lines that differ after a failed complete test in *.actual.html.
Diffstat (limited to 'lib/coderay/encoders/html')
-rw-r--r--lib/coderay/encoders/html/numerization.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/coderay/encoders/html/numerization.rb b/lib/coderay/encoders/html/numerization.rb
index 9f1667f..0b6cf7a 100644
--- a/lib/coderay/encoders/html/numerization.rb
+++ b/lib/coderay/encoders/html/numerization.rb
@@ -32,9 +32,19 @@ module Encoders
#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|