diff --git a/lib/asciidoctor/table.rb b/lib/asciidoctor/table.rb index 587fc2791c..f8f9510a02 100644 --- a/lib/asciidoctor/table.rb +++ b/lib/asciidoctor/table.rb @@ -473,7 +473,7 @@ def close_cell(eol = false) end else # QUESTION is this right for cells that span columns? - column = @table.columns[@current_row.size] + return unless (column = @table.columns[@current_row.size]) end cell = Table::Cell.new(column, cell_text, cell_spec, @last_cursor) diff --git a/test/tables_test.rb b/test/tables_test.rb index 57fd0504aa..936ecac97c 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -579,6 +579,22 @@ assert_xpath '/table/tbody/tr[3]/td[3]/p[text()="c"]', output, 1 end + test 'ignores cell with colspan that exceeds colspec' do + input = <<-EOS +[cols="1,1"] +|=== +3+|A +|B +a|C + +more C +|=== + EOS + output = render_embedded_string input + assert_css 'table', output, 1 + assert_css 'table *', output, 0 + end + test 'paragraph, verse and literal content' do input = <<-EOS [cols=",^v,^l",options="header"]