diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 03:53:43 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 03:55:05 -0700 |
| commit | cb8ce5b34edf5975b285005df2c5de48ae39e87e (patch) | |
| tree | 77c45a2b7c87464247f215cc9dcb7d09a02c58ad | |
| parent | 9e661bfa10d4d62eee40171be2c77f9d58fc087b (diff) | |
backport fix for #2502 propagate source location to table cell for description in horizontal dlist so it is included in truncation warning message
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 2 | ||||
| -rw-r--r-- | spec/list_spec.rb | 13 | ||||
| -rw-r--r-- | spec/spec_helper/matchers/have_message.rb | 4 |
4 files changed, 17 insertions, 3 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 271665cc..d51df265 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index f2b31534..89ff9a4c 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -1458,7 +1458,7 @@ module Asciidoctor 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 diff --git a/spec/list_spec.rb b/spec/list_spec.rb index a909a2fd..fe7f9c32 100644 --- a/spec/list_spec.rb +++ b/spec/list_spec.rb @@ -1500,6 +1500,19 @@ describe 'Asciidoctor::PDF::Converter - List' do (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 diff --git a/spec/spec_helper/matchers/have_message.rb b/spec/spec_helper/matchers/have_message.rb index 5abd4adb..bac9b2aa 100644 --- a/spec/spec_helper/matchers/have_message.rb +++ b/spec/spec_helper/matchers/have_message.rb @@ -27,8 +27,8 @@ RSpec::Matchers.define :have_message do |expected| 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 |
