asciidoctor-pdf 2.3.12 → 2.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +37 -0
- data/README.adoc +1 -1
- data/asciidoctor-pdf.gemspec +1 -1
- data/lib/asciidoctor/pdf/converter.rb +41 -24
- data/lib/asciidoctor/pdf/ext/asciidoctor/image.rb +3 -2
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +2 -0
- data/lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb +12 -0
- data/lib/asciidoctor/pdf/ext/prawn-svg.rb +1 -0
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39b6ad360fe1b653c7f0498edad3e45c8f76549e035f9dcdab76f088df362cbd
|
4
|
+
data.tar.gz: 81a541dc83a1aa325c3586fae64947e68128387634810512be01898b2096f684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fd8480e6c642612fe12656aef7208afee65fa6a126b56aa366d11dc11078271fc1744cb92d3849131f3c0948d5ccff6c4a1041a779b4244ebc9fbd768d26b8
|
7
|
+
data.tar.gz: 17378df2c24a571bb63334b4b2fe030f00ad9010dcbfeadef0fd4b626551984897841af0916228eac5bd11ff44f134ea9e6abf46cdf6a4a9a570995eca11bdeb
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,43 @@
|
|
5
5
|
This document provides a high-level view of the changes to the {project-name} by release.
|
6
6
|
For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
|
7
7
|
|
8
|
+
== 2.3.14 (2024-03-08) - @mojavelinux
|
9
|
+
|
10
|
+
Improvements::
|
11
|
+
|
12
|
+
* upgrade prawn-svg to 0.34 to add support for SVG referenced by image tag (SVG in SVG)
|
13
|
+
|
14
|
+
Bug Fixes::
|
15
|
+
|
16
|
+
* propagate source location to table cell for description in horizontal dlist so it is included in truncation warning message (#2502)
|
17
|
+
* eradicate use of the base64 library to fix warning about base64 gem when using Ruby >= 3.3
|
18
|
+
* 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
|
19
|
+
|
20
|
+
Build / Infrastructure::
|
21
|
+
|
22
|
+
* bump upper Ruby version to 3.3 in CI workflow
|
23
|
+
|
24
|
+
=== Details
|
25
|
+
|
26
|
+
{url-repo}/releases/tag/v2.3.14[git tag] | {url-repo}/compare/v2.3.13\...v2.3.14[full diff]
|
27
|
+
|
28
|
+
== 2.3.13 (2024-02-16) - @mojavelinux
|
29
|
+
|
30
|
+
Improvements::
|
31
|
+
|
32
|
+
* support toc start at value for page numbering and running content when toc is added using macro (#2489)
|
33
|
+
|
34
|
+
Bug Fixes::
|
35
|
+
|
36
|
+
* don't drop text on line above inline image macro in running content value (#2495)
|
37
|
+
* when looking for a value that only contains an image macro, match the whole string instead of per line (#2495)
|
38
|
+
* don't warn about missing character in fallback font when inline image is advanced to next page (#2492)
|
39
|
+
* fix page number of index entries in prepress book when page numbering starts at toc or after toc and toc is inserted using macro (#2487)
|
40
|
+
|
41
|
+
=== Details
|
42
|
+
|
43
|
+
{url-repo}/releases/tag/v2.3.13[git tag] | {url-repo}/compare/v2.3.12\...v2.3.13[full diff]
|
44
|
+
|
8
45
|
== 2.3.12 (2024-02-02) - @mojavelinux
|
9
46
|
|
10
47
|
Improvements::
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Asciidoctor PDF: A native PDF converter for AsciiDoc
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
-
v2.3.
|
3
|
+
v2.3.14, 2024-03-08
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
data/asciidoctor-pdf.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.add_runtime_dependency 'matrix', '~> 0.4' # required until prawn >= 2.5.0 is released
|
39
39
|
s.add_runtime_dependency 'prawn-table', '~> 0.2.0'
|
40
40
|
s.add_runtime_dependency 'prawn-templates', '~> 0.1.0'
|
41
|
-
s.add_runtime_dependency 'prawn-svg', '~> 0.
|
41
|
+
s.add_runtime_dependency 'prawn-svg', '~> 0.34.0'
|
42
42
|
s.add_runtime_dependency 'prawn-icon', '~> 3.0.0'
|
43
43
|
s.add_runtime_dependency 'concurrent-ruby', '~> 1.1'
|
44
44
|
s.add_runtime_dependency 'treetop', '~> 1.6.0'
|
@@ -109,7 +109,7 @@ module Asciidoctor
|
|
109
109
|
MeasurementPartsRx = /^(\d+(?:\.\d+)?)(in|mm|cm|p[txc])?$/
|
110
110
|
PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/
|
111
111
|
CalloutExtractRx = %r((?:(?://|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\2> ?(?=(?:\\?<!?\2(?:\d+|\.)\2> ?)*$))
|
112
|
-
ImageAttributeValueRx =
|
112
|
+
ImageAttributeValueRx = /^\Aimage:{1,2}(.*?)\[(.*?)\]$\Z/
|
113
113
|
StopPunctRx = /[.!?;:]$/
|
114
114
|
UriBreakCharsRx = %r((?:/|\?|&|#)(?!$))
|
115
115
|
UriBreakCharRepl = %(\\&#{ZeroWidthSpace})
|
@@ -174,7 +174,7 @@ module Asciidoctor
|
|
174
174
|
ink_cover_page doc, :front
|
175
175
|
has_front_cover = page_number > marked_page_number
|
176
176
|
doctype = doc.doctype
|
177
|
-
if (has_title_page = (
|
177
|
+
if (has_title_page = (title_as_page = doctype == 'book' || (doc.attr? 'title-page')) && (start_title_page doc))
|
178
178
|
# NOTE: the base font must be set before any content is written to the main or scratch document
|
179
179
|
font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style
|
180
180
|
if perform_on_single_page { ink_title_page doc }
|
@@ -189,7 +189,7 @@ module Asciidoctor
|
|
189
189
|
font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style
|
190
190
|
end
|
191
191
|
|
192
|
-
unless
|
192
|
+
unless title_as_page
|
193
193
|
body_start_page_number = page_number
|
194
194
|
theme_font :heading, level: 1 do
|
195
195
|
ink_general_heading doc, doc.doctitle, align: (@theme.heading_h1_text_align&.to_sym || :center), level: 1, role: :doctitle
|
@@ -200,10 +200,10 @@ module Asciidoctor
|
|
200
200
|
|
201
201
|
indent_section do
|
202
202
|
toc_num_levels = (doc.attr 'toclevels', 2).to_i
|
203
|
-
if (
|
203
|
+
if (toc_at_top = (doc.attr? 'toc') && !((toc_placement = doc.attr 'toc-placement') == 'macro' || toc_placement == 'preamble') && !(get_entries_for_toc doc).empty?)
|
204
204
|
start_new_page if @ppbook && verso_page?
|
205
205
|
add_dest_for_block doc, id: 'toc', y: (at_page_top? ? page_height : nil)
|
206
|
-
@toc_extent = allocate_toc doc, toc_num_levels, cursor, (
|
206
|
+
@toc_extent = allocate_toc doc, toc_num_levels, cursor, (title_as_page && theme.toc_break_after != 'auto')
|
207
207
|
else
|
208
208
|
@toc_extent = nil
|
209
209
|
end
|
@@ -215,7 +215,7 @@ module Asciidoctor
|
|
215
215
|
min_start_at = 1
|
216
216
|
end
|
217
217
|
|
218
|
-
if
|
218
|
+
if title_as_page
|
219
219
|
zero_page_offset = has_front_cover ? 1 : 0
|
220
220
|
first_page_offset = has_title_page ? zero_page_offset.next : zero_page_offset
|
221
221
|
body_offset = (body_start_page_number = page_number) - 1
|
@@ -228,8 +228,10 @@ module Asciidoctor
|
|
228
228
|
when 'title'
|
229
229
|
running_content_start_at = 'toc' unless has_title_page
|
230
230
|
when 'toc'
|
231
|
-
|
231
|
+
uses_start_at_toc = true
|
232
|
+
running_content_start_at = 'body' unless toc_at_top
|
232
233
|
when 'after-toc'
|
234
|
+
uses_start_at_after_toc = true
|
233
235
|
running_content_start_at = 'body'
|
234
236
|
end
|
235
237
|
end
|
@@ -248,8 +250,10 @@ module Asciidoctor
|
|
248
250
|
when 'title'
|
249
251
|
page_numbering_start_at = 'toc' unless has_title_page
|
250
252
|
when 'toc'
|
251
|
-
|
253
|
+
uses_start_at_toc = true
|
254
|
+
page_numbering_start_at = 'body' unless toc_at_top
|
252
255
|
when 'after-toc'
|
256
|
+
uses_start_at_after_toc = true
|
253
257
|
page_numbering_start_at = 'body'
|
254
258
|
end
|
255
259
|
end
|
@@ -303,12 +307,17 @@ module Asciidoctor
|
|
303
307
|
end
|
304
308
|
|
305
309
|
if (toc_extent = @toc_extent)
|
306
|
-
if
|
307
|
-
if
|
308
|
-
|
309
|
-
|
310
|
-
num_front_matter_pages[
|
311
|
-
|
310
|
+
if title_as_page && !toc_at_top && (uses_start_at_toc || uses_start_at_after_toc)
|
311
|
+
if uses_start_at_toc
|
312
|
+
toc_offset = toc_extent.from.page - 1
|
313
|
+
num_front_matter_pages[0] = toc_offset if @theme.running_content_start_at == 'toc'
|
314
|
+
num_front_matter_pages[1] = toc_offset if @theme.page_numbering_start_at == 'toc'
|
315
|
+
end
|
316
|
+
if uses_start_at_after_toc
|
317
|
+
after_toc_offset = toc_extent.to.page
|
318
|
+
after_toc_offset += 1 if @ppbook && (recto_page? after_toc_offset)
|
319
|
+
num_front_matter_pages[0] = after_toc_offset if @theme.running_content_start_at == 'after-toc'
|
320
|
+
num_front_matter_pages[1] = after_toc_offset if @theme.page_numbering_start_at == 'after-toc'
|
312
321
|
end
|
313
322
|
end
|
314
323
|
toc_page_nums = ink_toc doc, toc_num_levels, toc_extent.from.page, toc_extent.from.cursor, num_front_matter_pages[1]
|
@@ -1449,7 +1458,7 @@ module Asciidoctor
|
|
1449
1458
|
desc_container = Block.new node, :open
|
1450
1459
|
desc_container << (Block.new desc_container, :paragraph, source: (desc.instance_variable_get :@text), subs: :default) if desc.text?
|
1451
1460
|
desc.blocks.each {|b| desc_container << b.dup } if desc.blocks?
|
1452
|
-
row_data << { content: (::Prawn::Table::Cell::AsciiDoc.new self, content: (item[1] = desc_container), text_color: @font_color, padding: desc_padding, valign: :top) }
|
1461
|
+
row_data << { content: (::Prawn::Table::Cell::AsciiDoc.new self, content: (item[1] = desc_container), text_color: @font_color, padding: desc_padding, valign: :top, source_location: desc.source_location) }
|
1453
1462
|
else
|
1454
1463
|
row_data << {}
|
1455
1464
|
end
|
@@ -1712,7 +1721,7 @@ module Asciidoctor
|
|
1712
1721
|
if image_format == 'gif' && !(defined? ::GMagick::Image)
|
1713
1722
|
log :warn, %(GIF image format not supported. Install the prawn-gmagick gem or convert #{target} to PNG.)
|
1714
1723
|
image_path = nil
|
1715
|
-
elsif ::
|
1724
|
+
elsif ::Asciidoctor::Image::Base64Encoded === target
|
1716
1725
|
image_path = target
|
1717
1726
|
elsif (image_path = resolve_image_path node, target, image_format, (opts.fetch :relative_to_imagesdir, true))
|
1718
1727
|
if image_format == 'pdf'
|
@@ -1781,8 +1790,8 @@ module Asciidoctor
|
|
1781
1790
|
rendered_h = rendered_w = nil
|
1782
1791
|
span_page_width_if align_to_page do
|
1783
1792
|
if image_format == 'svg'
|
1784
|
-
if ::
|
1785
|
-
svg_data =
|
1793
|
+
if ::Asciidoctor::Image::Base64Encoded === image_path
|
1794
|
+
svg_data = image_path.unpack1 'm'
|
1786
1795
|
file_request_root = false
|
1787
1796
|
else
|
1788
1797
|
svg_data = ::File.read image_path, mode: 'r:UTF-8'
|
@@ -1833,8 +1842,8 @@ module Asciidoctor
|
|
1833
1842
|
else
|
1834
1843
|
# FIXME: this code really needs to be better organized!
|
1835
1844
|
# NOTE: use low-level API to access intrinsic dimensions; build_image_object caches image data previously loaded
|
1836
|
-
image_obj, image_info = ::
|
1837
|
-
::StringIO.open((
|
1845
|
+
image_obj, image_info = ::Asciidoctor::Image::Base64Encoded === image_path ?
|
1846
|
+
::StringIO.open((image_path.unpack1 'm'), 'rb') {|fd| build_image_object fd } :
|
1838
1847
|
::File.open(image_path, 'rb') {|fd| build_image_object fd }
|
1839
1848
|
actual_w = to_pt image_info.width, :px
|
1840
1849
|
width = actual_w * scale if scale
|
@@ -2368,8 +2377,16 @@ module Asciidoctor
|
|
2368
2377
|
if ((doc = node.document).attr? 'toc-placement', placement) && (doc.attr? 'toc') && !(get_entries_for_toc doc).empty?
|
2369
2378
|
start_toc_page node, placement if (is_book = doc.doctype == 'book')
|
2370
2379
|
add_dest_for_block node, id: (node.id || 'toc') if is_macro
|
2371
|
-
toc_extent = @toc_extent = allocate_toc doc, (doc.attr 'toclevels', 2).to_i, cursor, (
|
2372
|
-
|
2380
|
+
toc_extent = @toc_extent = allocate_toc doc, (doc.attr 'toclevels', 2).to_i, cursor, (title_as_page = is_book || (doc.attr? 'title-page'))
|
2381
|
+
if title_as_page
|
2382
|
+
if @theme.page_numbering_start_at == 'toc'
|
2383
|
+
@index.start_page_number = toc_extent.from.page
|
2384
|
+
elsif @theme.page_numbering_start_at == 'after-toc'
|
2385
|
+
new_start_page_number = toc_extent.to.page + 1
|
2386
|
+
new_start_page_number += 1 if @ppbook && (verso_page? new_start_page_number)
|
2387
|
+
@index.start_page_number = new_start_page_number
|
2388
|
+
end
|
2389
|
+
end
|
2373
2390
|
if is_macro
|
2374
2391
|
@disable_running_content[:header] += toc_extent.page_range if node.option? 'noheader'
|
2375
2392
|
@disable_running_content[:footer] += toc_extent.page_range if node.option? 'nofooter'
|
@@ -4296,11 +4313,11 @@ module Asciidoctor
|
|
4296
4313
|
end
|
4297
4314
|
@tmp_files ||= {}
|
4298
4315
|
# NOTE: base64 logic currently used for inline images
|
4299
|
-
if ::
|
4316
|
+
if ::Asciidoctor::Image::Base64Encoded === image_path
|
4300
4317
|
return @tmp_files[image_path] if @tmp_files.key? image_path
|
4301
4318
|
tmp_image = ::Tempfile.create %W(image- .#{image_format})
|
4302
4319
|
tmp_image.binmode unless image_format == 'svg'
|
4303
|
-
tmp_image.write
|
4320
|
+
tmp_image.write image_path.unpack1 'm'
|
4304
4321
|
tmp_image.close
|
4305
4322
|
@tmp_files[image_path] = tmp_image.path
|
4306
4323
|
# NOTE: this will catch a classloader resource path on JRuby (e.g., uri:classloader:/path/to/image)
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Asciidoctor
|
4
4
|
module Image
|
5
|
+
Base64Encoded = ::Module.new
|
5
6
|
DataUriRx = %r(^data:image/(?<fmt>png|jpe?g|gif|pdf|bmp|tiff|svg\+xml);base64,(?<data>.*)$)
|
6
7
|
FormatAliases = { 'jpg' => 'jpeg', 'svg+xml' => 'svg' }
|
7
8
|
|
@@ -11,7 +12,7 @@ module Asciidoctor
|
|
11
12
|
|
12
13
|
def self.target_and_format image_path, attributes = nil
|
13
14
|
if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
|
14
|
-
[(m[:data].extend
|
15
|
+
[(m[:data].extend Base64Encoded), (FormatAliases.fetch m[:fmt], m[:fmt])]
|
15
16
|
else
|
16
17
|
[image_path, attributes&.[]('format') || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
|
17
18
|
end
|
@@ -20,7 +21,7 @@ module Asciidoctor
|
|
20
21
|
def target_and_format
|
21
22
|
image_path = inline? ? target : (attr 'target')
|
22
23
|
if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
|
23
|
-
[(m[:data].extend
|
24
|
+
[(m[:data].extend Base64Encoded), (FormatAliases.fetch m[:fmt], m[:fmt])]
|
24
25
|
else
|
25
26
|
[image_path, (attr 'format', nil, false) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
|
26
27
|
end
|
@@ -33,7 +33,9 @@ Prawn::Text::Formatted::Box.prepend (Module.new do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
# help Prawn correctly resolve which font to analyze, including the font style
|
36
|
+
# also instruct Prawn to ignore fragment for inline image since the text is just a placeholder
|
36
37
|
def analyze_glyphs_for_fallback_font_support fragment_hash
|
38
|
+
return [fragment_hash] if fragment_hash[:image_obj]
|
37
39
|
fragment_font = fragment_hash[:font] || (original_font = @document.font.family)
|
38
40
|
effective_font_styles = @document.font_styles
|
39
41
|
fragment_font_opts = {}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# see https://github.com/mogest/prawn-svg/issues/164
|
4
|
+
Prawn::SVG::Elements::Use.prepend (Module.new do
|
5
|
+
def parse
|
6
|
+
result = super
|
7
|
+
if @referenced_element_source.name == 'symbol' && !(@referenced_element_source.attributes.key? 'viewBox')
|
8
|
+
@referenced_element_class = Prawn::SVG::Elements::Container
|
9
|
+
end
|
10
|
+
result
|
11
|
+
end
|
12
|
+
end)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'prawn-svg'
|
4
4
|
require_relative 'prawn-svg/calculators/document_sizing'
|
5
5
|
require_relative 'prawn-svg/elements/image'
|
6
|
+
require_relative 'prawn-svg/elements/use'
|
6
7
|
require_relative 'prawn-svg/loaders/data'
|
7
8
|
require_relative 'prawn-svg/loaders/file'
|
8
9
|
require_relative 'prawn-svg/loaders/web'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: 0.34.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.34.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: prawn-icon
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- lib/asciidoctor/pdf/ext/prawn-svg.rb
|
263
263
|
- lib/asciidoctor/pdf/ext/prawn-svg/calculators/document_sizing.rb
|
264
264
|
- lib/asciidoctor/pdf/ext/prawn-svg/elements/image.rb
|
265
|
+
- lib/asciidoctor/pdf/ext/prawn-svg/elements/use.rb
|
265
266
|
- lib/asciidoctor/pdf/ext/prawn-svg/loaders/data.rb
|
266
267
|
- lib/asciidoctor/pdf/ext/prawn-svg/loaders/file.rb
|
267
268
|
- lib/asciidoctor/pdf/ext/prawn-svg/loaders/web.rb
|
@@ -335,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
335
336
|
- !ruby/object:Gem::Version
|
336
337
|
version: '0'
|
337
338
|
requirements: []
|
338
|
-
rubygems_version: 3.3
|
339
|
+
rubygems_version: 3.5.3
|
339
340
|
signing_key:
|
340
341
|
specification_version: 4
|
341
342
|
summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn
|