From f4760fb9832659601e8248a60e33c9c79f796000 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 27 Jan 2024 03:24:08 -0700 Subject: [PATCH] resolves #2480 ensure indentation is preserved at page transition of index when media=prepress --- CHANGELOG.adoc | 1 + .../pdf/ext/prawn/document/column_box.rb | 5 +- spec/index_spec.rb | 57 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index aeef8c825..369ca291c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -40,6 +40,7 @@ Improvements:: Bug Fixes:: +* ensure indentation is preserved at page transition of index when media=prepress; prevents margin from shifting to the left (#2480) * 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 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 58c16a83d..97716e2c7 100644 --- a/spec/index_spec.rb +++ b/spec/index_spec.rb @@ -945,6 +945,63 @@ (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: 54, + page_margin_inner: 72, + page_margin_outer: 36, + } + pdf = to_pdf <<~'END', 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)) and ((fro)) + + ((apples)) and ((oranges)) + + ((over)) and ((under)) + + ((light)) and ((dark)) + + [index] + == Index + END + + 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,