From ae2ea0595afecf61799311fef23f9ebc1ae15692 Mon Sep 17 00:00:00 2001 From: kuran Date: Mon, 18 Nov 2024 09:46:10 +0900 Subject: [PATCH 1/2] Apply firstlinenum to text format --- lib/review/plaintextbuilder.rb | 7 +++++-- lib/review/topbuilder.rb | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) 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 From e6d3bca0f7970130410969b81eb5cd959b628a96 Mon Sep 17 00:00:00 2001 From: kuran Date: Mon, 25 Nov 2024 12:44:36 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E3=81=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/assets/syntax_book_index_detail.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 囲み記事