@@ -14,7 +14,7 @@ def self.number! output, mode = :table, options = {}
14
14
unless start . is_a? Integer
15
15
raise ArgumentError , "Invalid value %p for :line_number_start; Integer expected." % start
16
16
end
17
-
17
+
18
18
anchor_prefix = options [ :line_number_anchors ]
19
19
anchor_prefix = 'line' if anchor_prefix == true
20
20
anchor_prefix = anchor_prefix . to_s [ /\w +/ ] if anchor_prefix
@@ -28,7 +28,7 @@ def self.number! output, mode = :table, options = {}
28
28
else
29
29
proc { |line | line . to_s } # :to_s.to_proc in Ruby 1.8.7+
30
30
end
31
-
31
+
32
32
bold_every = options [ :bold_every ]
33
33
highlight_lines = options [ :highlight_lines ]
34
34
bolding =
@@ -55,15 +55,15 @@ def self.number! output, mode = :table, options = {}
55
55
else
56
56
raise ArgumentError , 'Invalid value %p for :bolding; false or Integer expected.' % bold_every
57
57
end
58
-
58
+
59
59
line_count = output . count ( "\n " )
60
60
position_of_last_newline = output . rindex ( RUBY_VERSION >= '1.9' ? /\n / : ?\n)
61
61
if position_of_last_newline
62
62
after_last_newline = output [ position_of_last_newline + 1 .. -1 ]
63
63
ends_with_newline = after_last_newline [ /\A (?:<\/ span>)*\z / ]
64
64
line_count += 1 if not ends_with_newline
65
65
end
66
-
66
+
67
67
case mode
68
68
when :inline
69
69
max_width = ( start + line_count ) . to_s . size
@@ -72,7 +72,7 @@ def self.number! output, mode = :table, options = {}
72
72
line_number_text = bolding . call line_number
73
73
indent = ' ' * ( max_width - line_number . to_s . size ) # TODO: Optimize (10^x)
74
74
line_number += 1
75
- "<span class=\" line-numbers\" >#{ indent } #{ line_number_text } </span>#{ line } "
75
+ "<div class= \" line #{ " odd" if line_number . odd? } \" >< span class=\" line-numbers\" >#{ indent } #{ line_number_text } </span>#{ line } </div> "
76
76
end
77
77
78
78
when :table
0 commit comments