Skip to content

Commit

Permalink
resolves #2495 don't drop text on line above inline image macro in ru…
Browse files Browse the repository at this point in the history
…nning content value (PR #2496)
  • Loading branch information
mojavelinux authored Feb 16, 2024
1 parent 5b895bf commit f6b96a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Improvements::

Bug Fixes::

* don't drop text on line above inline image macro in running content value (#2495)
* when looking for a value that only contains an image macro, match the whole string instead of per line (#2495)
* don't warn about missing character in fallback font when inline image is advanced to next page (#2492)
* correctly map all icons from FontAwesome 4 (#2373)
* resolve remote image in document title or section title with autogenerated ID
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Converter < ::Prawn::Document
PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/
CalloutExtractRx = %r((?:(?://|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\2> ?(?=(?:\\?<!?\2(?:\d+|\.)\2> ?)*$))
CalloutConflictRx = /([<>&])(; *<!?(|--)(?:\d+|\.)\3>)/
ImageAttributeValueRx = /^image:{1,2}(.*?)\[(.*?)\]$/
ImageAttributeValueRx = /\Aimage:{1,2}(.*?)\[(.*?)\]\Z/
StopPunctRx = /[.!?;:]$/
UriBreakCharsRx = %r((?:/|\?|&amp;|#)(?!$))
UriBreakCharRepl = %(\\&#{ZeroWidthSpace})
Expand Down
31 changes: 31 additions & 0 deletions spec/running_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3096,6 +3096,37 @@
(expect rects[1][:fill_color]).to eql '0000FF'
end

it 'should support multiline content with image on line above or below text' do
expected_image_data = File.binread fixture_file 'square.jpg'
pdf_theme = {
__dir__: fixtures_dir,
page_margin: 36,
footer_height: 36,
footer_columns: '=100%',
footer_recto_center_content: %(above +\nimage:square.jpg[fit=line]),
footer_recto_right_content: nil,
footer_verso_center_content: %(image:square.jpg[fit=line] +\nbelow),
footer_verso_left_content: nil,
}

pdf = to_pdf <<~'END', pdf_theme: pdf_theme, enable_footer: true
recto
<<<
verso
END
images = get_images pdf
(expect images).to have_size 2
images.each do |image|
(expect image.data).to eql expected_image_data
end
(expect (get_images pdf, 1)).to have_size 1
(expect (get_images pdf, 2)).to have_size 1
(expect (pdf.page 1).text).to include 'above'
(expect (pdf.page 2).text).to include 'below'
end

it 'should support data URI image', visual: true do
image_data = File.binread fixture_file 'tux.png'
encoded_image_data = Base64.strict_encode64 image_data
Expand Down

0 comments on commit f6b96a8

Please sign in to comment.