Skip to content

Commit

Permalink
update prawn-svg to 0.36.2 and amend related assertions (PR #2553)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Feb 11, 2025
1 parent a58deda commit 97b6d99
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Improvements::
* drop support for the unmaintained payment font (`pf`) for use in font-based icons
* refactor formatted text transform to simplify how inner space is collapsed; verify only inner hard breaks are preserved
* allow relative font size for sub and sup to be set independently; support combined setting for backwards compatibility
* upgrade prawn-svg to 0.36 to fix dependencies, improve gradient support, and support additional properties; disable experimental warnings when requiring prawn-svg on Ruby 2.7 (#2551)

Bug Fixes::

Expand Down
2 changes: 1 addition & 1 deletion asciidoctor-pdf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'matrix', '~> 0.4' # required until prawn >= 2.5.0 is released
s.add_runtime_dependency 'prawn-table', '~> 0.2.0'
s.add_runtime_dependency 'prawn-templates', '~> 0.1.0'
s.add_runtime_dependency 'prawn-svg', '~> 0.34.0'
s.add_runtime_dependency 'prawn-svg', '~> 0.36.0'
s.add_runtime_dependency 'prawn-icon', '~> 3.1.0'
s.add_runtime_dependency 'concurrent-ruby', '~> 1.1'
s.add_runtime_dependency 'treetop', '~> 1.6.0'
Expand Down
8 changes: 7 additions & 1 deletion lib/asciidoctor/pdf/ext/prawn-svg.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# frozen_string_literal: true

require 'prawn-svg'
if Warning[:experimental] && (RUBY_VERSION.start_with? '2.')
Warning[:experimental] = false
require 'prawn-svg'
Warning[:experimental] = true
else
require 'prawn-svg'
end
require_relative 'prawn-svg/calculators/document_sizing'
require_relative 'prawn-svg/elements/image'
require_relative 'prawn-svg/elements/use'
Expand Down
4 changes: 2 additions & 2 deletions spec/admonition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@
label_text = pdf.find_unique_text 'TIP'
(expect label_text).not_to be_nil
(expect label_text[:font_name]).to include 'Bold'
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end

it 'should resize fallback admonition label to fit in available space if icon fails to embed' do
Expand All @@ -726,7 +726,7 @@
label_text = pdf.find_unique_text 'WARNING'
(expect label_text).not_to be_nil
(expect label_text[:font_size]).to be < 10.5
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~could not embed admonition icon image: #{fixture_file 'broken.svg'}; The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end

# NOTE: this test also verifies the text transform is applied as requested by theme
Expand Down
2 changes: 1 addition & 1 deletion spec/cover_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

(expect pdf.pages).to have_size 1
(expect pdf.lines pdf.find_text page_number: 1).to eql ['content page']
end).to log_message severity: :WARN, message: %(~could not embed front cover image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~could not embed front cover image: #{fixture_file 'broken.svg'}; The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end

it 'should not add cover page if value is ~' do
Expand Down
2 changes: 1 addition & 1 deletion spec/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ def traverse node
(expect do
pdf = to_pdf %(image#{macro_delim}broken.svg[Broken SVG]), analyze: true
(expect pdf.lines).to eql [alt_text]
end).to log_message severity: :WARN, message: %(~could not embed image: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~could not embed image: #{fixture_file 'broken.svg'}; The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@
content
END
(expect pdf.images).to be_empty
end).to log_message severity: :WARN, message: %(~Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end

it 'should only warn once if background image cannot be loaded' do
Expand Down
Binary file modified spec/reference/image-svg-with-gradient.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/running_content_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,7 @@
pdf = to_pdf 'body', analyze: true, pdf_theme: pdf_theme, enable_footer: true
footer_text = pdf.find_unique_text font_color: '0000FF'
(expect footer_text[:string]).to eql '[no worky]'
end).to log_message severity: :WARN, message: %(~could not embed image in running content: #{fixture_file 'broken.svg'}; Missing end tag for 'rect')
end).to log_message severity: :WARN, message: %(~could not embed image in running content: #{fixture_file 'broken.svg'}; The data supplied is not a valid SVG document.\nMissing end tag for 'rect')
end

it 'should resolve attribute references in target of inline image' do
Expand Down

0 comments on commit 97b6d99

Please sign in to comment.