Skip to content

Commit

Permalink
use common Builder#table on each builders.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Aug 19, 2019
1 parent 53bf209 commit a1b7f79
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 56 deletions.
12 changes: 1 addition & 11 deletions lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(<div id="#{normalize_id(id)}" class="table">)
else
puts %Q(<div class="table">)
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 '</div>'
end

Expand Down
12 changes: 0 additions & 12 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions lib/review/markdownbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions lib/review/plaintextbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 1 addition & 10 deletions lib/review/topbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a1b7f79

Please sign in to comment.