asciidoctor-pdf 2.1.2 → 2.1.3

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: 2109e7ec140c759820252d4c7f0f155c2d7bf4adfcad9d34fddb8cf4bc81a260
4
- data.tar.gz: c18e3fb15231f968d907fc05693f6c4d7f9fbedfd29e368b0dc355f44d2e4254
3
+ metadata.gz: f7753392586bac4a044601fefa9ecb58745e02fc37434dd5a26e020692890e65
4
+ data.tar.gz: 301fe3fef546588aacba4ca8d9c5afd91d4a19a816f07a8fcc66121c8f58f626
5
5
  SHA512:
6
- metadata.gz: 4e51a465c863440441cae24e429bbf84d9fb782e2c711958d5b72dfa585ba4b1b7c9c94b92d8155b2cea0d72eec276fac6e4669ea8a50c175ff8ed82ab91eb8d
7
- data.tar.gz: a62b653261f3194d51a738cc4b1cf46f4a78a6ba0c1687fbeb06bf5049ecc9d65a20edd7acc463a2f4b473d1248795ce39902b214b87b019cbc8485d394a32f3
6
+ metadata.gz: b26fe1f74b22bd73eba166190d21afebafdc1630dba5fee8174aa946b463d81b7e620cb8f400e803507f050c6dd48a1d732a1273a78fc1cd0e958da69a0a3c9c
7
+ data.tar.gz: 15cd75342088585a51f19cb342a8023fbc2aa6d0cd89fff72385370172059ac10c98fa51b8126845ce40436fcd89dc0c1f47aa763df14dad24ba2bcd95f92205
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,19 @@
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.3 (2022-06-23) - @mojavelinux
9
+
10
+ Bug Fixes::
11
+
12
+ * interpret `start-at` theme keys with value `1` correctly (as `1` instead of `2`) (#2255)
13
+ * restore column layout after importing page(s) from PDF (#2253)
14
+ * fix crash when border color is transparent (`thematic-break-border-color`, `admonition-column-rule`, `quote-border-color`, `verse-border-color`)
15
+ * ensure page margin is restored after imported page
16
+
17
+ === Details
18
+
19
+ {url-repo}/releases/tag/v2.1.3[git tag] | {url-repo}/compare/v2.1.2\...v2.1.3[full diff]
20
+
8
21
  == 2.1.2 (2022-06-17) - @mojavelinux
9
22
 
10
23
  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.1.2, 2022-06-17
3
+ v2.1.3, 2022-06-23
4
4
  // Settings:
5
5
  :experimental:
6
6
  :idprefix:
@@ -22,8 +22,6 @@ endif::[]
22
22
  // Aliases:
23
23
  :project-name: Asciidoctor PDF
24
24
  :project-handle: asciidoctor-pdf
25
- // Variables:
26
- :release-line: 2.1.x
27
25
  // URLs:
28
26
  :url-gem: https://rubygems.org/gems/asciidoctor-pdf
29
27
  :url-project: https://github.com/asciidoctor/asciidoctor-pdf
@@ -213,7 +213,7 @@ module Asciidoctor
213
213
  first_page_offset = has_title_page ? zero_page_offset.next : zero_page_offset
214
214
  body_offset = (body_start_page_number = page_number) - 1
215
215
  if ::Integer === (running_content_start_at = @theme.running_content_start_at)
216
- running_content_body_offset = body_offset + [running_content_start_at.pred, 1].max
216
+ running_content_body_offset = body_offset + [running_content_start_at.pred, 0].max
217
217
  running_content_start_at = 'body'
218
218
  else
219
219
  running_content_body_offset = body_offset
@@ -227,7 +227,7 @@ module Asciidoctor
227
227
  end
228
228
  end
229
229
  if ::Integer === (page_numbering_start_at = @theme.page_numbering_start_at)
230
- page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 1].max
230
+ page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 0].max
231
231
  page_numbering_start_at = 'body'
232
232
  else
233
233
  page_numbering_body_offset = body_offset
@@ -263,12 +263,12 @@ module Asciidoctor
263
263
  else
264
264
  body_offset = body_start_page_number - 1
265
265
  if ::Integer === (running_content_start_at = @theme.running_content_start_at)
266
- running_content_body_offset = body_offset + [running_content_start_at.pred, 1].max
266
+ running_content_body_offset = body_offset + [running_content_start_at.pred, 0].max
267
267
  else
268
268
  running_content_body_offset = body_offset
269
269
  end
270
270
  if ::Integer === (page_numbering_start_at = @theme.page_numbering_start_at)
271
- page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 1].max
271
+ page_numbering_body_offset = body_offset + [page_numbering_start_at.pred, 0].max
272
272
  elsif page_numbering_start_at == 'cover' && has_front_cover
273
273
  page_numbering_body_offset = 0
274
274
  else
@@ -371,8 +371,6 @@ module Asciidoctor
371
371
  if (page_margin_inner = theme.page_margin_inner)
372
372
  page_margin_recto[3] = page_margin_verso[1] = page_margin_inner
373
373
  end
374
- # NOTE: prepare scratch document to use page margin from recto side (which has same width as verso side)
375
- set_page_margin page_margin_recto unless page_margin_recto == page_margin
376
374
  else
377
375
  @ppbook = nil
378
376
  end
@@ -581,6 +579,7 @@ module Asciidoctor
581
579
  end
582
580
 
583
581
  def prepare_theme theme
582
+ theme.base_border_color = nil if theme.base_border_color == 'transparent'
584
583
  theme.base_font_color ||= '000000'
585
584
  theme.base_font_size ||= 12
586
585
  theme.base_font_style = theme.base_font_style&.to_sym || :normal
@@ -943,7 +942,7 @@ module Asciidoctor
943
942
  if extent
944
943
  label_height = extent.single_page_height || cursor
945
944
  if (rule_width = @theme.admonition_column_rule_width || 0) > 0 &&
946
- (rule_color = @theme.admonition_column_rule_color || @theme.base_border_color)
945
+ (rule_color = resolve_theme_color :admonition_column_rule_color, @theme.base_border_color, nil)
947
946
  rule_style = @theme.admonition_column_rule_style&.to_sym || :solid
948
947
  float do
949
948
  extent.each_page do |first_page, last_page|
@@ -1273,7 +1272,7 @@ module Asciidoctor
1273
1272
  category = node.context == :quote ? :quote : :verse
1274
1273
  # NOTE: b_width and b_left_width are mutually exclusive
1275
1274
  if (b_left_width = @theme[%(#{category}_border_left_width)]) && b_left_width > 0
1276
- b_color = @theme[%(#{category}_border_color)] || @theme.base_border_color
1275
+ b_left_width = nil unless (b_color = resolve_theme_color %(#{category}_border_color), @theme.base_border_color, nil)
1277
1276
  else
1278
1277
  b_left_width = nil
1279
1278
  b_width = nil if (b_width = @theme[%(#{category}_border_width)]) == 0
@@ -2341,9 +2340,11 @@ module Asciidoctor
2341
2340
 
2342
2341
  def convert_thematic_break node
2343
2342
  pad_box @theme.thematic_break_padding || [@theme.thematic_break_margin_top, 0] do
2344
- stroke_horizontal_rule @theme.thematic_break_border_color,
2345
- line_width: @theme.thematic_break_border_width,
2346
- line_style: (@theme.thematic_break_border_style&.to_sym || :solid)
2343
+ if (b_color = resolve_theme_color :thematic_break_border_color)
2344
+ stroke_horizontal_rule b_color,
2345
+ line_width: @theme.thematic_break_border_width,
2346
+ line_style: (@theme.thematic_break_border_style&.to_sym || :solid)
2347
+ end
2347
2348
  end
2348
2349
  conceal_page_top { theme_margin :block, :bottom, (next_enclosed_block node) }
2349
2350
  end
@@ -4817,18 +4818,17 @@ module Asciidoctor
4817
4818
  end
4818
4819
 
4819
4820
  # NOTE: init_page is called within a float context; this will suppress prawn-svg messing with the cursor
4820
- # NOTE: init_page is not called for imported pages, front and back cover pages, and other image pages
4821
+ # NOTE: init_page is not called for imported pages, cover pages, image pages, and pages in the scratch document
4821
4822
  def init_page *_args
4822
4823
  next_page_side = page_side nil, @folio_placement[:inverted]
4823
4824
  if @media == 'prepress' && (next_page_margin = @page_margin_by_side[page_number == 1 ? :cover : next_page_side]) != page_margin
4824
4825
  set_page_margin next_page_margin
4825
4826
  end
4826
4827
  unless @page_bg_color == 'FFFFFF'
4827
- tare = true
4828
4828
  fill_absolute_bounds @page_bg_color
4829
+ tare = true
4829
4830
  end
4830
4831
  if (bg_image_path, bg_image_opts = @page_bg_image[next_page_side])
4831
- tare = true
4832
4832
  begin
4833
4833
  if bg_image_opts[:format] == 'pdf'
4834
4834
  # NOTE: pages that use PDF for the background do not support a background color or running content
@@ -4837,6 +4837,7 @@ module Asciidoctor
4837
4837
  else
4838
4838
  canvas { image bg_image_path, ({ position: :center, vposition: :center }.merge bg_image_opts) }
4839
4839
  end
4840
+ tare = true
4840
4841
  rescue
4841
4842
  facing_page_side = (PageSides - [next_page_side])[0]
4842
4843
  @page_bg_image[facing_page_side] = nil if @page_bg_image[facing_page_side] == @page_bg_image[next_page_side]
@@ -5031,10 +5032,8 @@ module Asciidoctor
5031
5032
  # QUESTION: should we pass a category as an argument?
5032
5033
  # QUESTION: should we make this a method on the theme ostruct? (e.g., @theme.resolve_color key, fallback)
5033
5034
  def resolve_theme_color key, fallback_color = nil, transparent_color = fallback_color
5034
- if (color = @theme[key])
5035
+ if (color = @theme[key] || fallback_color)
5035
5036
  color == 'transparent' ? transparent_color : color
5036
- else
5037
- fallback_color
5038
5037
  end
5039
5038
  end
5040
5039
 
@@ -5114,6 +5113,10 @@ module Asciidoctor
5114
5113
  end
5115
5114
 
5116
5115
  def init_scratch originator
5116
+ if @media == 'prepress' && page_margin != (page_margin_recto = @page_margin_by_side[:recto])
5117
+ # NOTE: prepare scratch document to use page margin from recto side (which has same width as verso side)
5118
+ set_page_margin page_margin_recto
5119
+ end
5117
5120
  @scratch_prototype = originator.instance_variable_get :@scratch_prototype
5118
5121
  @tmp_files = originator.instance_variable_get :@tmp_files
5119
5122
  text_formatter.scratch = true
@@ -6,20 +6,23 @@ Prawn::Document::ColumnBox.prepend (Module.new do
6
6
  def move_past_bottom
7
7
  (doc = @document).y = @y
8
8
  return if (@current_column = (@current_column + 1) % @columns) > 0
9
- par = @parent
10
- if (reset_y = @reflow_margins) && (reset_y == true || reset_y > doc.page_number)
11
- @y = par.absolute_top
12
- @height = par.height unless stretchy?
13
- end
9
+ parent_ = @parent
10
+ reset_top parent_ if (reflow_at = @reflow_margins) && (reflow_at == true || reflow_at > doc.page_number)
14
11
  initial_margins = doc.page.margins
15
- par.move_past_bottom
12
+ parent_.move_past_bottom
16
13
  if doc.page.margins != initial_margins
17
- doc.bounds = self.class.new doc, par, [(margin_box = doc.margin_box).absolute_left, @y],
14
+ doc.bounds = self.class.new doc, parent_, [(margin_box = doc.margin_box).absolute_left, @y],
18
15
  columns: @columns, reflow_margins: @reflow_margins, spacer: @spacer, width: margin_box.width, height: @height
19
16
  end
20
17
  nil
21
18
  end
22
19
 
20
+ def reset_top parent_ = @parent
21
+ @current_column = 0
22
+ @height = parent_.height unless stretchy?
23
+ @y = parent_.absolute_top
24
+ end
25
+
23
26
  # Rearranges the column box into a single column, where the original columns are in a single file. Used
24
27
  # for the purpose of computing the extent of content in a scratch document.
25
28
  def single_file
@@ -924,6 +924,8 @@ module Asciidoctor
924
924
  def import_page file, options = {}
925
925
  prev_page_layout = page.layout
926
926
  prev_page_size = page.size
927
+ prev_page_margin = page_margin
928
+ prev_bounds = bounds
927
929
  state.compress = false if state.compress # can't use compression if using template
928
930
  prev_text_rendering_mode = (defined? @text_rendering_mode) ? @text_rendering_mode : nil
929
931
  delete_current_page if options[:replace]
@@ -936,11 +938,15 @@ module Asciidoctor
936
938
  # NOTE: set page size & layout explicitly in case imported page differs
937
939
  # I'm not sure it's right to start a new page here, but unfortunately there's no other
938
940
  # way atm to prevent the size & layout of the imported page from affecting subsequent pages
939
- advance_page size: prev_page_size, layout: prev_page_layout if options.fetch :advance, true
941
+ if options.fetch :advance, true
942
+ advance_page layout: prev_page_layout, margin: prev_page_margin, size: prev_page_size
943
+ (@bounding_box = prev_bounds).reset_top if ColumnBox === prev_bounds
944
+ end
940
945
  elsif options.fetch :advance_if_missing, true
941
946
  delete_current_page
942
947
  # NOTE: see previous comment
943
- advance_page size: prev_page_size, layout: prev_page_layout
948
+ advance_page layout: prev_page_layout, margin: prev_page_margin, size: prev_page_size
949
+ @y = (@bounding_box = prev_bounds).reset_top if ColumnBox === prev_bounds
944
950
  else
945
951
  delete_current_page
946
952
  end
@@ -1112,7 +1118,8 @@ module Asciidoctor
1112
1118
  # This method performs all work in a scratch document (or documents). It begins by starting a
1113
1119
  # new page in the scratch document, first creating the scratch document if necessary. It then
1114
1120
  # applies all the settings from the main document to the scratch document that impact
1115
- # rendering. This includes the bounds, the cursor position, and the font settings.
1121
+ # rendering. This includes the bounds, the cursor position, and the font settings. This method
1122
+ # assumes that the content area remains constant when content flows from one page to the next.
1116
1123
  #
1117
1124
  # From this point, the number of attempts the method makes is determined by the value of the
1118
1125
  # keep_together keyword parameter. If the value is true (or the parent document is inhibiting
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.1.2'
5
+ VERSION = '2.1.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.1.2
4
+ version: 2.1.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-06-17 00:00:00.000000000 Z
12
+ date: 2022-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor