asciidoctor-pdf 2.1.0 → 2.1.3
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 +42 -0
- data/README.adoc +2 -4
- data/lib/asciidoctor/pdf/converter.rb +39 -32
- data/lib/asciidoctor/pdf/ext/prawn/document/column_box.rb +10 -7
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +38 -30
- data/lib/asciidoctor/pdf/formatted_text/text_background_and_border_renderer.rb +3 -3
- data/lib/asciidoctor/pdf/formatted_text/transform.rb +6 -3
- 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: f7753392586bac4a044601fefa9ecb58745e02fc37434dd5a26e020692890e65
|
4
|
+
data.tar.gz: 301fe3fef546588aacba4ca8d9c5afd91d4a19a816f07a8fcc66121c8f58f626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b26fe1f74b22bd73eba166190d21afebafdc1630dba5fee8174aa946b463d81b7e620cb8f400e803507f050c6dd48a1d732a1273a78fc1cd0e958da69a0a3c9c
|
7
|
+
data.tar.gz: 15cd75342088585a51f19cb342a8023fbc2aa6d0cd89fff72385370172059ac10c98fa51b8126845ce40436fcd89dc0c1f47aa763df14dad24ba2bcd95f92205
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,48 @@
|
|
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.1.3 (2022-06-23) - @mojavelinux
|
9
|
+
|
10
|
+
Bug Fixes::
|
11
|
+
|
12
|
+
* interpret `start-at` theme keys with value `1` correctly (as `1` instead of `2`) (#2255)
|
13
|
+
* restore column layout after importing page(s) from PDF (#2253)
|
14
|
+
* fix crash when border color is transparent (`thematic-break-border-color`, `admonition-column-rule`, `quote-border-color`, `verse-border-color`)
|
15
|
+
* ensure page margin is restored after imported page
|
16
|
+
|
17
|
+
=== Details
|
18
|
+
|
19
|
+
{url-repo}/releases/tag/v2.1.3[git tag] | {url-repo}/compare/v2.1.2\...v2.1.3[full diff]
|
20
|
+
|
21
|
+
== 2.1.2 (2022-06-17) - @mojavelinux
|
22
|
+
|
23
|
+
Bug Fixes::
|
24
|
+
|
25
|
+
* apply page layout from main document to new page in scratch document (#2248)
|
26
|
+
* use correct logic to insert page before TOC with automatic placement when doctype=book and media=prepress
|
27
|
+
* use `get_entries_for_toc` to determine if the TOC is non-empty rather than `Document#sections?`
|
28
|
+
|
29
|
+
=== Details
|
30
|
+
|
31
|
+
{url-repo}/releases/tag/v2.1.2[git tag] | {url-repo}/compare/v2.1.1\...v2.1.2[full diff]
|
32
|
+
|
33
|
+
== 2.1.1 (2022-06-15) - @mojavelinux
|
34
|
+
|
35
|
+
Improvements::
|
36
|
+
|
37
|
+
* store zero-based column on Extent for extensions to use to position cursor at start of extent
|
38
|
+
|
39
|
+
Bug Fixes::
|
40
|
+
|
41
|
+
* place block image in SVG format in correct column when align is left and page columns are enabled (#2241)
|
42
|
+
* accurately trap LoadError from CodeRay if source language is not recognized on code block
|
43
|
+
* only draw rounded rectangle around phrase if `border-radius` is > 0
|
44
|
+
* use `base-border-color` value if border width is set on role for inline phrase but not border color
|
45
|
+
|
46
|
+
=== Details
|
47
|
+
|
48
|
+
{url-repo}/releases/tag/v2.1.1[git tag] | {url-repo}/compare/v2.1.0\...v2.1.1[full diff]
|
49
|
+
|
8
50
|
== 2.1.0 (2022-06-11) - @mojavelinux
|
9
51
|
|
10
52
|
Enhancements::
|
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.1.
|
3
|
+
v2.1.3, 2022-06-23
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -22,8 +22,6 @@ endif::[]
|
|
22
22
|
// Aliases:
|
23
23
|
:project-name: Asciidoctor PDF
|
24
24
|
:project-handle: asciidoctor-pdf
|
25
|
-
// Variables:
|
26
|
-
:release-line: 2.1.x
|
27
25
|
// URLs:
|
28
26
|
:url-gem: https://rubygems.org/gems/asciidoctor-pdf
|
29
27
|
:url-project: https://github.com/asciidoctor/asciidoctor-pdf
|
@@ -46,7 +44,7 @@ The aim of this library is to take the pain out of creating PDF documents from A
|
|
46
44
|
|
47
45
|
[NOTE]
|
48
46
|
====
|
49
|
-
The documentation for the latest, stable release of Asciidoctor PDF
|
47
|
+
The documentation for the latest, stable release of Asciidoctor PDF is available at {url-project-docs}/.
|
50
48
|
|
51
49
|
If you're looking for the documentation for Asciidoctor PDF 1.6, refer to the {url-project-repo}/tree/v1.6.x#readme[README] in the v1.6.x branch.
|
52
50
|
Asciidoctor PDF 1.6 is no longer being developed and will reach EOL later this year.
|
@@ -198,8 +198,8 @@ module Asciidoctor
|
|
198
198
|
|
199
199
|
indent_section do
|
200
200
|
toc_num_levels = (doc.attr 'toclevels', 2).to_i
|
201
|
-
if (insert_toc = (doc.attr? 'toc') && !((toc_placement = doc.attr 'toc-placement') == 'macro' || toc_placement == 'preamble') && doc.
|
202
|
-
|
201
|
+
if (insert_toc = (doc.attr? 'toc') && !((toc_placement = doc.attr 'toc-placement') == 'macro' || toc_placement == 'preamble') && !(get_entries_for_toc doc).empty?)
|
202
|
+
start_new_page if @ppbook && verso_page?
|
203
203
|
add_dest_for_block doc, id: 'toc', y: (at_page_top? ? page_height : nil)
|
204
204
|
@toc_extent = allocate_toc doc, toc_num_levels, cursor, title_page_on
|
205
205
|
else
|
@@ -213,7 +213,7 @@ module Asciidoctor
|
|
213
213
|
first_page_offset = has_title_page ? zero_page_offset.next : zero_page_offset
|
214
214
|
body_offset = (body_start_page_number = page_number) - 1
|
215
215
|
if ::Integer === (running_content_start_at = @theme.running_content_start_at)
|
216
|
-
running_content_body_offset = body_offset + [running_content_start_at.pred,
|
216
|
+
running_content_body_offset = body_offset + [running_content_start_at.pred, 0].max
|
217
217
|
running_content_start_at = 'body'
|
218
218
|
else
|
219
219
|
running_content_body_offset = body_offset
|
@@ -227,7 +227,7 @@ module Asciidoctor
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
if ::Integer === (page_numbering_start_at = @theme.page_numbering_start_at)
|
230
|
-
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred,
|
230
|
+
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 0].max
|
231
231
|
page_numbering_start_at = 'body'
|
232
232
|
else
|
233
233
|
page_numbering_body_offset = body_offset
|
@@ -263,12 +263,12 @@ module Asciidoctor
|
|
263
263
|
else
|
264
264
|
body_offset = body_start_page_number - 1
|
265
265
|
if ::Integer === (running_content_start_at = @theme.running_content_start_at)
|
266
|
-
running_content_body_offset = body_offset + [running_content_start_at.pred,
|
266
|
+
running_content_body_offset = body_offset + [running_content_start_at.pred, 0].max
|
267
267
|
else
|
268
268
|
running_content_body_offset = body_offset
|
269
269
|
end
|
270
270
|
if ::Integer === (page_numbering_start_at = @theme.page_numbering_start_at)
|
271
|
-
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred,
|
271
|
+
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 0].max
|
272
272
|
elsif page_numbering_start_at == 'cover' && has_front_cover
|
273
273
|
page_numbering_body_offset = 0
|
274
274
|
else
|
@@ -371,8 +371,6 @@ module Asciidoctor
|
|
371
371
|
if (page_margin_inner = theme.page_margin_inner)
|
372
372
|
page_margin_recto[3] = page_margin_verso[1] = page_margin_inner
|
373
373
|
end
|
374
|
-
# NOTE: prepare scratch document to use page margin from recto side (which has same width as verso side)
|
375
|
-
set_page_margin page_margin_recto unless page_margin_recto == page_margin
|
376
374
|
else
|
377
375
|
@ppbook = nil
|
378
376
|
end
|
@@ -581,6 +579,7 @@ module Asciidoctor
|
|
581
579
|
end
|
582
580
|
|
583
581
|
def prepare_theme theme
|
582
|
+
theme.base_border_color = nil if theme.base_border_color == 'transparent'
|
584
583
|
theme.base_font_color ||= '000000'
|
585
584
|
theme.base_font_size ||= 12
|
586
585
|
theme.base_font_style = theme.base_font_style&.to_sym || :normal
|
@@ -943,7 +942,7 @@ module Asciidoctor
|
|
943
942
|
if extent
|
944
943
|
label_height = extent.single_page_height || cursor
|
945
944
|
if (rule_width = @theme.admonition_column_rule_width || 0) > 0 &&
|
946
|
-
(rule_color =
|
945
|
+
(rule_color = resolve_theme_color :admonition_column_rule_color, @theme.base_border_color, nil)
|
947
946
|
rule_style = @theme.admonition_column_rule_style&.to_sym || :solid
|
948
947
|
float do
|
949
948
|
extent.each_page do |first_page, last_page|
|
@@ -1108,7 +1107,10 @@ module Asciidoctor
|
|
1108
1107
|
srclang = node.attr 'language', 'text'
|
1109
1108
|
begin
|
1110
1109
|
::CodeRay::Scanners[(srclang = (srclang.start_with? 'html+') ? (srclang.slice 5, srclang.length).to_sym : srclang.to_sym)]
|
1111
|
-
rescue
|
1110
|
+
rescue
|
1111
|
+
until ::LoadError === (cause ||= $!) || ::ArgumentError === cause
|
1112
|
+
raise $! unless (cause = cause.cause)
|
1113
|
+
end
|
1112
1114
|
srclang = :text
|
1113
1115
|
end
|
1114
1116
|
fragments = (::CodeRay.scan source_string, srclang).to_prawn
|
@@ -1270,7 +1272,7 @@ module Asciidoctor
|
|
1270
1272
|
category = node.context == :quote ? :quote : :verse
|
1271
1273
|
# NOTE: b_width and b_left_width are mutually exclusive
|
1272
1274
|
if (b_left_width = @theme[%(#{category}_border_left_width)]) && b_left_width > 0
|
1273
|
-
b_color =
|
1275
|
+
b_left_width = nil unless (b_color = resolve_theme_color %(#{category}_border_color), @theme.base_border_color, nil)
|
1274
1276
|
else
|
1275
1277
|
b_left_width = nil
|
1276
1278
|
b_width = nil if (b_width = @theme[%(#{category}_border_width)]) == 0
|
@@ -1787,7 +1789,6 @@ module Asciidoctor
|
|
1787
1789
|
file_request_root = { base: (::File.dirname image_path), root: @jail_dir }
|
1788
1790
|
end
|
1789
1791
|
svg_obj = ::Prawn::SVG::Interface.new svg_data, self,
|
1790
|
-
position: alignment,
|
1791
1792
|
width: width,
|
1792
1793
|
fallback_font_name: fallback_svg_font_name,
|
1793
1794
|
enable_web_requests: allow_uri_read ? (method :load_open_uri).to_proc : false,
|
@@ -1804,7 +1805,6 @@ module Asciidoctor
|
|
1804
1805
|
if (rendered_h = svg_size.output_height) > (available_h = cursor - caption_h)
|
1805
1806
|
unless pinned || at_page_top?
|
1806
1807
|
advance_page
|
1807
|
-
(svg_obj.options[:at] = svg_obj.position)[0] += bounds.left if ColumnBox === bounds
|
1808
1808
|
available_h = cursor - caption_h
|
1809
1809
|
end
|
1810
1810
|
rendered_w = (svg_obj.resize height: (rendered_h = available_h)).output_width if rendered_h > available_h
|
@@ -1815,7 +1815,16 @@ module Asciidoctor
|
|
1815
1815
|
update_colors if graphic_state.color_space.empty?
|
1816
1816
|
ink_caption node, category: :image, end: :top, block_align: alignment, block_width: rendered_w, max_width: caption_max_width if caption_end == :top && node.title?
|
1817
1817
|
image_y = y
|
1818
|
-
|
1818
|
+
# NOTE: prawn-svg does not compute :at for alignment correctly in column box, so resort to our own logic
|
1819
|
+
case alignment
|
1820
|
+
when :center
|
1821
|
+
left = bounds.left + (available_w - rendered_w) * 0.5
|
1822
|
+
when :right
|
1823
|
+
left = bounds.left + available_w - rendered_w
|
1824
|
+
else
|
1825
|
+
left = bounds.left
|
1826
|
+
end
|
1827
|
+
svg_obj.options[:at] = [left, (image_cursor = cursor)]
|
1819
1828
|
svg_obj.draw # NOTE: cursor advances automatically
|
1820
1829
|
svg_obj.document.warnings.each do |img_warning|
|
1821
1830
|
log :warn, %(problem encountered in image: #{image_path}; #{img_warning})
|
@@ -2331,9 +2340,11 @@ module Asciidoctor
|
|
2331
2340
|
|
2332
2341
|
def convert_thematic_break node
|
2333
2342
|
pad_box @theme.thematic_break_padding || [@theme.thematic_break_margin_top, 0] do
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2343
|
+
if (b_color = resolve_theme_color :thematic_break_border_color)
|
2344
|
+
stroke_horizontal_rule b_color,
|
2345
|
+
line_width: @theme.thematic_break_border_width,
|
2346
|
+
line_style: (@theme.thematic_break_border_style&.to_sym || :solid)
|
2347
|
+
end
|
2337
2348
|
end
|
2338
2349
|
conceal_page_top { theme_margin :block, :bottom, (next_enclosed_block node) }
|
2339
2350
|
end
|
@@ -2342,7 +2353,7 @@ module Asciidoctor
|
|
2342
2353
|
# NOTE: only allow document to have a single managed toc
|
2343
2354
|
return if @toc_extent
|
2344
2355
|
is_macro = (placement = opts[:placement] || 'macro') == 'macro'
|
2345
|
-
if ((doc = node.document).attr? 'toc-placement', placement) && (doc.attr? 'toc') && doc.
|
2356
|
+
if ((doc = node.document).attr? 'toc-placement', placement) && (doc.attr? 'toc') && !(get_entries_for_toc doc).empty?
|
2346
2357
|
start_toc_page node, placement if (is_book = doc.doctype == 'book')
|
2347
2358
|
add_dest_for_block node, id: (node.id || 'toc') if is_macro
|
2348
2359
|
toc_extent = @toc_extent = allocate_toc doc, (doc.attr 'toclevels', 2).to_i, cursor, (title_page_on = is_book || (doc.attr? 'title-page'))
|
@@ -2792,13 +2803,7 @@ module Asciidoctor
|
|
2792
2803
|
value = (value.split LF).delete_if {|line| SimpleAttributeRefRx.match? line }.join LF if opts[:drop_lines_with_unresolved_attributes] && (value.include? '{')
|
2793
2804
|
value = value.gsub '\{', '{' if escaped_attr_ref
|
2794
2805
|
doc.set_attr 'attribute-missing', attribute_missing unless attribute_missing == 'skip'
|
2795
|
-
if imagesdir
|
2796
|
-
if imagesdir_to_restore
|
2797
|
-
doc.set_attr 'imagesdir', imagesdir_to_restore
|
2798
|
-
else
|
2799
|
-
doc.remove_attr 'imagesdir'
|
2800
|
-
end
|
2801
|
-
end
|
2806
|
+
imagesdir_to_restore ? (doc.set_attr 'imagesdir', imagesdir_to_restore) : (doc.remove_attr 'imagesdir') if imagesdir
|
2802
2807
|
value
|
2803
2808
|
end
|
2804
2809
|
|
@@ -4389,7 +4394,7 @@ module Asciidoctor
|
|
4389
4394
|
b_shift, b_gap_color = (b_width ||= 0.5) * 0.5, @page_bg_color
|
4390
4395
|
end
|
4391
4396
|
ink_caption node_with_caption, category: category if node_with_caption
|
4392
|
-
extent.from.page
|
4397
|
+
extent.from.page = page_number unless extent.from.page == page_number # sanity check
|
4393
4398
|
float do
|
4394
4399
|
extent.each_page do |first_page, last_page|
|
4395
4400
|
advance_page unless first_page
|
@@ -4813,18 +4818,17 @@ module Asciidoctor
|
|
4813
4818
|
end
|
4814
4819
|
|
4815
4820
|
# NOTE: init_page is called within a float context; this will suppress prawn-svg messing with the cursor
|
4816
|
-
# NOTE: init_page is not called for imported pages,
|
4821
|
+
# NOTE: init_page is not called for imported pages, cover pages, image pages, and pages in the scratch document
|
4817
4822
|
def init_page *_args
|
4818
4823
|
next_page_side = page_side nil, @folio_placement[:inverted]
|
4819
4824
|
if @media == 'prepress' && (next_page_margin = @page_margin_by_side[page_number == 1 ? :cover : next_page_side]) != page_margin
|
4820
4825
|
set_page_margin next_page_margin
|
4821
4826
|
end
|
4822
4827
|
unless @page_bg_color == 'FFFFFF'
|
4823
|
-
tare = true
|
4824
4828
|
fill_absolute_bounds @page_bg_color
|
4829
|
+
tare = true
|
4825
4830
|
end
|
4826
4831
|
if (bg_image_path, bg_image_opts = @page_bg_image[next_page_side])
|
4827
|
-
tare = true
|
4828
4832
|
begin
|
4829
4833
|
if bg_image_opts[:format] == 'pdf'
|
4830
4834
|
# NOTE: pages that use PDF for the background do not support a background color or running content
|
@@ -4833,6 +4837,7 @@ module Asciidoctor
|
|
4833
4837
|
else
|
4834
4838
|
canvas { image bg_image_path, ({ position: :center, vposition: :center }.merge bg_image_opts) }
|
4835
4839
|
end
|
4840
|
+
tare = true
|
4836
4841
|
rescue
|
4837
4842
|
facing_page_side = (PageSides - [next_page_side])[0]
|
4838
4843
|
@page_bg_image[facing_page_side] = nil if @page_bg_image[facing_page_side] == @page_bg_image[next_page_side]
|
@@ -5027,10 +5032,8 @@ module Asciidoctor
|
|
5027
5032
|
# QUESTION: should we pass a category as an argument?
|
5028
5033
|
# QUESTION: should we make this a method on the theme ostruct? (e.g., @theme.resolve_color key, fallback)
|
5029
5034
|
def resolve_theme_color key, fallback_color = nil, transparent_color = fallback_color
|
5030
|
-
if (color = @theme[key])
|
5035
|
+
if (color = @theme[key] || fallback_color)
|
5031
5036
|
color == 'transparent' ? transparent_color : color
|
5032
|
-
else
|
5033
|
-
fallback_color
|
5034
5037
|
end
|
5035
5038
|
end
|
5036
5039
|
|
@@ -5110,6 +5113,10 @@ module Asciidoctor
|
|
5110
5113
|
end
|
5111
5114
|
|
5112
5115
|
def init_scratch originator
|
5116
|
+
if @media == 'prepress' && page_margin != (page_margin_recto = @page_margin_by_side[:recto])
|
5117
|
+
# NOTE: prepare scratch document to use page margin from recto side (which has same width as verso side)
|
5118
|
+
set_page_margin page_margin_recto
|
5119
|
+
end
|
5113
5120
|
@scratch_prototype = originator.instance_variable_get :@scratch_prototype
|
5114
5121
|
@tmp_files = originator.instance_variable_get :@tmp_files
|
5115
5122
|
text_formatter.scratch = true
|
@@ -6,20 +6,23 @@ Prawn::Document::ColumnBox.prepend (Module.new do
|
|
6
6
|
def move_past_bottom
|
7
7
|
(doc = @document).y = @y
|
8
8
|
return if (@current_column = (@current_column + 1) % @columns) > 0
|
9
|
-
|
10
|
-
if (
|
11
|
-
@y = par.absolute_top
|
12
|
-
@height = par.height unless stretchy?
|
13
|
-
end
|
9
|
+
parent_ = @parent
|
10
|
+
reset_top parent_ if (reflow_at = @reflow_margins) && (reflow_at == true || reflow_at > doc.page_number)
|
14
11
|
initial_margins = doc.page.margins
|
15
|
-
|
12
|
+
parent_.move_past_bottom
|
16
13
|
if doc.page.margins != initial_margins
|
17
|
-
doc.bounds = self.class.new doc,
|
14
|
+
doc.bounds = self.class.new doc, parent_, [(margin_box = doc.margin_box).absolute_left, @y],
|
18
15
|
columns: @columns, reflow_margins: @reflow_margins, spacer: @spacer, width: margin_box.width, height: @height
|
19
16
|
end
|
20
17
|
nil
|
21
18
|
end
|
22
19
|
|
20
|
+
def reset_top parent_ = @parent
|
21
|
+
@current_column = 0
|
22
|
+
@height = parent_.height unless stretchy?
|
23
|
+
@y = parent_.absolute_top
|
24
|
+
end
|
25
|
+
|
23
26
|
# Rearranges the column box into a single column, where the original columns are in a single file. Used
|
24
27
|
# for the purpose of computing the extent of content in a scratch document.
|
25
28
|
def single_file
|
@@ -34,13 +34,14 @@ module Asciidoctor
|
|
34
34
|
# - :final_gap determines whether a gap is added below the last line
|
35
35
|
LineMetrics = ::Struct.new :height, :leading, :padding_top, :padding_bottom, :final_gap
|
36
36
|
|
37
|
-
Position = ::Struct.new :page, :cursor
|
37
|
+
Position = ::Struct.new :page, :column, :cursor
|
38
38
|
|
39
39
|
Extent = ::Struct.new :current, :from, :to do
|
40
|
-
def initialize current_page, current_cursor,
|
41
|
-
self.
|
42
|
-
self.from = Position.new
|
43
|
-
self.
|
40
|
+
def initialize current_page, current_column, current_cursor, from_page, from_column, from_cursor, to_page, to_cursor
|
41
|
+
self.current = Position.new current_page, current_column, current_cursor
|
42
|
+
self.from = Position.new from_page, from_column, from_cursor
|
43
|
+
self.from = current if from == current
|
44
|
+
self.to = Position.new to_page, nil, to_cursor
|
44
45
|
end
|
45
46
|
|
46
47
|
def each_page
|
@@ -64,23 +65,23 @@ module Asciidoctor
|
|
64
65
|
|
65
66
|
ScratchExtent = ::Struct.new :from, :to do
|
66
67
|
def initialize start_page, start_cursor, end_page, end_cursor
|
67
|
-
self.from = Position.new start_page, start_cursor
|
68
|
-
self.to = Position.new end_page, end_cursor
|
68
|
+
self.from = Position.new start_page, 0, start_cursor
|
69
|
+
self.to = Position.new end_page, 0, end_cursor
|
69
70
|
end
|
70
71
|
|
71
72
|
def position_onto pdf, keep_together = nil
|
72
73
|
current_page = pdf.page_number
|
74
|
+
current_column = ColumnBox === pdf.bounds ? (column_box = pdf.bounds).current_column : 0
|
73
75
|
current_cursor = pdf.cursor
|
74
|
-
|
75
|
-
to_page = current_page + (to.page - 1)
|
76
|
-
if advance_by > 0
|
76
|
+
if (advance_by = from.page - 1) > 0
|
77
77
|
advance_by.times { pdf.advance_page }
|
78
78
|
elsif keep_together && single_page? && !(try_to_fit_on_previous current_cursor)
|
79
79
|
pdf.advance_page
|
80
|
-
from_page += 1
|
81
|
-
to_page += 1
|
82
80
|
end
|
83
|
-
|
81
|
+
from_page = pdf.page_number
|
82
|
+
from_column = column_box&.current_column || 0
|
83
|
+
to_page = from_page + (to.page - from.page)
|
84
|
+
Extent.new current_page, current_column, current_cursor, from_page, from_column, from.cursor, to_page, to.cursor
|
84
85
|
end
|
85
86
|
|
86
87
|
def single_page?
|
@@ -923,6 +924,8 @@ module Asciidoctor
|
|
923
924
|
def import_page file, options = {}
|
924
925
|
prev_page_layout = page.layout
|
925
926
|
prev_page_size = page.size
|
927
|
+
prev_page_margin = page_margin
|
928
|
+
prev_bounds = bounds
|
926
929
|
state.compress = false if state.compress # can't use compression if using template
|
927
930
|
prev_text_rendering_mode = (defined? @text_rendering_mode) ? @text_rendering_mode : nil
|
928
931
|
delete_current_page if options[:replace]
|
@@ -935,11 +938,15 @@ module Asciidoctor
|
|
935
938
|
# NOTE: set page size & layout explicitly in case imported page differs
|
936
939
|
# I'm not sure it's right to start a new page here, but unfortunately there's no other
|
937
940
|
# way atm to prevent the size & layout of the imported page from affecting subsequent pages
|
938
|
-
|
941
|
+
if options.fetch :advance, true
|
942
|
+
advance_page layout: prev_page_layout, margin: prev_page_margin, size: prev_page_size
|
943
|
+
(@bounding_box = prev_bounds).reset_top if ColumnBox === prev_bounds
|
944
|
+
end
|
939
945
|
elsif options.fetch :advance_if_missing, true
|
940
946
|
delete_current_page
|
941
947
|
# NOTE: see previous comment
|
942
|
-
advance_page
|
948
|
+
advance_page layout: prev_page_layout, margin: prev_page_margin, size: prev_page_size
|
949
|
+
@y = (@bounding_box = prev_bounds).reset_top if ColumnBox === prev_bounds
|
943
950
|
else
|
944
951
|
delete_current_page
|
945
952
|
end
|
@@ -972,11 +979,11 @@ module Asciidoctor
|
|
972
979
|
state.on_page_create_callback = saved_callback
|
973
980
|
end
|
974
981
|
|
975
|
-
# This method is a smarter version of start_new_page. It calls start_new_page
|
976
|
-
#
|
977
|
-
#
|
982
|
+
# This method is a smarter version of start_new_page. It only calls start_new_page options are
|
983
|
+
# specified and the current page is the last page in the document. Otherwise, it advances the
|
984
|
+
# cursor to the next page (or column) using Bounds#move_past_bottom.
|
978
985
|
def advance_page options = {}
|
979
|
-
|
986
|
+
options.empty? || !last_page? ? bounds.move_past_bottom : (start_new_page options)
|
980
987
|
end
|
981
988
|
|
982
989
|
# Start a new page without triggering the on_page_create callback
|
@@ -1111,7 +1118,8 @@ module Asciidoctor
|
|
1111
1118
|
# This method performs all work in a scratch document (or documents). It begins by starting a
|
1112
1119
|
# new page in the scratch document, first creating the scratch document if necessary. It then
|
1113
1120
|
# applies all the settings from the main document to the scratch document that impact
|
1114
|
-
# rendering. This includes the bounds, the cursor position, and the font settings.
|
1121
|
+
# rendering. This includes the bounds, the cursor position, and the font settings. This method
|
1122
|
+
# assumes that the content area remains constant when content flows from one page to the next.
|
1115
1123
|
#
|
1116
1124
|
# From this point, the number of attempts the method makes is determined by the value of the
|
1117
1125
|
# keep_together keyword parameter. If the value is true (or the parent document is inhibiting
|
@@ -1136,19 +1144,19 @@ module Asciidoctor
|
|
1136
1144
|
# Note that if the block has content that itself requires a dry run, that nested dry run will
|
1137
1145
|
# be performed in a separate scratch document.
|
1138
1146
|
#
|
1139
|
-
#
|
1140
|
-
#
|
1141
|
-
#
|
1142
|
-
#
|
1143
|
-
#
|
1144
|
-
#
|
1145
|
-
#
|
1146
|
-
#
|
1147
|
-
#
|
1147
|
+
# options - A Hash of options that configure the dry run computation:
|
1148
|
+
# :keep_together - A Boolean indicating whether an attempt should be made to keep
|
1149
|
+
# the content on the same page (optional, default: false).
|
1150
|
+
# :single_page - A Boolean indicating whether the operation should stop if the
|
1151
|
+
# content exceeds the height of a single page.
|
1152
|
+
# :onto - The document onto which to position the scratch extent. If this option is
|
1153
|
+
# set, the method returns an Extent instance (optional, default: false)
|
1154
|
+
# :pages_advanced - The number of pages the content has been advanced during this
|
1155
|
+
# operation (internal only) (optional, default: 0)
|
1148
1156
|
#
|
1149
1157
|
# Returns an Extent or ScratchExtent object that describes the bounds of the content block.
|
1150
1158
|
def dry_run keep_together: nil, pages_advanced: 0, single_page: nil, onto: nil, &block
|
1151
|
-
(scratch_pdf = scratch).start_new_page
|
1159
|
+
(scratch_pdf = scratch).start_new_page layout: page.layout
|
1152
1160
|
saved_bounds = scratch_pdf.bounds
|
1153
1161
|
scratch_pdf.bounds = bounds.dup.tap do |bounds_copy|
|
1154
1162
|
bounds_copy.instance_variable_set :@document, scratch_pdf
|
@@ -25,11 +25,11 @@ module Asciidoctor::PDF::FormattedText
|
|
25
25
|
width = fragment.width
|
26
26
|
height = fragment.height
|
27
27
|
end
|
28
|
-
border_radius = data[:border_radius]
|
28
|
+
border_radius = data[:border_radius] || 0
|
29
29
|
if (background_color = data[:background_color])
|
30
30
|
prev_fill_color = pdf.fill_color
|
31
31
|
pdf.fill_color background_color
|
32
|
-
if border_radius
|
32
|
+
if border_radius > 0
|
33
33
|
pdf.fill_rounded_rectangle at, width, height, border_radius
|
34
34
|
else
|
35
35
|
pdf.fill_rectangle at, width, height
|
@@ -41,7 +41,7 @@ module Asciidoctor::PDF::FormattedText
|
|
41
41
|
prev_line_width = pdf.line_width
|
42
42
|
pdf.stroke_color border_color
|
43
43
|
pdf.line_width border_width
|
44
|
-
border_radius ? (pdf.stroke_rounded_rectangle at, width, height, border_radius) : (pdf.stroke_rectangle at, width, height)
|
44
|
+
border_radius > 0 ? (pdf.stroke_rounded_rectangle at, width, height, border_radius) : (pdf.stroke_rectangle at, width, height)
|
45
45
|
pdf.stroke_color prev_stroke_color
|
46
46
|
pdf.line_width prev_line_width
|
47
47
|
end
|
@@ -96,21 +96,24 @@ module Asciidoctor
|
|
96
96
|
}.compact,
|
97
97
|
}
|
98
98
|
@theme_settings.tap do |accum|
|
99
|
-
|
99
|
+
roles_with_styles = [].to_set
|
100
100
|
theme.each_pair do |key, val|
|
101
101
|
next unless (key = key.to_s).start_with? 'role_'
|
102
102
|
role, key = (key.slice 5, key.length).split '_', 2
|
103
103
|
if (prop = ThemeKeyToFragmentProperty[key])
|
104
104
|
(accum[role] ||= {})[prop] = val
|
105
|
+
if key == 'border_width' && val && !(theme[%(role_#{role}_border_color)])
|
106
|
+
accum[role][:border_color] = theme.base_border_color
|
107
|
+
end
|
105
108
|
#elsif key == 'font_kerning'
|
106
109
|
# unless (resolved_val = val == 'none' ? false : (val == 'normal' ? true : nil)).nil?
|
107
110
|
# (accum[role] ||= {})[:kerning] = resolved_val
|
108
111
|
# end
|
109
112
|
elsif key == 'font_style' || key == 'text_decoration'
|
110
|
-
|
113
|
+
roles_with_styles << role
|
111
114
|
end
|
112
115
|
end
|
113
|
-
|
116
|
+
roles_with_styles.each do |role|
|
114
117
|
(accum[role] ||= {})[:styles] = to_styles theme[%(role_#{role}_font_style)], theme[%(role_#{role}_text_decoration)]
|
115
118
|
end
|
116
119
|
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.1.
|
4
|
+
version: 2.1.3
|
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-06-
|
12
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor
|