asciidoctor-pdf 2.0.0.alpha.2 → 2.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da863e1bc05edaf64e5e443bb042fdaa01cc048ac559c9955bac4d7c27fff1c1
4
- data.tar.gz: 0712e9ee6655c004b82f64c78d3c1eb326c182576e447669cce11e4ff7ca34db
3
+ metadata.gz: 7688a2448dace024b0e6057e878d556ec99ee1ac97bf4c91803d59346a136741
4
+ data.tar.gz: 13807213320754c03cce6304300745ec31a349a8e95441e1495ddc6e6401a99a
5
5
  SHA512:
6
- metadata.gz: 8626792d427b27b635a6836fa0c1c7bf75faff5d82f1a71d74a23333e516086475e268cd524a5f5d2c0cfc9827b5b0f72a9d41fd6cc6b7c568506d914daf6840
7
- data.tar.gz: 764bc2e6b6f069d437583c095a92f9e92969e306c872ea92c52e805c0063fa1d810390a303b597252adb9ca33015bd340f5e8d3851a0d64bb96d0cdc5d523329
6
+ metadata.gz: f3207de1db655ec85350df8b37530306e1ac13d1c1108b091886a8b45fcd5ce42fdc417fc759ef40ba77945925518e76e31341d12ec951ee648772c5b81364da
7
+ data.tar.gz: ab345b122e4137e33ed8ab0956270ce067f20b8b8b4f6aba3737f54f002b60b0653d5e9fbc356778d3787f9601b2f4ed9a6e0a5694bab5c9f376365297ae0626
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,35 @@
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 {uri-repo}/commits/main[commit history] on GitHub.
7
7
 
8
+ == 2.0.0.alpha.3 (2022-05-01) - @mojavelinux
9
+
10
+ Enhancements::
11
+
12
+ * allow border width of block to be specified per edge using 4-value array (#2102)
13
+ * allow padding on block to be specified using 2-value array for ends and sides or 3-value array with implied left side value (#2104)
14
+ * allow margins in running content to be specified using 2-value array for ends and sides or 3-value array with implied left side value (#2104)
15
+ * allow theme to set border and padding on headings per level (#434)
16
+
17
+ Improvements::
18
+
19
+ * reduce top and bottom padding on quote and verse blocks in base theme
20
+ * use uniform top and bottom padding on quote blocks in default theme
21
+ * change `inscribe_` method prefix in converter to `ink_`
22
+
23
+ Bug Fixes::
24
+
25
+ * allow `ink_toc` method in extended converter to insert page above TOC page
26
+ * remap `layout_` methods contributed to converter by prepended module
27
+ * neutralize padding hacks in themes designed before the converter had smart margins
28
+ * allow smallest ends or sides border width on block to be less than 1
29
+ * cap border corners on block when width is defined using array (uniform or otherwise) (#2103)
30
+ * fix crash in certain circumstances when theme does not define value for `base-border-width` key
31
+ * use sensible fallbacks for table border and grid color and width (retains backwards compatibility)
32
+
33
+ === Details
34
+
35
+ {url-repo}/releases/tag/v2.0.0.alpha.3[git tag] | {url-repo}/compare/v2.0.0.alpha.2\...v2.0.0.alpha.3[full diff]
36
+
8
37
  == 2.0.0.alpha.2 (2022-04-29) - @mojavelinux
9
38
 
10
39
  Enhancements::
@@ -12,7 +41,7 @@ Enhancements::
12
41
  * separate `align` and `text-align` keys in theme schema; remap old keys for backwards compatibility (#2095)
13
42
  * allow theme to control the border on all sides of tables independently (#902)
14
43
  * keep section title with first block of content is `breakable` option is set on section (#2075, #38)
15
- * pass `part`, `chapterlike`, and `hidden` options to `arrange_section` method
44
+ * pass the `part` and `chapterlike` options to the `arrange_section` method for convenience
16
45
  * add support for `background-color` property on caption (#1995)
17
46
  * add support for image-based icons, resolved from `iconsdir` and having the `icontype` file extension (#1770)
18
47
  * add `asciidoctor/pdf/nogmagick` script to prevent Gmagick from handling PNG images (#1687)
@@ -36,7 +65,7 @@ Bug Fixes::
36
65
  * delete dests on page before deleting it (keeps generated PDF clean of obsolete destinations)
37
66
  * don't call `arrange_section` if section title is hidden
38
67
  * remove `theme_font` enclosure around call to `start_new_chapter` and `start_new_part`
39
- * change `layout_` method prefix to `inscribe_` in converter (#2099)
68
+ * change `layout_` method prefix in converter to `inscribe_` (#2099)
40
69
 
41
70
  === Details
42
71
 
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.0.alpha.2, 2022-04-29
3
+ v2.0.0.alpha.3, 2022-05-01
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.0.alpha.2
27
+ :release-version: 2.0.0.alpha.3
28
28
  // URIs:
29
29
  :url-asciidoctor: http://asciidoctor.org
30
30
  :url-gem: http://rubygems.org/gems/asciidoctor-pdf
@@ -76,10 +76,10 @@ admonition_label_font_style: bold
76
76
  admonition_label_text_transform: uppercase
77
77
  quote_border_color: 'EEEEEE'
78
78
  quote_border_left_width: 4
79
- quote_padding: [6, 12, 6, 14]
79
+ quote_padding: [3, 12, 3, 14]
80
80
  verse_border_color: 'EEEEEE'
81
81
  verse_border_left_width: 4
82
- verse_padding: [6, 12, 6, 14]
82
+ verse_padding: [3, 12, 3, 14]
83
83
  code_font_family: Courier
84
84
  code_font_size: 10.8
85
85
  code_line_height: 1.2
@@ -101,7 +101,6 @@ sidebar_title_font_style: bold
101
101
  table_border_color: '000000'
102
102
  table_border_style: solid
103
103
  table_border_width: 0.5
104
- table_grid_width: 0.5
105
104
  table_cell_padding: 2
106
105
  table_head_font_style: bold
107
106
  table_head_border_bottom_width: 1.25
@@ -168,8 +168,8 @@ quote:
168
168
  font_size: $base_font_size_large
169
169
  border_color: $base_border_color
170
170
  border_width: 0
171
- border_left_width: 5
172
- padding: [0, $horizontal_rhythm, $block_margin_bottom * 0.25, $horizontal_rhythm + $quote_border_left_width / 2]
171
+ border_left_width: $horizontal_rhythm / 3
172
+ padding: [$vertical_rhythm / 4, $horizontal_rhythm, $vertical_rhythm / 4, $horizontal_rhythm + $quote_border_left_width / 2]
173
173
  cite:
174
174
  font_size: $base_font_size_small
175
175
  font_color: $role_subtitle_font_color
@@ -5910,19 +5910,19 @@ Refer to the primary converter to discover the pseudo-HTML you can use for inlin
5910
5910
 
5911
5911
  So far we've just been biting around the edges.
5912
5912
  A more realistic use case is to customize the part title page in a multi-part book.
5913
- Since this is a specialized section element, there's a dedicated method named `inscribe_part_title` that you'll need to override.
5913
+ Since this is a specialized section element, there's a dedicated method named `ink_part_title` that you'll need to override.
5914
5914
 
5915
5915
  Let's customize the part title page by making the background orange, making the font white, centering the title on the page, and disabling the running content.
5916
5916
  (You don't need to start a new page before and after the part title since that's already done for you).
5917
5917
 
5918
5918
  [source,ruby]
5919
5919
  ----
5920
- def inscribe_part_title node, title, opts = {}
5921
- fill_absolute_bounds 'E64C3D'
5922
- move_down 20
5923
- typeset_text title, (calc_line_metrics 1.5), color: 'FFFFFF', inline_format: true, align: :center, size: 42
5924
- page.instance_variable_set :@imported_page, true
5925
- end
5920
+ def ink_part_title node, title, opts = {}
5921
+ fill_absolute_bounds 'E64C3D'
5922
+ move_down 20
5923
+ typeset_text title, (calc_line_metrics 1.5), color: 'FFFFFF', inline_format: true, align: :center, size: 42
5924
+ page.instance_variable_set :@imported_page, true
5925
+ end
5926
5926
  ----
5927
5927
 
5928
5928
  The method `typeset_text` and `calc_line_metrics` are provided by Asciidoctor PDF to make writing text easier.
@@ -168,7 +168,7 @@ module Asciidoctor
168
168
  if (bottom_gutter = @bottom_gutters[-1][node])
169
169
  prose_opts[:bottom_gutter] = bottom_gutter
170
170
  end
171
- inscribe_prose string, prose_opts
171
+ ink_prose string, prose_opts
172
172
  end
173
173
  ensure
174
174
  node.document.instance_variable_set :@converter, prev_converter if prev_converter
@@ -190,22 +190,22 @@ module Asciidoctor
190
190
 
191
191
  marked_page_number = page_number
192
192
  # NOTE: a new page will already be started (page_number = 2) if the front cover image is a PDF
193
- inscribe_cover_page doc, :front
193
+ ink_cover_page doc, :front
194
194
  has_front_cover = page_number > marked_page_number
195
- has_title_page = inscribe_title_page doc if (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page'))
195
+ has_title_page = ink_title_page doc if (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page'))
196
196
 
197
197
  @page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress' && page_number == 0
198
198
 
199
199
  start_new_page unless page&.empty? # rubocop:disable Lint/SafeNavigationWithEmpty
200
200
 
201
201
  # NOTE: the base font must be set before any content is written to the main or scratch document
202
- # this method is called inside inscribe_title_page if the title page is active
202
+ # this method is called inside ink_title_page if the title page is active
203
203
  font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style unless has_title_page
204
204
 
205
205
  unless title_page_on
206
206
  body_start_page_number = page_number
207
207
  theme_font :heading, level: 1 do
208
- inscribe_general_heading doc, doc.doctitle, align: (@theme.heading_h1_text_align&.to_sym || :center), level: 1, role: :doctitle
208
+ ink_general_heading doc, doc.doctitle, align: (@theme.heading_h1_text_align&.to_sym || :center), level: 1, role: :doctitle
209
209
  end if doc.header? && !doc.notitle
210
210
  end
211
211
 
@@ -301,14 +301,14 @@ module Asciidoctor
301
301
  traverse doc
302
302
 
303
303
  # NOTE: for a book, these are leftover footnotes; for an article this is everything
304
- outdent_section { inscribe_footnotes doc }
304
+ outdent_section { ink_footnotes doc }
305
305
 
306
306
  if @toc_extent
307
307
  if title_page_on && !insert_toc
308
308
  num_front_matter_pages[0] = @toc_extent.to.page if @theme.running_content_start_at == 'after-toc'
309
309
  num_front_matter_pages[1] = @toc_extent.to.page if @theme.page_numbering_start_at == 'after-toc'
310
310
  end
311
- toc_page_nums = inscribe_toc doc, toc_num_levels, @toc_extent.from.page, @toc_extent.from.cursor, num_front_matter_pages[1]
311
+ toc_page_nums = ink_toc doc, toc_num_levels, @toc_extent.from.page, @toc_extent.from.cursor, num_front_matter_pages[1]
312
312
  else
313
313
  toc_page_nums = []
314
314
  end
@@ -319,8 +319,8 @@ module Asciidoctor
319
319
  end
320
320
 
321
321
  unless page_count < body_start_page_number
322
- inscribe_running_content :header, doc, num_front_matter_pages, body_start_page_number unless doc.noheader || @theme.header_height.to_f == 0 # rubocop:disable Lint/FloatComparison
323
- inscribe_running_content :footer, doc, num_front_matter_pages, body_start_page_number unless doc.nofooter || @theme.footer_height.to_f == 0 # rubocop:disable Lint/FloatComparison
322
+ ink_running_content :header, doc, num_front_matter_pages, body_start_page_number unless doc.noheader || @theme.header_height.to_f == 0 # rubocop:disable Lint/FloatComparison
323
+ ink_running_content :footer, doc, num_front_matter_pages, body_start_page_number unless doc.nofooter || @theme.footer_height.to_f == 0 # rubocop:disable Lint/FloatComparison
324
324
  end
325
325
 
326
326
  add_outline doc, (doc.attr 'outlinelevels', toc_num_levels), toc_page_nums, num_front_matter_pages[1], has_front_cover
@@ -337,7 +337,7 @@ module Asciidoctor
337
337
  catalog.data[:ViewerPreferences] = { DisplayDocTitle: true }
338
338
 
339
339
  stamp_foreground_image doc, has_front_cover
340
- inscribe_cover_page doc, :back
340
+ ink_cover_page doc, :back
341
341
  add_dest_for_top doc
342
342
  nil
343
343
  end
@@ -461,7 +461,8 @@ module Asciidoctor
461
461
  end
462
462
 
463
463
  def prepare_theme theme
464
- theme.base_border_width || 0
464
+ theme.base_border_color ||= '000000'
465
+ theme.base_border_width ||= 0
465
466
  theme.base_font_color ||= '000000'
466
467
  theme.base_font_size ||= 12
467
468
  theme.base_font_style = theme.base_font_style&.to_sym || :normal
@@ -478,6 +479,7 @@ module Asciidoctor
478
479
  theme.list_item_spacing ||= 0
479
480
  theme.description_list_term_spacing ||= 0
480
481
  theme.description_list_description_indent ||= 0
482
+ theme.table_border_width ||= 0.5
481
483
  theme.image_border_width ||= 0
482
484
  theme.code_linenum_font_color ||= '999999'
483
485
  theme.callout_list_margin_top_after_code ||= 0
@@ -687,11 +689,11 @@ module Asciidoctor
687
689
  add_dest_for_block sect, id: sect_anchor, y: (at_page_top? ? page_height : nil)
688
690
  theme_font :heading, level: hlevel do
689
691
  if part
690
- inscribe_part_title sect, title, hopts
692
+ ink_part_title sect, title, hopts
691
693
  elsif chapterlike
692
- inscribe_chapter_title sect, title, hopts
694
+ ink_chapter_title sect, title, hopts
693
695
  else
694
- inscribe_general_heading sect, title, hopts
696
+ ink_general_heading sect, title, hopts
695
697
  end
696
698
  end unless hidden
697
699
 
@@ -700,7 +702,7 @@ module Asciidoctor
700
702
  else
701
703
  traverse sect
702
704
  end
703
- outdent_section { inscribe_footnotes sect } if chapterlike
705
+ outdent_section { ink_footnotes sect } if chapterlike
704
706
  sect.set_attr 'pdf-page-end', page_number
705
707
  end
706
708
 
@@ -721,7 +723,7 @@ module Asciidoctor
721
723
  end
722
724
 
723
725
  # QUESTION: if a footnote ref appears in a separate chapter, should the footnote def be duplicated?
724
- def inscribe_footnotes node
726
+ def ink_footnotes node
725
727
  return if (fns = (doc = node.document).footnotes - @rendered_footnotes).empty?
726
728
  theme_margin :block, :bottom if node.context == :document || node == node.document.blocks[-1]
727
729
  theme_margin :footnotes, :top
@@ -730,7 +732,7 @@ module Asciidoctor
730
732
  move_down delta
731
733
  end
732
734
  theme_font :footnotes do
733
- (title = doc.attr 'footnotes-title') && (inscribe_caption title, category: :footnotes)
735
+ (title = doc.attr 'footnotes-title') && (ink_caption title, category: :footnotes)
734
736
  item_spacing = @theme.footnotes_item_spacing
735
737
  index_offset = @rendered_footnotes.length
736
738
  sect_xreftext = node.context == :section && (node.xreftext node.document.attr 'xrefstyle')
@@ -740,7 +742,7 @@ module Asciidoctor
740
742
  fn.singleton_class.send :attr_accessor, :label unless fn.respond_to? :label=
741
743
  fn.label = %(#{label} - #{sect_xreftext})
742
744
  end
743
- inscribe_prose %(<a id="_footnotedef_#{index}">#{DummyText}</a>[<a anchor="_footnoteref_#{index}">#{label}</a>] #{fn.text}), margin_bottom: item_spacing, hyphenate: true
745
+ ink_prose %(<a id="_footnotedef_#{index}">#{DummyText}</a>[<a anchor="_footnoteref_#{index}">#{label}</a>] #{fn.text}), margin_bottom: item_spacing, hyphenate: true
744
746
  end
745
747
  @rendered_footnotes += fns if extent
746
748
  end
@@ -756,7 +758,7 @@ module Asciidoctor
756
758
  end
757
759
  # QUESTION: should we decouple styles from section titles?
758
760
  theme_font :heading, level: hlevel do
759
- inscribe_general_heading node, node.title, align: align, level: hlevel, outdent: (node.parent.context == :section)
761
+ ink_general_heading node, node.title, align: align, level: hlevel, outdent: (node.parent.context == :section)
760
762
  end
761
763
  end
762
764
 
@@ -765,7 +767,7 @@ module Asciidoctor
765
767
  outdent_section do
766
768
  pad_box @theme.abstract_padding do
767
769
  theme_font :abstract_title do
768
- inscribe_prose node.title, align: (@theme.abstract_title_text_align || @base_text_align).to_sym, margin_top: @theme.heading_margin_top, margin_bottom: @theme.heading_margin_bottom, line_height: (@theme.heading_line_height || @theme.base_line_height)
770
+ ink_prose node.title, align: (@theme.abstract_title_text_align || @base_text_align).to_sym, margin_top: @theme.heading_margin_top, margin_bottom: @theme.heading_margin_bottom, line_height: (@theme.heading_line_height || @theme.base_line_height)
769
771
  end if node.title?
770
772
  theme_font :abstract do
771
773
  prose_opts = { align: (@theme.abstract_text_align || @base_text_align).to_sym, hyphenate: true }
@@ -787,7 +789,7 @@ module Asciidoctor
787
789
  if child.context == :paragraph
788
790
  child.document.playback_attributes child.attributes
789
791
  prose_opts[:margin_bottom] = 0 if child == last_block
790
- inscribe_prose child.content, ((align = resolve_alignment_from_role child.roles) ? (prose_opts.merge align: align) : prose_opts.dup)
792
+ ink_prose child.content, ((align = resolve_alignment_from_role child.roles) ? (prose_opts.merge align: align) : prose_opts.dup)
791
793
  prose_opts.delete :first_line_options
792
794
  prose_opts.delete :margin_bottom
793
795
  else
@@ -799,7 +801,7 @@ module Asciidoctor
799
801
  if (align = resolve_alignment_from_role node.roles)
800
802
  prose_opts[:align] = align
801
803
  end
802
- inscribe_prose string, (prose_opts.merge margin_bottom: 0)
804
+ ink_prose string, (prose_opts.merge margin_bottom: 0)
803
805
  end
804
806
  end
805
807
  end
@@ -834,17 +836,17 @@ module Asciidoctor
834
836
 
835
837
  # TODO: check if we're within one line of the bottom of the page
836
838
  # and advance to the next page if so (similar to logic for section titles)
837
- inscribe_caption node, labeled: false if node.title?
839
+ ink_caption node, labeled: false if node.title?
838
840
 
839
841
  if (bottom_gutter = @bottom_gutters[-1][node])
840
842
  prose_opts[:bottom_gutter] = bottom_gutter
841
843
  end
842
844
 
843
845
  if roles.empty?
844
- inscribe_prose node.content, prose_opts
846
+ ink_prose node.content, prose_opts
845
847
  else
846
848
  theme_font_cascade (roles.map {|role| %(role_#{role}).to_sym }) do
847
- inscribe_prose node.content, prose_opts
849
+ ink_prose node.content, prose_opts
848
850
  end
849
851
  end
850
852
 
@@ -892,12 +894,8 @@ module Asciidoctor
892
894
  label_width = label_min_width if label_min_width && label_min_width > label_width
893
895
  end
894
896
  end
895
- unless ::Array === (cpad = @theme.admonition_padding || 0)
896
- cpad = ::Array.new 4, cpad
897
- end
898
- unless ::Array === (lpad = @theme.admonition_label_padding || cpad)
899
- lpad = ::Array.new 4, lpad
900
- end
897
+ cpad = expand_padding_value @theme.admonition_padding
898
+ lpad = (lpad = @theme.admonition_label_padding) ? (expand_padding_value lpad) : cpad
901
899
  arrange_block node do |extent|
902
900
  add_dest_for_block node if node.id
903
901
  theme_fill_and_stroke_block :admonition, extent if extent
@@ -905,7 +903,7 @@ module Asciidoctor
905
903
  if extent
906
904
  label_height = extent.single_page_height || cursor
907
905
  if (rule_color = @theme.admonition_column_rule_color) &&
908
- (rule_width = @theme.admonition_column_rule_width || @theme.base_border_width) && rule_width > 0
906
+ (rule_width = @theme.admonition_column_rule_width || @theme.base_border_width) > 0
909
907
  rule_style = @theme.admonition_column_rule_style&.to_sym || :solid
910
908
  float do
911
909
  extent.each_page do |first_page, last_page|
@@ -996,7 +994,7 @@ module Asciidoctor
996
994
  end
997
995
  end
998
996
  @text_transform = nil # already applied to label
999
- inscribe_prose label_text,
997
+ ink_prose label_text,
1000
998
  align: label_align,
1001
999
  valign: label_valign,
1002
1000
  line_height: 1,
@@ -1010,7 +1008,7 @@ module Asciidoctor
1010
1008
  end
1011
1009
  end
1012
1010
  pad_box [cpad[0], 0, cpad[2], label_width + lpad[1] + cpad[3]], node do
1013
- inscribe_caption node, category: :admonition, labeled: false if node.title?
1011
+ ink_caption node, category: :admonition, labeled: false if node.title?
1014
1012
  theme_font :admonition do
1015
1013
  traverse node
1016
1014
  end
@@ -1044,13 +1042,13 @@ module Asciidoctor
1044
1042
  arrange_block node do
1045
1043
  add_dest_for_block node if id
1046
1044
  tare_first_page_content_stream do
1047
- node.context == :example ? (inscribe_caption %(\u25bc #{node.title})) : (inscribe_caption node, labeled: false)
1045
+ node.context == :example ? (ink_caption %(\u25bc #{node.title})) : (ink_caption node, labeled: false)
1048
1046
  end if has_title
1049
1047
  traverse node
1050
1048
  end
1051
1049
  else
1052
1050
  add_dest_for_block node if id
1053
- node.context == :example ? (inscribe_caption %(\u25bc #{node.title})) : (inscribe_caption node, labeled: false) if has_title
1051
+ node.context == :example ? (ink_caption %(\u25bc #{node.title})) : (ink_caption node, labeled: false) if has_title
1054
1052
  traverse node
1055
1053
  end
1056
1054
  end
@@ -1094,7 +1092,7 @@ module Asciidoctor
1094
1092
  traverse node
1095
1093
  else # :verse
1096
1094
  content = guard_indentation node.content
1097
- inscribe_prose content,
1095
+ ink_prose content,
1098
1096
  normalize: false,
1099
1097
  align: :left,
1100
1098
  hyphenate: true,
@@ -1106,7 +1104,7 @@ module Asciidoctor
1106
1104
  margin_bottom @theme.block_margin_bottom
1107
1105
  theme_font %(#{category}_cite) do
1108
1106
  attribution_parts = citetitle ? [attribution, citetitle] : [attribution]
1109
- inscribe_prose %(#{EmDash} #{attribution_parts.join ', '}), align: :left, normalize: false, margin_bottom: 0
1107
+ ink_prose %(#{EmDash} #{attribution_parts.join ', '}), align: :left, normalize: false, margin_bottom: 0
1110
1108
  end
1111
1109
  end
1112
1110
  end
@@ -1124,7 +1122,7 @@ module Asciidoctor
1124
1122
  pad_box @theme.sidebar_padding, node do
1125
1123
  theme_font :sidebar_title do
1126
1124
  # QUESTION: should we allow margins of sidebar title to be customized?
1127
- inscribe_prose node.title, align: (@theme.sidebar_title_text_align || @theme.heading_text_align || @base_text_align).to_sym, margin_bottom: @theme.heading_margin_bottom, line_height: (@theme.heading_line_height || @theme.base_line_height)
1125
+ ink_prose node.title, align: (@theme.sidebar_title_text_align || @theme.heading_text_align || @base_text_align).to_sym, margin_bottom: @theme.heading_margin_bottom, line_height: (@theme.heading_line_height || @theme.base_line_height)
1128
1126
  end if node.title?
1129
1127
  theme_font :sidebar do
1130
1128
  traverse node
@@ -1163,7 +1161,7 @@ module Asciidoctor
1163
1161
  marker_width = rendered_width_of_string %(#{marker = conum_glyph index}x)
1164
1162
  float do
1165
1163
  bounding_box [0, cursor], width: marker_width do
1166
- inscribe_prose marker, align: :center, inline_format: false, margin: 0
1164
+ ink_prose marker, align: :center, inline_format: false, margin: 0
1167
1165
  end
1168
1166
  end
1169
1167
  end
@@ -1247,7 +1245,7 @@ module Asciidoctor
1247
1245
  max_term_width += (term_padding[1] + term_padding[3])
1248
1246
  term_column_width = [max_term_width, bounds.width * 0.5].min
1249
1247
  table table_data, position: :left, cell_style: { border_width: 0 }, column_widths: [term_column_width] do
1250
- @pdf.inscribe_table_caption node if node.title?
1248
+ @pdf.ink_table_caption node if node.title?
1251
1249
  end
1252
1250
  theme_margin :prose, :bottom, (next_enclosed_block actual_node) #unless actual_node.nested?
1253
1251
  when 'qanda'
@@ -1257,7 +1255,7 @@ module Asciidoctor
1257
1255
  else
1258
1256
  # TODO: check if we're within one line of the bottom of the page
1259
1257
  # and advance to the next page if so (similar to logic for section titles)
1260
- inscribe_caption node, category: :description_list, labeled: false if node.title?
1258
+ ink_caption node, category: :description_list, labeled: false if node.title?
1261
1259
 
1262
1260
  term_spacing = @theme.description_list_term_spacing
1263
1261
  term_height = theme_font(:description_list_term) { height_of_typeset_text 'A' }
@@ -1269,8 +1267,8 @@ module Asciidoctor
1269
1267
  term_font_styles = nil
1270
1268
  end
1271
1269
  terms.each_with_index do |term, idx|
1272
- # QUESTION: should we pass down styles in other calls to inscribe_prose
1273
- inscribe_prose term.text, margin_top: (idx > 0 ? term_spacing : 0), margin_bottom: 0, align: :left, normalize_line_height: true, styles: term_font_styles
1270
+ # QUESTION: should we pass down styles in other calls to ink_prose
1271
+ ink_prose term.text, margin_top: (idx > 0 ? term_spacing : 0), margin_bottom: 0, align: :left, normalize_line_height: true, styles: term_font_styles
1274
1272
  end
1275
1273
  end
1276
1274
  indent @theme.description_list_description_indent do
@@ -1357,7 +1355,7 @@ module Asciidoctor
1357
1355
  def convert_list node
1358
1356
  # TODO: check if we're within one line of the bottom of the page
1359
1357
  # and advance to the next page if so (similar to logic for section titles)
1360
- inscribe_caption node, category: :list, labeled: false if node.title?
1358
+ ink_caption node, category: :list, labeled: false if node.title?
1361
1359
 
1362
1360
  opts = {}
1363
1361
  if (align = resolve_alignment_from_role node.roles)
@@ -1454,7 +1452,7 @@ module Asciidoctor
1454
1452
  float do
1455
1453
  advance_page if @media == 'prepress' && cursor < marker_height
1456
1454
  flow_bounding_box position: start_position, width: marker_width do
1457
- inscribe_prose marker,
1455
+ ink_prose marker,
1458
1456
  align: :right,
1459
1457
  character_spacing: -0.5,
1460
1458
  color: marker_style[:font_color],
@@ -1482,16 +1480,16 @@ module Asciidoctor
1482
1480
  def traverse_list_item node, list_type, opts = {}
1483
1481
  if list_type == :dlist # qanda
1484
1482
  terms, desc = node
1485
- terms.each {|term| inscribe_prose %(<em>#{term.text}</em>), (opts.merge margin_bottom: @theme.description_list_term_spacing) }
1483
+ terms.each {|term| ink_prose %(<em>#{term.text}</em>), (opts.merge margin_bottom: @theme.description_list_term_spacing) }
1486
1484
  if desc
1487
- inscribe_prose desc.text, (opts.merge hyphenate: true) if desc.text?
1485
+ ink_prose desc.text, (opts.merge hyphenate: true) if desc.text?
1488
1486
  traverse desc
1489
1487
  end
1490
1488
  else
1491
1489
  if (primary_text = node.text).nil_or_empty?
1492
- inscribe_prose DummyText, opts unless node.blocks?
1490
+ ink_prose DummyText, opts unless node.blocks?
1493
1491
  else
1494
- inscribe_prose primary_text, (opts.merge hyphenate: true)
1492
+ ink_prose primary_text, (opts.merge hyphenate: true)
1495
1493
  end
1496
1494
  traverse node
1497
1495
  end
@@ -1562,7 +1560,7 @@ module Asciidoctor
1562
1560
  width = (width.to_f / 100) * page_width if ViewportWidth === width
1563
1561
 
1564
1562
  # NOTE: if width is not set explicitly and max-width is fit-content, caption height may not be accurate
1565
- caption_h = node.title? ? (inscribe_caption node, category: :image, side: :bottom, block_align: alignment, block_width: width, max_width: @theme.image_caption_max_width, dry_run: true, force_top_margin: true) : 0
1563
+ caption_h = node.title? ? (ink_caption node, category: :image, side: :bottom, block_align: alignment, block_width: width, max_width: @theme.image_caption_max_width, dry_run: true, force_top_margin: true) : 0
1566
1564
 
1567
1565
  align_to_page = node.option? 'align-to-page'
1568
1566
  pinned = opts[:pinned]
@@ -1645,7 +1643,7 @@ module Asciidoctor
1645
1643
  move_down rendered_h if y == image_y
1646
1644
  end
1647
1645
  end
1648
- inscribe_caption node, category: :image, side: :bottom, block_align: alignment, block_width: rendered_w, max_width: @theme.image_caption_max_width if node.title?
1646
+ ink_caption node, category: :image, side: :bottom, block_align: alignment, block_width: rendered_w, max_width: @theme.image_caption_max_width if node.title?
1649
1647
  theme_margin :block, :bottom, (next_enclosed_block node) unless pinned
1650
1648
  rescue => e
1651
1649
  raise if ::StopIteration === e
@@ -1685,9 +1683,9 @@ module Asciidoctor
1685
1683
  alignment = (alignment = node.attr 'align') ?
1686
1684
  ((BlockAlignmentNames.include? alignment) ? alignment.to_sym : :left) :
1687
1685
  (resolve_alignment_from_role node.roles) || (@theme.image_align&.to_sym || :left)
1688
- inscribe_prose alt_text_template % alt_text_vars, align: alignment, margin: 0, normalize: false, single_line: true
1686
+ ink_prose alt_text_template % alt_text_vars, align: alignment, margin: 0, normalize: false, single_line: true
1689
1687
  end
1690
- inscribe_caption node, category: :image, side: :bottom if node.title?
1688
+ ink_caption node, category: :image, side: :bottom if node.title?
1691
1689
  theme_margin :block, :bottom, (next_enclosed_block node) unless opts[:pinned]
1692
1690
  nil
1693
1691
  end
@@ -1696,8 +1694,8 @@ module Asciidoctor
1696
1694
  add_dest_for_block node if node.id
1697
1695
  audio_path = node.media_uri node.attr 'target'
1698
1696
  play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer
1699
- inscribe_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{audio_path}">#{audio_path}</a> <em>(audio)</em>), normalize: false, margin: 0, single_line: true
1700
- inscribe_caption node, labeled: false, side: :bottom if node.title?
1697
+ ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{audio_path}">#{audio_path}</a> <em>(audio)</em>), normalize: false, margin: 0, single_line: true
1698
+ ink_caption node, labeled: false, side: :bottom if node.title?
1701
1699
  theme_margin :block, :bottom, (next_enclosed_block node)
1702
1700
  end
1703
1701
 
@@ -1724,8 +1722,8 @@ module Asciidoctor
1724
1722
  if poster.nil_or_empty?
1725
1723
  add_dest_for_block node if node.id
1726
1724
  play_symbol = (node.document.attr? 'icons', 'font') ? %(<font name="fas">#{(icon_font_data 'fas').unicode 'play'}</font>) : RightPointer
1727
- inscribe_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{video_path}">#{video_path}</a> <em>(#{type})</em>), normalize: false, margin: 0, single_line: true
1728
- inscribe_caption node, labeled: false, side: :bottom if node.title?
1725
+ ink_prose %(#{play_symbol}#{NoBreakSpace}<a href="#{video_path}">#{video_path}</a> <em>(#{type})</em>), normalize: false, margin: 0, single_line: true
1726
+ ink_caption node, labeled: false, side: :bottom if node.title?
1729
1727
  theme_margin :block, :bottom, (next_enclosed_block node)
1730
1728
  else
1731
1729
  original_attributes = node.attributes.dup
@@ -2024,6 +2022,7 @@ module Asciidoctor
2024
2022
 
2025
2023
  base_header_cell_data = nil
2026
2024
  header_cell_line_metrics = nil
2025
+ body_cell_padding = expand_padding_value theme.table_cell_padding
2027
2026
 
2028
2027
  table_data = []
2029
2028
  theme_font :table do
@@ -2038,7 +2037,7 @@ module Asciidoctor
2038
2037
  table_header_size = head_rows.size
2039
2038
  head_font_info = font_info
2040
2039
  head_line_metrics = calc_line_metrics theme.table_head_line_height || theme.table_cell_line_height || @base_line_height
2041
- head_cell_padding = expand_padding_value theme.table_head_cell_padding || theme.table_cell_padding
2040
+ head_cell_padding = ((head_cell_padding = theme.table_head_cell_padding) ? (expand_padding_value head_cell_padding) : body_cell_padding).dup
2042
2041
  head_cell_padding[0] += head_line_metrics.padding_top
2043
2042
  head_cell_padding[2] += head_line_metrics.padding_bottom
2044
2043
  # QUESTION: why doesn't text transform inherit from table?
@@ -2077,7 +2076,6 @@ module Asciidoctor
2077
2076
  text_color: @font_color,
2078
2077
  }
2079
2078
  body_cell_line_metrics = calc_line_metrics (theme.table_cell_line_height || @base_line_height)
2080
- body_cell_padding = expand_padding_value theme.table_cell_padding
2081
2079
  (body_rows + node.rows[:foot]).each do |row|
2082
2080
  table_data << (row.map do |cell|
2083
2081
  cell_data = base_cell_data.merge \
@@ -2144,7 +2142,7 @@ module Asciidoctor
2144
2142
  end
2145
2143
  # NOTE: line metrics get applied when AsciiDoc content is converted
2146
2144
  cell_line_metrics = nil
2147
- asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding.dup)
2145
+ asciidoc_cell = ::Prawn::Table::Cell::AsciiDoc.new self, (cell_data.merge content: cell.inner_document, padding: body_cell_padding)
2148
2146
  cell_data = { content: asciidoc_cell }
2149
2147
  end
2150
2148
  if cell_line_metrics
@@ -2190,17 +2188,17 @@ module Asciidoctor
2190
2188
 
2191
2189
  rect_side_names = [:top, :right, :bottom, :left]
2192
2190
  grid_axis_names = [:rows, :cols]
2193
- border_color = (rect_side_names.zip expand_rect_values theme.table_border_color, (theme.base_border_color || 'transparent')).to_h
2191
+ border_color = (rect_side_names.zip expand_rect_values theme.table_border_color, theme.base_border_color).to_h
2194
2192
  border_style = (rect_side_names.zip (expand_rect_values theme.table_border_style, :solid).map(&:to_sym)).to_h
2195
- border_width = (rect_side_names.zip expand_rect_values theme.table_border_width, 0).to_h
2196
- grid_color = (grid_axis_names.zip expand_grid_values (theme.table_grid_color || [border_color[:top], border_color[:left]]), 'transparent').to_h
2193
+ border_width = (rect_side_names.zip expand_rect_values theme.table_border_width, theme.base_border_width).to_h
2194
+ grid_color = (grid_axis_names.zip expand_grid_values (theme.table_grid_color || [border_color[:top], border_color[:left]]), theme.base_border_color).to_h
2197
2195
  grid_style = (grid_axis_names.zip (expand_grid_values (theme.table_grid_style || [border_style[:top], border_style[:left]]), :solid).map(&:to_sym)).to_h
2198
- grid_width = (grid_axis_names.zip expand_grid_values theme.table_grid_width, 0).to_h
2196
+ grid_width = (grid_axis_names.zip expand_grid_values (theme.table_grid_width || [border_width[:top], border_width[:left]]), theme.base_border_width).to_h
2199
2197
 
2200
2198
  if table_header_size
2201
2199
  head_border_bottom_color = theme.table_head_border_bottom_color || grid_color[:rows]
2202
2200
  head_border_bottom_style = theme.table_head_border_bottom_style&.to_sym || grid_style[:rows]
2203
- head_border_bottom_width = theme.table_head_border_bottom_width || grid_width[:rows]
2201
+ head_border_bottom_width = theme.table_head_border_bottom_width || (grid_width[:rows] * 2.5)
2204
2202
  end
2205
2203
 
2206
2204
  case (grid = node.attr 'grid', 'all', 'table-grid')
@@ -2270,7 +2268,7 @@ module Asciidoctor
2270
2268
  table table_data, table_settings do
2271
2269
  # NOTE: call width to capture resolved table width
2272
2270
  table_width = width
2273
- @pdf.inscribe_table_caption node, alignment, table_width, caption_max_width if node.title? && caption_side == :top
2271
+ @pdf.ink_table_caption node, alignment, table_width, caption_max_width if node.title? && caption_side == :top
2274
2272
  # NOTE: align using padding instead of bounding_box as prawn-table does
2275
2273
  # using a bounding_box across pages mangles the margin box of subsequent pages
2276
2274
  if alignment != :left && table_width != (this_bounds = @pdf.bounds).width
@@ -2343,7 +2341,7 @@ module Asciidoctor
2343
2341
  bounds.subtract_left_padding left_padding
2344
2342
  bounds.subtract_right_padding right_padding if right_padding
2345
2343
  end
2346
- inscribe_table_caption node, alignment, table_width, caption_max_width, caption_side if node.title? && caption_side == :bottom
2344
+ ink_table_caption node, alignment, table_width, caption_max_width, caption_side if node.title? && caption_side == :bottom
2347
2345
  theme_margin :block, :bottom, (next_enclosed_block node)
2348
2346
  rescue ::Prawn::Errors::CannotFit
2349
2347
  log :error, (message_with_context 'cannot fit contents of table cell into specified column width', source_location: node.source_location)
@@ -2407,7 +2405,7 @@ module Asciidoctor
2407
2405
  @index.categories.each do |category|
2408
2406
  # NOTE: cursor method always returns 0 inside column_box; breaks reference_bounds.move_past_bottom
2409
2407
  bounds.move_past_bottom if space_needed_for_category > y - reference_bounds.absolute_bottom
2410
- inscribe_prose category.name,
2408
+ ink_prose category.name,
2411
2409
  align: :left,
2412
2410
  inline_format: false,
2413
2411
  margin_bottom: @theme.description_list_term_spacing,
@@ -2435,7 +2433,7 @@ module Asciidoctor
2435
2433
  text = %(#{text}, #{pagenums.join ', '})
2436
2434
  end
2437
2435
  subterm_indent = @theme.description_list_description_indent
2438
- inscribe_prose text, align: :left, margin: 0, hanging_indent: subterm_indent * 2
2436
+ ink_prose text, align: :left, margin: 0, hanging_indent: subterm_indent * 2
2439
2437
  indent subterm_indent do
2440
2438
  term.subterms.each do |subterm|
2441
2439
  convert_index_list_item subterm
@@ -2723,7 +2721,7 @@ module Asciidoctor
2723
2721
  end
2724
2722
 
2725
2723
  # Returns a Boolean indicating whether the title page was created
2726
- def inscribe_title_page doc
2724
+ def ink_title_page doc
2727
2725
  return unless doc.header? && !doc.notitle && @theme.title_page != false
2728
2726
 
2729
2727
  # NOTE: a new page may have already been started at this point, so decide what to do with it
@@ -2799,7 +2797,7 @@ module Asciidoctor
2799
2797
  move_down @theme.title_page_title_margin_top || 0
2800
2798
  indent (@theme.title_page_title_margin_left || 0), (@theme.title_page_title_margin_right || 0) do
2801
2799
  theme_font :title_page_title do
2802
- inscribe_prose doctitle.main, align: title_align, margin: 0
2800
+ ink_prose doctitle.main, align: title_align, margin: 0
2803
2801
  end
2804
2802
  end
2805
2803
  move_down @theme.title_page_title_margin_bottom || 0
@@ -2808,7 +2806,7 @@ module Asciidoctor
2808
2806
  move_down @theme.title_page_subtitle_margin_top || 0
2809
2807
  indent (@theme.title_page_subtitle_margin_left || 0), (@theme.title_page_subtitle_margin_right || 0) do
2810
2808
  theme_font :title_page_subtitle do
2811
- inscribe_prose subtitle, align: title_align, margin: 0
2809
+ ink_prose subtitle, align: title_align, margin: 0
2812
2810
  end
2813
2811
  end
2814
2812
  move_down @theme.title_page_subtitle_margin_bottom || 0
@@ -2833,7 +2831,7 @@ module Asciidoctor
2833
2831
  end
2834
2832
  end.join @theme.title_page_authors_delimiter
2835
2833
  theme_font :title_page_authors do
2836
- inscribe_prose authors, align: title_align, margin: 0, normalize: true
2834
+ ink_prose authors, align: title_align, margin: 0, normalize: true
2837
2835
  end
2838
2836
  end
2839
2837
  move_down @theme.title_page_authors_margin_bottom || 0
@@ -2846,18 +2844,18 @@ module Asciidoctor
2846
2844
  end
2847
2845
  indent (@theme.title_page_revision_margin_left || 0), (@theme.title_page_revision_margin_right || 0) do
2848
2846
  theme_font :title_page_revision do
2849
- inscribe_prose revision_text, align: title_align, margin: 0, normalize: false
2847
+ ink_prose revision_text, align: title_align, margin: 0, normalize: false
2850
2848
  end
2851
2849
  end
2852
2850
  move_down @theme.title_page_revision_margin_bottom || 0
2853
2851
  end
2854
2852
  end
2855
2853
 
2856
- inscribe_prose DummyText, margin: 0, line_height: 1, normalize: false if page.empty?
2854
+ ink_prose DummyText, margin: 0, line_height: 1, normalize: false if page.empty?
2857
2855
  true
2858
2856
  end
2859
2857
 
2860
- def inscribe_cover_page doc, face
2858
+ def ink_cover_page doc, face
2861
2859
  image_path, image_opts = resolve_background_image doc, @theme, %(#{face}-cover-image), theme_key: %(cover_#{face}_image).to_sym, symbolic_paths: ['', '~']
2862
2860
  if image_path
2863
2861
  if image_path.empty?
@@ -2903,7 +2901,7 @@ module Asciidoctor
2903
2901
 
2904
2902
  def start_new_chapter chapter
2905
2903
  start_new_page unless at_page_top?
2906
- # TODO: must call update_colors before advancing to next page if start_new_page is called in inscribe_chapter_title
2904
+ # TODO: must call update_colors before advancing to next page if start_new_page is called in ink_chapter_title
2907
2905
  start_new_page if @ppbook && verso_page? && !(chapter.option? 'nonfacing')
2908
2906
  end
2909
2907
 
@@ -2916,11 +2914,11 @@ module Asciidoctor
2916
2914
  start_page = page
2917
2915
  theme_font :heading, level: opts[:level] do
2918
2916
  if opts[:part]
2919
- inscribe_part_title sect, title, opts
2917
+ ink_part_title sect, title, opts
2920
2918
  elsif opts[:chapterlike]
2921
- inscribe_chapter_title sect, title, opts
2919
+ ink_chapter_title sect, title, opts
2922
2920
  else
2923
- inscribe_general_heading sect, title, opts
2921
+ ink_general_heading sect, title, opts
2924
2922
  end
2925
2923
  end
2926
2924
  if page == start_page
@@ -2931,64 +2929,81 @@ module Asciidoctor
2931
2929
  start_new_page if orphaned
2932
2930
  else
2933
2931
  theme_font :heading, level: (hlevel = opts[:level]) do
2934
- # FIXME: this height doesn't account for impact of text transform or inline formatting
2935
- heading_height =
2936
- (height_of_typeset_text title) +
2937
- (@theme[%(heading_h#{hlevel}_margin_top)] || @theme.heading_margin_top) +
2938
- (@theme[%(heading_h#{hlevel}_margin_bottom)] || @theme.heading_margin_bottom)
2939
- heading_height += @theme.heading_min_height_after if sect.blocks? && @theme.heading_min_height_after
2940
- start_new_page unless cursor > heading_height
2932
+ h_padding_t, h_padding_r, h_padding_b, h_padding_l = expand_padding_value @theme[%(heading_h#{hlevel}_padding)]
2933
+ h_fits = indent h_padding_l, h_padding_r do
2934
+ # FIXME: this height doesn't account for impact of text transform or inline formatting
2935
+ heading_h = (height_of_typeset_text title) +
2936
+ (@theme[%(heading_h#{hlevel}_margin_top)] || @theme.heading_margin_top) +
2937
+ (@theme[%(heading_h#{hlevel}_margin_bottom)] || @theme.heading_margin_bottom) + h_padding_t + h_padding_b
2938
+ heading_h += @theme.heading_min_height_after if @theme.heading_min_height_after && sect.blocks?
2939
+ cursor >= heading_h
2940
+ end
2941
+ start_new_page unless h_fits
2941
2942
  end
2942
2943
  end
2943
2944
  nil
2944
2945
  end
2945
2946
 
2946
- def inscribe_chapter_title node, title, opts = {}
2947
- inscribe_general_heading node, title, (opts.merge outdent: true)
2947
+ def ink_chapter_title node, title, opts = {}
2948
+ ink_general_heading node, title, (opts.merge outdent: true)
2948
2949
  end
2949
2950
 
2950
- alias inscribe_part_title inscribe_chapter_title
2951
+ alias ink_part_title ink_chapter_title
2951
2952
 
2952
- def inscribe_general_heading _node, title, opts = {}
2953
- inscribe_heading title, opts
2953
+ def ink_general_heading _node, title, opts = {}
2954
+ ink_heading title, opts
2954
2955
  end
2955
2956
 
2956
- # NOTE: inscribe_heading doesn't set the theme font because it's used for various types of headings
2957
- def inscribe_heading string, opts = {}
2958
- hlevel = opts[:level]
2957
+ # NOTE: ink_heading doesn't set the theme font because it's used for various types of headings
2958
+ def ink_heading string, opts = {}
2959
+ if (h_level = opts[:level])
2960
+ h_category = %(heading_h#{h_level})
2961
+ end
2959
2962
  unless (top_margin = (margin = (opts.delete :margin)) || (opts.delete :margin_top))
2960
2963
  if at_page_top?
2961
- if hlevel && (top_margin = @theme[%(heading_h#{hlevel}_margin_page_top)] || @theme.heading_margin_page_top) > 0
2964
+ if h_category && (top_margin = @theme[%(#{h_category}_margin_page_top)] || @theme.heading_margin_page_top) > 0
2962
2965
  move_down top_margin
2963
2966
  end
2964
2967
  top_margin = 0
2965
2968
  else
2966
- top_margin = (hlevel ? @theme[%(heading_h#{hlevel}_margin_top)] : nil) || @theme.heading_margin_top
2969
+ top_margin = (h_category ? @theme[%(#{h_category}_margin_top)] : nil) || @theme.heading_margin_top
2967
2970
  end
2968
2971
  end
2969
- bot_margin = margin || (opts.delete :margin_bottom) || (hlevel ? @theme[%(heading_h#{hlevel}_margin_bottom)] : nil) || @theme.heading_margin_bottom
2972
+ bot_margin = margin || (opts.delete :margin_bottom) || (h_category ? @theme[%(#{h_category}_margin_bottom)] : nil) || @theme.heading_margin_bottom
2970
2973
  if (transform = resolve_text_transform opts)
2971
2974
  string = transform_text string, transform
2972
2975
  end
2973
2976
  outdent_section opts.delete :outdent do
2974
2977
  margin_top top_margin
2975
- # QUESTION: should we move inherited styles to typeset_text?
2976
- if (inherited = apply_text_decoration font_styles, :heading, hlevel).empty?
2977
- inline_format_opts = true
2978
- else
2979
- inline_format_opts = [{ inherited: inherited }]
2978
+ start_cursor = cursor
2979
+ start_page_number = page_number
2980
+ pad_box h_category ? @theme[%(#{h_category}_padding)] : nil do
2981
+ # QUESTION: should we move inherited styles to typeset_text?
2982
+ if (inherited = apply_text_decoration font_styles, :heading, h_level).empty?
2983
+ inline_format_opts = true
2984
+ else
2985
+ inline_format_opts = [{ inherited: inherited }]
2986
+ end
2987
+ typeset_text string, (calc_line_metrics (opts.delete :line_height) || @base_line_height), {
2988
+ color: @font_color,
2989
+ inline_format: inline_format_opts,
2990
+ align: @base_text_align.to_sym,
2991
+ }.merge(opts)
2992
+ end
2993
+ if h_category && @theme[%(#{h_category}_border_width)] &&
2994
+ @theme[%(#{h_category}_border_color)] && page_number == start_page_number
2995
+ float do
2996
+ bounding_box [bounds.left, start_cursor], width: bounds.width, height: start_cursor - cursor do
2997
+ theme_fill_and_stroke_bounds h_category
2998
+ end
2999
+ end
2980
3000
  end
2981
- typeset_text string, (calc_line_metrics (opts.delete :line_height) || @base_line_height), {
2982
- color: @font_color,
2983
- inline_format: inline_format_opts,
2984
- align: @base_text_align.to_sym,
2985
- }.merge(opts)
2986
3001
  margin_bottom bot_margin
2987
3002
  end
2988
3003
  end
2989
3004
 
2990
3005
  # NOTE: inline_format is true by default
2991
- def inscribe_prose string, opts = {}
3006
+ def ink_prose string, opts = {}
2992
3007
  top_margin = (margin = (opts.delete :margin)) || (opts.delete :margin_top) || 0
2993
3008
  bot_margin = margin || (opts.delete :margin_bottom) || @theme.prose_margin_bottom
2994
3009
  if (transform = resolve_text_transform opts)
@@ -3035,13 +3050,13 @@ module Asciidoctor
3035
3050
  # The subject argument can either be a String or an AbstractNode. If
3036
3051
  # subject is an AbstractNode, only call this method if the node has a
3037
3052
  # title (i.e., subject.title? returns true).
3038
- def inscribe_caption subject, opts = {}
3053
+ def ink_caption subject, opts = {}
3039
3054
  if opts.delete :dry_run
3040
3055
  force_top_margin = !at_page_top? if (force_top_margin = opts.delete :force_top_margin).nil?
3041
3056
  return (dry_run keep_together: true, single_page: :enforce do
3042
3057
  # TODO: encapsulate this logic to force top margin to be applied
3043
3058
  margin_box.instance_variable_set :@y, margin_box.absolute_top + 0.0001 if force_top_margin
3044
- inscribe_caption subject, opts
3059
+ ink_caption subject, opts
3045
3060
  end).single_page_height
3046
3061
  end
3047
3062
  if ::Asciidoctor::AbstractBlock === subject
@@ -3111,7 +3126,7 @@ module Asciidoctor
3111
3126
  float { bounding_box(fill_at, width: container_width, height: caption_height) { fill_bounds bg_color } }
3112
3127
  end
3113
3128
  indent(*indent_by) do
3114
- inscribe_prose string, ({
3129
+ ink_prose string, ({
3115
3130
  margin_top: margin[:top],
3116
3131
  margin_bottom: margin[:bottom],
3117
3132
  align: text_align,
@@ -3125,16 +3140,22 @@ module Asciidoctor
3125
3140
  end
3126
3141
 
3127
3142
  # Render the caption for a table and return the height of the rendered content
3128
- def inscribe_table_caption node, table_alignment = :left, table_width = nil, max_width = nil, side = :top
3129
- inscribe_caption node, category: :table, side: side, block_align: table_alignment, block_width: table_width, max_width: max_width
3143
+ def ink_table_caption node, table_alignment = :left, table_width = nil, max_width = nil, side = :top
3144
+ ink_caption node, category: :table, side: side, block_align: table_alignment, block_width: table_width, max_width: max_width
3130
3145
  end
3131
3146
 
3132
3147
  def allocate_toc doc, toc_num_levels, toc_start_cursor, title_page_on
3133
- toc_start_page = page_number
3148
+ toc_start_page_number = page_number
3149
+ to_page = nil
3134
3150
  extent = dry_run onto: self do
3135
- inscribe_toc doc, toc_num_levels, toc_start_page, toc_start_cursor
3151
+ to_page = (ink_toc doc, toc_num_levels, toc_start_page_number, toc_start_cursor).end
3136
3152
  margin_bottom @theme.block_margin_bottom unless title_page_on
3137
3153
  end
3154
+ # NOTE: patch for custom converters that allocate extra TOC pages without actually creating them
3155
+ if to_page > extent.to.page
3156
+ extent.to.page = to_page
3157
+ extent.to.cursor = bounds.height
3158
+ end
3138
3159
  # NOTE: reserve pages for the toc; leaves cursor on page after last page in toc
3139
3160
  if title_page_on
3140
3161
  extent.each_page { start_new_page }
@@ -3146,14 +3167,14 @@ module Asciidoctor
3146
3167
  end
3147
3168
 
3148
3169
  # NOTE: num_front_matter_pages not used during a dry run
3149
- def inscribe_toc doc, num_levels, toc_page_number, start_cursor, num_front_matter_pages = 0
3170
+ def ink_toc doc, num_levels, toc_page_number, start_cursor, num_front_matter_pages = 0
3150
3171
  go_to_page toc_page_number unless (page_number == toc_page_number) || scratch?
3151
3172
  start_page_number = page_number
3152
3173
  move_cursor_to start_cursor
3153
3174
  unless (toc_title = doc.attr 'toc-title').nil_or_empty?
3154
3175
  theme_font_cascade [[:heading, level: 2], :toc_title] do
3155
3176
  toc_title_align = (@theme.toc_title_text_align || @theme.heading_h2_text_align || @theme.heading_text_align || @base_text_align).to_sym
3156
- inscribe_general_heading doc, toc_title, align: toc_title_align, level: 2, outdent: true, role: :toctitle
3177
+ ink_general_heading doc, toc_title, align: toc_title_align, level: 2, outdent: true, role: :toctitle
3157
3178
  end
3158
3179
  end
3159
3180
  # QUESTION: should we skip this whole method if num_levels < 0?
@@ -3178,7 +3199,7 @@ module Asciidoctor
3178
3199
  }
3179
3200
  end
3180
3201
  theme_margin :toc, :top
3181
- inscribe_toc_level doc.sections, num_levels, dot_leader, num_front_matter_pages
3202
+ ink_toc_level doc.sections, num_levels, dot_leader, num_front_matter_pages
3182
3203
  end
3183
3204
  # NOTE: range must be calculated relative to toc_page_number; absolute page number in scratch document is arbitrary
3184
3205
  toc_page_numbers = (toc_page_number..(toc_page_number + (page_number - start_page_number)))
@@ -3186,7 +3207,7 @@ module Asciidoctor
3186
3207
  toc_page_numbers
3187
3208
  end
3188
3209
 
3189
- def inscribe_toc_level sections, num_levels, dot_leader, num_front_matter_pages
3210
+ def ink_toc_level sections, num_levels, dot_leader, num_front_matter_pages
3190
3211
  # NOTE: font options aren't always reliable, so store size separately
3191
3212
  toc_font_info = theme_font :toc do
3192
3213
  { font: font, size: @font_size }
@@ -3202,7 +3223,7 @@ module Asciidoctor
3202
3223
  if scratch?
3203
3224
  indent 0, pgnum_label_placeholder_width do
3204
3225
  # NOTE: must wrap title in empty anchor element in case links are styled with different font family / size
3205
- inscribe_prose sect_title, anchor: true, normalize: false, hanging_indent: hanging_indent, normalize_line_height: true, margin: 0
3226
+ ink_prose sect_title, anchor: true, normalize: false, hanging_indent: hanging_indent, normalize_line_height: true, margin: 0
3206
3227
  end
3207
3228
  else
3208
3229
  physical_pgnum = sect.attr 'pdf-page-start'
@@ -3247,7 +3268,7 @@ module Asciidoctor
3247
3268
  end
3248
3269
  end
3249
3270
  indent @theme.toc_indent do
3250
- inscribe_toc_level sect.sections, num_levels_for_sect, dot_leader, num_front_matter_pages
3271
+ ink_toc_level sect.sections, num_levels_for_sect, dot_leader, num_front_matter_pages
3251
3272
  end if num_levels_for_sect > sect.level
3252
3273
  end
3253
3274
  end
@@ -3275,15 +3296,15 @@ module Asciidoctor
3275
3296
  icon_data
3276
3297
  end
3277
3298
 
3278
- # TODO: delegate to inscribe_page_header and inscribe_page_footer per page
3279
- def inscribe_running_content periphery, doc, skip = [1, 1], body_start_page_number = 1
3299
+ # TODO: delegate to ink_page_header and ink_page_footer per page
3300
+ def ink_running_content periphery, doc, skip = [1, 1], body_start_page_number = 1
3280
3301
  skip_pages, skip_pagenums = skip
3281
3302
  # NOTE: find and advance to first non-imported content page to use as model page
3282
- return unless (content_start_page = state.pages[skip_pages..-1].index {|it| !it.imported_page? })
3283
- content_start_page += (skip_pages + 1)
3303
+ return unless (content_start_page_number = state.pages[skip_pages..-1].index {|it| !it.imported_page? })
3304
+ content_start_page_number += (skip_pages + 1)
3284
3305
  num_pages = page_count
3285
3306
  prev_page_number = page_number
3286
- go_to_page content_start_page
3307
+ go_to_page content_start_page_number
3287
3308
 
3288
3309
  # FIXME: probably need to treat doctypes differently
3289
3310
  is_book = doc.doctype == 'book'
@@ -3379,7 +3400,7 @@ module Asciidoctor
3379
3400
  pagenums_enabled = doc.attr? 'pagenums'
3380
3401
  periphery_layout_cache = {}
3381
3402
  # NOTE: this block is invoked during PDF generation, after #write -> #render_file and thus after #convert_document
3382
- repeat (content_start_page..num_pages), dynamic: true do
3403
+ repeat (content_start_page_number..num_pages), dynamic: true do
3383
3404
  pgnum = page_number
3384
3405
  # NOTE: don't write on pages which are imported / inserts (otherwise we can get a corrupt PDF)
3385
3406
  next if page.imported_page? || (disable_on_pages.include? pgnum)
@@ -3501,7 +3522,7 @@ module Asciidoctor
3501
3522
  trim_content_margin_recto = @theme[%(#{periphery}_recto_content_margin)] || @theme[%(#{periphery}_content_margin)] || [0, 'inherit', 0, 'inherit']
3502
3523
  trim_content_margin_recto = (expand_margin_value trim_content_margin_recto).map.with_index {|v, i| i.odd? && v == 'inherit' ? page_margin_recto[i] - trim_margin_recto[i] : v.to_f }
3503
3524
  if (trim_padding_recto = @theme[%(#{periphery}_recto_padding)] || @theme[%(#{periphery}_padding)])
3504
- trim_padding_recto = (expand_margin_value trim_padding_recto).map.with_index {|v, i| v + trim_content_margin_recto[i] }
3525
+ trim_padding_recto = (expand_padding_value trim_padding_recto).map.with_index {|v, i| v + trim_content_margin_recto[i] }
3505
3526
  else
3506
3527
  trim_padding_recto = trim_content_margin_recto
3507
3528
  end
@@ -3511,7 +3532,7 @@ module Asciidoctor
3511
3532
  trim_content_margin_verso = @theme[%(#{periphery}_verso_content_margin)] || @theme[%(#{periphery}_content_margin)] || [0, 'inherit', 0, 'inherit']
3512
3533
  trim_content_margin_verso = (expand_margin_value trim_content_margin_verso).map.with_index {|v, i| i.odd? && v == 'inherit' ? page_margin_verso[i] - trim_margin_verso[i] : v.to_f }
3513
3534
  if (trim_padding_verso = @theme[%(#{periphery}_verso_padding)] || @theme[%(#{periphery}_padding)])
3514
- trim_padding_verso = (expand_margin_value trim_padding_verso).map.with_index {|v, i| v + trim_content_margin_verso[i] }
3535
+ trim_padding_verso = (expand_padding_value trim_padding_verso).map.with_index {|v, i| v + trim_content_margin_verso[i] }
3515
3536
  else
3516
3537
  trim_padding_verso = trim_content_margin_verso
3517
3538
  end
@@ -3843,7 +3864,7 @@ module Asciidoctor
3843
3864
  def theme_fill_and_stroke_block category, extent, opts = {}
3844
3865
  node_with_caption = nil unless (node_with_caption = opts[:caption_node])&.title?
3845
3866
  unless extent
3846
- inscribe_caption node_with_caption, category: category if node_with_caption
3867
+ ink_caption node_with_caption, category: category if node_with_caption
3847
3868
  return
3848
3869
  end
3849
3870
  if (b_width = (opts.key? :border_width) ? opts[:border_width] : @theme[%(#{category}_border_width)])
@@ -3857,7 +3878,7 @@ module Asciidoctor
3857
3878
  bg_color = nil
3858
3879
  end
3859
3880
  unless b_width || bg_color
3860
- inscribe_caption node_with_caption, category: category if node_with_caption
3881
+ ink_caption node_with_caption, category: category if node_with_caption
3861
3882
  return
3862
3883
  end
3863
3884
  if (b_color = @theme[%(#{category}_border_color)]) == 'transparent'
@@ -3875,7 +3896,7 @@ module Asciidoctor
3875
3896
  else # let page background cut into block background; guarantees b_width is set
3876
3897
  b_shift, b_gap_color = (b_width ||= 0.5) * 0.5, @page_bg_color
3877
3898
  end
3878
- inscribe_caption node_with_caption, category: category if node_with_caption
3899
+ ink_caption node_with_caption, category: category if node_with_caption
3879
3900
  extent.from.page += 1 unless extent.from.page == page_number # sanity check
3880
3901
  float do
3881
3902
  extent.each_page do |first_page, last_page|
@@ -4012,9 +4033,7 @@ module Asciidoctor
4012
4033
  # NOTE: it also removes zero-width spaces
4013
4034
  arranger.finalize_line
4014
4035
  actual_width = width_of_fragments arranger.fragments
4015
- unless ::Array === (padding = @theme[%(#{category}_padding)])
4016
- padding = ::Array.new 4, padding
4017
- end
4036
+ padding = expand_padding_value @theme[%(#{category}_padding)]
4018
4037
  if actual_width > (available_width = bounds.width - padding[3].to_f - padding[1].to_f)
4019
4038
  adjusted_font_size = ((available_width * font_size).to_f / actual_width).truncate 4
4020
4039
  if (min = @theme[%(#{category}_font_size_min)] || @theme.base_font_size_min) && adjusted_font_size < min
@@ -4596,26 +4615,34 @@ module Asciidoctor
4596
4615
  end
4597
4616
 
4598
4617
  # Deprecated method names
4599
- alias layout_footnotes inscribe_footnotes
4600
- alias layout_title_page inscribe_title_page
4601
- alias layout_cover_page inscribe_cover_page
4602
- alias layout_chapter_title inscribe_chapter_title
4603
- alias layout_part_title inscribe_part_title
4604
- alias layout_general_heading inscribe_general_heading
4605
- alias layout_heading inscribe_heading
4606
- alias layout_prose inscribe_prose
4607
- alias layout_caption inscribe_caption
4608
- alias layout_table_caption inscribe_table_caption
4609
- alias layout_toc inscribe_toc
4610
- alias layout_toc_level inscribe_toc_level
4611
- alias layout_running_content inscribe_running_content
4612
-
4618
+ alias layout_footnotes ink_footnotes
4619
+ alias layout_title_page ink_title_page
4620
+ alias layout_cover_page ink_cover_page
4621
+ alias layout_chapter_title ink_chapter_title
4622
+ alias layout_part_title ink_part_title
4623
+ alias layout_general_heading ink_general_heading
4624
+ alias layout_heading ink_heading
4625
+ alias layout_prose ink_prose
4626
+ alias layout_caption ink_caption
4627
+ alias layout_table_caption ink_table_caption
4628
+ alias layout_toc ink_toc
4629
+ alias layout_toc_level ink_toc_level
4630
+ alias layout_running_content ink_running_content
4631
+
4632
+ # intercepts "class CustomPDFConverter < (Asciidoctor::Converter.for 'pdf')"
4613
4633
  def self.method_added method
4614
4634
  if (method_name = method.to_s).start_with? 'layout_'
4615
- alias_method %(inscribe_#{method_name.slice 7, method_name.length}).to_sym, method
4635
+ alias_method %(ink_#{method_name.slice 7, method_name.length}).to_sym, method
4616
4636
  end
4617
4637
  end
4618
4638
 
4639
+ # intercepts "(Asciidoctor::Converter.for 'pdf').prepend CustomConverterExtensions"
4640
+ def self.prepend *mods
4641
+ super
4642
+ mods.each {|mod| (mod.instance_methods false).each {|method| method_added method } }
4643
+ self
4644
+ end
4645
+
4619
4646
  private
4620
4647
 
4621
4648
  def add_link_to_image uri, image_info, image_opts
@@ -538,17 +538,20 @@ module Asciidoctor
538
538
  # Example:
539
539
  #
540
540
  # pad_box 20 do
541
- # text 'A paragraph inside a blox with even padding on all sides.'
541
+ # text 'A paragraph inside a blox with even padding from all edges.'
542
542
  # end
543
543
  #
544
- # pad_box [10, 10, 10, 20] do
545
- # text 'An indented paragraph inside a box with equal padding on all sides.'
544
+ # pad_box [10, 5] do
545
+ # text 'A paragraph inside a box with different padding from ends and sides.'
546
+ # end
547
+ #
548
+ # pad_box [5, 10, 15, 20] do
549
+ # text 'A paragraph inside a box with different padding from each edge.'
546
550
  # end
547
551
  #
548
552
  def pad_box padding, node = nil
549
553
  if padding
550
- # TODO: implement shorthand combinations like in CSS
551
- p_top, p_right, p_bottom, p_left = ::Array === padding ? padding : (::Array.new 4, padding)
554
+ p_top, p_right, p_bottom, p_left = expand_padding_value padding
552
555
  # logic is intentionally inlined
553
556
  begin
554
557
  if node && ((last_block = node).content_model != :compound || (last_block = node.blocks[-1])&.context == :paragraph)
@@ -560,8 +563,8 @@ module Asciidoctor
560
563
  bounds.add_left_padding p_left
561
564
  bounds.add_right_padding p_right
562
565
  yield
563
- cursor > p_bottom ? (move_down p_bottom) : reference_bounds.move_past_bottom unless at_page_top?
564
566
  ensure
567
+ cursor > p_bottom ? (move_down p_bottom) : reference_bounds.move_past_bottom unless at_page_top?
565
568
  @bottom_gutters.pop
566
569
  bounds.subtract_left_padding p_left
567
570
  bounds.subtract_right_padding p_right
@@ -576,26 +579,25 @@ module Asciidoctor
576
579
  end
577
580
 
578
581
  def expand_padding_value shorthand
579
- unless (padding = (@side_area_shorthand_cache ||= {})[shorthand])
580
- if ::Array === shorthand
581
- case shorthand.size
582
+ (@edge_shorthand_cache ||= ::Hash.new do |store, key|
583
+ if ::Array === key
584
+ case key.size
582
585
  when 1
583
- padding = [shorthand[0], shorthand[0], shorthand[0], shorthand[0]]
586
+ value = [(value0 = key[0] || 0), value0, value0, value0]
584
587
  when 2
585
- padding = [shorthand[0], shorthand[1], shorthand[0], shorthand[1]]
588
+ value = [(value0 = key[0] || 0), (value1 = key[1] || 0), value0, value1]
586
589
  when 3
587
- padding = [shorthand[0], shorthand[1], shorthand[2], shorthand[1]]
590
+ value = [key[0] || 0, (value1 = key[1] || 0), key[2] || 0, value1]
588
591
  when 4
589
- padding = shorthand
592
+ value = key.map {|it| it || 0 }
590
593
  else
591
- padding = shorthand.slice 0, 4
594
+ value = (key.slice 0, 4).map {|it| it || 0 }
592
595
  end
593
596
  else
594
- padding = ::Array.new 4, (shorthand || 0)
597
+ value = [(value0 = key || 0), value0, value0, value0]
595
598
  end
596
- @side_area_shorthand_cache[shorthand] = padding
597
- end
598
- padding.dup
599
+ store[key] = value
600
+ end)[shorthand]
599
601
  end
600
602
 
601
603
  alias expand_margin_value expand_padding_value
@@ -700,7 +702,8 @@ module Asciidoctor
700
702
  def fill_and_stroke_bounds f_color = fill_color, s_color = stroke_color, options = {}
701
703
  no_fill = !f_color || f_color == 'transparent'
702
704
  if ::Array === (s_width = options[:line_width] || 0)
703
- s_width_max = s_width.map(&:to_i).max
705
+ s_width = [s_width[0], s_width[1], s_width[0], s_width[1]] if s_width.size == 2
706
+ s_width_max = (s_width = s_width.map {|it| it || 0 }).max
704
707
  radius = 0
705
708
  else
706
709
  radius = options[:radius] || 0
@@ -718,13 +721,19 @@ module Asciidoctor
718
721
 
719
722
  # stroke
720
723
  if s_width_max
721
- if (s_width_end = s_width[0] || 0) > 0
722
- stroke_horizontal_rule s_color, line_width: s_width_end, line_style: options[:line_style]
723
- stroke_horizontal_rule s_color, line_width: s_width_end, line_style: options[:line_style], at: bounds.height
724
+ s_width_top, s_width_right, s_width_bottom, s_width_left = s_width
725
+ projection_top, projection_right, projection_bottom, projection_left = s_width.map {|it| it * 0.5 }
726
+ if s_width_top > 0
727
+ stroke_horizontal_rule s_color, line_width: s_width_top, line_style: options[:line_style], left_projection: projection_left, right_projection: projection_right
728
+ end
729
+ if s_width_right > 0
730
+ stroke_vertical_rule s_color, line_width: s_width_right, line_style: options[:line_style], at: bounds.width, top_projection: projection_top, bottom_projection: projection_bottom
731
+ end
732
+ if s_width_bottom > 0
733
+ stroke_horizontal_rule s_color, line_width: s_width_bottom, line_style: options[:line_style], at: bounds.height, left_projection: projection_left, right_projection: projection_right
724
734
  end
725
- if (s_width_side = s_width[1] || 0) > 0
726
- stroke_vertical_rule s_color, line_width: s_width_side, line_style: options[:line_style]
727
- stroke_vertical_rule s_color, line_width: s_width_side, line_style: options[:line_style], at: bounds.width
735
+ if s_width_left > 0
736
+ stroke_vertical_rule s_color, line_width: s_width_left, line_style: options[:line_style], top_projection: projection_top, bottom_projection: projection_bottom
728
737
  end
729
738
  else
730
739
  stroke_color s_color
@@ -759,8 +768,8 @@ module Asciidoctor
759
768
  rule_y = cursor - (options[:at] || 0)
760
769
  rule_style = options[:line_style]
761
770
  rule_width = options[:line_width] || 0.5
762
- rule_x_start = bounds.left
763
- rule_x_end = bounds.right
771
+ rule_x_start = bounds.left - (options[:left_projection] || 0)
772
+ rule_x_end = bounds.right - (options[:right_projection] || 0)
764
773
  save_graphics_state do
765
774
  stroke_color rule_color
766
775
  case rule_style
@@ -790,8 +799,8 @@ module Asciidoctor
790
799
  #
791
800
  def stroke_vertical_rule rule_color = stroke_color, options = {}
792
801
  rule_x = options[:at] || 0
793
- rule_y_from = bounds.top
794
- rule_y_to = bounds.bottom
802
+ rule_y_from = bounds.top + (options[:top_projection] || 0)
803
+ rule_y_to = bounds.bottom - (options[:bottom_projection] || 0)
795
804
  rule_style = options[:line_style]
796
805
  rule_width = options[:line_width] || 0.5
797
806
  save_graphics_state do
@@ -18,6 +18,7 @@ module Asciidoctor
18
18
  AmbiguousAlignKeys = %w(base heading heading_h1 heading_h2 heading_h3 heading_h4 heading_h5 heading_h6 title_page abstract abstract_title admonition_label sidebar_title toc_title).each_with_object({}) do |prefix, accum|
19
19
  accum[%(#{prefix}_align)] = %(#{prefix}_text_align)
20
20
  end
21
+ PaddingBottomHackKeys = %w(example_padding quote_padding sidebar_padding verse_padding)
21
22
 
22
23
  VariableRx = /\$([a-z0-9_-]+)/
23
24
  LoneVariableRx = /^\$([a-z0-9_-]+)$/
@@ -173,6 +174,11 @@ module Asciidoctor
173
174
  elsif (rekey = AmbiguousAlignKeys[key]) ||
174
175
  ((key.start_with? 'role_') && (key.end_with? '_align') && (rekey = key.sub RoleAlignKeyRx, '_text_align'))
175
176
  data[rekey] = evaluate val, data
177
+ elsif PaddingBottomHackKeys.include? key
178
+ val = evaluate val, data
179
+ # normalize padding hacks for themes designed before the converter had smart margins
180
+ val[2] = val[0] if ::Array === val && val[0].to_f >= 0 && val[2].to_f <= 0
181
+ data[key] = val
176
182
  # QUESTION: do we really need to evaluate_math in this case?
177
183
  elsif key.end_with? '_color'
178
184
  if key == 'table_border_color'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.0.0.alpha.2'
5
+ VERSION = '2.0.0.alpha.3'
6
6
  end
7
7
  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.0.alpha.2
4
+ version: 2.0.0.alpha.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-04-29 00:00:00.000000000 Z
12
+ date: 2022-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor