Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #2410 catalog all footnotes found inside AsciiDoc table cells #2411

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Bug Fixes::

* restore bottom margin on table with `breakable` or `unbreakable` option (#2379)
* honor theme settings for caption on table with `breakable` or `unbreakable` option (#2379)
* catalog all footnotes found inside AsciiDoc table cells and render them in the footnotes list (#2410)
* correctly map all icons from FontAwesome 4 (#2373)
* resolve remote image in document title or section title with autogenerated ID
* keep caret between items in menu macro with previous item if items wrap
Expand Down
4 changes: 2 additions & 2 deletions lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ def dry_run
apply_font_properties do
extent = @pdf.dry_run keep_together: true, single_page: true do
push_scratch parent_doc
doc.catalog[:footnotes] = parent_doc.catalog[:footnotes]
# NOTE: we should be able to use cell.max_width, but returns 0 in some conditions (like when colspan > 1)
indent cell.padding_left, bounds.width - cell.width + cell.padding_right do
move_down padding_y if padding_y > 0
conceal_page_top { traverse cell.content }
end
pop_scratch parent_doc
doc.catalog[:footnotes] = parent_doc.catalog[:footnotes]
end
end
# NOTE: prawn-table doesn't support cells that exceed the height of a single page
Expand Down Expand Up @@ -90,6 +88,8 @@ def draw_content
# end
# end
start_page = pdf.page_number
parent_doc = (doc = content.document).nested? ? doc.parent_document : doc
doc.catalog[:footnotes] = parent_doc.catalog[:footnotes]
# 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
Expand Down
24 changes: 23 additions & 1 deletion spec/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@
(expect (markers_x[0] - left_edge).round 2).to eql reference_x
end

it 'should capture footnotes in AsciiDoc table cell and render them with other footnotes' do
it 'should capture footnote in AsciiDoc table cell and render them with other footnotes' do
pdf = to_pdf <<~'END', analyze: true
before{empty}footnote:[Footnote before table]

Expand All @@ -2050,6 +2050,28 @@
(expect pdf.lines).to eql expected_lines
end

it 'should capture footnotes in multiple AsciiDoc table cells and render them with other footnotes' do
pdf = to_pdf <<~'END', analyze: true
[cols=1a]
|===
|first{empty}footnote:[First footnote inside table]
|second{empty}footnote:[Second footnote inside table]
|===

third{empty}footnote:[Footnote outside of table]
END

expected_lines = [
'first[1]',
'second[2]',
'third[3]',
'1. First footnote inside table',
'2. Second footnote inside table',
'3. Footnote outside of table',
]
(expect pdf.lines).to eql expected_lines
end

it 'should not fail to fit content in table cell and create blank page when margin bottom is 0' do
pdf_theme = {
base_font_family: 'M+ 1mn',
Expand Down