asciidoctor-pdf 2.0.7 → 2.0.8

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: f836f6c86c31a3bbd792bba4608f397422361bcc5b297355eccab266a3a5ac0b
4
- data.tar.gz: b31b434d0d7bede025b4f3c25e71a518f120a66840dfb7df72308d17fda9bd8e
3
+ metadata.gz: cd47554913fab2e3f8002491a92c430e0dbfe48b9177705470ffa7c64155289b
4
+ data.tar.gz: 580c0c9e6a46e5614927f42c4ad309e303dd69681bf10ddb674241cd930e6b31
5
5
  SHA512:
6
- metadata.gz: 84899cfb74ce8ef2c97111d585e73529318c3f0a44756f75674338f58c1d46693925fe1f9d42b9666f07d8a1bed68f606ec3ec2b664816d0c92998494e90a39a
7
- data.tar.gz: a50053c502cf572929c49802208e18faa9f1e5bf0a2f3e47972c3863fafa3c43e157425e7b3c5a1ad12cc0e301d8e461a108907e48f5b80aaa0f05938dc2e6a2
6
+ metadata.gz: 326e87435e664dde2e944b878d2c5c9a5b71cfd285da78115331a8cd14e20f2aaa0cb2b81779bc99ca8642df004ef03f60386a971e9176eb03d17755a9db951b
7
+ data.tar.gz: 7d7cd662e4bbe5df6d10c057e2f00a1a1c800f0e5a3e4f7731c94b657b0bf6ec51599e88d42dbd806a1e4bf991e54282c4efb820b0d39912ed34a74d25f89ff4
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,26 @@
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.0.8 (2022-06-08) - @mojavelinux
9
+
10
+ Improvements::
11
+
12
+ * encapsulate logic to adjust column box inside float and dry run
13
+ * automatically set height on column box if not specified; update value automatically when reflowing margins
14
+
15
+ Bug Fixes::
16
+
17
+ * correctly compute value of to cursor on extent when column box starts below top of page (#2230)
18
+ * fix crash in `ColumnBox#move_past_bottom` when `:reflow_margins` option is not set
19
+ * fix x position of SVG when advanced to next column of column box
20
+ * `at_page_top?` should consider top of column box to be top of page
21
+ * prevent SVG image taller than column from being advanced to next column
22
+ * don't push section that follows index section in article to new page if last page of index does not extend to bottom of page
23
+
24
+ === Details
25
+
26
+ {url-repo}/releases/tag/v2.0.8[git tag] | {url-repo}/compare/v2.0.7\...v2.0.8[full diff]
27
+
8
28
  == 2.0.7 (2022-06-03) - @mojavelinux
9
29
 
10
30
  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.0.7, 2022-06-03
3
+ v2.0.8, 2022-06-08
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.7
27
+ :release-version: 2.0.8
28
28
  // URLs:
29
29
  :url-gem: https://rubygems.org/gems/asciidoctor-pdf
30
30
  :url-project: https://github.com/asciidoctor/asciidoctor-pdf
@@ -62,7 +62,7 @@ Asciidoctor PDF converts an AsciiDoc document directly to a PDF document.
62
62
  The style and layout of the PDF are controlled by a dedicated theme file.
63
63
  To the degree possible, Asciidoctor PDF supports all the features of AsciiDoc that are supported by Asciidoctor.
64
64
  It also provides {url-project-docs}/features/[PDF-specific features].
65
- However, there are {url-project-docs}/features/#limitations[certain limits] imposed by the PDF format and the PDF library this extension uses.
65
+ However, there are {url-project-docs}/features/#limitations[certain limitations] imposed by the PDF format and the PDF library this extension uses.
66
66
 
67
67
  Asciidoctor PDF uses the Prawn gem and Prawn's extensions, such as prawn-svg and prawn-table, to generate a PDF document.
68
68
  {url-prawn}[Prawn] is a general purpose PDF generator for Ruby that features high-level APIs for common needs like setting up the page and inserting images and low-level APIs for positioning and rendering text and graphics.
@@ -182,7 +182,7 @@ Asciidoctor creates the output file in the same directory as the input file by d
182
182
  Open the [.path]_basic-example.pdf_ file with a PDF viewer to see the result.
183
183
 
184
184
  .Example PDF document rendered in a PDF viewer
185
- image::docs/modules/ROOT/images/basic-example-pdf-screenshot.png[Screenshot of PDF document,960,540,pdfwidth=100%]
185
+ image::docs/modules/ROOT/images/basic-example-pdf-screenshot.png[Screenshot of PDF document,960,pdfwidth=100%]
186
186
 
187
187
  For more information about how to use Asciidoctor PDF and PDF-specific AsciiDoc syntax, see the {url-project-docs}/[Asciidoctor PDF documentation].
188
188
 
@@ -162,7 +162,6 @@ module Asciidoctor
162
162
  doc.attributes['outline'] = '' unless (doc.attribute_locked? 'outline') || ((doc.instance_variable_get :@attributes_modified).include? 'outline')
163
163
  doc.attributes['outline-title'] = '' unless (doc.attribute_locked? 'outline-title') || ((doc.instance_variable_get :@attributes_modified).include? 'outline-title')
164
164
  doc.attributes['pagenums'] = '' unless (doc.attribute_locked? 'pagenums') || ((doc.instance_variable_get :@attributes_modified).include? 'pagenums')
165
- #assign_missing_section_ids doc
166
165
 
167
166
  on_page_create(&(method :init_page))
168
167
 
@@ -703,6 +702,7 @@ module Asciidoctor
703
702
  def convert_index_section node
704
703
  space_needed_for_category = @theme.description_list_term_spacing + (2 * (height_of_typeset_text 'A'))
705
704
  pagenum_sequence_style = node.document.attr 'index-pagenum-sequence-style'
705
+ end_cursor = nil
706
706
  column_box [0, cursor], columns: @theme.index_columns, width: bounds.width, reflow_margins: true, spacer: @theme.index_column_gap do
707
707
  @index.categories.each do |category|
708
708
  bounds.move_past_bottom if space_needed_for_category > cursor
@@ -714,7 +714,10 @@ module Asciidoctor
714
714
  category.terms.each {|term| convert_index_list_item term, pagenum_sequence_style }
715
715
  @theme.prose_margin_bottom > cursor ? bounds.move_past_bottom : (move_down @theme.prose_margin_bottom)
716
716
  end
717
+ end_cursor = cursor if bounds.current_column == 0
717
718
  end
719
+ # Q: could we move this logic into column_box?
720
+ move_cursor_to end_cursor if end_cursor
718
721
  nil
719
722
  end
720
723
 
@@ -1752,6 +1755,7 @@ module Asciidoctor
1752
1755
  if (rendered_h = svg_size.output_height) > (available_h = cursor - caption_h)
1753
1756
  unless pinned || at_page_top?
1754
1757
  advance_page
1758
+ (svg_obj.options[:at] = svg_obj.position)[0] += bounds.left if ColumnBox === bounds
1755
1759
  available_h = cursor - caption_h
1756
1760
  end
1757
1761
  rendered_w = (svg_obj.resize height: (rendered_h = available_h)).output_width if rendered_h > available_h
@@ -1,20 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Prawn::Document::ColumnBox.prepend (Module.new do
4
- def absolute_bottom
5
- stretchy? ? @parent.absolute_bottom : super
6
- end
4
+ attr_accessor :current_column
7
5
 
8
6
  def move_past_bottom
9
7
  (doc = @document).y = @y
10
8
  return if (@current_column = (@current_column + 1) % @columns) > 0
11
- @y = (par = @parent).absolute_top if @reflow_margins
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
12
14
  initial_margins = doc.page.margins
13
15
  par.move_past_bottom
14
16
  if doc.page.margins != initial_margins
15
- doc.bounds = self.class.new doc, par, (margin_box = doc.margin_box).absolute_top_left,
16
- columns: @columns, reflow_margins: true, spacer: @spacer, width: margin_box.width
17
+ doc.bounds = self.class.new doc, par, [(margin_box = doc.margin_box).absolute_left, @y],
18
+ columns: @columns, reflow_margins: @reflow_margins, spacer: @spacer, width: margin_box.width, height: @height
19
+ end
20
+ nil
21
+ end
22
+
23
+ # Rearranges the column box into a single column, where the original columns are in a single file. Used
24
+ # for the purpose of computing the extent of content in a scratch document.
25
+ def single_file
26
+ if @reflow_margins && @parent.absolute_top > @y && @columns > @current_column + 1
27
+ # defer reflow margins until all columns on current page have been exhausted
28
+ @reflow_margins = @document.page_number + (@columns - @current_column)
17
29
  end
30
+ @width = bare_column_width
31
+ @columns = 1
32
+ @current_column = 0
18
33
  nil
19
34
  end
20
35
  end)
@@ -251,16 +251,17 @@ module Asciidoctor
251
251
  # Returns whether the cursor is at the top of the page (i.e., margin box).
252
252
  #
253
253
  def at_page_top?
254
- @y == @margin_box.absolute_top
254
+ @y == (ColumnBox === bounds ? bounds : @margin_box).absolute_top
255
255
  end
256
256
 
257
257
  # Prevents at_page_top? from returning true while yielding to the specified block.
258
258
  #
259
259
  def conceal_page_top
260
- @margin_box.instance_variable_set :@y, (old_top = @margin_box.absolute_top) + 0.0001
260
+ old_top = (outer_bounds = ColumnBox === bounds ? bounds : @margin_box).absolute_top
261
+ outer_bounds.instance_variable_set :@y, old_top + 0.0001
261
262
  yield
262
263
  ensure
263
- @margin_box.instance_variable_set :@y, old_top
264
+ outer_bounds.instance_variable_set :@y, old_top
264
265
  end
265
266
 
266
267
  # Returns whether the current page is the last page in the document.
@@ -560,11 +561,11 @@ module Asciidoctor
560
561
  def float
561
562
  original_page_number = page_number
562
563
  original_y = y
563
- original_column = bounds.instance_variable_get :@current_column if ColumnBox === bounds
564
+ original_column = bounds.current_column if ColumnBox === bounds
564
565
  yield
565
566
  go_to_page original_page_number unless page_number == original_page_number
566
567
  self.y = original_y
567
- bounds.instance_variable_set :@current_column, original_column if original_column
568
+ bounds.current_column = original_column if original_column
568
569
  end
569
570
 
570
571
  # Short-circuits the call to the built-in move_up operation
@@ -721,6 +722,12 @@ module Asciidoctor
721
722
  end
722
723
  end
723
724
 
725
+ # Wraps the column_box method and automatically sets the height unless the :height option is specified.
726
+ def column_box point, options, &block
727
+ options[:height] = cursor unless options.key? :height
728
+ super
729
+ end
730
+
724
731
  # A flowing version of bounding_box. If the content runs to another page, the cursor starts at
725
732
  # the top of the page instead of from the original cursor position. Similar to span, except
726
733
  # the :position option is limited to a numeric value and additional options are passed through
@@ -1146,10 +1153,7 @@ module Asciidoctor
1146
1153
  scratch_pdf.bounds = bounds.dup.tap do |bounds_copy|
1147
1154
  bounds_copy.instance_variable_set :@document, scratch_pdf
1148
1155
  bounds_copy.instance_variable_set :@parent, saved_bounds
1149
- if ColumnBox === bounds_copy
1150
- bounds_copy.instance_variable_set :@width, bounds_copy.bare_column_width
1151
- bounds_copy.instance_variable_set :@current_column, (bounds_copy.instance_variable_set :@columns, 1) - 1
1152
- end
1156
+ bounds_copy.single_file if ColumnBox === bounds_copy
1153
1157
  end
1154
1158
  scratch_pdf.move_cursor_to cursor unless (scratch_start_at_top = keep_together || pages_advanced > 0 || at_page_top?)
1155
1159
  scratch_start_cursor = scratch_pdf.cursor
@@ -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, aliases: true, filename: BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
72
+ (::OpenStruct.new ::YAML.safe_load io, filename: BaseThemePath).tap {|theme| theme.__dir__ = ThemesDir }
73
73
  end
74
74
  end
75
75
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module PDF
5
- VERSION = '2.0.7'
5
+ VERSION = '2.0.8'
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.7
4
+ version: 2.0.8
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-03 00:00:00.000000000 Z
12
+ date: 2022-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor