diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-06-25 12:16:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-25 12:16:59 -0600 |
| commit | 5fd22a20eafcb515f0fda7ddc5ef4e6bf458a376 (patch) | |
| tree | f962c7659c132476033f68669933b9ac2f2b74f1 /lib | |
| parent | 92ccc32bb086415cd2decde63505b769ead30c7c (diff) | |
resolves #2261 include source location in warning message for truncated table cell if sourcemap is enabled (PR #2262)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 8 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn-table/cell.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb | 4 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 7df81d1e..2096df4a 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -2023,7 +2023,8 @@ module Asciidoctor content: cell_text, colspan: cell.colspan || 1, align: (cell.attr 'halign').to_sym, - valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym + valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym, + source_location: cell.source_location end) end end unless head_rows.empty? @@ -2042,7 +2043,8 @@ module Asciidoctor colspan: cell.colspan || 1, rowspan: cell.rowspan || 1, align: (cell.attr 'halign').to_sym, - valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym + valign: (val = cell.attr 'valign') == 'middle' ? :center : val.to_sym, + source_location: cell.source_location cell_line_metrics = body_cell_line_metrics case cell.style when :emphasis @@ -2103,7 +2105,7 @@ module Asciidoctor # NOTE: line metrics get applied when AsciiDoc content is converted cell_line_metrics = nil asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding) - cell_data = { content: asciidoc_cell } + cell_data = { content: asciidoc_cell, source_location: cell.source_location } end if cell_line_metrics cell_padding = body_cell_padding.dup diff --git a/lib/asciidoctor/pdf/ext/prawn-table/cell.rb b/lib/asciidoctor/pdf/ext/prawn-table/cell.rb index dac6af83..19d4adac 100644 --- a/lib/asciidoctor/pdf/ext/prawn-table/cell.rb +++ b/lib/asciidoctor/pdf/ext/prawn-table/cell.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true Prawn::Table::Cell.prepend (Module.new do + attr_writer :source_location + def border_color= color color = [color, color] if Asciidoctor::PDF::ThemeLoader::CMYKColorValue === color super diff --git a/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb b/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb index 0af9cd52..07406237 100644 --- a/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +++ b/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb @@ -91,7 +91,9 @@ module Prawn # TODO: apply horizontal alignment; currently it is necessary to specify alignment on content blocks apply_font_properties { pdf.traverse content } if (extra_pages = pdf.page_number - start_page) > 0 - logger.error %(the table cell on page #{start_page} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page) unless extra_pages == 1 && pdf.page.empty? + unless extra_pages == 1 && pdf.page.empty? + logger.error message_with_context %(the table cell on page #{start_page} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page), source_location: @source_location + end extra_pages.times { pdf.delete_current_page } end nil diff --git a/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb b/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb index cd279fd4..aa73ccac 100644 --- a/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb +++ b/lib/asciidoctor/pdf/ext/prawn-table/cell/text.rb @@ -16,7 +16,9 @@ class Prawn::Table::Cell::Text height: spanned_content_height + FPTolerance, at: [0, @pdf.cursor]).render end - logger.error %(the table cell on page #{@pdf.page_number} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page) unless remaining_text.empty? || @pdf.scratch? + unless remaining_text.empty? || @pdf.scratch? + logger.error message_with_context %(the table cell on page #{@pdf.page_number} has been truncated; Asciidoctor PDF does not support table cell content that exceeds the height of a single page), source_location: @source_location + end end end |
