Skip to content

Commit

Permalink
upgrade prawn-svg to 0.34 to fix warning about base64 gem when using …
Browse files Browse the repository at this point in the history
…Ruby >= 3.3; apply additional patch to fix bug in prawn-svg
  • Loading branch information
mojavelinux committed Mar 7, 2024
1 parent 5d79b13 commit 9e661bf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co

== Unreleased

_No changes since previous release._
Improvements::

* upgrade prawn-svg to 0.34 to add support for SVG referenced by image tag (SVG in SVG)

Bug Fixes::

* upgrade prawn-svg to 0.34 to fix warning about base64 gem when using Ruby >= 3.3; apply additional patch to fix bug in prawn-svg

== 2.3.13 (2024-02-16) - @mojavelinux

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.33.0'
s.add_runtime_dependency 'prawn-svg', '~> 0.34.0'
s.add_runtime_dependency 'prawn-icon', '~> 3.0.0'
s.add_runtime_dependency 'concurrent-ruby', '~> 1.1'
s.add_runtime_dependency 'treetop', '~> 1.6.0'
Expand Down
1 change: 1 addition & 0 deletions lib/asciidoctor/pdf/ext/prawn-svg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'prawn-svg'
require_relative 'prawn-svg/calculators/document_sizing'
require_relative 'prawn-svg/elements/image'
require_relative 'prawn-svg/elements/use'
require_relative 'prawn-svg/loaders/data'
require_relative 'prawn-svg/loaders/file'
require_relative 'prawn-svg/loaders/web'
Expand Down
12 changes: 12 additions & 0 deletions lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# see https://github.com/mogest/prawn-svg/issues/164
Prawn::SVG::Elements::Use.prepend (Module.new do
def parse
result = super
if @referenced_element_source.name == 'symbol' && !(@referenced_element_source.attributes.key? 'viewBox')
@referenced_element_class = Prawn::SVG::Elements::Container
end
result
end
end)
10 changes: 5 additions & 5 deletions spec/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1157,23 +1157,23 @@ def traverse node
end
end

it 'should not embed local SVG in inline image', visual: true do
it 'should embed local SVG in inline image', visual: true do
(expect do
to_file = to_pdf_file <<~'EOS', 'image-inline-svg-with-local-svg.pdf'
image:svg-with-local-svg.svg[pdfwidth=1.27cm] lacks the red square.
image:svg-with-local-svg.svg[pdfwidth=1.27cm] contains a red square.
EOS
(expect to_file).to visually_match 'image-inline-svg-with-local-svg.pdf'
end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'svg-with-local-svg.svg'}; Unsupported image type supplied to image tag)
end).to not_log_message
end

it 'should not embed local SVG in block image', visual: true do
(expect do
to_file = to_pdf_file <<~'EOS', 'image-block-svg-with-local-svg.pdf'
.Lacks the red square
.Contains a red square
image::svg-with-local-svg.svg[pdfwidth=5in]
EOS
(expect to_file).to visually_match 'image-block-svg-with-local-svg.pdf'
end).to log_message severity: :WARN, message: %(~problem encountered in image: #{fixture_file 'svg-with-local-svg.svg'}; Unsupported image type supplied to image tag)
end).to not_log_message
end
end

Expand Down
Binary file modified spec/reference/image-block-svg-with-local-svg.pdf
Binary file not shown.
Binary file modified spec/reference/image-inline-svg-with-local-svg.pdf
Binary file not shown.

0 comments on commit 9e661bf

Please sign in to comment.