diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-05-11 18:53:21 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-11 18:53:21 -0600 |
| commit | ba5e2881e0f4eb44569e152588cf5e06b0f318c9 (patch) | |
| tree | 377be0dcc65e599cade9227ccd65896dcf2f40c8 /spec | |
| parent | 023dbcb7fe834ec4bf7634ed64c80369bff6472d (diff) | |
resolves #2150 coerce image-caption-max-width to fit-content if float attribute is set on block image (PR #2160)
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/image_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 704a2211..36299557 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -2010,6 +2010,46 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect caption_text_l1[:x] + caption_text_l1[:width]).to be_within(1).of caption_text_l2[:x] + caption_text_l2[:width] end + it 'should configure caption width to fit image width if float attribute is set on image' do + input = <<~'EOS' + .This is a picture of our beloved Tux. + image::tux.png[align=right,float=right] + EOS + + tux_image = (to_pdf input, analyze: :image).images[0] + pdf = to_pdf input, analyze: true + caption_texts = pdf.text + (expect caption_texts).to have_size 2 + caption_text_l1, caption_text_l2 = caption_texts + (expect caption_text_l1[:y]).to be > caption_text_l2[:y] + (expect caption_text_l1[:string]).to start_with 'Figure 1.' + (expect caption_text_l1[:width]).to be < tux_image[:width] + (expect caption_text_l2[:width]).to be < tux_image[:width] + (expect caption_text_l1[:x]).to eql tux_image[:x] + (expect caption_text_l2[:x]).to eql caption_text_l1[:x] + end + + it 'should not change caption width if float attribute is set on image and caption max width is fit-content' do + pdf_theme = { image_caption_align: 'inherit', image_caption_max_width: 'fit-content(50%)' } + input = <<~'EOS' + .This is a picture of our beloved Tux. + image::tux.png[align=right,float=right] + EOS + + tux_image = (to_pdf input, pdf_theme: pdf_theme, analyze: :image).images[0] + pdf = to_pdf input, pdf_theme: pdf_theme, analyze: true + caption_texts = pdf.text + (expect caption_texts).to have_size 3 + caption_text_l1, caption_text_l2, caption_text_l3 = caption_texts + (expect caption_text_l1[:y]).to be > caption_text_l2[:y] + (expect caption_text_l2[:y]).to be > caption_text_l3[:y] + (expect caption_text_l1[:string]).to start_with 'Figure 1.' + (expect caption_text_l1[:width]).to be < (tux_image[:width] * 0.5) + (expect caption_text_l2[:width]).to be < (tux_image[:width] * 0.5) + (expect caption_text_l3[:width]).to be < (tux_image[:width] * 0.5) + (expect caption_text_l1[:x]).to be > (tux_image[:x] + tux_image[:width] * 0.5) + end + it 'should restrict caption width to percentage of image width if max-width is fit-content function' do pdf_theme = { image_caption_align: 'inherit', |
