Skip to content

Commit

Permalink
resolves #731 warn if image referenced in running content is missing …
Browse files Browse the repository at this point in the history
…(PR #1085)
  • Loading branch information
mojavelinux authored Jun 1, 2019
1 parent 51477f8 commit 437cd7c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 17 additions & 13 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2913,21 +2913,25 @@ def layout_running_content periphery, doc, opts = {}
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
Expand Down

0 comments on commit 437cd7c

Please sign in to comment.