class Asciidoctor::Table::ParserContext
def close_cell(eol = false)
row has been met, close the row and begin a new one.
the current row and, if the number of expected columns for the current
Public: Close the current cell, instantiate a new Table::Cell, add it to
def close_cell(eol = false) cell_text = @buffer.strip @buffer = '' if @format == 'psv' cell_spec = take_cell_spec if cell_spec.nil? warn "asciidoctor: ERROR: #{@last_cursor.line_info}: table missing leading separator, recovering automatically" cell_spec = {} repeat = 1 else repeat = cell_spec.fetch('repeatcol', 1) cell_spec.delete('repeatcol') end else cell_spec = nil repeat = 1 if @format == 'csv' if !cell_text.empty? && cell_text.include?('"') # this may not be perfect logic, but it hits the 99% if cell_text.start_with?('"') && cell_text.end_with?('"') # unquote cell_text = cell_text[1...-1].strip end # collapses escaped quotes cell_text = cell_text.tr_s('"', '"') end end end 1.upto(repeat) do |i| # make column resolving an operation if @col_count == -1 @table.columns << (column = Table::Column.new(@table, @current_row.size + i - 1)) if cell_spec && (cell_spec.has_key? 'colspan') && (extra_cols = cell_spec['colspan'].to_i - 1) > 0 extra_cols.times do |j| @table.columns << Table::Column.new(@table, @current_row.size + i + j - 1) end end else # QUESTION is this right for cells that span columns? column = @table.columns[@current_row.size] 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 # don't close the row if we're on the first line and the column count has not been set explicitly # TODO perhaps the col_count/linenum logic should be in end_of_row? (or a should_end_row? method) close_row if end_of_row? && (@col_count != -1 || @linenum > 0 || (eol && i == repeat)) end @cell_open = false nil end