Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #2495 don't drop text on line above inline image macro in running content value #2496

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading