Skip to content

Commit

Permalink
resolves #4573 log error when incomplete row is detected at end of ta…
Browse files Browse the repository at this point in the history
…ble (PR #4590)
  • Loading branch information
mojavelinux committed May 16, 2024
1 parent 1b2f7c7 commit ad827b1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Improvements::
* Remove empty line at top of table cells in manpage output (#4482) (*@strager*)
* Return `nil` if name passed to `Asciidoctor::SafeMode.value_for_name` is not recognized (#3526)
* Modify default stylesheet to honor text-* roles on quote blocks
* Log error when an incomplete row is detected at the end of a table (#4573)

Bug Fixes::

Expand Down
1 change: 1 addition & 0 deletions lib/asciidoctor/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,7 @@ def self.parse_table table_reader, parent, attributes
end
end

parser_ctx.close_table
table.assign_column_widths unless (table.attributes['colcount'] ||= table.columns.size) == 0 || explicit_colspecs
table.has_header_option = true if implicit_header
table.partition_header_footer attributes
Expand Down
6 changes: 6 additions & 0 deletions lib/asciidoctor/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@ def close_cell eol = false
nil
end

def close_table
return if @column_visits == 0
logger.error message_with_context 'dropping cells from incomplete row detected end of table', source_location: @reader.cursor_before_mark
nil
end

private

# Internal: Close the row by adding it to the Table and resetting the row
Expand Down
17 changes: 17 additions & 0 deletions test/tables_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,23 @@
end
end

test 'should drop incomplete row at end of table and log an error' do
input = <<~'EOS'
[cols=2*]
|===
|a |b
|c |d
|e
|===
EOS
using_memory_logger do |logger|
output = convert_string_to_embedded input
assert_css 'table', output, 1
assert_css 'table tr', output, 2
assert_message logger, :ERROR, '<stdin>: line 5: dropping cells from incomplete row detected end of table', Hash
end
end

test 'should apply cell style for column to repeated content' do
input = <<~'EOS'
[cols=",^l"]
Expand Down

0 comments on commit ad827b1

Please sign in to comment.