asciidoctor-pdf-table-break 1.0.0 → 1.0.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: de514b2984c827ec505996e116fda87ad5134ae4e82e74ecf0e99286af856fa1
4
- data.tar.gz: 9430c1c541b26c9b1e7bf7424d30d93e4f96ef6aba3a7b47b5ab6e82413e593a
3
+ metadata.gz: 6efa4ac4626d6cdd4c2cd1ecd78b7094c1a9f2ccee06be5da4a7d9fbd32be9f1
4
+ data.tar.gz: 8973d4788509c38fe821f2158c41abc23b42a2521eb46a25cec815b9f80954b3
5
5
  SHA512:
6
- metadata.gz: 0ffbe8393f1a7faa61ef82ee4bb1879496f82ce8f624bfadba6beb4c0198290a54eb8ff0a8f5cb4ef6759f5e27098a6904f9461a4d964a2db80333f31adc312c
7
- data.tar.gz: 5ed03de5ba3d9ab53ea1955b4b8e8845d32ea769e7aa9387f4da24b25e89bdce619faf6d4173b030ce61c5e512a81fb312fcc570809345235e0685ede5422ca1
6
+ metadata.gz: 94915273d61c338ed591f6c2ff38951c5216894a22f3f3f91025863ca2acc39c594aee40e7472c74c79c3b5c860b9b554adb45894576b097bee0e94b7b7b9c9b
7
+ data.tar.gz: 70ddd0605a2987e2f5c2c9861ec21aadfdaa96d6460c13edfa434c790fd5244004be319465c37d307f111f37969c11b86a1a3e12fe1b7226f1a5fc708fdde320
@@ -5,7 +5,7 @@
5
5
  # Adds explicit page-break support inside AsciiDoc tables.
6
6
  #
7
7
  # Usage:
8
- # asciidoctor-pdf -r asciidoctor-table-break document.adoc
8
+ # asciidoctor-pdf -r asciidoctor-pdf-table-break document.adoc
9
9
  #
10
10
  # SYNTAX — two equivalent forms:
11
11
  #
@@ -38,13 +38,32 @@
38
38
  # - The table caption/title and anchor appear only on the first page.
39
39
  # - Border handling: the outer frame border is replaced by the grid line
40
40
  # width at break boundaries, producing seamless visual continuity.
41
+ #
42
+ # LOADING ORDER
43
+ # Use class-based subclassing (register_for 'pdf') rather than Module#prepend
44
+ # so this extension sits correctly at the top of any custom converter chain.
45
+ # Require this gem AFTER all other -r PDF extensions so that
46
+ # Asciidoctor::Converter.for('pdf') already reflects the full chain before
47
+ # this class subclasses it.
41
48
 
42
49
  require 'asciidoctor/pdf'
43
50
 
44
- Asciidoctor::PDF::Converter.prepend(Module.new do # rubocop:disable Style/CommentedKeyword
51
+ class PDFConverterTableBreak < (Asciidoctor::Converter.for 'pdf')
52
+ register_for 'pdf'
53
+
45
54
  def convert_table node
46
55
  body_rows = node.rows[:body]
47
56
 
57
+ # Save node state before any early return so the ensure block always has
58
+ # valid references. In a prepend approach, returning early before these
59
+ # assignments leaves them nil, and the ensure block would then corrupt the
60
+ # node by setting body/foot to nil.
61
+ orig_body = node.rows[:body]
62
+ orig_foot = node.rows[:foot]
63
+ orig_id = node.id
64
+ orig_title = node.title if node.title?
65
+ orig_attrs = node.attributes.dup
66
+
48
67
  # Detect break rows: every cell must have source text '<<<'.
49
68
  # Covers both N+| <<< (single spanning cell) and | <<< | <<< | ... (one per column).
50
69
  break_idxs = body_rows.each_index.select do |i|
@@ -65,13 +84,6 @@ Asciidoctor::PDF::Converter.prepend(Module.new do # rubocop:disable Style/Commen
65
84
  grid_rows_w = (expand_grid_values grid_raw, 0)[0]
66
85
  orig_tbl_bw = @theme.table_border_width
67
86
 
68
- # Save node state for restoration in the ensure block.
69
- orig_body = node.rows[:body]
70
- orig_foot = node.rows[:foot]
71
- orig_id = node.id
72
- orig_title = node.title if node.title?
73
- orig_attrs = node.attributes.dup
74
-
75
87
  ranges.each_with_index do |range, seg_idx|
76
88
  is_first = seg_idx == 0
77
89
  is_last = seg_idx == last_idx
@@ -112,4 +124,4 @@ Asciidoctor::PDF::Converter.prepend(Module.new do # rubocop:disable Style/Commen
112
124
  node.instance_variable_set :@title, orig_title if defined?(orig_title) && orig_title
113
125
  node.instance_variable_set :@attributes, orig_attrs if orig_attrs
114
126
  end
115
- end)
127
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-pdf-table-break
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 白一百 baiyibai