summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-11 16:57:52 -0600
committerGitHub <noreply@github.com>2022-05-11 16:57:52 -0600
commit6a91de0db46c2715527140c70c0a9e17df7c358a (patch)
treedf567917bd28568d7b57847416a7c1aa46699f30 /spec
parenta0e2297b43d31b6ae26967342dc40a9631630ac5 (diff)
resolves #2156 honor caption-align when element align is not left and caption-max-width is % of element width (PR #2157)
Diffstat (limited to 'spec')
-rw-r--r--spec/image_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index 0b57e273..704a2211 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -2059,6 +2059,39 @@ describe 'Asciidoctor::PDF::Converter - Image' do
(expect caption_text_l1[:x]).to eql tux_image[:x]
(expect caption_text_l2[:x]).to eql caption_text_l1[:x]
end
+
+ it 'should align caption within width of image if alignment is fixed and max-width is percentage of image width' do
+ pdf_theme = {
+ image_caption_align: 'left',
+ image_caption_max_width: 'fit-content(50%)',
+ }
+
+ input = <<~'EOS'
+ .This is a picture of our beloved Tux.
+ image::tux.png[align=right]
+ EOS
+
+ pdf = to_pdf input, pdf_theme: pdf_theme, analyze: :image
+
+ images = pdf.images
+ (expect images).to have_size 1
+ tux_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 eql tux_image[:x]
+ (expect caption_text_l2[:x]).to eql caption_text_l1[:x]
+ (expect caption_text_l3[:x]).to eql caption_text_l2[:x]
+ end
end
context 'Border' do