asciidoctor-pdf 2.0.1 → 2.0.4
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 +40 -3
- data/README.adoc +3 -10
- data/lib/asciidoctor/pdf/converter.rb +32 -19
- data/lib/asciidoctor/pdf/ext/prawn-table.rb +11 -0
- 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: ff0a79d0d99869a25e820f003920cb1cbb8485f103c73c6f51e6cb74b97ddcb5
|
4
|
+
data.tar.gz: 318f9318f55317e4483f8e566a58db5aa4407642e75a2ece66dfa1f2f150c8bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ea1f2ad102f118e1de4d90ce4cf763db78f691ac6ddf5c93d9f2183b3fc0736a6767d20272d8b86815f0902088b2c42ed3dc72e59d587934d6738428271712
|
7
|
+
data.tar.gz: e686737ae4e56e8bd1f82bb916fb49bf77d937d226fec53f24753144d43304efe99e55c42dcaca27372e08ab1695dd3c711e727687ebbf17bc38a99a99b9ef5d
|
data/CHANGELOG.adoc
CHANGED
@@ -5,13 +5,50 @@
|
|
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.4 (2022-05-25) - @mojavelinux
|
9
|
+
|
10
|
+
Bug Fixes::
|
11
|
+
|
12
|
+
* fix calculation of TOC extent when TOC entry has children but no ID (#2208)
|
13
|
+
|
14
|
+
=== Details
|
15
|
+
|
16
|
+
{url-repo}/releases/tag/v2.0.4[git tag] | {url-repo}/compare/v2.0.3\...v2.0.4[full diff]
|
17
|
+
|
18
|
+
== 2.0.3 (2022-05-25) - @mojavelinux
|
19
|
+
|
20
|
+
Improvements::
|
21
|
+
|
22
|
+
* compute the optimize settings in init_pdf and store as Hash instead of after writing the PDF file
|
23
|
+
|
24
|
+
Bug Fixes::
|
25
|
+
|
26
|
+
* adjust TrimBox to fit inside of BleedBox when using optimizer and compliance is PDF/X (#2203)
|
27
|
+
* set height of resized image to available height to avoid float precision error when scaling down image to fit page (#2205)
|
28
|
+
* prevent content on title page from overrunning the bounds of a single page and warn; restriction applies to `ink_title_page`
|
29
|
+
|
30
|
+
=== Details
|
31
|
+
|
32
|
+
{url-repo}/releases/tag/v2.0.3[git tag] | {url-repo}/compare/v2.0.2\...v2.0.3[full diff]
|
33
|
+
|
34
|
+
== 2.0.2 (2022-05-22) - @mojavelinux
|
35
|
+
|
36
|
+
Bug Fixes::
|
37
|
+
|
38
|
+
* use specified column widths to avoid bugs in column width calculation when using colspans (#1368)
|
39
|
+
* advance table to next page if rowspan in first row does not fit in space remaining on current page (#403)
|
40
|
+
|
41
|
+
=== Details
|
42
|
+
|
43
|
+
{url-repo}/releases/tag/v2.0.2[git tag] | {url-repo}/compare/v2.0.1\...v2.0.2[full diff]
|
44
|
+
|
8
45
|
== 2.0.1 (2022-05-21) - @mojavelinux
|
9
46
|
|
10
47
|
Bug Fixes::
|
11
48
|
|
12
|
-
* scale inline image to fit within available height of page, accounting for the top padding of the line and the bottom gutter (#2193)
|
13
|
-
* short-circuit
|
14
|
-
* break and wrap long contiguous text in source block when linenums
|
49
|
+
* scale inline image to fit within available height of page, accounting for the top padding of the line height and the bottom gutter (#2193)
|
50
|
+
* short-circuit formatted text routine and log error if fragments in first line cannot fit on an empty page
|
51
|
+
* break and wrap long contiguous text in source block when linenums is enabled (#2198)
|
15
52
|
|
16
53
|
=== Details
|
17
54
|
|
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.4, 2022-05-25
|
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.4
|
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
|
@@ -152,7 +152,7 @@ module Asciidoctor
|
|
152
152
|
# TODO: delegate to convert_method_missing
|
153
153
|
log :warn, %(missing convert handler for #{name} node in #{@backend} backend)
|
154
154
|
end
|
155
|
-
# NOTE: inline
|
155
|
+
# NOTE: inline node handlers generate HTML-like strings; all other handlers write directly to the PDF object
|
156
156
|
::Asciidoctor::Inline === node ? result : self
|
157
157
|
end
|
158
158
|
|
@@ -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;
|
@@ -2167,6 +2176,7 @@ module Asciidoctor
|
|
2167
2176
|
|
2168
2177
|
left_padding = right_padding = nil
|
2169
2178
|
table table_data, table_settings do
|
2179
|
+
@column_widths = column_widths unless column_widths.empty?
|
2170
2180
|
# NOTE: call width to capture resolved table width
|
2171
2181
|
table_width = width
|
2172
2182
|
@pdf.ink_table_caption node, alignment, table_width, caption_max_width if node.title? && caption_end == :top
|
@@ -3607,7 +3617,6 @@ module Asciidoctor
|
|
3607
3617
|
end
|
3608
3618
|
end
|
3609
3619
|
|
3610
|
-
# TODO: prevent content from spilling to next page
|
3611
3620
|
theme_font :title_page do
|
3612
3621
|
if (title_top = @theme.title_page_title_top)
|
3613
3622
|
@y = resolve_top title_top
|
@@ -3747,9 +3756,9 @@ module Asciidoctor
|
|
3747
3756
|
hanging_indent = @theme.toc_hanging_indent
|
3748
3757
|
entries.each do |entry|
|
3749
3758
|
next if (num_levels_for_entry = (entry.attr 'toclevels', num_levels).to_i) < (entry_level = entry.level + 1).pred ||
|
3750
|
-
!(entry_anchor = (entry.attr 'pdf-anchor') || entry.id) ||
|
3751
3759
|
((entry.option? 'notitle') && entry == entry.document.last_child && entry.empty?)
|
3752
3760
|
theme_font :toc, level: entry_level do
|
3761
|
+
next unless (entry_anchor = (entry.attr 'pdf-anchor') || entry.id)
|
3753
3762
|
entry_title = entry.context == :section ? entry.numbered_title : (entry.title? ? entry.title : (entry.xreftext 'basic'))
|
3754
3763
|
next if entry_title.empty?
|
3755
3764
|
entry_title = transform_text entry_title, @text_transform if @text_transform
|
@@ -4402,13 +4411,8 @@ module Asciidoctor
|
|
4402
4411
|
pdf_doc.render_file target
|
4403
4412
|
# QUESTION: restore attributes first?
|
4404
4413
|
@pdfmark&.generate_file target
|
4405
|
-
if (
|
4406
|
-
|
4407
|
-
quality, compliance = quality.split ',', 2
|
4408
|
-
elsif quality.include? '/'
|
4409
|
-
quality, compliance = nil, quality
|
4410
|
-
end
|
4411
|
-
(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
|
4412
4416
|
end
|
4413
4417
|
to_file = true
|
4414
4418
|
end
|
@@ -4635,6 +4639,15 @@ module Asciidoctor
|
|
4635
4639
|
(max_height = bounds.height) < preferred_size ? max_height : preferred_size
|
4636
4640
|
end
|
4637
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
|
+
|
4638
4651
|
def font_path font_file, fonts_dir
|
4639
4652
|
# resolve relative to built-in font dir unless path is absolute
|
4640
4653
|
::File.absolute_path font_file, fonts_dir
|
@@ -1,6 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'prawn/table'
|
4
|
+
|
5
|
+
Prawn::Table.prepend (Module.new do
|
6
|
+
def initial_row_on_initial_page
|
7
|
+
return 0 if fits_on_page? @pdf.bounds.height
|
8
|
+
height_required = (row (0..number_of_header_rows)).height_with_span
|
9
|
+
return -1 if fits_on_page? height_required, true
|
10
|
+
@pdf.bounds.move_past_bottom
|
11
|
+
0
|
12
|
+
end
|
13
|
+
end)
|
14
|
+
|
4
15
|
require_relative 'prawn-table/cell'
|
5
16
|
require_relative 'prawn-table/cell/asciidoc'
|
6
17
|
require_relative 'prawn-table/cell/text'
|
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.4
|
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-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|