Skip to content

Commit

Permalink
Merge pull request #1931 from kurank/firstlinenum-text
Browse files Browse the repository at this point in the history
Apply firstlinenum to text format
  • Loading branch information
kmuto authored Nov 25, 2024
2 parents 3bb7c66 + e6d3bca commit bba805e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 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
4 changes: 2 additions & 2 deletions test/assets/syntax_book_index_detail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
-----------------------------
169C 2L 0.2P 第II部 部見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
=============================
6110C 188L 11P ch02
6111C 188L 11P ch02
-----------------------------
52C 1L 0.0P 第2章 長い章見出し■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□
10C 1L 0.0P 2.1 ブロック命令
784C 27L 1.4P 2.1.1 ソースコード
785C 27L 1.4P 2.1.1 ソースコード
338C 8L 0.5P 2.1.2 図
709C 22L 1.3P 2.1.3 表
1154C 56L 2.8P 2.1.4 囲み記事
Expand Down

0 comments on commit bba805e

Please sign in to comment.