asciidoctor-lists-extended 1.2.1 → 1.2.2

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: 0a31187262d6b0b69f19786b57e05023e174e4aef336538624260d18e57af748
4
- data.tar.gz: 335046829304d4f70054535a11cb247313347dda9a048f8b5ac9076e83fcbf69
3
+ metadata.gz: eea56f2723162b60d59bbb2d93db827851391f3e6ad27868e79e3cd48260087e
4
+ data.tar.gz: 0c8f0a1cea5a7afd52c934b43e41557f7e41869e9ffe4fc159a7cfc70fd0ee8d
5
5
  SHA512:
6
- metadata.gz: 2850824a15b099050d2f49ad77fc3152732c8490361c9c406519a3424a27dce7bd240baff4e0ac46dce0b5f1e9ed285f1043bd82ef917bd9aa88c9090e1edda1
7
- data.tar.gz: f19b9819b2b074e7f0c7af333696eb88f212de7620b87007994904279288199867bce593175220c4b060bcb07602a35e3c8f8feece1bfd6320a716c5ded745b8
6
+ metadata.gz: 2e901929fc60afc373360eaa07f0822a05a12270c2fc9c6757741d8e52db864702f663b03921d35f497b5583daa884ed63da9eea99ebb88434f0461675ed1c98
7
+ data.tar.gz: 92059b3b00548fd752791b1bda2abef6d7288d1dc9b0726b23fe499e0a4e00db9b25e3e64b7a72f3bbc400a698596285af6934175e8f00f22d51f5ecdfc4d03f
@@ -38,6 +38,7 @@ module Asciidoctor
38
38
  @list_entry_indent = nil
39
39
  @list_first_entry_margin = nil
40
40
  @list_toc_insert_idx = 0
41
+ @virtual_list_sections = [] # list-of:: virtual sections, kept for running content
41
42
  end
42
43
 
43
44
  # -----------------------------------------------------------------------
@@ -82,6 +83,7 @@ module Asciidoctor
82
83
  def ink_toc(doc, num_levels, toc_page_number, start_cursor, num_front_matter_pages = 0)
83
84
  @inline_num_front_matter_pages = num_front_matter_pages
84
85
  @list_toc_insert_idx = 0
86
+ @virtual_list_sections = []
85
87
 
86
88
  # toc-in-toc: insert the Table of Contents itself as the first entry in
87
89
  # the PDF ToC, before any list-of:: sections. Excluded from the bookmark
@@ -111,10 +113,13 @@ module Asciidoctor
111
113
  # Bare macros (no parent section and no title= attribute) have no
112
114
  # meaningful label for the ToC or outline — skip the virtual section.
113
115
  unless list_title.nil_or_empty?
114
- insert_list_into_toc_section doc, list_title, list_page_nums, list_id, @list_toc_insert_idx,
116
+ virtual_section = insert_list_into_toc_section doc, list_title, list_page_nums, list_id, @list_toc_insert_idx,
115
117
  pdf_dest: @last_list_dest || dest_top(list_page_nums.first),
116
118
  exclude_from_toc: resolve_exclude_from_toc(config),
117
119
  exclude_from_outline: resolve_exclude_from_outline(config)
120
+ # Retain a reference so running content can show the list title on its
121
+ # own pages; the section itself is purged from the tree below.
122
+ @virtual_list_sections << virtual_section
118
123
  @list_toc_insert_idx += 1
119
124
  end
120
125
  end
@@ -159,6 +164,33 @@ module Asciidoctor
159
164
  purge_virtual_sections doc
160
165
  end
161
166
 
167
+ # -----------------------------------------------------------------------
168
+ # ink_running_content override
169
+ # -----------------------------------------------------------------------
170
+ # asciidoctor-pdf builds its per-page running-content title map from
171
+ # doc.find_by(context: :section), keyed by each section's pdf-page-start.
172
+ # Our list-of:: virtual sections carry both a title and a pdf-page-start,
173
+ # but they were purged in ink_toc's ensure (which runs before this), so the
174
+ # list-of pages fall back to the preface/chapter title. Re-insert them for
175
+ # the duration of the indexing pass, then purge again so they cannot leak
176
+ # into the scratch/final document tree.
177
+ def ink_running_content(periphery, doc, *args)
178
+ reinsert_virtual_list_sections doc
179
+ super
180
+ ensure
181
+ purge_virtual_sections doc
182
+ end
183
+
184
+ # Restore the retained list-of:: virtual sections into their original
185
+ # parent so doc.find_by(context: :section) can see them again.
186
+ def reinsert_virtual_list_sections(doc)
187
+ @virtual_list_sections.each do |sect|
188
+ parent = sect.parent || doc
189
+ parent.blocks << sect if parent.respond_to?(:blocks) && !(parent.blocks.include? sect)
190
+ parent.sections << sect if parent.respond_to?(:sections) && !(parent.sections.include? sect)
191
+ end
192
+ end
193
+
162
194
  # -----------------------------------------------------------------------
163
195
  # get_entries_for_toc override
164
196
  # -----------------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-lists-extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 白一百 baiyibai