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 7ef2996 commit 02261a1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Bug Fixes::
* prevent special character substitution from interfering with callouts in plain verbatim block (#2390)
* remove deprecated, undocumented `svg-font-family` theme key (the correct key is `svg-fallback-font-family`)
* major improvement to OTF support following release of ttfunk 1.8.0 (automatic transitive dependency of prawn)
* 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.1.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)
12 changes: 6 additions & 6 deletions spec/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1217,23 +1217,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 <<~'END', '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.
END
(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).not_to log_message
end

it 'should not embed local SVG in block image', visual: true do
(expect do
to_file = to_pdf_file <<~'END', 'image-block-svg-with-local-svg.pdf'
.Lacks the red square
.Contains a red square
image::svg-with-local-svg.svg[pdfwidth=5in]
END
(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).not_to log_message
end
end

Expand Down Expand Up @@ -2211,7 +2211,7 @@ def traverse node
(expect to_file).to visually_match 'image-multiple-inline.pdf'
end

it 'should not mangle character spacing in line if inline image wraps', visual: true do
it '.only should not mangle character spacing in line if inline image wraps', visual: true do
to_file = to_pdf_file <<~'END', 'image-wrap-inline.pdf'
[cols="30e,58,12",width=75%]
|===
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 02261a1

Please sign in to comment.