diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-02-28 00:41:09 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2020-02-28 00:56:57 -0700 |
| commit | c8fea0f417344502d721efab131b867bcc44b6c8 (patch) | |
| tree | ef7459503ce7c29a70acafa913db53e900c0d8bc | |
| parent | 9197c387b9f6aa0d7dc1d4eb270ff61833a6eaa2 (diff) | |
resolves #1578 only suggest installing prawn-gmagick gem if not loaded (PR #1579)
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb | 2 | ||||
| -rw-r--r-- | spec/image_spec.rb | 9 |
4 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5da2ef46..f2175f5e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -12,6 +12,7 @@ Bug Fixes:: * do not hyphen a hyphen when hyphenation is enabled (#1562) * fix crash when applying text transform to heading cell in table body (#1575) * honor font style when looking for glyph in font +* only suggest installing prawn-gmagick gem if not loaded (#1578) == 1.5.2 (2020-02-21) - @mojavelinux diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index ba7c7824..7a3445f8 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -1527,7 +1527,7 @@ module Asciidoctor layout_caption node, category: :image, side: :bottom, block_align: alignment, block_width: rendered_w, max_width: @theme.image_caption_max_width if node.title? theme_margin :block, :bottom unless pinned rescue - on_image_error :exception, node, target, (opts.merge message: %(could not embed image: #{image_path}; #{$!.message}#{::Prawn::Errors::UnsupportedImageType === $! ? '; install prawn-gmagick gem to add support' : ''})) + on_image_error :exception, node, target, (opts.merge message: %(could not embed image: #{image_path}; #{$!.message}#{::Prawn::Errors::UnsupportedImageType === $! && !(defined? ::GMagick::Image) ? '; install prawn-gmagick gem to add support' : ''})) end end diff --git a/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb b/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb index dd915e18..32a16fd1 100644 --- a/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb +++ b/lib/asciidoctor/pdf/formatted_text/inline_image_arranger.rb @@ -115,7 +115,7 @@ module Asciidoctor::PDF::FormattedText fragment[:image_width] = fragment[:width] = image_w fragment[:image_height] = image_h rescue - logger.warn %(could not embed image: #{image_path}; #{$!.message}#{::Prawn::Errors::UnsupportedImageType === $! ? '; install prawn-gmagick gem to add support' : ''}) unless scratch + logger.warn %(could not embed image: #{image_path}; #{$!.message}#{::Prawn::Errors::UnsupportedImageType === $! && !(defined? ::GMagick::Image) ? '; install prawn-gmagick gem to add support' : ''}) unless scratch drop = true # delegate to cleanup logic in ensure block ensure # NOTE skip rendering image in scratch document or if image can't be loaded diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 8948e44d..c8515fe8 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -417,6 +417,15 @@ describe 'Asciidoctor::PDF::Converter - Image' do (expect pdf.images).to have_size 1 end end if defined? GMagick::Image + + it 'should not suggest installing prawn-gmagick if gem has already been loaded' do + ['::', ':'].each do |macro_delim| + (expect do + pdf = to_pdf %(image#{macro_delim}lorem-ipsum.yml[Unrecognized image format]), analyze: :image + (expect pdf.images).to have_size 0 + end).to log_message severity: :WARN, message: %(could not embed image: #{fixture_file 'lorem-ipsum.yml'}; image file is an unrecognised format) + end + end if defined? GMagick::Image end context 'BMP' do |
