diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 03:08:02 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2024-03-07 03:31:52 -0700 |
| commit | 9e661bfa10d4d62eee40171be2c77f9d58fc087b (patch) | |
| tree | d0a7d1202c9b046a50eb1872527d18808400c29f | |
| parent | 5d79b13dab365fca27fe4cb53420117b1674a914 (diff) | |
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
| -rw-r--r-- | CHANGELOG.adoc | 8 | ||||
| -rw-r--r-- | asciidoctor-pdf.gemspec | 2 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn-svg.rb | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb | 12 | ||||
| -rw-r--r-- | spec/image_spec.rb | 10 | ||||
| -rw-r--r-- | spec/reference/image-block-svg-with-local-svg.pdf | bin | 10460 -> 9669 bytes | |||
| -rw-r--r-- | spec/reference/image-inline-svg-with-local-svg.pdf | bin | 10546 -> 9788 bytes |
7 files changed, 26 insertions, 7 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0605d3a3..271665cc 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 diff --git a/asciidoctor-pdf.gemspec b/asciidoctor-pdf.gemspec index b73b4e82..161eb722 100644 --- a/asciidoctor-pdf.gemspec +++ b/asciidoctor-pdf.gemspec @@ -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' diff --git a/lib/asciidoctor/pdf/ext/prawn-svg.rb b/lib/asciidoctor/pdf/ext/prawn-svg.rb index 7e66f5a6..40597815 100644 --- a/lib/asciidoctor/pdf/ext/prawn-svg.rb +++ b/lib/asciidoctor/pdf/ext/prawn-svg.rb @@ -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' diff --git a/lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb b/lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb new file mode 100644 index 00000000..ae761dd5 --- /dev/null +++ b/lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb @@ -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) diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 1abcb752..5c6e3087 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -1157,23 +1157,23 @@ describe 'Asciidoctor::PDF::Converter - Image' do 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 diff --git a/spec/reference/image-block-svg-with-local-svg.pdf b/spec/reference/image-block-svg-with-local-svg.pdf Binary files differindex b48a3a9f..4e586303 100644 --- a/spec/reference/image-block-svg-with-local-svg.pdf +++ b/spec/reference/image-block-svg-with-local-svg.pdf diff --git a/spec/reference/image-inline-svg-with-local-svg.pdf b/spec/reference/image-inline-svg-with-local-svg.pdf Binary files differindex 43f914d9..eccdc5fa 100644 --- a/spec/reference/image-inline-svg-with-local-svg.pdf +++ b/spec/reference/image-inline-svg-with-local-svg.pdf |
