asciidoctor-pdf 2.3.19 → 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: 465fb67274afdfc25ce6bddf7a7f0f8a7079bcc828d11cd86472c30f62b6cf5c
4
- data.tar.gz: e034a8cbedf9329cdd48d2cc03063ca146ae9cf1ed28e2417b878ce14b4ca680
3
+ metadata.gz: c14c6b1955b9d36bc085d127fef49bf8f90f3a035e8b6e3d196bf6fe4ee22323
4
+ data.tar.gz: a0755e6cfb29974f58b94f6785fb871ca99bf7101b18e1a60b6e7c7cada9f3e9
5
5
  SHA512:
6
- metadata.gz: a8da14edb4931a36dcfe223d1ccbe9dbaf6aa3c0a443818412062850158a5c7f15eebb6b3cbe39824440b9c9613d232ee2537a5d77ec156d491e8e619139694a
7
- data.tar.gz: 991f86d8acdddb6e4ec1773d5db27fce3673ec4f8a0c4b7889a6095ef69c52d1e08b0dc63fcdde797beaf4f4d12bea49f11595f67e576d5da7594386f9c76f6e
6
+ metadata.gz: bdd80f2e12b579772e5f0d433f2e002e56ff864f71400baaafa178a6a139817e875651b5feb494fc7b5a25907ef3f4ba331b622fda563befe65e0a3c38687d60
7
+ data.tar.gz: 7922d5ac110d170fe242070ef65d324bd8ff9fd5bd7820111324d9cfb878070238f2b9057808beb5c1aee33aad94062590ef21f388a3efef45a6d98b84fec71f
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,32 @@
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
+
8
34
  == 2.3.19 (2024-10-11) - @mojavelinux
9
35
 
10
36
  Improvements::
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.19, 2024-10-11
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
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.3.19'
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.19
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-10-11 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
@@ -351,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
351
352
  - !ruby/object:Gem::Version
352
353
  version: '0'
353
354
  requirements: []
354
- rubygems_version: 3.5.16
355
+ rubygems_version: 3.5.22
355
356
  signing_key:
356
357
  specification_version: 4
357
358
  summary: Converts AsciiDoc documents to PDF using Asciidoctor and Prawn