Skip to content

Commit

Permalink
Apply firstlinenum to text format
Browse files Browse the repository at this point in the history
  • Loading branch information
kurank committed Nov 18, 2024
1 parent 3bb7c66 commit ae2ea05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/review/plaintextbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def builder_init_file
@subsubsection = 0
@subsubsubsection = 0
@blank_seen = true
@first_line_num = nil
end
private :builder_init_file

Expand Down Expand Up @@ -213,12 +214,13 @@ def emlist(lines, caption = nil, _lang = nil)
end

def emlistnum(lines, caption = nil, _lang = nil)
first_line_number = line_num
blank
if caption_top?('list') && caption.present?
puts compile_inline(caption)
end
lines.each_with_index do |line, i|
puts((i + 1).to_s.rjust(2) + ": #{line}")
puts((i + first_line_number).to_s.rjust(2) + ": #{line}")
end
if !caption_top?('list') && caption.present?
puts compile_inline(caption)
Expand All @@ -245,8 +247,9 @@ def listnum(lines, id, caption, lang = nil)
end

def listnum_body(lines, _lang)
first_line_number = line_num
lines.each_with_index do |line, i|
puts((i + 1).to_s.rjust(2) + ": #{line}")
puts((i + first_line_number).to_s.rjust(2) + ": #{line}")
end
end

Expand Down
7 changes: 5 additions & 2 deletions lib/review/topbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def builder_init_file
'bpo' => 'bpo',
'source' => 'ソースコードリスト'
}
@first_line_num = nil
end
private :builder_init_file

Expand Down Expand Up @@ -149,13 +150,14 @@ def base_parablock(type, lines, caption = nil)
end

def emlistnum(lines, caption = nil, _lang = nil)
first_line_number = line_num
blank
puts "◆→開始:#{@titles['emlist']}←◆"
if caption_top?('list') && caption.present?
puts "■#{compile_inline(caption)}"
end
lines.each_with_index do |line, i|
puts((i + 1).to_s.rjust(2) + ": #{line}")
puts((i + first_line_number).to_s.rjust(2) + ": #{line}")
end
if !caption_top?('list') && caption.present?
puts "■#{compile_inline(caption)}"
Expand Down Expand Up @@ -185,8 +187,9 @@ def listnum(lines, id, caption, lang = nil)
end

def listnum_body(lines, _lang)
first_line_number = line_num
lines.each_with_index do |line, i|
puts((i + 1).to_s.rjust(2) + ": #{line}")
puts((i + first_line_number).to_s.rjust(2) + ": #{line}")
end
end

Expand Down

0 comments on commit ae2ea05

Please sign in to comment.