From 07c94b5789cbfbe03c82622dda6cd8441d238490 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 27 Jan 2024 14:04:37 -0700 Subject: [PATCH] resolves #2480 ensure indentation is preserved at page transition of index when media=prepress (PR #2481) --- CHANGELOG.adoc | 4 +- .../pdf/ext/prawn/document/column_box.rb | 5 +- spec/index_spec.rb | 60 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5cf2e48bd..7a316e0e1 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -7,7 +7,9 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co == Unreleased -_No changes since previous release._ +Bug Fixes:: + +* ensure indentation is preserved at page transition of index when media=prepress; prevents margin from shifting to the left (#2480) == 2.3.11 (2024-01-23) - @mojavelinux diff --git a/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb b/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb index c61baf0af..0b260fab5 100644 --- a/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb +++ b/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb @@ -15,8 +15,11 @@ def move_past_bottom initial_margins = doc.page.margins parent_.move_past_bottom if doc.page.margins != initial_margins - doc.bounds = self.class.new doc, parent_, [(margin_box = doc.margin_box).absolute_left, @y], + doc.bounds = bounds = self.class.new doc, parent_, [(margin_box = doc.margin_box).absolute_left, @y], columns: @columns, reflow_margins: @reflow_margins, spacer: @spacer, width: margin_box.width, height: @height + # ensure indentation is preserved across page break + bounds.add_left_padding @total_left_padding if @total_left_padding > 0 + bounds.add_right_padding @total_right_padding if @total_right_padding > 0 end nil end diff --git a/spec/index_spec.rb b/spec/index_spec.rb index 17e0d5dbe..6b731d88b 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -934,6 +934,66 @@ (expect s_category_text[:x]).to eql 36.0 end + # this happens if the term sits right on the page boundary and the hanging indent is still active + it 'should preserve indentation when recreating column box on subsequent pages' do + pdf_theme = { + page_margin: [50, 54], + page_margin_inner: 72, + page_margin_outer: 36, + } + pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true + = Document Title + :doctype: book + :media: prepress + :notitle: + :pdf-page-size: A5 + + == Chapter + + ((foo)) and ((bar)) + + ((yin)) and ((yang)) + + ((tea)) and ((coffee)) + + ((left)) and ((right)) + + ((salt)) and ((pepper)) + + ((up)) and ((down)) + + ((sugar)) and ((spice)) + + ((day)) and ((night)) + + ((melody)) and ((harmony)) + + ((inside)) and ((outside)) + + ((forward)) and ((back)) + + ((cake)) and ((icing)) + + ((to that place where you wish to go)) and ((fro)) + + ((apples)) and ((oranges)) + + ((over)) and ((under)) + + ((light)) and ((dark)) + + [index] + == Index + EOS + + wrapped_text = pdf.find_unique_text 'to go, 1', page_number: 4 + (expect wrapped_text).not_to be_nil + (expect wrapped_text[:x]).to eql 66.0 + u_category_text = pdf.find_unique_text 'U', page_number: 4 + (expect u_category_text).not_to be_nil + (expect u_category_text[:x]).to eql 36.0 + end + it 'should preserve column count on subsequent pages' do pdf_theme = { page_margin: 36,