asciidoctor-lists-extended 1.1.10 → 1.2.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a31187262d6b0b69f19786b57e05023e174e4aef336538624260d18e57af748
|
|
4
|
+
data.tar.gz: 335046829304d4f70054535a11cb247313347dda9a048f8b5ac9076e83fcbf69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2850824a15b099050d2f49ad77fc3152732c8490361c9c406519a3424a27dce7bd240baff4e0ac46dce0b5f1e9ed285f1043bd82ef917bd9aa88c9090e1edda1
|
|
7
|
+
data.tar.gz: f19b9819b2b074e7f0c7af333696eb88f212de7620b87007994904279288199867bce593175220c4b060bcb07602a35e3c8f8feece1bfd6320a716c5ded745b8
|
|
@@ -86,11 +86,15 @@ module Asciidoctor
|
|
|
86
86
|
# toc-in-toc: insert the Table of Contents itself as the first entry in
|
|
87
87
|
# the PDF ToC, before any list-of:: sections. Excluded from the bookmark
|
|
88
88
|
# outline because asciidoctor-pdf's add_outline already adds a ToC bookmark.
|
|
89
|
-
|
|
89
|
+
# IMPORTANT: do this in both scratch and final passes. During scratch,
|
|
90
|
+
# @toc_extent may not yet be set; fall back to toc_page_number so the
|
|
91
|
+
# dry-run ToC entry count/height matches the final pass.
|
|
92
|
+
if doc.attr? 'toc-in-toc'
|
|
90
93
|
toc_entry_title = doc.attr('toc-title') || 'Table of Contents'
|
|
91
|
-
|
|
94
|
+
toc_entry_range = @toc_extent&.page_range || (toc_page_number..toc_page_number)
|
|
95
|
+
insert_list_into_toc_section doc, toc_entry_title, toc_entry_range,
|
|
92
96
|
'_toc_in_toc', @list_toc_insert_idx,
|
|
93
|
-
pdf_dest: dest_top(@toc_extent.page_range.first),
|
|
97
|
+
pdf_dest: (@toc_extent ? dest_top(@toc_extent.page_range.first) : nil),
|
|
94
98
|
exclude_from_outline: true
|
|
95
99
|
@list_toc_insert_idx += 1
|
|
96
100
|
end
|
|
@@ -118,6 +122,7 @@ module Asciidoctor
|
|
|
118
122
|
result = super
|
|
119
123
|
|
|
120
124
|
# Phase 2: render deferred inline section-scoped lists.
|
|
125
|
+
|
|
121
126
|
# traverse doc has completed before ink_toc is called, so all
|
|
122
127
|
# pdf-page-start attributes are now set and page numbers are real.
|
|
123
128
|
unless @inline_render_positions.empty?
|
|
@@ -150,6 +155,8 @@ module Asciidoctor
|
|
|
150
155
|
end
|
|
151
156
|
|
|
152
157
|
result
|
|
158
|
+
ensure
|
|
159
|
+
purge_virtual_sections doc
|
|
153
160
|
end
|
|
154
161
|
|
|
155
162
|
# -----------------------------------------------------------------------
|
|
@@ -175,6 +182,16 @@ module Asciidoctor
|
|
|
175
182
|
super outline, filtered, num_levels, expand_levels
|
|
176
183
|
end
|
|
177
184
|
|
|
185
|
+
# -----------------------------------------------------------------------
|
|
186
|
+
# convert_section override
|
|
187
|
+
# -----------------------------------------------------------------------
|
|
188
|
+
# Virtual sections inserted only to drive ToC/outline entries should not
|
|
189
|
+
# be rendered as normal body headings during document traversal.
|
|
190
|
+
def convert_section(node, *args)
|
|
191
|
+
return if node.attr? 'list-virtual-section'
|
|
192
|
+
super node, *args
|
|
193
|
+
end
|
|
194
|
+
|
|
178
195
|
# -----------------------------------------------------------------------
|
|
179
196
|
# convert_paragraph override
|
|
180
197
|
# -----------------------------------------------------------------------
|
|
@@ -276,6 +293,22 @@ module Asciidoctor
|
|
|
276
293
|
|
|
277
294
|
private
|
|
278
295
|
|
|
296
|
+
# -----------------------------------------------------------------------
|
|
297
|
+
# purge_virtual_sections
|
|
298
|
+
# -----------------------------------------------------------------------
|
|
299
|
+
# Remove synthetic sections inserted only for ToC/outline generation so
|
|
300
|
+
# they cannot leak into subsequent passes or downstream section processing.
|
|
301
|
+
def purge_virtual_sections(doc)
|
|
302
|
+
return unless doc
|
|
303
|
+
doc.find_by(context: :section).each do |sect|
|
|
304
|
+
next unless sect.attr? 'list-virtual-section'
|
|
305
|
+
parent = sect.parent
|
|
306
|
+
next unless parent
|
|
307
|
+
parent.blocks.delete sect if parent.respond_to? :blocks
|
|
308
|
+
parent.sections.delete sect if parent.respond_to? :sections
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
279
312
|
# -----------------------------------------------------------------------
|
|
280
313
|
# mark_empty_list_sections
|
|
281
314
|
# -----------------------------------------------------------------------
|
|
@@ -115,11 +115,25 @@ module Asciidoctor
|
|
|
115
115
|
base_idx = 0
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
+
# If a virtual section with this id was already inserted during an earlier
|
|
119
|
+
# pass (e.g. scratch before final), refresh it in place rather than
|
|
120
|
+
# inserting a duplicate that would skew ToC height and entry count.
|
|
121
|
+
if (existing = grandparent_section.blocks.find { |b| b.context == :section && b.id == list_id })
|
|
122
|
+
existing.title = list_title
|
|
123
|
+
existing.set_attr 'pdf-destination', pdf_dest if pdf_dest
|
|
124
|
+
existing.set_attr 'pdf-page-start', list_page_nums.first
|
|
125
|
+
existing.set_attr 'list-virtual-section', ''
|
|
126
|
+
exclude_from_toc ? existing.set_attr('list-exclude-from-toc', '') : existing.remove_attr('list-exclude-from-toc')
|
|
127
|
+
exclude_from_outline ? existing.set_attr('list-exclude-from-outline', '') : existing.remove_attr('list-exclude-from-outline')
|
|
128
|
+
return existing
|
|
129
|
+
end
|
|
130
|
+
|
|
118
131
|
list_section = Asciidoctor::Section.new grandparent_section, toc_level, false
|
|
119
132
|
list_section.set_attr 'pdf-destination', pdf_dest if pdf_dest
|
|
120
133
|
list_section.title = list_title
|
|
121
134
|
list_section.id = list_id
|
|
122
135
|
list_section.set_attr 'pdf-page-start', list_page_nums.first
|
|
136
|
+
list_section.set_attr 'list-virtual-section', ''
|
|
123
137
|
list_section.set_attr 'list-exclude-from-toc', '' if exclude_from_toc
|
|
124
138
|
list_section.set_attr 'list-exclude-from-outline', '' if exclude_from_outline
|
|
125
139
|
grandparent_section.blocks.insert base_idx + insert_idx, list_section
|