Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply firstlinenum to text format #1931

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading