This method is deprecated or moved on the latest stable version.
The last existing version (v1_9_3_392) is shown here.
add_line_numbers(src)
public
Prepend src with line numbers. Relies on the first line of a
source code listing having:
# File xxxxx, line dddd
If it has, line numbers are added an ‘, line dddd’ is removed.
# File lib/rdoc/generator/markup.rb, line 87
def add_line_numbers(src)
return unless src.sub!(/\A(.*)(, line (\d+))/, '\1')
first = $3.to_i - 1
last = first + src.count("\n")
size = last.to_s.length
line = first
src.gsub!(/^/) do
res = if line == first then
" " * (size + 1)
else
"<span class=\"line-num\">%2$*1$d</span> " % [size, line]
end
line += 1
res
end
end