asciidoctor-pdf 2.1.0 → 2.1.1

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: 3fc9b0baae841d33e6205109c5aeacbb88bc196e6396b5dac8df187e0d209f9c
4
- data.tar.gz: 21fd8ea4cebcb721dc273fa1a8f81104ec8f14f6a4c1a6f396bf6194f5e2309d
3
+ metadata.gz: bfcc8354e8152f540a4510dbddc39d38d577ee958aa51fbfb10b92d965abaa0c
4
+ data.tar.gz: 68848a664ded97d88c45e2d8357f3880a5e10f4b6cc0f0c44b014cd85088d1ea
5
5
  SHA512:
6
- metadata.gz: 956e66763693837a9483919f0b8b0428adbda5858efbfa75aa7b3a2fc04aff92a8e666643f7aae74ee01b656c1b9ad16984173dec4d0b0552bf668d0ad73d024
7
- data.tar.gz: e6e2ca9d393d1eafbea531bdf9b828d50075bf398723ecca99549175331aa9f1422a9640128ccbf511e8ec97db3e7ce0c6d763a3bc28aeadf92fc6fd2a130f77
6
+ metadata.gz: b1fb4074705e06fb70c188278e677c69f696e832d28d5ad49e6135b218ef36416abfaebfdedd980ff094579ae509d5006b59a52c57cf62374e9bdd69822b3714
7
+ data.tar.gz: 07acff80d3d5c04e5ba8fbf591bbf3d952685bd0de605ac0e60645bbe478eafd1013451d4085abf8e2a41a996f5c4d8bba885377a1878a301ad75e144c0d2316
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,23 @@
5
5
  This document provides a high-level view of the changes to the {project-name} by release.
6
6
  For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
7
7
 
8
+ == 2.1.1 (2022-06-15) - @mojavelinux
9
+
10
+ Improvements::
11
+
12
+ * store zero-based column on Extent for extensions to use to position cursor at start of extent
13
+
14
+ Bug Fixes::
15
+
16
+ * place block image in SVG format in correct column when align is left and page columns are enabled (#2241)
17
+ * accurately trap LoadError from CodeRay if source language is not recognized on code block
18
+ * only draw rounded rectangle around phrase if `border-radius` is > 0
19
+ * use `base-border-color` value if border width is set on role for inline phrase but not border color
20
+
21
+ === Details
22
+
23
+ {url-repo}/releases/tag/v2.1.1[git tag] | {url-repo}/compare/v2.1.0\...v2.1.1[full diff]
24
+
8
25
  == 2.1.0 (2022-06-11) - @mojavelinux
9
26
 
10
27
  Enhancements::
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Asciidoctor PDF: A native PDF converter for AsciiDoc
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
3
- v2.1.0, 2022-06-11
3
+ v2.1.1, 2022-06-15
4
4
  // Settings:
5
5
  :experimental:
6
6
  :idprefix:
@@ -46,7 +46,7 @@ The aim of this library is to take the pain out of creating PDF documents from A
46
46
 
47
47
  [NOTE]
48
48
  ====
49
- The documentation for the latest, stable release of Asciidoctor PDF 2.0.x is available at {url-project-docs}/.
49
+ The documentation for the latest, stable release of Asciidoctor PDF is available at {url-project-docs}/.
50
50
 
51
51
  If you're looking for the documentation for Asciidoctor PDF 1.6, refer to the {url-project-repo}/tree/v1.6.x#readme[README] in the v1.6.x branch.
52
52
  Asciidoctor PDF 1.6 is no longer being developed and will reach EOL later this year.
@@ -1108,7 +1108,10 @@ module Asciidoctor
1108
1108
  srclang = node.attr 'language', 'text'
1109
1109
  begin
1110
1110
  ::CodeRay::Scanners[(srclang = (srclang.start_with? 'html+') ? (srclang.slice 5, srclang.length).to_sym : srclang.to_sym)]
1111
- rescue ::ArgumentError
1111
+ rescue
1112
+ until ::LoadError === (cause ||= $!) || ::ArgumentError === cause
1113
+ raise $! unless (cause = cause.cause)
1114
+ end
1112
1115
  srclang = :text
1113
1116
  end
1114
1117
  fragments = (::CodeRay.scan source_string, srclang).to_prawn
@@ -1787,7 +1790,6 @@ module Asciidoctor
1787
1790
  file_request_root = { base: (::File.dirname image_path), root: @jail_dir }
1788
1791
  end
1789
1792
  svg_obj = ::Prawn::SVG::Interface.new svg_data, self,
1790
- position: alignment,
1791
1793
  width: width,
1792
1794
  fallback_font_name: fallback_svg_font_name,
1793
1795
  enable_web_requests: allow_uri_read ? (method :load_open_uri).to_proc : false,
@@ -1804,7 +1806,6 @@ module Asciidoctor
1804
1806
  if (rendered_h = svg_size.output_height) > (available_h = cursor - caption_h)
1805
1807
  unless pinned || at_page_top?
1806
1808
  advance_page
1807
- (svg_obj.options[:at] = svg_obj.position)[0] += bounds.left if ColumnBox === bounds
1808
1809
  available_h = cursor - caption_h
1809
1810
  end
1810
1811
  rendered_w = (svg_obj.resize height: (rendered_h = available_h)).output_width if rendered_h > available_h
@@ -1815,7 +1816,16 @@ module Asciidoctor
1815
1816
  update_colors if graphic_state.color_space.empty?
1816
1817
  ink_caption node, category: :image, end: :top, block_align: alignment, block_width: rendered_w, max_width: caption_max_width if caption_end == :top && node.title?
1817
1818
  image_y = y
1818
- image_cursor = cursor
1819
+ # NOTE: prawn-svg does not compute :at for alignment correctly in column box, so resort to our own logic
1820
+ case alignment
1821
+ when :center
1822
+ left = bounds.left + (available_w - rendered_w) * 0.5
1823
+ when :right
1824
+ left = bounds.left + available_w - rendered_w
1825
+ else
1826
+ left = bounds.left
1827
+ end
1828
+ svg_obj.options[:at] = [left, (image_cursor = cursor)]
1819
1829
  svg_obj.draw # NOTE: cursor advances automatically
1820
1830
  svg_obj.document.warnings.each do |img_warning|
1821
1831
  log :warn, %(problem encountered in image: #{image_path}; #{img_warning})
@@ -4389,7 +4399,7 @@ module Asciidoctor
4389
4399
  b_shift, b_gap_color = (b_width ||= 0.5) * 0.5, @page_bg_color
4390
4400
  end
4391
4401
  ink_caption node_with_caption, category: category if node_with_caption
4392
- extent.from.page += 1 unless extent.from.page == page_number || ColumnBox === bounds # sanity check
4402
+ extent.from.page = page_number unless extent.from.page == page_number # sanity check
4393
4403
  float do
4394
4404
  extent.each_page do |first_page, last_page|
4395
4405
  advance_page unless first_page
@@ -34,13 +34,14 @@ module Asciidoctor
34
34
  # - :final_gap determines whether a gap is added below the last line
35
35
  LineMetrics = ::Struct.new :height, :leading, :padding_top, :padding_bottom, :final_gap
36
36
 
37
- Position = ::Struct.new :page, :cursor
37
+ Position = ::Struct.new :page, :column, :cursor
38
38
 
39
39
  Extent = ::Struct.new :current, :from, :to do
40
- def initialize current_page, current_cursor, start_page, start_cursor, end_page, end_cursor
41
- self.from = self.current = Position.new current_page, current_cursor
42
- self.from = Position.new start_page, start_cursor unless start_page == current_page && start_cursor == current_cursor
43
- self.to = Position.new end_page, end_cursor
40
+ def initialize current_page, current_column, current_cursor, from_page, from_column, from_cursor, to_page, to_cursor
41
+ self.current = Position.new current_page, current_column, current_cursor
42
+ self.from = Position.new from_page, from_column, from_cursor
43
+ self.from = current if from == current
44
+ self.to = Position.new to_page, nil, to_cursor
44
45
  end
45
46
 
46
47
  def each_page
@@ -64,23 +65,23 @@ module Asciidoctor
64
65
 
65
66
  ScratchExtent = ::Struct.new :from, :to do
66
67
  def initialize start_page, start_cursor, end_page, end_cursor
67
- self.from = Position.new start_page, start_cursor
68
- self.to = Position.new end_page, end_cursor
68
+ self.from = Position.new start_page, 0, start_cursor
69
+ self.to = Position.new end_page, 0, end_cursor
69
70
  end
70
71
 
71
72
  def position_onto pdf, keep_together = nil
72
73
  current_page = pdf.page_number
74
+ current_column = ColumnBox === pdf.bounds ? (column_box = pdf.bounds).current_column : 0
73
75
  current_cursor = pdf.cursor
74
- from_page = current_page + (advance_by = from.page - 1)
75
- to_page = current_page + (to.page - 1)
76
- if advance_by > 0
76
+ if (advance_by = from.page - 1) > 0
77
77
  advance_by.times { pdf.advance_page }
78
78
  elsif keep_together && single_page? && !(try_to_fit_on_previous current_cursor)
79
79
  pdf.advance_page
80
- from_page += 1
81
- to_page += 1
82
80
  end
83
- Extent.new current_page, current_cursor, from_page, from.cursor, to_page, to.cursor
81
+ from_page = pdf.page_number
82
+ from_column = column_box&.current_column || 0
83
+ to_page = from_page + (to.page - from.page)
84
+ Extent.new current_page, current_column, current_cursor, from_page, from_column, from.cursor, to_page, to.cursor
84
85
  end
85
86
 
86
87
  def single_page?
@@ -972,11 +973,11 @@ module Asciidoctor
972
973
  state.on_page_create_callback = saved_callback
973
974
  end
974
975
 
975
- # This method is a smarter version of start_new_page. It calls start_new_page
976
- # if the current page is the last page of the document. Otherwise, it simply
977
- # advances to the next existing page.
976
+ # This method is a smarter version of start_new_page. It only calls start_new_page options are
977
+ # specified and the current page is the last page in the document. Otherwise, it advances the
978
+ # cursor to the next page (or column) using Bounds#move_past_bottom.
978
979
  def advance_page options = {}
979
- !options.empty? && last_page? ? (start_new_page options) : bounds.move_past_bottom
980
+ options.empty? || !last_page? ? bounds.move_past_bottom : (start_new_page options)
980
981
  end
981
982
 
982
983
  # Start a new page without triggering the on_page_create callback
@@ -1136,15 +1137,15 @@ module Asciidoctor
1136
1137
  # Note that if the block has content that itself requires a dry run, that nested dry run will
1137
1138
  # be performed in a separate scratch document.
1138
1139
  #
1139
- # opts - A Hash of options that configure the dry run computation:
1140
- # :keep_together - A Boolean indicating whether an attempt should be made to keep the
1141
- # content on the same page (optional, default: false).
1142
- # :single_page - A Boolean indicating whether the operation should stop if the content
1143
- # exceeds the height of a single page.
1144
- # :onto - The document onto which to position the scratch extent. If this option is
1145
- # set, the method returns an Extent instead of a ScratchExtent (optional, default: nil)
1146
- # :pages_advanced - The number of pages the content has been advanced during this
1147
- # operation (internal only) (optional, default: 0)
1140
+ # options - A Hash of options that configure the dry run computation:
1141
+ # :keep_together - A Boolean indicating whether an attempt should be made to keep
1142
+ # the content on the same page (optional, default: false).
1143
+ # :single_page - A Boolean indicating whether the operation should stop if the
1144
+ # content exceeds the height of a single page.
1145
+ # :onto - The document onto which to position the scratch extent. If this option is
1146
+ # set, the method returns an Extent instance (optional, default: false)
1147
+ # :pages_advanced - The number of pages the content has been advanced during this
1148
+ # operation (internal only) (optional, default: 0)
1148
1149
  #
1149
1150
  # Returns an Extent or ScratchExtent object that describes the bounds of the content block.
1150
1151
  def dry_run keep_together: nil, pages_advanced: 0, single_page: nil, onto: nil, &block
@@ -25,11 +25,11 @@ module Asciidoctor::PDF::FormattedText
25
25
  width = fragment.width
26
26
  height = fragment.height
27
27
  end
28
- border_radius = data[:border_radius]
28
+ border_radius = data[:border_radius] || 0
29
29
  if (background_color = data[:background_color])
30
30
  prev_fill_color = pdf.fill_color
31
31
  pdf.fill_color background_color
32
- if border_radius
32
+ if border_radius > 0
33
33
  pdf.fill_rounded_rectangle at, width, height, border_radius
34
34
  else
35
35
  pdf.fill_rectangle at, width, height
@@ -41,7 +41,7 @@ module Asciidoctor::PDF::FormattedText
41
41
  prev_line_width = pdf.line_width
42
42
  pdf.stroke_color border_color
43
43
  pdf.line_width border_width
44
- border_radius ? (pdf.stroke_rounded_rectangle at, width, height, border_radius) : (pdf.stroke_rectangle at, width, height)
44
+ border_radius > 0 ? (pdf.stroke_rounded_rectangle at, width, height, border_radius) : (pdf.stroke_rectangle at, width, height)
45
45
  pdf.stroke_color prev_stroke_color
46
46
  pdf.line_width prev_line_width
47
47
  end
@@ -102,6 +102,9 @@ module Asciidoctor
102
102
  role, key = (key.slice 5, key.length).split '_', 2
103
103
  if (prop = ThemeKeyToFragmentProperty[key])
104
104
  (accum[role] ||= {})[prop] = val
105
+ if key == 'border_width' && val && !(theme[%(role_#{role}_border_color)])
106
+ accum[role][:border_color] = theme.base_border_color
107
+ end
105
108
  #elsif key == 'font_kerning'
106
109
  # unless (resolved_val = val == 'none' ? false : (val == 'normal' ? true : nil)).nil?
107
110
  # (accum[role] ||= {})[:kerning] = resolved_val
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.1.0'
5
+ VERSION = '2.1.1'
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.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-11 00:00:00.000000000 Z
12
+ date: 2022-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor