Skip to content

Commit

Permalink
resolves asciidoctor#2480 ensure indentation is preserved at page tra…
Browse files Browse the repository at this point in the history
…nsition of index when media=prepress
  • Loading branch information
mojavelinux committed Jan 27, 2024
1 parent 53beea6 commit f4760fb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
57 changes: 57 additions & 0 deletions spec/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f4760fb

Please sign in to comment.