def close_cell(eol = false)
cell_text = @buffer.strip
@buffer = ''
if @format == 'psv'
cell_spec = take_cell_spec
if cell_spec
repeat = cell_spec.fetch('repeatcol', 1)
cell_spec.delete('repeatcol')
else
warn %(asciidoctor: ERROR: #{@last_cursor.line_info}: table missing leading separator, recovering automatically)
cell_spec = {}
repeat = 1
end
else
cell_spec = nil
repeat = 1
if @format == 'csv'
if !cell_text.empty? && cell_text.include?('"')
if cell_text.start_with?('"') && cell_text.end_with?('"')
cell_text = cell_text[1...-1].strip
end
cell_text = cell_text.tr_s('"', '"')
end
end
end
1.upto(repeat) do |i|
if @col_count == -1
@table.columns << (column = Table::Column.new(@table, @table.columns.size + i - 1))
if cell_spec && (cell_spec.key? 'colspan') && (extra_cols = cell_spec['colspan'].to_i - 1) > 0
offset = @table.columns.size
extra_cols.times do |j|
@table.columns << Table::Column.new(@table, offset + j)
end
end
else
unless (column = @table.columns[@current_row.size])
warn %(asciidoctor: ERROR: #{@last_cursor.line_info}: dropping cell because it exceeds specified number of columns)
return
end
end
cell = Table::Cell.new(column, cell_text, cell_spec, @last_cursor)
@last_cursor = @reader.cursor
unless !cell.rowspan || cell.rowspan == 1
activate_rowspan(cell.rowspan, (cell.colspan || 1))
end
@col_visits += (cell.colspan || 1)
@current_row << cell
close_row if end_of_row? && (@col_count != -1 || @linenum > 0 || (eol && i == repeat))
end
@cell_open = false
nil
end