diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-12-07 23:52:23 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2021-09-04 15:40:29 -0600 |
| commit | 8a8d4cc72681bb2a6fb17c78489326846e62e218 (patch) | |
| tree | f5187162968702d4e29a8e50c6228401de1a7a68 | |
| parent | 3a41e954b30cc7639bd1616a87aea334f8175ac9 (diff) | |
backport #1833 align footnotes block to bottom of page it is placed on
| -rw-r--r-- | CHANGELOG.adoc | 6 | ||||
| -rw-r--r-- | examples/basic-example.pdf | 150 | ||||
| -rw-r--r-- | examples/chronicles-example.pdf | 12 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 17 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn/extensions.rb | 5 | ||||
| -rw-r--r-- | spec/footnote_spec.rb | 2 | ||||
| -rw-r--r-- | spec/reference/open-unbreakable-option-fit.pdf | 90 |
7 files changed, 150 insertions, 132 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 1da1594a..cc34895a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -5,6 +5,12 @@ This document provides a high-level view of the changes to the {project-name} by release. For a detailed view of what has changed, refer to the {uri-repo}/commits/v1.6.x[commit history] on GitHub. +== Unreleased + +Enhancements:: + +* align footnotes block to the bottom of the page it is placed on (#1833) + == 1.6.0 (2021-05-10) - @mojavelinux Enhancements:: diff --git a/examples/basic-example.pdf b/examples/basic-example.pdf index 3ee319ce..74118970 100644 --- a/examples/basic-example.pdf +++ b/examples/basic-example.pdf @@ -47,7 +47,7 @@ endobj >> endobj 6 0 obj -<< /Length 10174 +<< /Length 10166 >> stream q @@ -577,7 +577,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 186.8264 Td +48.24 69.1703 Td ET 0.0 0.0 0.0 SCN @@ -586,7 +586,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 186.8264 Td +48.24 69.1703 Td /F1.0 8 Tf <5b> Tj ET @@ -597,7 +597,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 186.8264 Td +51.112 69.1703 Td /F1.0 8 Tf <31> Tj ET @@ -608,7 +608,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 186.8264 Td +55.584 69.1703 Td /F1.0 8 Tf <5d204173636969446f6320737570706f72747320756e6f7264657265642c206f7264657265642c20616e64206465736372697074696f6e206c697374732e> Tj ET @@ -619,7 +619,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 171.8036 Td +48.24 54.1474 Td ET 0.0 0.0 0.0 SCN @@ -628,7 +628,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 171.8036 Td +48.24 54.1474 Td /F1.0 8 Tf <5b> Tj ET @@ -639,7 +639,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 171.8036 Td +51.112 54.1474 Td /F1.0 8 Tf <32> Tj ET @@ -650,7 +650,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 171.8036 Td +55.584 54.1474 Td /F1.0 8 Tf [<5d2059> 69.8242 <6f75206d61> 20.0195 <792063686f6f73652066726f6d207371756172652c20646973632c20616e6420636972636c6520666f72207468652062756c6c6574207374796c652e>] TJ ET @@ -956,24 +956,24 @@ endobj [7 0 R /XYZ 0 269.2419 null] endobj 25 0 obj -[7 0 R /XYZ 48.24 195.3704 null] +[7 0 R /XYZ 48.24 77.7143 null] endobj 26 0 obj << /Border [0 0 0] /Dest (_footnoteref_1) /Subtype /Link -/Rect [51.112 184.4904 55.584 195.3704] +/Rect [51.112 66.8343 55.584 77.7143] /Type /Annot >> endobj 27 0 obj -[7 0 R /XYZ 48.24 180.3476 null] +[7 0 R /XYZ 48.24 62.6914 null] endobj 28 0 obj << /Border [0 0 0] /Dest (_footnoteref_2) /Subtype /Link -/Rect [51.112 169.4676 55.584 180.3476] +/Rect [51.112 51.8114 55.584 62.6914] /Type /Annot >> endobj @@ -1470,72 +1470,72 @@ xref 0000000406 00000 n 0000000457 00000 n 0000000729 00000 n -0000010956 00000 n -0000011434 00000 n -0000011603 00000 n -0000011645 00000 n -0000011694 00000 n -0000011901 00000 n -0000012066 00000 n -0000012232 00000 n -0000012277 00000 n -0000012329 00000 n -0000012462 00000 n -0000012513 00000 n -0000012646 00000 n -0000012811 00000 n -0000012856 00000 n -0000013028 00000 n -0000013200 00000 n -0000013369 00000 n -0000013414 00000 n -0000013463 00000 n -0000013592 00000 n -0000013641 00000 n -0000013770 00000 n -0000013894 00000 n -0000014020 00000 n -0000014136 00000 n -0000014254 00000 n -0000014377 00000 n -0000014501 00000 n -0000014575 00000 n -0000014737 00000 n -0000014924 00000 n -0000015093 00000 n -0000015230 00000 n -0000015378 00000 n -0000015423 00000 n -0000015693 00000 n -0000015963 00000 n -0000021723 00000 n -0000021940 00000 n -0000023294 00000 n -0000024208 00000 n -0000032422 00000 n -0000032634 00000 n -0000033988 00000 n -0000034903 00000 n -0000038613 00000 n -0000038825 00000 n -0000039127 00000 n -0000040041 00000 n -0000045591 00000 n -0000045813 00000 n -0000047167 00000 n -0000048081 00000 n -0000051165 00000 n -0000051376 00000 n -0000052730 00000 n -0000053644 00000 n -0000056420 00000 n -0000056628 00000 n -0000057982 00000 n +0000010948 00000 n +0000011426 00000 n +0000011595 00000 n +0000011637 00000 n +0000011686 00000 n +0000011893 00000 n +0000012058 00000 n +0000012224 00000 n +0000012269 00000 n +0000012321 00000 n +0000012454 00000 n +0000012505 00000 n +0000012638 00000 n +0000012803 00000 n +0000012848 00000 n +0000013020 00000 n +0000013192 00000 n +0000013361 00000 n +0000013406 00000 n +0000013454 00000 n +0000013581 00000 n +0000013629 00000 n +0000013756 00000 n +0000013880 00000 n +0000014006 00000 n +0000014122 00000 n +0000014240 00000 n +0000014363 00000 n +0000014487 00000 n +0000014561 00000 n +0000014723 00000 n +0000014910 00000 n +0000015079 00000 n +0000015216 00000 n +0000015364 00000 n +0000015409 00000 n +0000015679 00000 n +0000015949 00000 n +0000021709 00000 n +0000021926 00000 n +0000023280 00000 n +0000024194 00000 n +0000032408 00000 n +0000032620 00000 n +0000033974 00000 n +0000034889 00000 n +0000038599 00000 n +0000038811 00000 n +0000039113 00000 n +0000040027 00000 n +0000045577 00000 n +0000045799 00000 n +0000047153 00000 n +0000048067 00000 n +0000051151 00000 n +0000051362 00000 n +0000052716 00000 n +0000053630 00000 n +0000056406 00000 n +0000056614 00000 n +0000057968 00000 n trailer << /Size 68 /Root 2 0 R /Info 1 0 R >> startxref -58896 +58882 %%EOF diff --git a/examples/chronicles-example.pdf b/examples/chronicles-example.pdf index c6ea7f07..66e0f714 100644 --- a/examples/chronicles-example.pdf +++ b/examples/chronicles-example.pdf @@ -2638,7 +2638,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 57.2198 Td +48.24 54.1474 Td ET 0.0 0.0 0.0 SCN @@ -2647,7 +2647,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 57.2198 Td +48.24 54.1474 Td /F1.0 8 Tf <5b> Tj ET @@ -2658,7 +2658,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 57.2198 Td +51.112 54.1474 Td /F1.0 8 Tf <31> Tj ET @@ -2669,7 +2669,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 57.2198 Td +55.584 54.1474 Td /F1.0 8 Tf [<5d204465664f7073206973206120706f72746d616e74656175206f6620d2646566656e73697665d320616e6420d26f706572> 20.0195 <6174696f6e73d32e>] TJ ET @@ -3007,13 +3007,13 @@ endobj >> endobj 42 0 obj -[20 0 R /XYZ 48.24 65.7638 null] +[20 0 R /XYZ 48.24 62.6914 null] endobj 43 0 obj << /Border [0 0 0] /Dest (_footnoteref_1) /Subtype /Link -/Rect [51.112 54.8838 55.584 65.7638] +/Rect [51.112 51.8114 55.584 62.6914] /Type /Annot >> endobj diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 5c1374dc..0eeab4a2 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -607,13 +607,18 @@ module Asciidoctor def layout_footnotes node return if (fns = (doc = node.document).footnotes - @footnotes).empty? theme_margin :footnotes, :top - theme_font :footnotes do - (title = doc.attr 'footnotes-title') && (layout_caption title, category: :footnotes) - item_spacing = @theme.footnotes_item_spacing || 0 - fns.each do |fn| - layout_prose %(<a id="_footnotedef_#{index = fn.index}">#{DummyText}</a>[<a anchor="_footnoteref_#{index}">#{index}</a>] #{fn.text}), margin_bottom: item_spacing, hyphenate: true + with_dry_run do |box_height = nil| + if box_height && (delta = cursor - box_height) > 0 + move_down delta + end + theme_font :footnotes do + (title = doc.attr 'footnotes-title') && (layout_caption title, category: :footnotes) + item_spacing = @theme.footnotes_item_spacing + fns.each do |fn| + layout_prose %(<a id="_footnotedef_#{index = fn.index}">#{DummyText}</a>[<a anchor="_footnoteref_#{index}">#{index}</a>] #{fn.text}), margin_bottom: item_spacing, hyphenate: true + end + @footnotes += fns unless scratch? end - @footnotes += fns end nil end diff --git a/lib/asciidoctor/pdf/ext/prawn/extensions.rb b/lib/asciidoctor/pdf/ext/prawn/extensions.rb index fc565f12..218427dd 100644 --- a/lib/asciidoctor/pdf/ext/prawn/extensions.rb +++ b/lib/asciidoctor/pdf/ext/prawn/extensions.rb @@ -903,6 +903,11 @@ module Asciidoctor [(whole_pages * full_page_height + partial_page_height), whole_pages, partial_page_height] end + def with_dry_run &block + total_height, = dry_run(&block) + instance_exec total_height, &block + end + # Attempt to keep the objects generated in the block on the same page # # TODO: short-circuit nested usage diff --git a/spec/footnote_spec.rb b/spec/footnote_spec.rb index 462c8dc8..0a717b63 100644 --- a/spec/footnote_spec.rb +++ b/spec/footnote_spec.rb @@ -24,6 +24,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do # footnote item (expect (strings.slice 6, 3).join).to eql '[1] More about that thing.' (expect text[6][:y]).to be < text[5][:y] + (expect text[6][:y]).to be < 60 (expect text[6][:page_number]).to be 1 (expect text[6][:font_size]).to be 8 (expect (text.slice 6, 3).map {|it| [it[:y], it[:font_size]] }.uniq).to have_size 1 @@ -58,6 +59,7 @@ describe 'Asciidoctor::PDF::Converter - Footnote' do (expect strings.slice(-3, 3).join).to eql '[1] More about that thing.' (expect text[-1][:page_number]).to be 2 (expect text[-1][:font_size]).to be 8 + (expect text[-1][:y]).to be < 60 end it 'should add title to footnotes block if footnotes-title is set' do diff --git a/spec/reference/open-unbreakable-option-fit.pdf b/spec/reference/open-unbreakable-option-fit.pdf index ac413af1..ec35bf30 100644 --- a/spec/reference/open-unbreakable-option-fit.pdf +++ b/spec/reference/open-unbreakable-option-fit.pdf @@ -4,8 +4,8 @@ << /Title (Untitled) /Creator (Asciidoctor PDF 1.6.1.dev, based on Prawn 2.4.0) /Producer (Asciidoctor PDF 1.6.1.dev, based on Prawn 2.4.0) -/ModDate (D:20210904153834-06'00') -/CreationDate (D:20210904153834-06'00') +/ModDate (D:20210904154011-06'00') +/CreationDate (D:20210904154011-06'00') >> endobj 2 0 obj @@ -393,7 +393,7 @@ endobj >> endobj 14 0 obj -<< /Length 6695 +<< /Length 6683 >> stream q @@ -814,7 +814,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 617.3546 Td +48.24 84.1931 Td ET 0.0 0.0 0.0 SCN @@ -823,7 +823,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 617.3546 Td +48.24 84.1931 Td /F1.0 8 Tf <5b> Tj ET @@ -834,7 +834,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 617.3546 Td +51.112 84.1931 Td /F1.0 8 Tf <31> Tj ET @@ -845,7 +845,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 617.3546 Td +55.584 84.1931 Td /F1.0 8 Tf <5d206d6f6e6579> Tj ET @@ -856,7 +856,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 602.3317 Td +48.24 69.1703 Td ET 0.0 0.0 0.0 SCN @@ -865,7 +865,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 602.3317 Td +48.24 69.1703 Td /F1.0 8 Tf <5b> Tj ET @@ -876,7 +876,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 602.3317 Td +51.112 69.1703 Td /F1.0 8 Tf <32> Tj ET @@ -887,7 +887,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 602.3317 Td +55.584 69.1703 Td /F1.0 8 Tf <5d20436c6172696669636174696f6e2061626f757420746869732073746174656d656e742e> Tj ET @@ -898,7 +898,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 587.3089 Td +48.24 54.1474 Td ET 0.0 0.0 0.0 SCN @@ -907,7 +907,7 @@ ET 0.2 0.2 0.2 SCN BT -48.24 587.3089 Td +48.24 54.1474 Td /F1.0 8 Tf <5b> Tj ET @@ -918,7 +918,7 @@ ET 0.2588 0.5451 0.7922 SCN BT -51.112 587.3089 Td +51.112 54.1474 Td /F1.0 8 Tf <33> Tj ET @@ -929,7 +929,7 @@ ET 0.2 0.2 0.2 SCN BT -55.584 587.3089 Td +55.584 54.1474 Td /F1.0 8 Tf <5d20646f6c6c61722062696c6c73> Tj ET @@ -991,35 +991,35 @@ endobj >> endobj 21 0 obj -[15 0 R /XYZ 48.24 625.8986 null] +[15 0 R /XYZ 48.24 92.7371 null] endobj 22 0 obj << /Border [0 0 0] /Dest (_footnoteref_1) /Subtype /Link -/Rect [51.112 615.0186 55.584 625.8986] +/Rect [51.112 81.8571 55.584 92.7371] /Type /Annot >> endobj 23 0 obj -[15 0 R /XYZ 48.24 610.8757 null] +[15 0 R /XYZ 48.24 77.7143 null] endobj 24 0 obj << /Border [0 0 0] /Dest (_footnoteref_2) /Subtype /Link -/Rect [51.112 599.9957 55.584 610.8757] +/Rect [51.112 66.8343 55.584 77.7143] /Type /Annot >> endobj 25 0 obj -[15 0 R /XYZ 48.24 595.8529 null] +[15 0 R /XYZ 48.24 62.6914 null] endobj 26 0 obj << /Border [0 0 0] /Dest (_footnoteref_3) /Subtype /Link -/Rect [51.112 584.9729 55.584 595.8529] +/Rect [51.112 51.8114 55.584 62.6914] /Type /Annot >> endobj @@ -1169,34 +1169,34 @@ xref 0000004846 00000 n 0000004896 00000 n 0000005029 00000 n -0000011777 00000 n -0000012134 00000 n -0000012306 00000 n -0000012357 00000 n -0000012489 00000 n -0000012539 00000 n -0000012672 00000 n -0000012722 00000 n -0000012851 00000 n -0000012901 00000 n -0000013030 00000 n -0000013080 00000 n -0000013209 00000 n -0000013283 00000 n -0000013408 00000 n -0000013468 00000 n -0000021260 00000 n -0000021472 00000 n -0000022826 00000 n -0000023740 00000 n -0000026990 00000 n -0000027201 00000 n -0000028555 00000 n +0000011765 00000 n +0000012122 00000 n +0000012294 00000 n +0000012345 00000 n +0000012477 00000 n +0000012527 00000 n +0000012660 00000 n +0000012709 00000 n +0000012836 00000 n +0000012885 00000 n +0000013012 00000 n +0000013061 00000 n +0000013188 00000 n +0000013262 00000 n +0000013387 00000 n +0000013447 00000 n +0000021239 00000 n +0000021451 00000 n +0000022805 00000 n +0000023719 00000 n +0000026969 00000 n +0000027180 00000 n +0000028534 00000 n trailer << /Size 38 /Root 2 0 R /Info 1 0 R >> startxref -29469 +29448 %%EOF |
