diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6055fadd8..f20aa4f3c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -9,6 +9,8 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co 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) * support toc start at value for page numbering and running content when toc is added using macro (#2489) * fix page number of index entries in prepress book when page numbering starts at toc or after toc and toc is inserted using macro (#2487) diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 4c3ace373..f2b315348 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -109,7 +109,7 @@ class Converter < ::Prawn::Document MeasurementPartsRx = /^(\d+(?:\.\d+)?)(in|mm|cm|p[txc])?$/ PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/ CalloutExtractRx = %r((?:(?://|#|--|;;) ?)?(\\)? ?(?=(?:\\? ?)*$)) - 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 d2eb6482e..ceb504bbb 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 <<~'EOS', pdf_theme: pdf_theme, enable_footer: true + recto + + <<< + + verso + EOS + 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