asciidoctor-multipage 0.0.10 → 0.0.11
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 +4 -4
- data/lib/asciidoctor-multipage.rb +54 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d22229b52f7ecc747f4c4f80fcfe6b3d097d49a0ba7c1e375de6f72280c950
|
4
|
+
data.tar.gz: 901b657b48543dc3466154c0ba5d00d82d639f1b72a747eae5bb5821cd287cb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c37d84631c4d9bbdd02a272fd61dd5c5cf26b6a60f2e203378ca0dc669edd731284b13bf5d9fdfae601209ae38ddf9647ad8e7091e7a46b6810cb5beb7e6a6
|
7
|
+
data.tar.gz: 7bf7e7e32dac50d8619ee1ac52e9bc501c2d1cb5585e391f7501ed2b6e7bd1ab67b265c7e7d1a4e2df5cc95e0077fcdd768faaf76d1b6e886894140b85669bec
|
@@ -52,6 +52,14 @@ class Asciidoctor::Document
|
|
52
52
|
# nodes are no longer accessible.
|
53
53
|
attr_writer :sectnum
|
54
54
|
|
55
|
+
# A pointer to the original converter (first converter instantiated to
|
56
|
+
# convert the original document). As we create additional documents
|
57
|
+
# ourselves, AsciiDoctor will instantiate additional instances of
|
58
|
+
# MultipageHtml5Converter for each created document. These instances need
|
59
|
+
# to share state, so they can use the original converter instance
|
60
|
+
# for that purpose.
|
61
|
+
attr_accessor :mp_root
|
62
|
+
|
55
63
|
# Override the AbstractBlock sections?() check to enable the Table Of
|
56
64
|
# Contents. This extension may generate short pages that would normally have
|
57
65
|
# no need for a TOC. However, we override the Html5Converter outline() in
|
@@ -101,6 +109,12 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
101
109
|
|
102
110
|
attr_accessor :pages
|
103
111
|
|
112
|
+
# contains the entire outline of the top-level document, used
|
113
|
+
# as a guide-rail for creating TOC elements for documents we
|
114
|
+
# split off. Only expected to be set in the top-level converter
|
115
|
+
# (see AsciiDoctor::Document::mp_root)
|
116
|
+
attr_accessor :full_outline
|
117
|
+
|
104
118
|
def initialize(backend, opts = {})
|
105
119
|
@xml_mode = false
|
106
120
|
@void_element_slash = nil
|
@@ -118,8 +132,29 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
118
132
|
page << block
|
119
133
|
end
|
120
134
|
|
135
|
+
# ensures that the AsciiDoctor::Document::mp_root is correctly
|
136
|
+
# set on the document object. The variable could have already been
|
137
|
+
# set if we created the document ourselves
|
138
|
+
# (see ::MultipageHtml5Converter::convert_section), in which case it's
|
139
|
+
# not changed. If the documented is "nested", then we expect the parent
|
140
|
+
# document to already have it set. Otherwise, this is expected to be
|
141
|
+
# a top-level document, and we assign ourselves as its original converter.
|
142
|
+
def check_root(doc)
|
143
|
+
unless doc.mp_root
|
144
|
+
if doc.nested?
|
145
|
+
doc.mp_root = doc.parent_document.mp_root
|
146
|
+
else
|
147
|
+
doc.mp_root = self
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
121
152
|
# Process Document (either the original full document or a processed page)
|
122
153
|
def convert_document(node)
|
154
|
+
|
155
|
+
# make sure document has original converter reference
|
156
|
+
check_root(node)
|
157
|
+
|
123
158
|
if node.processed
|
124
159
|
# This node (an individual page) can now be handled by
|
125
160
|
# Html5Converter.
|
@@ -166,8 +201,16 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
166
201
|
# Generate navigation links for all pages
|
167
202
|
generate_nav_links(node)
|
168
203
|
|
169
|
-
# Create and save a skeleton document for generating the TOC lists
|
170
|
-
|
204
|
+
# Create and save a skeleton document for generating the TOC lists,
|
205
|
+
# but don't attempt to create outline for nested documents.
|
206
|
+
unless node.nested?
|
207
|
+
# if the original converter has the @full_outline set already, we are about
|
208
|
+
# to replace it. That's not supposed to happen, and probably means we encountered
|
209
|
+
# a document structure we aren't prepared for. Log an error and move on.
|
210
|
+
logger.error "Regenerating document outline, something wrong?" if node.mp_root.full_outline
|
211
|
+
node.mp_root.full_outline = new_outline_doc(node)
|
212
|
+
end
|
213
|
+
|
171
214
|
# Save the document catalog to use for each part/chapter page.
|
172
215
|
@catalog = node.catalog
|
173
216
|
|
@@ -179,7 +222,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
179
222
|
part = block
|
180
223
|
part.convert
|
181
224
|
text = %(<<#{part.id},#{part.captioned_title}>>)
|
182
|
-
if desc = block.attr('desc') then text << %( – #{desc}) end
|
225
|
+
if (desc = block.attr('desc')) then text << %( – #{desc}) end
|
183
226
|
parts_list << Asciidoctor::ListItem.new(parts_list, text)
|
184
227
|
end
|
185
228
|
end
|
@@ -197,6 +240,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
197
240
|
# Process Document in embeddable mode (either the original full document or a
|
198
241
|
# processed page)
|
199
242
|
def convert_embedded(node)
|
243
|
+
# make sure document has original converter reference
|
244
|
+
check_root(node)
|
200
245
|
if node.processed
|
201
246
|
# This node (an individual page) can now be handled by
|
202
247
|
# Html5Converter.
|
@@ -350,7 +395,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
350
395
|
end
|
351
396
|
|
352
397
|
# From node, create a skeleton document that will be used to generate the
|
353
|
-
# TOC. This is first used to create a full skeleton (
|
398
|
+
# TOC. This is first used to create a full skeleton (@full_outline) from the
|
354
399
|
# original document (for_page=nil). Then it is used for each individual page
|
355
400
|
# to create a second skeleton from the first. In this way, TOC entries are
|
356
401
|
# included that are not part of the current page, or excluded if not
|
@@ -392,10 +437,10 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
392
437
|
# outline.
|
393
438
|
def convert_outline(node, opts = {})
|
394
439
|
doc = node.document
|
395
|
-
# Find this node in the
|
396
|
-
page_node =
|
440
|
+
# Find this node in the @full_outline skeleton document
|
441
|
+
page_node = doc.mp_root.full_outline.find_by(id: node.id).first
|
397
442
|
# Create a skeleton document for this particular page
|
398
|
-
custom_outline_doc = new_outline_doc(
|
443
|
+
custom_outline_doc = new_outline_doc(doc.mp_root.full_outline, for_page: page_node)
|
399
444
|
opts[:page_id] = node.id
|
400
445
|
# Generate an extra TOC entry for the root page. Add additional styling if
|
401
446
|
# the current page is the root page.
|
@@ -455,6 +500,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
455
500
|
page.sectnum = node.parent.sectnum
|
456
501
|
end
|
457
502
|
|
503
|
+
page.mp_root = doc.mp_root
|
504
|
+
|
458
505
|
# Process node according to mplevel
|
459
506
|
if node.mplevel == :branch
|
460
507
|
# Retain any part intro blocks, delete others, and add a list
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-multipage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen T. Heisler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|