diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 4a7deb1f1..527d2ca5d 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index a11a69106..01b8d0bc7 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -109,7 +109,7 @@ class Converter < ::Prawn::Document PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/ CalloutExtractRx = %r((?:(?://|#|--|;;) ?)?(\\)? ?(?=(?:\\? ?)*$)) CalloutConflictRx = /([<>&])(; *)/ - ImageAttributeValueRx = /^image:{1,2}(.*?)\[(.*?)\]$/ + ImageAttributeValueRx = /\Aimage:{1,2}(.*?)\[(.*?)\]\Z/ StopPunctRx = /[.!?;:]$/ UriBreakCharsRx = %r((?:/|\?|&|#)(?!$)) UriBreakCharRepl = %(\\&#{ZeroWidthSpace}) diff --git a/spec/running_content_spec.rb b/spec/running_content_spec.rb index 17a480901..b4f3beff8 100644 --- a/spec/running_content_spec.rb +++ b/spec/running_content_spec.rb @@ -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