asciidoctor-pdf 2.3.18 → 2.3.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87e6612af4d8eeff07ca0444050488e1aef241133e695c9bd817be2aa6d59352
4
- data.tar.gz: 988bcc07fd515953fb2a8370288ed51224ed3e69f3220c5c7683d87e30d9f436
3
+ metadata.gz: c14c6b1955b9d36bc085d127fef49bf8f90f3a035e8b6e3d196bf6fe4ee22323
4
+ data.tar.gz: a0755e6cfb29974f58b94f6785fb871ca99bf7101b18e1a60b6e7c7cada9f3e9
5
5
  SHA512:
6
- metadata.gz: fa91581c98fd7d96dcfe91c18b16811bee9443640d94e645ce3c6a02be5b3ac5860d3510f5709eb0d8a86a16eea255c06355f3a54258ee20a8d3020741b579e4
7
- data.tar.gz: fd46bb12d35dd00126955c3654e10471a3063bba3b9ab9ccec31e90e8d6310e62c36709d90ba627b1b7e55b875bafb4917060300cae29a0fdc2c7f410a89074f
6
+ metadata.gz: bdd80f2e12b579772e5f0d433f2e002e56ff864f71400baaafa178a6a139817e875651b5feb494fc7b5a25907ef3f4ba331b622fda563befe65e0a3c38687d60
7
+ data.tar.gz: 7922d5ac110d170fe242070ef65d324bd8ff9fd5bd7820111324d9cfb878070238f2b9057808beb5c1aee33aad94062590ef21f388a3efef45a6d98b84fec71f
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,48 @@
5
5
  This document provides a high-level view of the changes to the {project-name} by release.
6
6
  For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
7
7
 
8
+ == 2.3.20 (2025-09-17) - @mojavelinux
9
+
10
+ Improvements::
11
+
12
+ * add symbols for shift, command, option, and return keys to the fallback font
13
+ * render horizontal dlist without using prawn-table, allowing the description to exceed the height of one page (#2591)
14
+ * allow relative font size for sub and sup to be set independently (support combined setting for backwards compatibility)
15
+ * allow value of `base-font-size-min` and `<category>-font-size-min` theme keys to be relative (e.g., 0.75em) (#2547)
16
+ * respect `hide-uri-scheme` attribute when appending URL to link text when media is print or prepress (#2583)
17
+
18
+ Bug Fixes::
19
+
20
+ * always force NULL character to have 0 width, even if missing from font (#2585)
21
+ * don't drop line in running content if attribute reference resolves to text that contains attribute reference (not originally present)
22
+ * correctly calculate extent for block in columns that starts below doctitle (#2579)
23
+ * support internal link on image (value of link attribute starts with #) (#2572)
24
+
25
+ Compliance::
26
+
27
+ * suppress warning about the use of Ruby's logger gem when loading Asciidoctor
28
+ * ignore error if bigdecimal gem cannot be eagerly required
29
+
30
+ === Details
31
+
32
+ {url-repo}/releases/tag/v2.3.20[git tag] | {url-repo}/compare/v2.3.19\...v2.3.20[full diff]
33
+
34
+ == 2.3.19 (2024-10-11) - @mojavelinux
35
+
36
+ Improvements::
37
+
38
+ * replace OpenStruct with internal ThemeData class for storing theme data (#2535)
39
+
40
+ Bug Fixes::
41
+
42
+ * support horizontal alignment on AsciiDoc table cell that only contains paragraphs (#2358)
43
+ * don't allow AsciiDoc table cell to overrun bottom of page on which it fits (#2538)
44
+ * don't look for NULL glyph in fallback font as this can impact line height (#2541)
45
+
46
+ === Details
47
+
48
+ {url-repo}/releases/tag/v2.3.19[git tag] | {url-repo}/compare/v2.3.18\...v2.3.19[full diff]
49
+
8
50
  == 2.3.18 (2024-07-27) - @mojavelinux
9
51
 
10
52
  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.18, 2024-07-27
3
+ v2.3.20, 2025-09-17
4
4
  // Settings:
5
5
  :experimental:
6
6
  :idprefix:
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.add_runtime_dependency 'prawn-templates', '~> 0.1.0'
42
42
  s.add_runtime_dependency 'prawn-svg', '~> 0.34.0'
43
43
  s.add_runtime_dependency 'prawn-icon', '~> 3.0.0'
44
- s.add_runtime_dependency 'concurrent-ruby', '~> 1.1'
44
+ s.add_runtime_dependency 'concurrent-ruby', '~> 1.3'
45
45
  s.add_runtime_dependency 'treetop', '~> 1.6.0'
46
46
 
47
47
  s.add_development_dependency 'rake', '~> 13.0.0'
@@ -104,7 +104,7 @@ module Asciidoctor
104
104
  }
105
105
  TypographicQuotes = %w(&#8220; &#8221; &#8216; &#8217;)
106
106
  InlineFormatSniffRx = /[<&]/
107
- SimpleAttributeRefRx = /(?<!\\)\{\w+(?:-\w+)*\}/
107
+ SimpleAttributeRefRx = /(?<!\\)\{(\w+(?:-\w+)*)\}/
108
108
  MeasurementRxt = '\\d+(?:\\.\\d+)?(?:in|cm|mm|p[txc])?'
109
109
  MeasurementPartsRx = /^(\d+(?:\.\d+)?)(in|mm|cm|p[txc])?$/
110
110
  PageSizeRx = /^(?:\[(#{MeasurementRxt}), ?(#{MeasurementRxt})\]|(#{MeasurementRxt})(?: x |x)(#{MeasurementRxt})|\S+)$/
@@ -1421,55 +1421,62 @@ module Asciidoctor
1421
1421
  convert_list list
1422
1422
  markers.pop
1423
1423
  when 'horizontal'
1424
- table_data = []
1425
- term_padding = term_padding_no_blocks = term_font_color = term_transform = desc_padding = term_line_metrics = term_inline_format = term_kerning = nil
1424
+ ink_caption node, category: :description_list, labeled: false if node.title?
1426
1425
  max_term_width = 0
1426
+ term_height = term_padding = term_font_styles = term_transform = desc_padding = term_line_metrics = term_inline_format = term_kerning = nil
1427
1427
  theme_font :description_list_term do
1428
- term_font_color = @font_color
1428
+ term_height = height_of_typeset_text 'A'
1429
1429
  term_transform = @text_transform
1430
1430
  term_inline_format = (term_font_styles = font_styles).empty? ? true : [inherited: { styles: term_font_styles }]
1431
1431
  term_line_metrics = calc_line_metrics @base_line_height
1432
- term_padding_no_blocks = [term_line_metrics.padding_top, 10, term_line_metrics.padding_bottom, 10]
1433
- (term_padding = (term_padding_no_blocks.drop 0))[2] += @theme.prose_margin_bottom * 0.5
1432
+ term_padding = [term_line_metrics.padding_top, 10, term_line_metrics.padding_bottom, 10]
1434
1433
  desc_padding = [0, 10, 0, 10]
1435
1434
  term_kerning = default_kerning?
1436
1435
  end
1437
- actual_node, node = node, node.dup
1438
- (node.instance_variable_set :@blocks, node.items.map(&:dup)).each do |item|
1436
+ prose_height = height_of_typeset_text 'A'
1437
+ items = node.items.map do |item|
1439
1438
  terms, desc = item
1440
- term_text = terms.map(&:text).join ?\n
1441
- term_text = transform_text term_text, term_transform if term_transform
1442
- if (term_width = width_of term_text, inline_format: term_inline_format, kerning: term_kerning) > max_term_width
1443
- max_term_width = term_width
1444
- end
1445
- row_data = [{
1446
- text_color: term_font_color,
1447
- kerning: term_kerning,
1448
- content: term_text,
1449
- inline_format: term_inline_format,
1450
- padding: desc&.blocks? ? term_padding : term_padding_no_blocks,
1451
- leading: term_line_metrics.leading,
1452
- # FIXME: prawn-table doesn't have support for final_gap option
1453
- #final_gap: term_line_metrics.final_gap,
1454
- valign: :top,
1455
- }]
1456
- if desc
1457
- desc_container = Block.new node, :open
1458
- desc_container << (Block.new desc_container, :paragraph, source: (desc.instance_variable_get :@text), subs: :default) if desc.text?
1459
- desc.blocks.each {|b| desc_container << b.dup } if desc.blocks?
1460
- row_data << { content: (::Prawn::Table::Cell::AsciiDoc.new self, content: (item[1] = desc_container), text_color: @font_color, padding: desc_padding, valign: :top, source_location: desc.source_location) }
1461
- else
1462
- row_data << {}
1439
+ terms_as_text = terms.map do |term|
1440
+ term_text = term_transform ? (transform_text term.text, term_transform) : term.text
1441
+ if (term_width = width_of term_text, inline_format: term_inline_format, kerning: term_kerning) > max_term_width
1442
+ max_term_width = term_width
1443
+ end
1444
+ term_text
1463
1445
  end
1464
- table_data << row_data
1446
+ [terms_as_text, desc]
1465
1447
  end
1466
- max_term_width += (term_padding[1] + term_padding[3])
1467
- term_column_width = [max_term_width, bounds.width * 0.5].min
1468
- table table_data, position: :left, column_widths: [term_column_width] do
1469
- cells.style border_width: 0
1470
- @pdf.ink_table_caption node if node.title?
1448
+ term_side_padding = term_padding[1] + (term_left = term_padding[3])
1449
+ max_term_width += term_side_padding
1450
+ term_column_width = [max_term_width, bounds.width * 0.5 - term_side_padding].min
1451
+ term_spacing = @theme.description_list_term_spacing
1452
+ items.each do |terms_as_text, desc|
1453
+ advance_page if !at_page_top? && cursor < [((term_spacing + term_height) * terms_as_text.size) - term_spacing, desc ? prose_height : 0].max
1454
+ initial_y = y
1455
+ initial_page_number = page_number
1456
+ indent term_left, (bounds.width - term_column_width) do
1457
+ theme_font :description_list_term do
1458
+ terms_as_text.each_with_index do |term_text, idx|
1459
+ ink_prose term_text, margin_top: (idx > 0 ? term_spacing : 0), margin_bottom: 0, align: :left, normalize_line_height: true, styles: term_font_styles
1460
+ end
1461
+ end
1462
+ end
1463
+ if desc # rubocop:disable Style/Next
1464
+ after_term_y = y
1465
+ after_term_page_number = page_number
1466
+ go_to_page initial_page_number if page_number > initial_page_number
1467
+ @y = initial_y
1468
+ indent term_column_width + desc_padding[3], desc_padding[1] do
1469
+ traverse_list_item desc, :dlist_desc, normalize_line_height: true, margin_bottom: ((next_enclosed_block desc, descend: true) ? nil : 0)
1470
+ end
1471
+ if page_number < after_term_page_number
1472
+ go_to_page after_term_page_number
1473
+ @y = after_term_y
1474
+ elsif y > after_term_y
1475
+ @y = after_term_y
1476
+ end
1477
+ end
1471
1478
  end
1472
- theme_margin :prose, :bottom, (next_enclosed_block actual_node) #unless actual_node.nested?
1479
+ theme_margin :prose, :bottom, (next_enclosed_block node) unless node.nested?
1473
1480
  when 'qanda'
1474
1481
  @list_numerals << 1
1475
1482
  convert_list node
@@ -2459,6 +2466,7 @@ module Asciidoctor
2459
2466
  %(#{anchor}<a href="#{target}"#{attrs.join}>#{breakable_uri text}</a>)
2460
2467
  # NOTE: @media may not be initialized if method is called before convert phase
2461
2468
  elsif (doc.attr? 'show-link-uri') || (@media != 'screen' && (doc.attr_unspecified? 'show-link-uri'))
2469
+ bare_target = (bare_target.split UriSchemeBoundaryRx, 2)[1] || bare_target if doc.attr? 'hide-uri-scheme'
2462
2470
  # QUESTION: should we insert breakable chars into URI when building fragment instead?
2463
2471
  # TODO: allow style of printed link to be controlled by theme
2464
2472
  %(#{anchor}<a href="#{target}"#{attrs.join}>#{text}</a> [<font size="0.85em">#{breakable_uri bare_target}</font>&#93;)
@@ -2639,7 +2647,11 @@ module Asciidoctor
2639
2647
  img = %([#{node.attr 'alt'}&#93;)
2640
2648
  end
2641
2649
  end
2642
- (node.attr? 'link') ? %(<a href="#{node.attr 'link'}">#{img}</a>) : img
2650
+ if (node.attr? 'link') && (link = node.attr 'link')
2651
+ link.chr == '#' ? %(<a anchor="#{link.slice 1}">#{img}</a>) : %(<a href="#{link}">#{img}</a>)
2652
+ else
2653
+ img
2654
+ end
2643
2655
  end
2644
2656
 
2645
2657
  def convert_inline_indexterm node
@@ -2831,8 +2843,11 @@ module Asciidoctor
2831
2843
  # FIXME: get sub_attributes to handle drop-line w/o a warning
2832
2844
  doc.set_attr 'attribute-missing', 'skip' unless (attribute_missing = doc.attr 'attribute-missing') == 'skip'
2833
2845
  value = value.gsub '\{', '\\\\\\{' if (escaped_attr_ref = value.include? '\{')
2846
+ value_before_subs = value
2834
2847
  value = (subs = opts[:subs]) ? (doc.apply_subs value, subs) : (doc.apply_subs value)
2835
- value = (value.split LF).delete_if {|line| SimpleAttributeRefRx.match? line }.join LF if opts[:drop_lines_with_unresolved_attributes] && (value.include? '{')
2848
+ if opts[:drop_lines_with_unresolved_attributes] && (value.include? '{')
2849
+ value = (value.split LF).delete_if {|line| SimpleAttributeRefRx =~ line && (value_before_subs.include? '{' + $1 + '}') }.join LF
2850
+ end
2836
2851
  value = value.gsub '\{', '{' if escaped_attr_ref
2837
2852
  doc.set_attr 'attribute-missing', attribute_missing unless attribute_missing == 'skip'
2838
2853
  page_layout_to_restore ? (doc.set_attr 'page-layout', page_layout_to_restore) : (doc.remove_attr 'page-layout') if page_layout
@@ -4724,7 +4739,12 @@ module Asciidoctor
4724
4739
  image_y = y - image_opts[:vposition]
4725
4740
  end unless (image_y = image_opts[:y])
4726
4741
 
4727
- link_annotation [image_x, (image_y - image_height), (image_x + image_width), image_y], Border: [0, 0, 0], A: { Type: :Action, S: :URI, URI: uri.as_pdf }
4742
+ loc = [image_x, (image_y - image_height), (image_x + image_width), image_y]
4743
+ if uri.chr == '#'
4744
+ link_annotation loc, Border: [0, 0, 0], Dest: (uri.slice 1)
4745
+ else
4746
+ link_annotation loc, Border: [0, 0, 0], A: { Type: :Action, S: :URI, URI: uri.as_pdf }
4747
+ end
4728
4748
  end
4729
4749
 
4730
4750
  def admonition_icon_data key
@@ -4805,7 +4825,7 @@ module Asciidoctor
4805
4825
  padding = expand_padding_value @theme[%(#{category}_padding)]
4806
4826
  if actual_width > (available_width = bounds.width - padding[3].to_f - padding[1].to_f)
4807
4827
  adjusted_font_size = ((available_width * font_size).to_f / actual_width).truncate 4
4808
- if (min = @theme[%(#{category}_font_size_min)] || @theme.base_font_size_min) && adjusted_font_size < min
4828
+ if (min = @theme[%(#{category}_font_size_min)] || @theme.base_font_size_min) && adjusted_font_size < (min = resolve_font_size min)
4809
4829
  min
4810
4830
  else
4811
4831
  adjusted_font_size
@@ -4813,6 +4833,19 @@ module Asciidoctor
4813
4833
  end
4814
4834
  end
4815
4835
 
4836
+ def resolve_font_size value
4837
+ return value unless ::String === value
4838
+ if value.end_with? 'rem'
4839
+ @root_font_size * value.to_f
4840
+ elsif value.end_with? 'em'
4841
+ font_size * value.to_f
4842
+ elsif value.end_with? '%'
4843
+ font_size * (value.to_f / 100)
4844
+ else
4845
+ value.to_f
4846
+ end
4847
+ end
4848
+
4816
4849
  def consolidate_ranges nums
4817
4850
  if nums.size > 1
4818
4851
  prev = nil
@@ -1146,7 +1146,11 @@ module Asciidoctor
1146
1146
  bounds_copy.instance_variable_set :@parent, saved_bounds
1147
1147
  bounds_copy.single_file if ColumnBox === bounds_copy
1148
1148
  end
1149
- scratch_pdf.move_cursor_to cursor unless (scratch_start_at_top = keep_together || pages_advanced > 0 || at_page_top?)
1149
+ if !(scratch_start_at_top = keep_together || pages_advanced > 0 || at_page_top?)
1150
+ scratch_pdf.move_cursor_to cursor
1151
+ elsif ColumnBox === bounds
1152
+ scratch_pdf.move_cursor_to scratch_pdf.bounds.top
1153
+ end
1150
1154
  scratch_start_cursor = scratch_pdf.cursor
1151
1155
  scratch_start_page = scratch_pdf.page_number
1152
1156
  inhibit_new_page = state.on_page_create_callback == InhibitNewPageProc
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Prawn::Font::TTF.prepend (Module.new do
4
+ def character_width_by_code code
5
+ return 0 if code == 0
6
+ super
7
+ end
8
+ end)
@@ -9,7 +9,7 @@ Prawn::Text::Formatted::Arranger.prepend (Module.new do
9
9
  super
10
10
  @dummy_text = ?\u0000
11
11
  @normalize_line_height = false
12
- @sub_and_sup_relative_size = 0.583
12
+ @sub_relative_size = @sup_relative_size = 0.583
13
13
  end
14
14
 
15
15
  def format_array= array
@@ -38,13 +38,18 @@ Prawn::Text::Formatted::Arranger.prepend (Module.new do
38
38
  end
39
39
 
40
40
  def apply_font_size size, styles
41
- if (subscript? styles) || (superscript? styles)
41
+ if (sub = subscript? styles) || (superscript? styles)
42
42
  size ||= @document.font_size
43
+ if instance_variable_defined? :@sub_and_sup_relative_size
44
+ relative_size = @sub_and_sup_relative_size
45
+ else
46
+ relative_size = sub ? @sub_relative_size : @sup_relative_size
47
+ end
43
48
  if String === size
44
49
  units = (size.end_with? 'em', '%') ? ((size.end_with? '%') ? '%' : 'em') : ''
45
- size = %(#{size.to_f * @sub_and_sup_relative_size}#{units})
50
+ size = %(#{size.to_f * relative_size}#{units})
46
51
  else
47
- size *= @sub_and_sup_relative_size
52
+ size *= relative_size
48
53
  end
49
54
  @document.font_size(size) { yield }
50
55
  elsif size
@@ -61,8 +61,8 @@ Prawn::Text::Formatted::Box.prepend (Module.new do
61
61
  form_fragments_from_like_font_glyph_pairs font_glyph_pairs, fragment_hash
62
62
  end
63
63
 
64
- # TODO: remove once Prawn 2.5 is released
65
64
  def find_font_for_this_glyph char, current_font, current_font_opts = {}, fallback_fonts_to_check = [], original_font = current_font
65
+ return current_font if char == ?\u0000 # never look for NUL character in fallback fonts as it's not rendered
66
66
  (doc = @document).font current_font, current_font_opts
67
67
  if doc.font.glyph_present? char
68
68
  current_font
@@ -73,9 +73,8 @@ module Prawn
73
73
  end
74
74
  # NOTE: draw_bounded_content automatically adds FPTolerance to width and height
75
75
  pdf.bounds.instance_variable_set :@width, spanned_content_width
76
- padding_adjustment = content.context == :document ? padding_bottom : 0
77
- # NOTE: we've already reserved the space, so just let the box stretch to bottom of the content area
78
- pdf.bounds.instance_variable_set :@height, (pdf.y - pdf.page.margins[:bottom] - padding_adjustment)
76
+ # NOTE: we've already reserved the space, so just let the box stretch to the maximum that could fit on a page
77
+ pdf.bounds.instance_variable_set :@height, (pdf.margin_box.height - padding_top - padding_bottom)
79
78
  if @valign != :top && (excess_y = spanned_content_height - natural_content_height) > 0
80
79
  # QUESTION: could this cause a unexpected page overrun?
81
80
  pdf.move_down(@valign == :center ? (excess_y.fdiv 2) : excess_y)
@@ -116,11 +115,16 @@ module Prawn
116
115
  font_size = font_info[:size]
117
116
  end
118
117
  font_style ||= font_info[:style]
118
+ if (@align == :center || @align == :right) && content.blocks.map(&:context).uniq == [:paragraph]
119
+ prev_text_align = pdf.instance_variable_get :@base_text_align
120
+ pdf.instance_variable_set :@base_text_align, @align
121
+ end
119
122
  pdf.font font_family, size: font_size, style: font_style do
120
123
  yield
121
124
  ensure
122
125
  pdf.font_color = prev_font_color if prev_font_color
123
126
  pdf.font_scale = prev_font_scale if prev_font_scale
127
+ pdf.instance_variable_set :@base_text_align, prev_text_align if prev_text_align
124
128
  end
125
129
  end
126
130
  end
@@ -8,6 +8,7 @@ Prawn::FLOAT_PRECISION = 1e-3
8
8
  require_relative 'prawn/document/column_box'
9
9
  require_relative 'prawn/font_metric_cache'
10
10
  require_relative 'prawn/font/afm'
11
+ require_relative 'prawn/font/ttf'
11
12
  require_relative 'prawn/images'
12
13
  require_relative 'prawn/formatted_text/arranger'
13
14
  require_relative 'prawn/formatted_text/box'
@@ -212,8 +212,12 @@ module Asciidoctor
212
212
  fragment[:callback] = [TextBackgroundAndBorderRenderer] | fragment[:callback]
213
213
  end
214
214
  end if attributes.key? :class
215
- if inherited && (link = inherited[:link])
216
- fragment[:link] = link
215
+ if inherited
216
+ if (link = inherited[:link])
217
+ fragment[:link] = link
218
+ elsif (anchor = inherited[:anchor])
219
+ fragment[:anchor] = anchor
220
+ end
217
221
  end
218
222
  if (img_w = attributes[:width])
219
223
  fragment[:image_width] = img_w
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asciidoctor
4
+ module PDF
5
+ class ThemeData
6
+ attr_reader :table
7
+
8
+ def initialize data = nil
9
+ @table = (data || {}).transform_keys(&:to_sym)
10
+ end
11
+
12
+ def [] name
13
+ @table[name.to_sym]
14
+ end
15
+
16
+ def []= name, value
17
+ @table[name.to_sym] = value
18
+ end
19
+
20
+ def each_pair &block
21
+ @table.each_pair(&block)
22
+ end
23
+
24
+ def eql? other
25
+ @table.to_h.eql? other.to_h
26
+ end
27
+
28
+ def delete_field name
29
+ @table.delete name
30
+ end
31
+
32
+ def dup
33
+ ThemeData.new @table
34
+ end
35
+
36
+ def method_missing name, *args
37
+ if (name_str = name.to_s).end_with? '='
38
+ @table[name_str.chop.to_sym] = args[0]
39
+ else
40
+ @table[name]
41
+ end
42
+ end
43
+
44
+ def respond_to? name, _include_all = false
45
+ @table.key? name.to_sym
46
+ end
47
+
48
+ def respond_to_missing? name, _include_all = false
49
+ @table.key? name.to_sym
50
+ end
51
+
52
+ def to_h
53
+ @table
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ostruct'
3
+ require_relative 'theme_data'
4
4
  require_relative 'measurements'
5
5
 
6
6
  module Asciidoctor
@@ -69,7 +69,7 @@ module Asciidoctor
69
69
  # NOTE: base theme is loaded "as is" (no post-processing)
70
70
  def self.load_base_theme
71
71
  ::File.open BaseThemePath, mode: 'r:UTF-8' do |io|
72
- (::OpenStruct.new ::YAML.safe_load io, filename: BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
72
+ (ThemeData.new ::YAML.safe_load io, filename: BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
73
73
  end
74
74
  end
75
75
 
@@ -78,7 +78,7 @@ module Asciidoctor
78
78
  if theme_path == BaseThemePath
79
79
  load_base_theme
80
80
  else
81
- theme_data = load_file theme_path, (::OpenStruct.new base_font_size: 12), theme_dir
81
+ theme_data = load_file theme_path, (ThemeData.new base_font_size: 12), theme_dir
82
82
  unless (::File.dirname theme_path) == ThemesDir
83
83
  theme_data.base_text_align ||= 'left'
84
84
  theme_data.base_line_height ||= 1
@@ -102,12 +102,12 @@ module Asciidoctor
102
102
  line.sub(HexColorEntryRx) { %(#{(m = $~)[:k]}: #{m[:h] || (m[:k].end_with? 'color') ? "'#{m[:v]}'" : m[:v]}) }
103
103
  end.join unless (::File.dirname filename) == ThemesDir
104
104
  yaml_data = ::YAML.safe_load data, aliases: true, filename: filename
105
- (loaded = (theme_data ||= ::OpenStruct.new).__loaded__ ||= ::Set.new).add filename
105
+ (loaded = (theme_data ||= ThemeData.new).__loaded__ ||= ::Set.new).add filename
106
106
  if ::Hash === yaml_data && (extends = yaml_data.delete 'extends')
107
107
  (Array extends).each do |extend_path|
108
108
  extend_path = extend_path.slice 0, extend_path.length - 11 if (force = extend_path.end_with? ' !important')
109
109
  if extend_path == 'base'
110
- theme_data = ::OpenStruct.new theme_data.to_h.merge load_base_theme.to_h if (loaded.add? 'base') || force
110
+ theme_data = ThemeData.new theme_data.to_h.merge load_base_theme.to_h if (loaded.add? 'base') || force
111
111
  next
112
112
  elsif BundledThemeNames.include? extend_path
113
113
  extend_path, extend_theme_dir = resolve_theme_file extend_path, ThemesDir
@@ -123,7 +123,7 @@ module Asciidoctor
123
123
  end
124
124
 
125
125
  def load hash, theme_data = nil
126
- ::Hash === hash ? hash.reduce(theme_data || ::OpenStruct.new) {|data, (key, val)| process_entry key, val, data, true } : (theme_data || ::OpenStruct.new)
126
+ ::Hash === hash ? hash.reduce(theme_data || ThemeData.new) {|data, (key, val)| process_entry key, val, data, true } : (theme_data || ThemeData.new)
127
127
  end
128
128
 
129
129
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.3.18'
5
+ VERSION = '2.3.20'
6
6
  end
7
7
  end
@@ -2,7 +2,10 @@
2
2
 
3
3
  proc do
4
4
  old_verbose, $VERBOSE = $VERBOSE, nil
5
- require 'bigdecimal' # eagerly require bigdecimal without warnings to avoid warning caused by ttfunk 1.7.0
5
+ begin
6
+ require 'bigdecimal' # try to eagerly require bigdecimal with warnings off to avoid warning caused by ttfunk 1.7.0
7
+ rescue Exception # rubocop:disable Lint/SuppressedException,Lint/RescueException
8
+ end
6
9
  $VERBOSE = old_verbose
7
10
  end.call
8
11
 
@@ -11,7 +14,11 @@ autoload :StringIO, 'stringio'
11
14
  autoload :Tempfile, 'tempfile'
12
15
  require 'time' unless defined? Time.parse
13
16
  require_relative 'pdf/version'
14
- require 'asciidoctor'
17
+ proc do
18
+ old_verbose, $VERBOSE = $VERBOSE, nil
19
+ require 'asciidoctor' # avoid warning in Ruby 3.4 caused by use of logger
20
+ $VERBOSE = old_verbose
21
+ end.call
15
22
  require 'prawn'
16
23
  require 'prawn/templates'
17
24
  require_relative 'pdf/measurements'
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.3.18
4
+ version: 2.3.20
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: 2024-07-27 00:00:00.000000000 Z
12
+ date: 2025-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '1.1'
132
+ version: '1.3'
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '1.1'
139
+ version: '1.3'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: treetop
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +290,7 @@ files:
290
290
  - lib/asciidoctor/pdf/ext/prawn/document/column_box.rb
291
291
  - lib/asciidoctor/pdf/ext/prawn/extensions.rb
292
292
  - lib/asciidoctor/pdf/ext/prawn/font/afm.rb
293
+ - lib/asciidoctor/pdf/ext/prawn/font/ttf.rb
293
294
  - lib/asciidoctor/pdf/ext/prawn/font_metric_cache.rb
294
295
  - lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb
295
296
  - lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb
@@ -325,6 +326,7 @@ files:
325
326
  - lib/asciidoctor/pdf/sanitizer.rb
326
327
  - lib/asciidoctor/pdf/section_info_by_page.rb
327
328
  - lib/asciidoctor/pdf/text_transformer.rb
329
+ - lib/asciidoctor/pdf/theme_data.rb
328
330
  - lib/asciidoctor/pdf/theme_loader.rb
329
331
  - lib/asciidoctor/pdf/version.rb
330
332
  homepage: https://asciidoctor.org/docs/asciidoctor-pdf
@@ -350,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
352
  - !ruby/object:Gem::Version
351
353
  version: '0'
352
354
  requirements: []
353
- rubygems_version: 3.5.11
355
+ rubygems_version: 3.5.22
354
356
  signing_key:
355
357
  specification_version: 4
356
358
  summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn