asciidoctor-pdf 2.0.2 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +37 -0
- data/README.adoc +3 -10
- data/lib/asciidoctor/pdf/converter.rb +30 -18
- data/lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb +6 -2
- data/lib/asciidoctor/pdf/formatted_text/inline_text_aligner.rb +9 -4
- data/lib/asciidoctor/pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c80f2acfd251ff6721a173c153551989ca3372a3a51ddbf628176f24dd84f5f
|
4
|
+
data.tar.gz: 19c675f8b088711366559a831dcea41e2008a242dc4e19a321f7e40df50e1acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994846a17ff30b567e29a7a14f63c8d74348ac1644a4bd9ce1d85e687736c8f0a241a5f1fa91a84c52b3ecb9c66ef68701162bdf53fd7e5733c4e6df7b19f81b
|
7
|
+
data.tar.gz: 3889ba7c0cee283800c613a6d8d5e2c34b29d1cccb3d68a5d83c09c9ff300e1550c6cf28ffdc5b3b3873a35f14b6ad2b90a75f6e97431d0667c6c4b62a1e5a79
|
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.0.5 (2022-05-26) - @mojavelinux
|
9
|
+
|
10
|
+
Bug Fixes::
|
11
|
+
|
12
|
+
* do not filter TOC entries without an ID when computing the TOC extent (#2210)
|
13
|
+
* fix width of multi-word phrase with background and border offset (#2059)
|
14
|
+
|
15
|
+
=== Details
|
16
|
+
|
17
|
+
{url-repo}/releases/tag/v2.0.5[git tag] | {url-repo}/compare/v2.0.4\...v2.0.5[full diff]
|
18
|
+
|
19
|
+
== 2.0.4 (2022-05-25) - @mojavelinux
|
20
|
+
|
21
|
+
Bug Fixes::
|
22
|
+
|
23
|
+
* fix calculation of TOC extent when TOC entry has children but no ID (#2208)
|
24
|
+
|
25
|
+
=== Details
|
26
|
+
|
27
|
+
{url-repo}/releases/tag/v2.0.4[git tag] | {url-repo}/compare/v2.0.3\...v2.0.4[full diff]
|
28
|
+
|
29
|
+
== 2.0.3 (2022-05-25) - @mojavelinux
|
30
|
+
|
31
|
+
Improvements::
|
32
|
+
|
33
|
+
* compute the optimize settings in init_pdf and store as Hash instead of after writing the PDF file
|
34
|
+
|
35
|
+
Bug Fixes::
|
36
|
+
|
37
|
+
* adjust TrimBox to fit inside of BleedBox when using optimizer and compliance is PDF/X (#2203)
|
38
|
+
* set height of resized image to available height to avoid float precision error when scaling down image to fit page (#2205)
|
39
|
+
* prevent content on title page from overrunning the bounds of a single page and warn; restriction applies to `ink_title_page`
|
40
|
+
|
41
|
+
=== Details
|
42
|
+
|
43
|
+
{url-repo}/releases/tag/v2.0.3[git tag] | {url-repo}/compare/v2.0.2\...v2.0.3[full diff]
|
44
|
+
|
8
45
|
== 2.0.2 (2022-05-22) - @mojavelinux
|
9
46
|
|
10
47
|
Bug Fixes::
|
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.0.
|
3
|
+
v2.0.5, 2022-05-26
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -24,7 +24,7 @@ endif::[]
|
|
24
24
|
:project-handle: asciidoctor-pdf
|
25
25
|
// Variables:
|
26
26
|
:release-line: 2.0.x
|
27
|
-
:release-version: 2.0.
|
27
|
+
:release-version: 2.0.5
|
28
28
|
// URLs:
|
29
29
|
:url-gem: https://rubygems.org/gems/asciidoctor-pdf
|
30
30
|
:url-project: https://github.com/asciidoctor/asciidoctor-pdf
|
@@ -97,14 +97,7 @@ Pass the name of the gem to the `gem install` command as follows:
|
|
97
97
|
Installing Asciidoctor PDF will install a number of other gems mentioned in these docs, including asciidoctor, prawn, prawn-svg, prawn-table, prawn-icon, and ttfunk.
|
98
98
|
For the most part, the versions of these dependencies are locked to the version of Asciidoctor PDF.
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
$ gem install matrix
|
103
|
-
|
104
|
-
The matrix gem used to be bundled in the Ruby distribution, but was split out starting in Ruby 3.1.
|
105
|
-
This requirement will be lifted once Prawn declares it as a runtime dependency.
|
106
|
-
|
107
|
-
For further installation information, see {url-project-docs}/install/[the installation documentation].
|
100
|
+
For further installation information about installing Asciidoctor PDF, see {url-project-docs}/install/[the installation documentation].
|
108
101
|
For troubleshooting help, see {url-project-docs}/install/#installation-troubleshooting[Installation troubleshooting].
|
109
102
|
|
110
103
|
=== Install a prerelease or development version
|
@@ -174,7 +174,9 @@ module Asciidoctor
|
|
174
174
|
if (has_title_page = (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page')) && (start_title_page doc))
|
175
175
|
# NOTE: the base font must be set before any content is written to the main or scratch document
|
176
176
|
font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style
|
177
|
-
ink_title_page doc
|
177
|
+
if perform_on_single_page { ink_title_page doc }
|
178
|
+
log :warn, 'the title page contents has been truncated to prevent it from overrunning the bounds of a single page'
|
179
|
+
end
|
178
180
|
start_new_page
|
179
181
|
else
|
180
182
|
@page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress' && page_number == 0
|
@@ -321,6 +323,7 @@ module Asciidoctor
|
|
321
323
|
stamp_foreground_image doc, has_front_cover
|
322
324
|
ink_cover_page doc, :back
|
323
325
|
add_dest_for_top doc
|
326
|
+
state.pages.each {|it| fit_trim_box it } if (@optimize&.[] :compliance)&.start_with? 'PDF/X'
|
324
327
|
nil
|
325
328
|
end
|
326
329
|
|
@@ -411,8 +414,14 @@ module Asciidoctor
|
|
411
414
|
# NOTE: we have to init Pdfmark class here while we have reference to the doc
|
412
415
|
@pdfmark = (doc.attr? 'pdfmark') ? (Pdfmark.new doc) : nil
|
413
416
|
# NOTE: defer instantiating optimizer until we know min pdf version
|
414
|
-
if (
|
415
|
-
|
417
|
+
if (optimize = doc.attr 'optimize') &&
|
418
|
+
((defined? ::Asciidoctor::PDF::Optimizer) || !(Helpers.require_library OptimizerRequirePath, 'rghost', :warn).nil?)
|
419
|
+
@optimize = (optimize.include? ',') ?
|
420
|
+
([:quality, :compliance].zip (optimize.split ',', 2)).to_h :
|
421
|
+
((optimize.include? '/') ? { compliance: optimize } : { quality: optimize })
|
422
|
+
fit_trim_box if @optimize[:compliance]&.start_with? 'PDF/X'
|
423
|
+
else
|
424
|
+
@optimize = nil
|
416
425
|
end
|
417
426
|
allocate_scratch_prototype
|
418
427
|
self
|
@@ -1110,11 +1119,11 @@ module Asciidoctor
|
|
1110
1119
|
end
|
1111
1120
|
if (srclang = node.attr 'language')
|
1112
1121
|
if srclang.include? '?'
|
1113
|
-
if (lexer = ::Rouge::Lexer.find_fancy srclang)
|
1122
|
+
if (lexer = ::Rouge::Lexer.find_fancy srclang)&.tag == 'php' && !(node.option? 'mixed') && !((lexer_opts = lexer.options).key? 'start_inline')
|
1114
1123
|
lexer = lexer.class.new lexer_opts.merge 'start_inline' => true
|
1115
1124
|
end
|
1116
|
-
elsif (lexer = ::Rouge::Lexer.find srclang)
|
1117
|
-
lexer = lexer.new start_inline: true
|
1125
|
+
elsif (lexer = ::Rouge::Lexer.find srclang)&.tag == 'php' && !(node.option? 'mixed')
|
1126
|
+
lexer = lexer.new start_inline: true
|
1118
1127
|
end
|
1119
1128
|
end
|
1120
1129
|
lexer ||= ::Rouge::Lexers::PlainText
|
@@ -1205,10 +1214,10 @@ module Asciidoctor
|
|
1205
1214
|
b_left_width = nil
|
1206
1215
|
b_width = nil if (b_width = @theme[%(#{category}_border_width)]) == 0
|
1207
1216
|
end
|
1208
|
-
if (attribution =
|
1217
|
+
if (attribution = node.attr 'attribution')
|
1209
1218
|
# NOTE: temporary workaround to allow bare & to be used without having to wrap value in single quotes
|
1210
1219
|
attribution = escape_amp attribution if attribution.include? '&'
|
1211
|
-
if (citetitle = node.attr 'citetitle')
|
1220
|
+
if (citetitle = node.attr 'citetitle')&.include? '&'
|
1212
1221
|
citetitle = escape_amp citetitle
|
1213
1222
|
end
|
1214
1223
|
end
|
@@ -1760,7 +1769,7 @@ module Asciidoctor
|
|
1760
1769
|
advance_page
|
1761
1770
|
available_h = cursor - caption_h
|
1762
1771
|
end
|
1763
|
-
rendered_w
|
1772
|
+
rendered_w = (image_info.calc_image_dimensions height: (rendered_h = available_h))[0] if rendered_h > available_h
|
1764
1773
|
end
|
1765
1774
|
add_dest_for_block node if node.id
|
1766
1775
|
# NOTE: workaround to fix Prawn not adding fill and stroke commands on page that only has an image;
|
@@ -3608,7 +3617,6 @@ module Asciidoctor
|
|
3608
3617
|
end
|
3609
3618
|
end
|
3610
3619
|
|
3611
|
-
# TODO: prevent content from spilling to next page
|
3612
3620
|
theme_font :title_page do
|
3613
3621
|
if (title_top = @theme.title_page_title_top)
|
3614
3622
|
@y = resolve_top title_top
|
@@ -3748,7 +3756,6 @@ module Asciidoctor
|
|
3748
3756
|
hanging_indent = @theme.toc_hanging_indent
|
3749
3757
|
entries.each do |entry|
|
3750
3758
|
next if (num_levels_for_entry = (entry.attr 'toclevels', num_levels).to_i) < (entry_level = entry.level + 1).pred ||
|
3751
|
-
!(entry_anchor = (entry.attr 'pdf-anchor') || entry.id) ||
|
3752
3759
|
((entry.option? 'notitle') && entry == entry.document.last_child && entry.empty?)
|
3753
3760
|
theme_font :toc, level: entry_level do
|
3754
3761
|
entry_title = entry.context == :section ? entry.numbered_title : (entry.title? ? entry.title : (entry.xreftext 'basic'))
|
@@ -3762,6 +3769,7 @@ module Asciidoctor
|
|
3762
3769
|
ink_prose entry_title, anchor: true, normalize: false, hanging_indent: hanging_indent, normalize_line_height: true, margin: 0
|
3763
3770
|
end
|
3764
3771
|
else
|
3772
|
+
entry_anchor = (entry.attr 'pdf-anchor') || entry.id
|
3765
3773
|
if !(physical_pgnum = entry.attr 'pdf-page-start') &&
|
3766
3774
|
(target_page_ref = (get_dest entry_anchor)&.first) &&
|
3767
3775
|
(target_page_idx = state.pages.index {|candidate| candidate.dictionary == target_page_ref })
|
@@ -4403,13 +4411,8 @@ module Asciidoctor
|
|
4403
4411
|
pdf_doc.render_file target
|
4404
4412
|
# QUESTION: restore attributes first?
|
4405
4413
|
@pdfmark&.generate_file target
|
4406
|
-
if (
|
4407
|
-
|
4408
|
-
quality, compliance = quality.split ',', 2
|
4409
|
-
elsif quality.include? '/'
|
4410
|
-
quality, compliance = nil, quality
|
4411
|
-
end
|
4412
|
-
(Optimizer.new quality, pdf_doc.min_version, compliance).optimize_file target
|
4414
|
+
if (optimize = @optimize)
|
4415
|
+
(Optimizer.new optimize[:quality], pdf_doc.min_version, optimize[:compliance]).optimize_file target
|
4413
4416
|
end
|
4414
4417
|
to_file = true
|
4415
4418
|
end
|
@@ -4636,6 +4639,15 @@ module Asciidoctor
|
|
4636
4639
|
(max_height = bounds.height) < preferred_size ? max_height : preferred_size
|
4637
4640
|
end
|
4638
4641
|
|
4642
|
+
def fit_trim_box page_ = page
|
4643
|
+
page_.dictionary.data[:TrimBox].tap do |trim_box|
|
4644
|
+
trim_box[0] += 1e-4
|
4645
|
+
trim_box[1] += 1e-4
|
4646
|
+
trim_box[2] -= 1e-4
|
4647
|
+
trim_box[3] -= 1e-4
|
4648
|
+
end
|
4649
|
+
end
|
4650
|
+
|
4639
4651
|
def font_path font_file, fonts_dir
|
4640
4652
|
# resolve relative to built-in font dir unless path is absolute
|
4641
4653
|
::File.absolute_path font_file, fonts_dir
|
@@ -5,8 +5,12 @@ Prawn::Text::Formatted::Fragment.prepend (Module.new do
|
|
5
5
|
|
6
6
|
# Prevent fragment from being written by discarding the text, optionally forcing the width to 0
|
7
7
|
def conceal force_width_to_zero = false
|
8
|
-
|
9
|
-
|
8
|
+
if force_width_to_zero
|
9
|
+
@width = 0
|
10
|
+
@text = ''
|
11
|
+
else
|
12
|
+
@text = ' ' * space_count # preserve space_count so width is still computed correctly
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
# Don't strip soft hyphens when repacking unretrieved fragments
|
@@ -9,11 +9,16 @@ module Asciidoctor::PDF::FormattedText
|
|
9
9
|
text = fragment.text
|
10
10
|
x = fragment.left
|
11
11
|
y = fragment.baseline
|
12
|
-
align = fragment.format_state[:align]
|
13
|
-
if
|
14
|
-
|
12
|
+
align = (format_state = fragment.format_state)[:align]
|
13
|
+
if align == :center || align == :right
|
14
|
+
gap_width = (format_state.key? :width) ?
|
15
|
+
fragment.width - (document.width_of text) :
|
16
|
+
(format_state[:border_offset] || 0) * 2
|
17
|
+
x += gap_width * (align == :center ? 0.5 : 1) if gap_width > 0
|
18
|
+
end
|
19
|
+
document.word_spacing fragment.word_spacing do
|
20
|
+
document.draw_text! text, at: [x, y], kerning: document.default_kerning?
|
15
21
|
end
|
16
|
-
document.draw_text! text, at: [x, y]
|
17
22
|
fragment.conceal
|
18
23
|
end
|
19
24
|
end
|
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.0.
|
4
|
+
version: 2.0.5
|
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: 2022-05-
|
12
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|