asciidoctor-pdf 2.1.4 → 2.2.0
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 +48 -4
- data/README.adoc +1 -1
- data/bin/asciidoctor-pdf +28 -9
- data/bin/asciidoctor-pdf-optimize +1 -2
- data/lib/asciidoctor/pdf/converter.rb +146 -109
- data/lib/asciidoctor/pdf/ext/asciidoctor/document.rb +5 -0
- data/lib/asciidoctor/pdf/ext/prawn/extensions.rb +10 -4
- data/lib/asciidoctor/pdf/ext/prawn-table/cell/asciidoc.rb +2 -1
- 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: 5dbb3a6c2c5b664510e19714de969553f3943994b4be273238c646e41274885f
|
|
4
|
+
data.tar.gz: f6495e965c651113bbc61383d82a18db4fb78a7df64644801bd10fba1c6ed078
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b93162e6b69d1c32cf3365c08f78457f80cb1588a98c847b0ddfa6946074ba1c7c163009434243d9c78d87e6982c84b2c74eb06fbb72003f003854fbadea926
|
|
7
|
+
data.tar.gz: 2cc9d0d4d64ac4ae889e54cf272339019ec91a812ba38f22f28b81abb8daa6af086941e8b50bb95a70f1f1028dd06879952fd51da4219fc46db523f4757ca774
|
data/CHANGELOG.adoc
CHANGED
|
@@ -5,6 +5,54 @@
|
|
|
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.2.0 (2022-07-22) - @mojavelinux
|
|
9
|
+
|
|
10
|
+
Enhancements::
|
|
11
|
+
|
|
12
|
+
* allow page background image to be specified per layout using `+{page-layout}+` attribute reference in path (#1739)
|
|
13
|
+
* allow page margin for rotated page to be configured independently using `page-margin-rotated` theme key or `pdf-page-margin-rotated` document attribute (#1719)
|
|
14
|
+
* allow orphan detection to be enabled for all section titles and discrete headings by setting `heading-min-height-after` to `auto` in theme (#2268)
|
|
15
|
+
* set `docimagesdir` attribute when attribute substitutions are applied to value from theme (#2278)
|
|
16
|
+
* start page numbering and running content on empty verso page before first chapter of prepress book if `start-at` value is 0 (#2252)
|
|
17
|
+
* don't force page break after TOC with automatic placement in article if `title-page` attribute is set and value of `toc-break-after` theme key is `auto` (#1768)
|
|
18
|
+
* add `--theme` option to CLI as shorthand for `-a pdf-theme` (#2250)
|
|
19
|
+
* add `--sourcemap` option to CLI to enable `:sourcemap` option on processor (#2265)
|
|
20
|
+
* broaden support for relative font sizes in theme to more than just inline elements; document support for relative font sizes
|
|
21
|
+
* allow theme to control font properties of marker for ordered list using `olist-marker` category (#2279)
|
|
22
|
+
* allow theme to control font style of marker (per marker or all markers) for unordered list
|
|
23
|
+
|
|
24
|
+
Improvements::
|
|
25
|
+
|
|
26
|
+
* add internal `Document#attr_unspecified?` method to simplify check for an attribute which has not been set or unset
|
|
27
|
+
|
|
28
|
+
Bug Fixes::
|
|
29
|
+
|
|
30
|
+
* always set `imagesdir` attribute to value of `themesdir` when resolving images from theme
|
|
31
|
+
* allow `top` keys in `title-page` theme category to accept a fixed value (e.g., `1in`) (#2269)
|
|
32
|
+
* prevent orphan detection for heading (section title or discrete heading) from modifying document state (#2288)
|
|
33
|
+
|
|
34
|
+
Compliance::
|
|
35
|
+
|
|
36
|
+
* configure table borders in way that is compatible with prawn-table > 0.2.2
|
|
37
|
+
* don't coerce font size < 1 to relative font size; relative font size should be specified in units
|
|
38
|
+
|
|
39
|
+
=== Details
|
|
40
|
+
|
|
41
|
+
{url-repo}/releases/tag/v2.2.0[git tag] | {url-repo}/compare/v2.1.6\...v2.2.0[full diff]
|
|
42
|
+
|
|
43
|
+
== 2.1.6 (2022-07-19) - @mojavelinux
|
|
44
|
+
|
|
45
|
+
Bug Fixes::
|
|
46
|
+
|
|
47
|
+
* resolve font size for monospaced cell when font size value on `codespan` key in theme is relative (#2281)
|
|
48
|
+
|
|
49
|
+
== 2.1.5 (2022-07-10) - @mojavelinux
|
|
50
|
+
|
|
51
|
+
Bug Fixes::
|
|
52
|
+
|
|
53
|
+
* fix position of background color on caption with outside margin (#2271)
|
|
54
|
+
* don't allow font scale to compound when entering nested table (#2276)
|
|
55
|
+
|
|
8
56
|
== 2.1.4 (2022-06-26) - @mojavelinux
|
|
9
57
|
|
|
10
58
|
Improvements::
|
|
@@ -17,10 +65,6 @@ Bug Fixes::
|
|
|
17
65
|
* apply text-tranform from custom role on phrase after attributes have been resolved (#2263)
|
|
18
66
|
* make URL check more strict so image target containing a colon is not mistaken as a URL
|
|
19
67
|
|
|
20
|
-
=== Details
|
|
21
|
-
|
|
22
|
-
{url-repo}/releases/tag/v2.1.4[git tag] | {url-repo}/compare/v2.1.3\...v2.1.4[full diff]
|
|
23
|
-
|
|
24
68
|
== 2.1.3 (2022-06-23) - @mojavelinux
|
|
25
69
|
|
|
26
70
|
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.
|
|
3
|
+
v2.2.0, 2022-07-22
|
|
4
4
|
// Settings:
|
|
5
5
|
:experimental:
|
|
6
6
|
:idprefix:
|
data/bin/asciidoctor-pdf
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
if File.file?(asciidoctor_pdf = (File.
|
|
4
|
+
if File.file? (asciidoctor_pdf = File.join (File.dirname __dir__), 'lib/asciidoctor/pdf.rb')
|
|
5
5
|
require asciidoctor_pdf
|
|
6
6
|
else
|
|
7
7
|
require 'asciidoctor/pdf'
|
|
8
8
|
end
|
|
9
9
|
require 'asciidoctor/cli'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# FIXME: provide an API in Asciidoctor for sub-projects to prepend version information
|
|
12
|
+
options = (Asciidoctor::Cli::Options.new backend: 'pdf', header_footer: true).extend (Module.new do
|
|
13
|
+
def print_version os = $stdout
|
|
14
|
+
os.write %(Asciidoctor PDF #{Asciidoctor::PDF::VERSION} using )
|
|
15
|
+
super
|
|
16
|
+
end
|
|
17
|
+
end)
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
args = ARGV.dup
|
|
20
|
+
|
|
21
|
+
if (theme_idx = args.index {|it| it == '--theme' || (it.start_with? '--theme=') })
|
|
22
|
+
if (theme_arg = args[theme_idx]).length > 7
|
|
23
|
+
args[theme_idx..theme_idx] = ['-a', %(pdf#{theme_arg.slice 1, theme_arg.length})]
|
|
24
|
+
elsif (val = args[theme_idx + 1]) && !(val.start_with? '-')
|
|
25
|
+
args[theme_idx] = '-a'
|
|
26
|
+
args[theme_idx + 1] = %(pdf-theme=#{val})
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if (Gem::Version.new Asciidoctor::VERSION) < (Gem::Version.new '2.1.0') && (args.include? '--sourcemap')
|
|
31
|
+
args.delete '--sourcemap'
|
|
32
|
+
Asciidoctor::Extensions.register do
|
|
33
|
+
preprocessor do
|
|
34
|
+
process {|doc| (doc.sourcemap = true) && nil }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
18
37
|
end
|
|
19
38
|
|
|
20
|
-
# FIXME This is a really bizarre API. Please make me simpler.
|
|
21
|
-
case (result = options.parse!
|
|
39
|
+
# FIXME: This is a really bizarre API. Please make me simpler.
|
|
40
|
+
case (result = options.parse! args)
|
|
22
41
|
when Integer
|
|
23
42
|
exit result
|
|
24
43
|
else
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
optimizer = File.
|
|
5
|
-
if File.exist? optimizer
|
|
4
|
+
if File.file? (optimizer = File.join (File.dirname __dir__), 'lib/asciidoctor/pdf/optimizer.rb')
|
|
6
5
|
require optimizer
|
|
7
6
|
else
|
|
8
7
|
require 'asciidoctor/pdf/optimizer'
|
|
@@ -27,8 +27,6 @@ module Asciidoctor
|
|
|
27
27
|
|
|
28
28
|
attr_accessor :font_scale
|
|
29
29
|
|
|
30
|
-
attr_reader :root_font_size
|
|
31
|
-
|
|
32
30
|
attr_reader :index
|
|
33
31
|
|
|
34
32
|
attr_reader :theme
|
|
@@ -162,11 +160,11 @@ module Asciidoctor
|
|
|
162
160
|
doc.promote_preface_block
|
|
163
161
|
init_pdf doc
|
|
164
162
|
# set default value for outline, outline-title, and pagenums attributes if not otherwise set
|
|
165
|
-
doc.attributes['outline'] = ''
|
|
166
|
-
doc.attributes['outline-title'] = ''
|
|
167
|
-
doc.attributes['pagenums'] = ''
|
|
163
|
+
doc.attributes['outline'] = '' if doc.attr_unspecified? 'outline'
|
|
164
|
+
doc.attributes['outline-title'] = '' if doc.attr_unspecified? 'outline-title'
|
|
165
|
+
doc.attributes['pagenums'] = '' if doc.attr_unspecified? 'pagenums'
|
|
168
166
|
|
|
169
|
-
on_page_create(&(method :init_page))
|
|
167
|
+
on_page_create(&(method :init_page).curry[doc])
|
|
170
168
|
|
|
171
169
|
marked_page_number = page_number
|
|
172
170
|
# NOTE: a new page will already be started (page_number = 2) if the front cover image is a PDF
|
|
@@ -181,7 +179,7 @@ module Asciidoctor
|
|
|
181
179
|
end
|
|
182
180
|
start_new_page
|
|
183
181
|
else
|
|
184
|
-
@
|
|
182
|
+
@page_margin[:cover] = @page_margin[page.layout][:recto] if @media == 'prepress' && page_number == 0
|
|
185
183
|
start_new_page unless page&.empty? # rubocop:disable Lint/SafeNavigationWithEmpty
|
|
186
184
|
# NOTE: the base font must be set before any content is written to the main or scratch document
|
|
187
185
|
# this method is called inside ink_title_page if the title page is active
|
|
@@ -202,19 +200,24 @@ module Asciidoctor
|
|
|
202
200
|
if (insert_toc = (doc.attr? 'toc') && !((toc_placement = doc.attr 'toc-placement') == 'macro' || toc_placement == 'preamble') && !(get_entries_for_toc doc).empty?)
|
|
203
201
|
start_new_page if @ppbook && verso_page?
|
|
204
202
|
add_dest_for_block doc, id: 'toc', y: (at_page_top? ? page_height : nil)
|
|
205
|
-
@toc_extent = allocate_toc doc, toc_num_levels, cursor, title_page_on
|
|
203
|
+
@toc_extent = allocate_toc doc, toc_num_levels, cursor, (title_page_on && theme.toc_break_after != 'auto')
|
|
206
204
|
else
|
|
207
205
|
@toc_extent = nil
|
|
208
206
|
end
|
|
209
207
|
|
|
210
|
-
|
|
208
|
+
if @ppbook && verso_page? && !(((next_block = doc.first_child)&.context == :preamble ? next_block.first_child : next_block)&.option? 'nonfacing')
|
|
209
|
+
min_start_at = 0
|
|
210
|
+
start_new_page
|
|
211
|
+
else
|
|
212
|
+
min_start_at = 1
|
|
213
|
+
end
|
|
211
214
|
|
|
212
215
|
if title_page_on
|
|
213
216
|
zero_page_offset = has_front_cover ? 1 : 0
|
|
214
217
|
first_page_offset = has_title_page ? zero_page_offset.next : zero_page_offset
|
|
215
218
|
body_offset = (body_start_page_number = page_number) - 1
|
|
216
219
|
if ::Integer === (running_content_start_at = @theme.running_content_start_at)
|
|
217
|
-
running_content_body_offset = body_offset + [running_content_start_at.pred,
|
|
220
|
+
running_content_body_offset = body_offset + [running_content_start_at.pred, min_start_at.pred].max
|
|
218
221
|
running_content_start_at = 'body'
|
|
219
222
|
else
|
|
220
223
|
running_content_body_offset = body_offset
|
|
@@ -228,7 +231,7 @@ module Asciidoctor
|
|
|
228
231
|
end
|
|
229
232
|
end
|
|
230
233
|
if ::Integer === (page_numbering_start_at = @theme.page_numbering_start_at)
|
|
231
|
-
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred,
|
|
234
|
+
page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, min_start_at.pred].max
|
|
232
235
|
page_numbering_start_at = 'body'
|
|
233
236
|
else
|
|
234
237
|
page_numbering_body_offset = body_offset
|
|
@@ -353,7 +356,6 @@ module Asciidoctor
|
|
|
353
356
|
@cache_uri = doc.attr? 'cache-uri'
|
|
354
357
|
@jail_dir = doc.safe < ::Asciidoctor::SafeMode::SAFE ? nil : doc.base_dir
|
|
355
358
|
@media ||= doc.attr 'media', 'screen'
|
|
356
|
-
@page_margin_by_side = { recto: (page_margin_recto = page_margin), verso: (page_margin_verso = page_margin), cover: page_margin }
|
|
357
359
|
case doc.attr 'pdf-folio-placement', (@media == 'prepress' ? 'physical' : 'virtual')
|
|
358
360
|
when 'physical'
|
|
359
361
|
@folio_placement = { basis: :physical }
|
|
@@ -364,6 +366,13 @@ module Asciidoctor
|
|
|
364
366
|
else
|
|
365
367
|
@folio_placement = { basis: :virtual }
|
|
366
368
|
end
|
|
369
|
+
@page_margin = { cover: page_margin }
|
|
370
|
+
@page_margin[:portrait] = @page_margin[:landscape] = { recto: (page_margin_recto = page_margin), verso: (page_margin_verso = page_margin) }
|
|
371
|
+
if (rotated_page_margin = resolve_page_margin (doc.attr 'pdf-page-margin-rotated') || theme.page_margin_rotated)
|
|
372
|
+
rotated_page_margin = expand_margin_value rotated_page_margin
|
|
373
|
+
@edge_shorthand_cache = nil
|
|
374
|
+
@page_margin[PageLayouts[(PageLayouts.index page.layout) - 1]] = { recto: rotated_page_margin, verso: rotated_page_margin.dup }
|
|
375
|
+
end
|
|
367
376
|
if @media == 'prepress'
|
|
368
377
|
@ppbook = doc.doctype == 'book'
|
|
369
378
|
if (page_margin_outer = theme.page_margin_outer)
|
|
@@ -375,17 +384,7 @@ module Asciidoctor
|
|
|
375
384
|
else
|
|
376
385
|
@ppbook = nil
|
|
377
386
|
end
|
|
378
|
-
|
|
379
|
-
@page_bg_image = { verso: bg_image, recto: bg_image }
|
|
380
|
-
else
|
|
381
|
-
@page_bg_image = { verso: nil, recto: nil }
|
|
382
|
-
end
|
|
383
|
-
if (bg_image = resolve_background_image doc, theme, 'page-background-image-verso')
|
|
384
|
-
@page_bg_image[:verso] = bg_image[0] && bg_image
|
|
385
|
-
end
|
|
386
|
-
if (bg_image = resolve_background_image doc, theme, 'page-background-image-recto')
|
|
387
|
-
@page_bg_image[:recto] = bg_image[0] && bg_image
|
|
388
|
-
end
|
|
387
|
+
@page_bg_image = {}
|
|
389
388
|
@page_bg_color = resolve_theme_color :page_background_color, 'FFFFFF'
|
|
390
389
|
# QUESTION: should ThemeLoader handle registering fonts instead?
|
|
391
390
|
register_fonts theme.font_catalog, ((doc.attr 'pdf-fontsdir')&.sub '{docdir}', (doc.attr 'docdir')) || 'GEM_FONTS_DIR'
|
|
@@ -398,8 +397,7 @@ module Asciidoctor
|
|
|
398
397
|
@base_text_align = (text_align = doc.attr 'text-align') && (TextAlignmentNames.include? text_align) ? text_align : theme.base_text_align
|
|
399
398
|
@base_line_height = theme.base_line_height
|
|
400
399
|
@cjk_line_breaks = doc.attr? 'scripts', 'cjk'
|
|
401
|
-
if (hyphen_lang = (doc.attr 'hyphens') ||
|
|
402
|
-
(((doc.attribute_locked? 'hyphens') || ((doc.instance_variable_get :@attributes_modified).include? 'hyphens')) ? nil : @theme.base_hyphens)) &&
|
|
400
|
+
if (hyphen_lang = (doc.attr 'hyphens') || ((doc.attr_unspecified? 'hyphens') ? @theme.base_hyphens : nil)) &&
|
|
403
401
|
((defined? ::Text::Hyphen::VERSION) || !(Helpers.require_library 'text/hyphen', 'text-hyphen', :warn).nil?)
|
|
404
402
|
hyphen_lang = doc.attr 'lang' if !(::String === hyphen_lang) || hyphen_lang.empty?
|
|
405
403
|
hyphen_lang = 'en_us' if hyphen_lang.nil_or_empty? || hyphen_lang == 'en'
|
|
@@ -437,34 +435,7 @@ module Asciidoctor
|
|
|
437
435
|
end
|
|
438
436
|
|
|
439
437
|
def build_pdf_options doc, theme
|
|
440
|
-
|
|
441
|
-
when ::Array
|
|
442
|
-
if page_margin.empty?
|
|
443
|
-
page_margin = nil
|
|
444
|
-
else
|
|
445
|
-
page_margin = page_margin.slice 0, 4 if page_margin.length > 4
|
|
446
|
-
page_margin = page_margin.map {|v| ::Numeric === v ? v : (str_to_pt v.to_s) }
|
|
447
|
-
end
|
|
448
|
-
when ::Numeric
|
|
449
|
-
page_margin = [page_margin]
|
|
450
|
-
when ::String
|
|
451
|
-
if page_margin.empty?
|
|
452
|
-
page_margin = nil
|
|
453
|
-
elsif (page_margin.start_with? '[') && (page_margin.end_with? ']')
|
|
454
|
-
if (page_margin = (page_margin.slice 1, page_margin.length - 2).rstrip).empty?
|
|
455
|
-
page_margin = nil
|
|
456
|
-
else
|
|
457
|
-
if (page_margin = page_margin.split ',', -1).length > 4
|
|
458
|
-
page_margin = page_margin.slice 0, 4
|
|
459
|
-
end
|
|
460
|
-
page_margin = page_margin.map {|v| str_to_pt v.rstrip }
|
|
461
|
-
end
|
|
462
|
-
else
|
|
463
|
-
page_margin = [(str_to_pt page_margin)]
|
|
464
|
-
end
|
|
465
|
-
else
|
|
466
|
-
page_margin = nil
|
|
467
|
-
end
|
|
438
|
+
page_margin = resolve_page_margin (doc.attr 'pdf-page-margin') || theme.page_margin
|
|
468
439
|
|
|
469
440
|
if (doc.attr? 'pdf-page-size') && PageSizeRx =~ (doc.attr 'pdf-page-size')
|
|
470
441
|
# e.g, [8.5in, 11in]
|
|
@@ -917,7 +888,7 @@ module Asciidoctor
|
|
|
917
888
|
label_width = label_min_width || (icon_size * 1.5)
|
|
918
889
|
elsif (icon_path = has_icon || !(icon_path = (@theme[%(admonition_icon_#{type})] || {})[:image]) ?
|
|
919
890
|
(get_icon_image_path node, type) :
|
|
920
|
-
(ThemeLoader.resolve_theme_asset (apply_subs_discretely doc, icon_path, subs: [:attributes]), @themesdir)) &&
|
|
891
|
+
(ThemeLoader.resolve_theme_asset (apply_subs_discretely doc, icon_path, subs: [:attributes], imagesdir: @themesdir), @themesdir)) &&
|
|
921
892
|
(::File.readable? icon_path)
|
|
922
893
|
icons = true
|
|
923
894
|
# TODO: introduce @theme.admonition_image_width? or use size key from admonition_icon_<name>?
|
|
@@ -1464,7 +1435,8 @@ module Asciidoctor
|
|
|
1464
1435
|
end
|
|
1465
1436
|
max_term_width += (term_padding[1] + term_padding[3])
|
|
1466
1437
|
term_column_width = [max_term_width, bounds.width * 0.5].min
|
|
1467
|
-
table table_data, position: :left,
|
|
1438
|
+
table table_data, position: :left, column_widths: [term_column_width] do
|
|
1439
|
+
cells.style border_width: 0
|
|
1468
1440
|
@pdf.ink_table_caption node if node.title?
|
|
1469
1441
|
end
|
|
1470
1442
|
theme_margin :prose, :bottom, (next_enclosed_block actual_node) #unless actual_node.nested?
|
|
@@ -1633,6 +1605,9 @@ module Asciidoctor
|
|
|
1633
1605
|
marker = node.parent.style == 'decimal' && index.abs < 10 ? %(#{index < 0 ? '-' : ''}0#{index.abs}.) : %(#{index}.)
|
|
1634
1606
|
dir = (node.parent.option? 'reversed') ? :pred : :next
|
|
1635
1607
|
@list_numerals << (index.public_send dir)
|
|
1608
|
+
[:font_color, :font_family, :font_size, :font_style, :line_height].each do |prop|
|
|
1609
|
+
marker_style[prop] = @theme[%(olist_marker_#{prop})] || marker_style[prop]
|
|
1610
|
+
end
|
|
1636
1611
|
end
|
|
1637
1612
|
end
|
|
1638
1613
|
else # :ulist
|
|
@@ -1647,7 +1622,7 @@ module Asciidoctor
|
|
|
1647
1622
|
else
|
|
1648
1623
|
marker = @theme[%(ulist_marker_#{marker_type}_content)] || Bullets[marker_type]
|
|
1649
1624
|
end
|
|
1650
|
-
[:font_color, :font_family, :font_size, :line_height].each do |prop|
|
|
1625
|
+
[:font_color, :font_family, :font_size, :font_style, :line_height].each do |prop|
|
|
1651
1626
|
marker_style[prop] = @theme[%(ulist_marker_#{marker_type}_#{prop})] || @theme[%(ulist_marker_#{prop})] || marker_style[prop]
|
|
1652
1627
|
end if marker
|
|
1653
1628
|
end
|
|
@@ -1658,8 +1633,9 @@ module Asciidoctor
|
|
|
1658
1633
|
log :info, 'deprecated fa icon set found in theme; use fas, far, or fab instead'
|
|
1659
1634
|
marker_style[:font_family] = FontAwesomeIconSets.find {|candidate| (icon_font_data candidate).yaml[candidate].value? marker } || 'fas'
|
|
1660
1635
|
end
|
|
1636
|
+
marker_style[:font_style] &&= marker_style[:font_style].to_sym
|
|
1661
1637
|
marker_gap = rendered_width_of_char 'x'
|
|
1662
|
-
font marker_style[:font_family], marker_style[:font_size] do
|
|
1638
|
+
font marker_style[:font_family], size: marker_style[:font_size], style: marker_style[:font_style] do
|
|
1663
1639
|
marker_width = rendered_width_of_string marker
|
|
1664
1640
|
# NOTE: compensate if character_spacing is not applied to first character
|
|
1665
1641
|
# see https://github.com/prawnpdf/prawn/commit/c61c5d48841910aa11b9e3d6f0e01b68ce435329
|
|
@@ -1678,6 +1654,7 @@ module Asciidoctor
|
|
|
1678
1654
|
color: marker_style[:font_color],
|
|
1679
1655
|
inline_format: false,
|
|
1680
1656
|
line_height: marker_style[:line_height],
|
|
1657
|
+
style: marker_style[:font_style],
|
|
1681
1658
|
margin: 0,
|
|
1682
1659
|
normalize: false,
|
|
1683
1660
|
single_line: true
|
|
@@ -1942,10 +1919,10 @@ module Asciidoctor
|
|
|
1942
1919
|
if at_page_top?
|
|
1943
1920
|
if page_layout && page_layout != page.layout && page.empty?
|
|
1944
1921
|
delete_current_page
|
|
1945
|
-
advance_page layout: page_layout
|
|
1922
|
+
advance_page layout: page_layout, margin: @page_margin[page_layout][page_side nil, @folio_placement[:inverted]]
|
|
1946
1923
|
end
|
|
1947
1924
|
elsif page_layout
|
|
1948
|
-
advance_page layout: page_layout
|
|
1925
|
+
advance_page layout: page_layout, margin: @page_margin[page_layout][page_side nil, @folio_placement[:inverted]]
|
|
1949
1926
|
else
|
|
1950
1927
|
advance_page
|
|
1951
1928
|
end
|
|
@@ -1996,6 +1973,7 @@ module Asciidoctor
|
|
|
1996
1973
|
num_cols = node.columns.size
|
|
1997
1974
|
table_header_size = false
|
|
1998
1975
|
theme = @theme
|
|
1976
|
+
prev_font_scale, @font_scale = @font_scale, 1 if node.document.nested?
|
|
1999
1977
|
|
|
2000
1978
|
tbl_bg_color = resolve_theme_color :table_background_color
|
|
2001
1979
|
# QUESTION: should we fallback to page background color? (which is never transparent)
|
|
@@ -2135,7 +2113,7 @@ module Asciidoctor
|
|
|
2135
2113
|
end
|
|
2136
2114
|
# NOTE: line metrics get applied when AsciiDoc content is converted
|
|
2137
2115
|
cell_line_metrics = nil
|
|
2138
|
-
asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding)
|
|
2116
|
+
asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding, root_font_size: @root_font_size)
|
|
2139
2117
|
cell_data = { content: asciidoc_cell, source_location: cell.source_location }
|
|
2140
2118
|
end
|
|
2141
2119
|
if cell_line_metrics
|
|
@@ -2240,10 +2218,10 @@ module Asciidoctor
|
|
|
2240
2218
|
# NOTE: position is handled by this method
|
|
2241
2219
|
position: :left,
|
|
2242
2220
|
# NOTE: the border color, style, and width of the outer frame is set in the table callback block
|
|
2243
|
-
cell_style: { border_color: grid_color.values, border_lines: grid_style.values, border_width: grid_width.values },
|
|
2244
2221
|
width: table_width,
|
|
2245
2222
|
column_widths: column_widths,
|
|
2246
2223
|
}
|
|
2224
|
+
cell_style = { border_color: grid_color.values, border_lines: grid_style.values, border_width: grid_width.values }
|
|
2247
2225
|
|
|
2248
2226
|
# QUESTION: should we support nth; should we support sequence of roles?
|
|
2249
2227
|
case node.attr 'stripes', nil, 'table-stripes'
|
|
@@ -2259,6 +2237,8 @@ module Asciidoctor
|
|
|
2259
2237
|
|
|
2260
2238
|
left_padding = right_padding = nil
|
|
2261
2239
|
table table_data, table_settings do
|
|
2240
|
+
# NOTE: cell_style must be applied manually to be compatible with both prawn-table 0.2.2 and prawn-table 0.2.3
|
|
2241
|
+
cells.style cell_style
|
|
2262
2242
|
@column_widths = column_widths unless column_widths.empty?
|
|
2263
2243
|
# NOTE: call width to capture resolved table width
|
|
2264
2244
|
table_width = width
|
|
@@ -2339,6 +2319,8 @@ module Asciidoctor
|
|
|
2339
2319
|
theme_margin :block, :bottom, (next_enclosed_block node)
|
|
2340
2320
|
rescue ::Prawn::Errors::CannotFit
|
|
2341
2321
|
log :error, (message_with_context 'cannot fit contents of table cell into specified column width', source_location: node.source_location)
|
|
2322
|
+
ensure
|
|
2323
|
+
@font_scale = prev_font_scale if prev_font_scale
|
|
2342
2324
|
end
|
|
2343
2325
|
|
|
2344
2326
|
def convert_thematic_break node
|
|
@@ -2428,7 +2410,7 @@ module Asciidoctor
|
|
|
2428
2410
|
# QUESTION: should we insert breakable chars into URI when building fragment instead?
|
|
2429
2411
|
%(#{anchor}<a href="#{target}"#{attrs.join}>#{breakable_uri text}</a>)
|
|
2430
2412
|
# NOTE: @media may not be initialized if method is called before convert phase
|
|
2431
|
-
elsif (doc.attr? 'show-link-uri') ||
|
|
2413
|
+
elsif (doc.attr? 'show-link-uri') || (@media != 'screen' && (doc.attr_unspecified? 'show-link-uri'))
|
|
2432
2414
|
# QUESTION: should we insert breakable chars into URI when building fragment instead?
|
|
2433
2415
|
# TODO: allow style of printed link to be controlled by theme
|
|
2434
2416
|
%(#{anchor}<a href="#{target}"#{attrs.join}>#{text}</a> [<font size="0.85em">#{breakable_uri bare_target}</font>])
|
|
@@ -2792,6 +2774,11 @@ module Asciidoctor
|
|
|
2792
2774
|
if (imagesdir = opts[:imagesdir])
|
|
2793
2775
|
imagesdir_to_restore = doc.attr 'imagesdir'
|
|
2794
2776
|
doc.set_attr 'imagesdir', imagesdir
|
|
2777
|
+
remove_docimagesdir = doc.set_attr 'docimagesdir', (::File.absolute_path imagesdir_to_restore.to_s, (doc.attr 'docdir', '')), false
|
|
2778
|
+
end
|
|
2779
|
+
if (page_layout = opts[:page_layout])
|
|
2780
|
+
page_layout_to_restore = doc.attr 'page-layout'
|
|
2781
|
+
doc.set_attr 'page-layout', page.layout.to_s
|
|
2795
2782
|
end
|
|
2796
2783
|
# FIXME: get sub_attributes to handle drop-line w/o a warning
|
|
2797
2784
|
doc.set_attr 'attribute-missing', 'skip' unless (attribute_missing = doc.attr 'attribute-missing') == 'skip'
|
|
@@ -2800,20 +2787,26 @@ module Asciidoctor
|
|
|
2800
2787
|
value = (value.split LF).delete_if {|line| SimpleAttributeRefRx.match? line }.join LF if opts[:drop_lines_with_unresolved_attributes] && (value.include? '{')
|
|
2801
2788
|
value = value.gsub '\{', '{' if escaped_attr_ref
|
|
2802
2789
|
doc.set_attr 'attribute-missing', attribute_missing unless attribute_missing == 'skip'
|
|
2803
|
-
|
|
2790
|
+
page_layout_to_restore ? (doc.set_attr 'page-layout', page_layout_to_restore) : (doc.remove_attr 'page-layout') if page_layout
|
|
2791
|
+
if imagesdir
|
|
2792
|
+
imagesdir_to_restore ? (doc.set_attr 'imagesdir', imagesdir_to_restore) : (doc.remove_attr 'imagesdir')
|
|
2793
|
+
doc.remove_attr 'docimagesdir' if remove_docimagesdir
|
|
2794
|
+
end
|
|
2804
2795
|
value
|
|
2805
2796
|
end
|
|
2806
2797
|
|
|
2807
2798
|
# Position the cursor for where to ink the specified section title or discrete heading node.
|
|
2808
2799
|
#
|
|
2809
|
-
# This method computes whether there
|
|
2810
|
-
# from being orphaned. If there
|
|
2800
|
+
# This method computes whether there's enough room on the page to prevent the specified node
|
|
2801
|
+
# from being orphaned. If there's not enough room, the method will advance the cursor to
|
|
2811
2802
|
# the next page. This method is not called if the cursor is already at the top of the page or
|
|
2812
2803
|
# whether this node has no node that follows it in document order.
|
|
2813
2804
|
def arrange_heading node, title, opts
|
|
2814
|
-
if node.option? 'breakable'
|
|
2805
|
+
if (min_height_after = @theme.heading_min_height_after) == 'auto' || (node.option? 'breakable')
|
|
2815
2806
|
orphaned = nil
|
|
2807
|
+
doc = node.document
|
|
2816
2808
|
dry_run single_page: true do
|
|
2809
|
+
push_scratch doc
|
|
2817
2810
|
start_page = page
|
|
2818
2811
|
theme_font :heading, level: opts[:level] do
|
|
2819
2812
|
if opts[:part]
|
|
@@ -2828,6 +2821,8 @@ module Asciidoctor
|
|
|
2828
2821
|
page.tare_content_stream
|
|
2829
2822
|
orphaned = stop_if_first_page_empty { node.context == :section ? (traverse node) : (convert node.next_sibling) }
|
|
2830
2823
|
end
|
|
2824
|
+
ensure
|
|
2825
|
+
pop_scratch doc
|
|
2831
2826
|
end
|
|
2832
2827
|
advance_page if orphaned
|
|
2833
2828
|
else
|
|
@@ -2838,9 +2833,7 @@ module Asciidoctor
|
|
|
2838
2833
|
heading_h = (height_of_typeset_text title) +
|
|
2839
2834
|
(@theme[%(heading_h#{hlevel}_margin_top)] || @theme.heading_margin_top) +
|
|
2840
2835
|
(@theme[%(heading_h#{hlevel}_margin_bottom)] || @theme.heading_margin_bottom) + h_padding_t + h_padding_b
|
|
2841
|
-
|
|
2842
|
-
heading_h += min_height_after
|
|
2843
|
-
end
|
|
2836
|
+
heading_h += min_height_after if min_height_after && (node.context == :section ? node.blocks? : !node.last_child?)
|
|
2844
2837
|
cursor >= heading_h
|
|
2845
2838
|
end
|
|
2846
2839
|
advance_page unless h_fits
|
|
@@ -3103,7 +3096,8 @@ module Asciidoctor
|
|
|
3103
3096
|
end
|
|
3104
3097
|
unless scratch? || !(bg_color = @theme[%(#{category_caption}_background_color)] || @theme.caption_background_color)
|
|
3105
3098
|
caption_height = height_of_typeset_text string
|
|
3106
|
-
fill_at = [bounds.left, cursor
|
|
3099
|
+
fill_at = [bounds.left, cursor]
|
|
3100
|
+
fill_at[1] -= (margin[:top] || 0) unless at_page_top?
|
|
3107
3101
|
float { bounding_box(fill_at, width: container_width, height: caption_height) { fill_bounds bg_color } }
|
|
3108
3102
|
end
|
|
3109
3103
|
indent(*indent_by) do
|
|
@@ -3141,7 +3135,7 @@ module Asciidoctor
|
|
|
3141
3135
|
open_graphics_state if face == :front
|
|
3142
3136
|
return
|
|
3143
3137
|
elsif image_path == '~'
|
|
3144
|
-
@
|
|
3138
|
+
@page_margin[:cover] = @page_margin[page.layout][:recto] if @media == 'prepress'
|
|
3145
3139
|
return
|
|
3146
3140
|
end
|
|
3147
3141
|
|
|
@@ -3272,7 +3266,7 @@ module Asciidoctor
|
|
|
3272
3266
|
|
|
3273
3267
|
def allocate_running_content_layout doc, page, periphery, cache
|
|
3274
3268
|
cache[layout = page.layout] ||= begin
|
|
3275
|
-
page_margin_recto = @
|
|
3269
|
+
page_margin_recto = @page_margin[layout][:recto]
|
|
3276
3270
|
trim_margin_recto = @theme[%(#{periphery}_recto_margin)] || @theme[%(#{periphery}_margin)] || [0, 'inherit', 0, 'inherit']
|
|
3277
3271
|
trim_margin_recto = (expand_margin_value trim_margin_recto).map.with_index {|v, i| i.odd? && v == 'inherit' ? page_margin_recto[i] : v.to_f }
|
|
3278
3272
|
trim_content_margin_recto = @theme[%(#{periphery}_recto_content_margin)] || @theme[%(#{periphery}_content_margin)] || [0, 'inherit', 0, 'inherit']
|
|
@@ -3282,7 +3276,7 @@ module Asciidoctor
|
|
|
3282
3276
|
else
|
|
3283
3277
|
trim_padding_recto = trim_content_margin_recto
|
|
3284
3278
|
end
|
|
3285
|
-
page_margin_verso = @
|
|
3279
|
+
page_margin_verso = @page_margin[layout][:verso]
|
|
3286
3280
|
trim_margin_verso = @theme[%(#{periphery}_verso_margin)] || @theme[%(#{periphery}_margin)] || [0, 'inherit', 0, 'inherit']
|
|
3287
3281
|
trim_margin_verso = (expand_margin_value trim_margin_verso).map.with_index {|v, i| i.odd? && v == 'inherit' ? page_margin_verso[i] : v.to_f }
|
|
3288
3282
|
trim_content_margin_verso = @theme[%(#{periphery}_verso_content_margin)] || @theme[%(#{periphery}_content_margin)] || [0, 'inherit', 0, 'inherit']
|
|
@@ -3677,7 +3671,7 @@ module Asciidoctor
|
|
|
3677
3671
|
logo_image_attrs = (AttributeList.new $2).parse %w(alt width height)
|
|
3678
3672
|
if logo_image_from_theme
|
|
3679
3673
|
relative_to_imagesdir = false
|
|
3680
|
-
logo_image_path = apply_subs_discretely doc, $1, subs: [:attributes]
|
|
3674
|
+
logo_image_path = apply_subs_discretely doc, $1, subs: [:attributes], imagesdir: @themesdir
|
|
3681
3675
|
logo_image_path = ThemeLoader.resolve_theme_asset logo_image_path, @themesdir unless doc.is_uri? logo_image_path
|
|
3682
3676
|
else
|
|
3683
3677
|
relative_to_imagesdir = true
|
|
@@ -3687,7 +3681,7 @@ module Asciidoctor
|
|
|
3687
3681
|
logo_image_attrs = {}
|
|
3688
3682
|
relative_to_imagesdir = false
|
|
3689
3683
|
if logo_image_from_theme
|
|
3690
|
-
logo_image_path = apply_subs_discretely doc, logo_image_path, subs: [:attributes]
|
|
3684
|
+
logo_image_path = apply_subs_discretely doc, logo_image_path, subs: [:attributes], imagesdir: @themesdir
|
|
3691
3685
|
logo_image_path = ThemeLoader.resolve_theme_asset logo_image_path, @themesdir unless doc.is_uri? logo_image_path
|
|
3692
3686
|
end
|
|
3693
3687
|
end
|
|
@@ -3773,12 +3767,12 @@ module Asciidoctor
|
|
|
3773
3767
|
end
|
|
3774
3768
|
end
|
|
3775
3769
|
|
|
3776
|
-
def allocate_toc doc, toc_num_levels, toc_start_cursor,
|
|
3770
|
+
def allocate_toc doc, toc_num_levels, toc_start_cursor, break_after_toc
|
|
3777
3771
|
toc_start_page_number = page_number
|
|
3778
3772
|
to_page = nil
|
|
3779
3773
|
extent = dry_run onto: self do
|
|
3780
3774
|
to_page = (ink_toc doc, toc_num_levels, toc_start_page_number, toc_start_cursor).end
|
|
3781
|
-
theme_margin :block, :bottom unless
|
|
3775
|
+
theme_margin :block, :bottom unless break_after_toc
|
|
3782
3776
|
end
|
|
3783
3777
|
# NOTE: patch for custom converters that allocate extra TOC pages without actually creating them
|
|
3784
3778
|
if to_page > extent.to.page
|
|
@@ -3786,7 +3780,7 @@ module Asciidoctor
|
|
|
3786
3780
|
extent.to.cursor = bounds.height
|
|
3787
3781
|
end
|
|
3788
3782
|
# NOTE: reserve pages for the toc; leaves cursor on page after last page in toc
|
|
3789
|
-
if
|
|
3783
|
+
if break_after_toc
|
|
3790
3784
|
extent.each_page { start_new_page }
|
|
3791
3785
|
else
|
|
3792
3786
|
extent.each_page {|first_page| start_new_page unless first_page }
|
|
@@ -4057,18 +4051,14 @@ module Asciidoctor
|
|
|
4057
4051
|
return []
|
|
4058
4052
|
elsif (image_path.include? ':') && image_path =~ ImageAttributeValueRx
|
|
4059
4053
|
image_attrs = (AttributeList.new $2).parse %w(alt width)
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
elsif from_theme
|
|
4068
|
-
image_path = apply_subs_discretely doc, image_path, subs: [:attributes]
|
|
4069
|
-
image_relative_to = @themesdir
|
|
4054
|
+
image_path = $1
|
|
4055
|
+
image_relative_to = true
|
|
4056
|
+
end
|
|
4057
|
+
if from_theme
|
|
4058
|
+
image_path = apply_subs_discretely doc, image_path, subs: [:attributes], imagesdir: (image_relative_to = @themesdir), page_layout: page.layout.to_s
|
|
4059
|
+
elsif image_path.include? '{page-layout}'
|
|
4060
|
+
image_path = image_path.sub '{page-layout}', page.layout.to_s
|
|
4070
4061
|
end
|
|
4071
|
-
|
|
4072
4062
|
image_path, image_format = ::Asciidoctor::Image.target_and_format image_path, image_attrs
|
|
4073
4063
|
image_path = resolve_image_path doc, image_path, image_format, image_relative_to
|
|
4074
4064
|
|
|
@@ -4282,6 +4272,27 @@ module Asciidoctor
|
|
|
4282
4272
|
end
|
|
4283
4273
|
end
|
|
4284
4274
|
|
|
4275
|
+
def resolve_page_margin value
|
|
4276
|
+
return if value.nil_or_empty?
|
|
4277
|
+
case value
|
|
4278
|
+
when ::Array
|
|
4279
|
+
value = value.slice 0, 4 if value.length > 4
|
|
4280
|
+
value.map {|v| ::Numeric === v ? v : (str_to_pt v.to_s) }
|
|
4281
|
+
when ::Numeric
|
|
4282
|
+
[value]
|
|
4283
|
+
when ::String
|
|
4284
|
+
if (value.start_with? '[') && (value.end_with? ']')
|
|
4285
|
+
return if (value = (value.slice 1, value.length - 2).rstrip).empty?
|
|
4286
|
+
if (value = value.split ',', -1).length > 4
|
|
4287
|
+
value = value.slice 0, 4
|
|
4288
|
+
end
|
|
4289
|
+
value.map {|v| str_to_pt v.rstrip }
|
|
4290
|
+
else
|
|
4291
|
+
[(str_to_pt value)]
|
|
4292
|
+
end
|
|
4293
|
+
end
|
|
4294
|
+
end
|
|
4295
|
+
|
|
4285
4296
|
def resolve_text_align_from_role roles, query_theme: false, remove_predefined: false
|
|
4286
4297
|
if (align_role = roles.reverse.find {|r| TextAlignmentRoles.include? r })
|
|
4287
4298
|
roles.replace roles - TextAlignmentRoles if remove_predefined
|
|
@@ -4334,17 +4345,17 @@ module Asciidoctor
|
|
|
4334
4345
|
elsif @ppbook && page_number > 0 && recto_page?
|
|
4335
4346
|
start_new_page
|
|
4336
4347
|
end
|
|
4337
|
-
side = page_side (recycle ? nil : page_number + 1), @folio_placement[:inverted]
|
|
4338
|
-
prev_bg_image = @page_bg_image[side]
|
|
4339
|
-
prev_bg_color = @page_bg_color
|
|
4340
4348
|
if (bg_image = resolve_background_image doc, @theme, 'title-page-background-image')
|
|
4341
|
-
|
|
4349
|
+
side = page_side (recycle ? nil : page_number + 1), @folio_placement[:inverted]
|
|
4350
|
+
prev_bg_image = get_page_bg_image doc, @theme, (layout = page.layout), side
|
|
4351
|
+
@page_bg_image[layout][side] = bg_image[0] && bg_image
|
|
4342
4352
|
end
|
|
4343
4353
|
if (bg_color = resolve_theme_color :title_page_background_color)
|
|
4354
|
+
prev_bg_color = @page_bg_color
|
|
4344
4355
|
@page_bg_color = bg_color
|
|
4345
4356
|
end
|
|
4346
|
-
recycle ? float { init_page self } : start_new_page
|
|
4347
|
-
@page_bg_image[side] = prev_bg_image if bg_image
|
|
4357
|
+
recycle ? float { init_page doc, self } : start_new_page
|
|
4358
|
+
@page_bg_image[layout][side] = prev_bg_image if bg_image
|
|
4348
4359
|
@page_bg_color = prev_bg_color if bg_color
|
|
4349
4360
|
true
|
|
4350
4361
|
end
|
|
@@ -4431,7 +4442,12 @@ module Asciidoctor
|
|
|
4431
4442
|
if opts.key? :level
|
|
4432
4443
|
hlevel_category = %(#{category}_h#{opts[:level]})
|
|
4433
4444
|
family = @theme[%(#{hlevel_category}_font_family)] || @theme[%(#{category}_font_family)] || @theme.base_font_family || font_family
|
|
4434
|
-
size =
|
|
4445
|
+
if (size = @theme[%(#{hlevel_category}_font_size)] || @theme[%(#{category}_font_size)])
|
|
4446
|
+
scale = @font_scale unless ::String === size
|
|
4447
|
+
else
|
|
4448
|
+
scale = @font_scale
|
|
4449
|
+
size = @root_font_size
|
|
4450
|
+
end
|
|
4435
4451
|
style = @theme[%(#{hlevel_category}_font_style)] || @theme[%(#{category}_font_style)]
|
|
4436
4452
|
color = @theme[%(#{hlevel_category}_font_color)] || @theme[%(#{category}_font_color)]
|
|
4437
4453
|
kerning = resolve_font_kerning @theme[%(#{hlevel_category}_font_kerning)] || @theme[%(#{category}_font_kerning)]
|
|
@@ -4441,7 +4457,11 @@ module Asciidoctor
|
|
|
4441
4457
|
else
|
|
4442
4458
|
inherited_font = font_info
|
|
4443
4459
|
family = @theme[%(#{category}_font_family)] || inherited_font[:family]
|
|
4444
|
-
|
|
4460
|
+
if (size = @theme[%(#{category}_font_size)])
|
|
4461
|
+
scale = @font_scale unless ::String === size
|
|
4462
|
+
else
|
|
4463
|
+
size = inherited_font[:size]
|
|
4464
|
+
end
|
|
4445
4465
|
style = @theme[%(#{category}_font_style)] || inherited_font[:style]
|
|
4446
4466
|
color = @theme[%(#{category}_font_color)]
|
|
4447
4467
|
kerning = resolve_font_kerning @theme[%(#{category}_font_kerning)]
|
|
@@ -4457,6 +4477,7 @@ module Asciidoctor
|
|
|
4457
4477
|
|
|
4458
4478
|
result = nil
|
|
4459
4479
|
font family, size: size, style: style&.to_sym do
|
|
4480
|
+
@font_size *= scale if scale
|
|
4460
4481
|
result = yield
|
|
4461
4482
|
ensure
|
|
4462
4483
|
@font_color = prev_color if color
|
|
@@ -4793,6 +4814,23 @@ module Asciidoctor
|
|
|
4793
4814
|
(code.start_with? '\u') ? ([((code.slice 2, code.length).to_i 16)].pack 'U1') : code
|
|
4794
4815
|
end
|
|
4795
4816
|
|
|
4817
|
+
def get_page_bg_image doc, theme_, layout, side
|
|
4818
|
+
(@page_bg_image[layout] ||= begin
|
|
4819
|
+
if (bg_image = resolve_background_image doc, theme_, 'page-background-image')&.first
|
|
4820
|
+
val = { verso: bg_image, recto: bg_image }
|
|
4821
|
+
else
|
|
4822
|
+
val = { verso: nil, recto: nil }
|
|
4823
|
+
end
|
|
4824
|
+
if (bg_image = resolve_background_image doc, theme_, 'page-background-image-verso')
|
|
4825
|
+
val[:verso] = bg_image[0] && bg_image
|
|
4826
|
+
end
|
|
4827
|
+
if (bg_image = resolve_background_image doc, theme_, 'page-background-image-recto')
|
|
4828
|
+
val[:recto] = bg_image[0] && bg_image
|
|
4829
|
+
end
|
|
4830
|
+
val
|
|
4831
|
+
end)[side]
|
|
4832
|
+
end
|
|
4833
|
+
|
|
4796
4834
|
def get_icon_image_path node, type, resolve = true
|
|
4797
4835
|
doc = node.document
|
|
4798
4836
|
doc.remove_attr 'data-uri' if (data_uri_enabled = doc.attr? 'data-uri')
|
|
@@ -4816,18 +4854,17 @@ module Asciidoctor
|
|
|
4816
4854
|
@float_box = { page: page_number, top: box_t, right: box_r, bottom: box_b, left: box_l, width: box_w, height: box_h, gap: gap }
|
|
4817
4855
|
end
|
|
4818
4856
|
|
|
4819
|
-
# NOTE: init_page is called within a float context; this will suppress prawn-svg messing with the cursor
|
|
4820
4857
|
# NOTE: init_page is not called for imported pages, cover pages, image pages, and pages in the scratch document
|
|
4821
|
-
def init_page
|
|
4858
|
+
def init_page doc, _self
|
|
4822
4859
|
next_page_side = page_side nil, @folio_placement[:inverted]
|
|
4823
|
-
if @media == 'prepress' && (next_page_margin =
|
|
4860
|
+
if @media == 'prepress' && (next_page_margin = page_number == 1 ? @page_margin[:cover] : @page_margin[page.layout][next_page_side]) != page_margin
|
|
4824
4861
|
set_page_margin next_page_margin
|
|
4825
4862
|
end
|
|
4826
4863
|
unless @page_bg_color == 'FFFFFF'
|
|
4827
4864
|
fill_absolute_bounds @page_bg_color
|
|
4828
4865
|
tare = true
|
|
4829
4866
|
end
|
|
4830
|
-
if (bg_image_path, bg_image_opts = @
|
|
4867
|
+
if (bg_image_path, bg_image_opts = get_page_bg_image doc, @theme, (layout = page.layout), next_page_side)
|
|
4831
4868
|
begin
|
|
4832
4869
|
if bg_image_opts[:format] == 'pdf'
|
|
4833
4870
|
# NOTE: pages that use PDF for the background do not support a background color or running content
|
|
@@ -4838,9 +4875,10 @@ module Asciidoctor
|
|
|
4838
4875
|
end
|
|
4839
4876
|
tare = true
|
|
4840
4877
|
rescue
|
|
4841
|
-
facing_page_side = (PageSides -
|
|
4842
|
-
|
|
4843
|
-
|
|
4878
|
+
facing_page_side = PageSides[(PageSides.index next_page_side) - 1]
|
|
4879
|
+
bg_image_by_side = @page_bg_image[layout]
|
|
4880
|
+
bg_image_by_side[facing_page_side] = nil if bg_image_by_side[facing_page_side] == bg_image_by_side[next_page_side]
|
|
4881
|
+
bg_image_by_side[next_page_side] = nil
|
|
4844
4882
|
log :warn, %(could not embed page background image: #{bg_image_path}; #{$!.message})
|
|
4845
4883
|
end
|
|
4846
4884
|
end
|
|
@@ -5011,7 +5049,9 @@ module Asciidoctor
|
|
|
5011
5049
|
end
|
|
5012
5050
|
|
|
5013
5051
|
def resolve_top val
|
|
5014
|
-
if val
|
|
5052
|
+
if ::Numeric === val
|
|
5053
|
+
@y - val
|
|
5054
|
+
elsif val.end_with? 'vh'
|
|
5015
5055
|
page_height * (1 - (val.to_f / 100))
|
|
5016
5056
|
elsif val.end_with? '%'
|
|
5017
5057
|
@y - effective_page_height * (val.to_f / 100)
|
|
@@ -5103,20 +5143,17 @@ module Asciidoctor
|
|
|
5103
5143
|
@label = :scratch
|
|
5104
5144
|
@save_state = nil
|
|
5105
5145
|
@scratch_depth = 0
|
|
5106
|
-
# NOTE: don't need background image in scratch document; can cause marshal error anyway
|
|
5107
|
-
saved_page_bg_image, @page_bg_image = @page_bg_image, { verso: nil, recto: nil }
|
|
5108
5146
|
# NOTE: pdfmark has a reference to the Asciidoctor::Document, which we don't want to serialize
|
|
5109
5147
|
saved_pdfmark, @pdfmark = @pdfmark, nil
|
|
5110
5148
|
# IMPORTANT: don't set font before using marshal as it causes serialization to fail
|
|
5111
5149
|
result = yield
|
|
5112
5150
|
@pdfmark = saved_pdfmark
|
|
5113
|
-
@page_bg_image = saved_page_bg_image
|
|
5114
5151
|
@label = :primary
|
|
5115
5152
|
result
|
|
5116
5153
|
end
|
|
5117
5154
|
|
|
5118
5155
|
def init_scratch originator
|
|
5119
|
-
if @media == 'prepress' && page_margin != (page_margin_recto = @
|
|
5156
|
+
if @media == 'prepress' && page_margin != (page_margin_recto = @page_margin[page.layout][:recto])
|
|
5120
5157
|
# NOTE: prepare scratch document to use page margin from recto side (which has same width as verso side)
|
|
5121
5158
|
set_page_margin page_margin_recto
|
|
5122
5159
|
end
|
|
@@ -371,14 +371,16 @@ module Asciidoctor
|
|
|
371
371
|
else
|
|
372
372
|
super points.to_f
|
|
373
373
|
end
|
|
374
|
-
# NOTE: assume em value (since a font size of 1 is extremely unlikely)
|
|
375
|
-
elsif points <= 1
|
|
376
|
-
super @font_size * points
|
|
377
374
|
else
|
|
378
375
|
super points
|
|
379
376
|
end
|
|
380
377
|
end
|
|
381
378
|
|
|
379
|
+
def set_font font, size = nil
|
|
380
|
+
@font = font
|
|
381
|
+
font_size size if size
|
|
382
|
+
end
|
|
383
|
+
|
|
382
384
|
def resolve_font_style styles
|
|
383
385
|
if styles.include? :bold
|
|
384
386
|
(styles.include? :italic) ? :bold_italic : :bold
|
|
@@ -1121,6 +1123,10 @@ module Asciidoctor
|
|
|
1121
1123
|
# Note that if the block has content that itself requires a dry run, that nested dry run will
|
|
1122
1124
|
# be performed in a separate scratch document.
|
|
1123
1125
|
#
|
|
1126
|
+
# The block passed to dry run should take steps to avoid leaving the document state modified.
|
|
1127
|
+
# This can be done by calling `push_scratch doc` at the start of the block and `pop_scratch`
|
|
1128
|
+
# in the ensure clause of the block.
|
|
1129
|
+
#
|
|
1124
1130
|
# options - A Hash of options that configure the dry run computation:
|
|
1125
1131
|
# :keep_together - A Boolean indicating whether an attempt should be made to keep
|
|
1126
1132
|
# the content on the same page (optional, default: false).
|
|
@@ -1133,7 +1139,7 @@ module Asciidoctor
|
|
|
1133
1139
|
#
|
|
1134
1140
|
# Returns an Extent or ScratchExtent object that describes the bounds of the content block.
|
|
1135
1141
|
def dry_run keep_together: nil, pages_advanced: 0, single_page: nil, onto: nil, &block
|
|
1136
|
-
(scratch_pdf = scratch).start_new_page layout: page.layout
|
|
1142
|
+
(scratch_pdf = scratch).start_new_page layout: page.layout, margin: page_margin
|
|
1137
1143
|
saved_bounds = scratch_pdf.bounds
|
|
1138
1144
|
scratch_pdf.bounds = bounds.dup.tap do |bounds_copy|
|
|
1139
1145
|
bounds_copy.instance_variable_set :@document, scratch_pdf
|
|
@@ -7,6 +7,7 @@ module Prawn
|
|
|
7
7
|
include ::Asciidoctor::Logging
|
|
8
8
|
|
|
9
9
|
attr_accessor :align
|
|
10
|
+
attr_accessor :root_font_size
|
|
10
11
|
attr_accessor :valign
|
|
11
12
|
|
|
12
13
|
def initialize pdf, opts = {}
|
|
@@ -109,7 +110,7 @@ module Prawn
|
|
|
109
110
|
prev_font_color, pdf.font_color = pdf.font_color, font_color if font_color
|
|
110
111
|
font_family ||= font_info[:family]
|
|
111
112
|
if font_size
|
|
112
|
-
prev_font_scale, pdf.font_scale = pdf.font_scale, (font_size.to_f / @
|
|
113
|
+
prev_font_scale, pdf.font_scale = pdf.font_scale, (font_size.to_f / @root_font_size)
|
|
113
114
|
else
|
|
114
115
|
font_size = font_info[:size]
|
|
115
116
|
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.
|
|
4
|
+
version: 2.2.0
|
|
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-
|
|
12
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: asciidoctor
|