diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-06-01 04:36:23 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-01 04:36:23 -0600 |
| commit | 437cd7c45270ceccebf5db73f43d0b186a3bf093 (patch) | |
| tree | ff1e467b172616bb13a01876b5975949239b2419 | |
| parent | 51477f8778fc19f549325587c8f25358347efb46 (diff) | |
resolves #731 warn if image referenced in running content is missing (PR #1085)
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor-pdf/converter.rb | 30 |
2 files changed, 18 insertions, 13 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 336b9d0d..18c7c43c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -30,6 +30,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[ * ensure index section doesn't get numbered when using Asciidoctor < 1.5.7 * add part signifier and part number to part title if partnums is set; allow signifier to be customized using part-signifier attribute (#597) * add support for the chapter-signifier attribute as the prefered alternative to chapter-label +* warn if the image referenced in the running content cannot be found (#731) == 1.5.0.alpha.17 (2019-04-23) - @mojavelinux diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb index 2fff5f83..5b41ea8d 100644 --- a/lib/asciidoctor-pdf/converter.rb +++ b/lib/asciidoctor-pdf/converter.rb @@ -2913,21 +2913,25 @@ class Converter < ::Prawn::Document ColumnPositions.each do |position| unless (val = @theme[%(#{periphery}_#{side}_#{position}_content)]).nil_or_empty? # TODO support image URL (using resolve_image_path) - if (val.include? ':') && val =~ ImageAttributeValueRx && - ::File.readable?(path = (ThemeLoader.resolve_theme_asset $1, (doc.attr 'pdf-stylesdir'))) - attrs = (AttributeList.new $2).parse - col_width = colspec_dict[side][position][:width] - if (fit = attrs['fit']) == 'contain' - width = col_width - else - unless (width = resolve_explicit_width attrs, col_width) - # QUESTION should we lookup and scale intrinsic width if explicit width is not given? - # NOTE failure message will be reported later when image is rendered - width = (to_pt intrinsic_image_dimensions(path)[:width], :px) rescue 0 + if (val.include? ':') && val =~ ImageAttributeValueRx + if ::File.readable?(path = (ThemeLoader.resolve_theme_asset $1, (doc.attr 'pdf-stylesdir'))) + attrs = (AttributeList.new $2).parse + col_width = colspec_dict[side][position][:width] + if (fit = attrs['fit']) == 'contain' + width = col_width + else + unless (width = resolve_explicit_width attrs, col_width) + # QUESTION should we lookup and scale intrinsic width if explicit width is not given? + # NOTE failure message will be reported later when image is rendered + width = (to_pt intrinsic_image_dimensions(path)[:width], :px) rescue 0 + end + width = col_width if fit == 'scale-down' && width > col_width end - width = col_width if fit == 'scale-down' && width > col_width + side_content[position] = { path: path, width: width, fit: !!fit } + else + logger.warn %(image to embed not found or not readable: #{path}) + side_content[position] = val end - side_content[position] = { path: path, width: width, fit: !!fit } else side_content[position] = val end |
