Skip to content

Commit a53f94d

Browse files
committed
patched elsewhere - ugly hack, but it should do
1 parent 720aa80 commit a53f94d

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/coderay/encoders/html.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def self.token_path_to_hint hint, kinds
172172
def setup options
173173
super
174174

175-
@line_number = 1
176175
if options[:wrap] || options[:line_numbers]
177176
@real_out = @out
178177
@out = ''
@@ -298,9 +297,6 @@ def end_group kind
298297

299298
# whole lines to be highlighted, eg. a deleted line in a diff
300299
def begin_line kind
301-
@out << '<div class="line'
302-
@out << ' odd' if @line_number.odd?
303-
@out << '">'
304300
if style = @span_for_kind[@last_opened ? [kind, *@opened] : kind]
305301
if style['class="']
306302
@out << style.sub('class="', 'class="line ')
@@ -323,8 +319,6 @@ def end_line kind
323319
@out << '</span>'
324320
@last_opened = @opened.last if @last_opened
325321
end
326-
@out << '</div>'
327-
@line_number += 1
328322
end
329323

330324
end

lib/coderay/encoders/html/numbering.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def self.number! output, mode = :table, options = {}
1414
unless start.is_a? Integer
1515
raise ArgumentError, "Invalid value %p for :line_number_start; Integer expected." % start
1616
end
17-
17+
1818
anchor_prefix = options[:line_number_anchors]
1919
anchor_prefix = 'line' if anchor_prefix == true
2020
anchor_prefix = anchor_prefix.to_s[/\w+/] if anchor_prefix
@@ -28,7 +28,7 @@ def self.number! output, mode = :table, options = {}
2828
else
2929
proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+
3030
end
31-
31+
3232
bold_every = options[:bold_every]
3333
highlight_lines = options[:highlight_lines]
3434
bolding =
@@ -55,15 +55,15 @@ def self.number! output, mode = :table, options = {}
5555
else
5656
raise ArgumentError, 'Invalid value %p for :bolding; false or Integer expected.' % bold_every
5757
end
58-
58+
5959
line_count = output.count("\n")
6060
position_of_last_newline = output.rindex(RUBY_VERSION >= '1.9' ? /\n/ : ?\n)
6161
if position_of_last_newline
6262
after_last_newline = output[position_of_last_newline + 1 .. -1]
6363
ends_with_newline = after_last_newline[/\A(?:<\/span>)*\z/]
6464
line_count += 1 if not ends_with_newline
6565
end
66-
66+
6767
case mode
6868
when :inline
6969
max_width = (start + line_count).to_s.size
@@ -72,7 +72,7 @@ def self.number! output, mode = :table, options = {}
7272
line_number_text = bolding.call line_number
7373
indent = ' ' * (max_width - line_number.to_s.size) # TODO: Optimize (10^x)
7474
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>"
7676
end
7777

7878
when :table

0 commit comments

Comments
 (0)