Skip to content

Commit

Permalink
backport fix for #2502 propagate source location to table cell for de…
Browse files Browse the repository at this point in the history
…scription in horizontal dlist so it is included in truncation warning message
  • Loading branch information
mojavelinux committed Mar 7, 2024
1 parent 9e661bf commit cb8ce5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Improvements::

Bug Fixes::

* propagate source location to table cell for description in horizontal dlist so it is included in truncation warning message (#2502)
* upgrade prawn-svg to 0.34 to fix warning about base64 gem when using Ruby >= 3.3; apply additional patch to fix bug in prawn-svg

== 2.3.13 (2024-02-16) - @mojavelinux
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ def convert_dlist node
desc_container = Block.new node, :open
desc_container << (Block.new desc_container, :paragraph, source: (desc.instance_variable_get :@text), subs: :default) if desc.text?
desc.blocks.each {|b| desc_container << b.dup } if desc.blocks?
row_data << { content: (::Prawn::Table::Cell::AsciiDoc.new self, content: (item[1] = desc_container), text_color: @font_color, padding: desc_padding, valign: :top) }
row_data << { content: (::Prawn::Table::Cell::AsciiDoc.new self, content: (item[1] = desc_container), text_color: @font_color, padding: desc_padding, valign: :top, source_location: desc.source_location) }
else
row_data << {}
end
Expand Down
13 changes: 13 additions & 0 deletions spec/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,19 @@
(expect texts[0][:y].round 2).to eql (texts[1][:y].round 2)
end
end

it 'should report source location of truncated item description in dlist' do
(expect do
pdf = to_pdf <<~EOS, sourcemap: true, attribute_overrides: { 'docfile' => 'test.adoc' }, analyze: true
[horizontal]
step 1::
#{['* task'] * 50 * ?\n}
EOS

(expect pdf.pages.size).to eql 1
(expect (pdf.find_unique_text 'step 1')).not_to be_nil
end).to log_message severity: :ERROR, message: 'the table cell on page 1 has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page', file: 'test.adoc', lineno: 3
end
end

context 'Unordered' do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper/matchers/have_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def with_memory_logger level = nil
elsif message_text === expected_message
result = true
end
result = false if (file = expected[:file]) && !(Hash === message_data && file == message_data[:source_location].file)
result = false if (lineno = expected[:lineno]) && !(Hash === message_data && lineno == message_data[:source_location].lineno)
result = false if (file = expected[:file]) && !(Hash === message_data && file == message_data[:source_location]&.file)
result = false if (lineno = expected[:lineno]) && !(Hash === message_data && lineno == message_data[:source_location]&.lineno)
end
actual = message
end
Expand Down

0 comments on commit cb8ce5b

Please sign in to comment.