Skip to content

Commit

Permalink
resolves asciidoctor#4573 log error when incomplete row is detected a…
Browse files Browse the repository at this point in the history
…t end of table
  • Loading branch information
mojavelinux committed May 16, 2024
1 parent 7510201 commit b1d54d7
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 @@ -65,6 +65,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
if @column_visits > 0
logger.error message_with_context 'dropping trailing cells at end of table because they do not form a complete row', source_location: @reader.cursor_before_mark
end
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 trailing cells at end of table because they do not form a complete row', Hash
end
end

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

0 comments on commit b1d54d7

Please sign in to comment.