Skip to content

Commit

Permalink
resolves #2480 ensure indentation is preserved at page transition of …
Browse files Browse the repository at this point in the history
…index when media=prepress (PR #2481)
  • Loading branch information
mojavelinux committed Jan 27, 2024
1 parent aa1744d commit 07c94b5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion lib/asciidoctor/pdf/ext/prawn/document/column_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 60 additions & 0 deletions spec/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 07c94b5

Please sign in to comment.