diff --git a/lib/review/plaintextbuilder.rb b/lib/review/plaintextbuilder.rb index d041a48ea..78eebdf95 100644 --- a/lib/review/plaintextbuilder.rb +++ b/lib/review/plaintextbuilder.rb @@ -48,6 +48,7 @@ def builder_init_file @subsubsection = 0 @subsubsubsection = 0 @blank_seen = true + @first_line_num = nil end private :builder_init_file @@ -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) @@ -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 diff --git a/lib/review/topbuilder.rb b/lib/review/topbuilder.rb index ee1040ef9..f7085ff4a 100644 --- a/lib/review/topbuilder.rb +++ b/lib/review/topbuilder.rb @@ -56,6 +56,7 @@ def builder_init_file 'bpo' => 'bpo', 'source' => 'ソースコードリスト' } + @first_line_num = nil end private :builder_init_file @@ -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)}" @@ -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 diff --git a/test/assets/syntax_book_index_detail.txt b/test/assets/syntax_book_index_detail.txt index 000aa099a..42c823508 100644 --- a/test/assets/syntax_book_index_detail.txt +++ b/test/assets/syntax_book_index_detail.txt @@ -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 囲み記事