From a1b7f7902954c701715686e84da40afb1b20abcd Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Mon, 19 Aug 2019 10:00:02 +0900 Subject: [PATCH] use common Builder#table on each builders. --- lib/review/htmlbuilder.rb | 12 +----------- lib/review/latexbuilder.rb | 12 ------------ lib/review/markdownbuilder.rb | 12 ------------ lib/review/plaintextbuilder.rb | 15 ++++----------- lib/review/topbuilder.rb | 11 +---------- 5 files changed, 6 insertions(+), 56 deletions(-) diff --git a/lib/review/htmlbuilder.rb b/lib/review/htmlbuilder.rb index 15c76bbbf..07f11a30e 100644 --- a/lib/review/htmlbuilder.rb +++ b/lib/review/htmlbuilder.rb @@ -642,22 +642,12 @@ def image_header(id, caption) end def table(lines, id = nil, caption = nil) - sepidx, rows = parse_table_rows(lines) if id puts %Q(
) else puts %Q(
) end - begin - if caption.present? - table_header(id, caption) - end - rescue KeyError - error "no such table: #{id}" - end - table_begin(rows.first.size) - table_rows(sepidx, rows) - table_end + super(lines, id, caption) puts '
' end diff --git a/lib/review/latexbuilder.rb b/lib/review/latexbuilder.rb index 1555d9e70..7b2926518 100644 --- a/lib/review/latexbuilder.rb +++ b/lib/review/latexbuilder.rb @@ -593,18 +593,6 @@ def indepimage(lines, id, caption = nil, metric = nil) alias_method :numberlessimage, :indepimage - def table(lines, id = nil, caption = nil) - sepidx, rows = parse_table_rows(lines) - begin - table_header(id, caption) if caption.present? - rescue KeyError - error "no such table: #{id}" - end - table_begin(rows.first.size) - table_rows(sepidx, rows) - table_end - end - def table_rows(sepidx, rows) if sepidx sepidx.times do diff --git a/lib/review/markdownbuilder.rb b/lib/review/markdownbuilder.rb index 596f8fe1c..96998b723 100644 --- a/lib/review/markdownbuilder.rb +++ b/lib/review/markdownbuilder.rb @@ -246,18 +246,6 @@ def cmd(lines) puts '```' end - def table(lines, id = nil, caption = nil) - sepidx, rows = parse_table_rows(lines) - begin - table_header(id, caption) unless caption.nil? - rescue KeyError - error "no such table: #{id}" - end - table_begin(rows.first.size) - table_rows(sepidx, rows) - table_end - end - def table_rows(sepidx, rows) if sepidx sepidx.times do diff --git a/lib/review/plaintextbuilder.rb b/lib/review/plaintextbuilder.rb index 256e9f6ed..bfd0a9475 100644 --- a/lib/review/plaintextbuilder.rb +++ b/lib/review/plaintextbuilder.rb @@ -220,18 +220,11 @@ def texequation(lines, id = nil, caption = '') blank end - def table(lines, id = nil, caption = nil) - sepidx, rows = parse_table_rows(lines) - blank - - begin - table_header(id, caption) if caption.present? - rescue KeyError - error "no such table: #{id}" + def table(lines, id = nil, caption = nil, noblank = nil) + unless noblank + blank end - table_begin(rows.first.size) - table_rows(sepidx, rows) - table_end + super(lines, id, caption) end def table_header(id, caption) diff --git a/lib/review/topbuilder.rb b/lib/review/topbuilder.rb index beda9b524..ca9d7b9f7 100644 --- a/lib/review/topbuilder.rb +++ b/lib/review/topbuilder.rb @@ -200,18 +200,9 @@ def texequation(lines, id = nil, caption = '') end def table(lines, id = nil, caption = nil) - sepidx, rows = parse_table_rows(lines) blank puts "◆→開始:#{@titles['table']}←◆" - - begin - table_header(id, caption) if caption.present? - rescue KeyError - error "no such table: #{id}" - end - table_begin(rows.first.size) - table_rows(sepidx, rows) - table_end + super(lines, id, caption, true) end def th(str)