asciidoctor-multipage 0.0.4 → 0.0.9
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 +34 -19
- 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: b61bac9f5757d7dd1864896ce026ba9459f05a4b2860b8fcc04087b02f6d99e4
|
4
|
+
data.tar.gz: 80e39a0c29b8a125f4001cd290e3d2b8494b51b67f0a4e96f3a3951ffccde583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 921880fa69d16485028b378017b680ea7cab5f30376361da442cdf3f7c53d144e67d7a8af76dc0134bb0cff41a66b00242e82519878bf2a91c748ba98931adc3
|
7
|
+
data.tar.gz: 2430e67e5d8992737a9b77f7d0512853b4ae7a8771b44e57347cf9547930f91860acb70acb3acbd0161ff0dc3c1b69fb968f5c1d96b2785db699aca2129f0f9f
|
@@ -17,6 +17,7 @@ class Asciidoctor::AbstractNode
|
|
17
17
|
node_tree << current
|
18
18
|
current = current.parent
|
19
19
|
end
|
20
|
+
node_tree << current
|
20
21
|
if node_tree.include?(self) ||
|
21
22
|
node_tree.include?(self.parent)
|
22
23
|
return true
|
@@ -120,7 +121,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
120
121
|
# Process Document (either the original full document or a processed page)
|
121
122
|
def convert_document(node)
|
122
123
|
if node.processed
|
123
|
-
# This node can now be handled by
|
124
|
+
# This node (an individual page) can now be handled by
|
125
|
+
# Html5Converter.
|
124
126
|
super
|
125
127
|
else
|
126
128
|
# This node is the original full document which has not yet been
|
@@ -146,6 +148,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
146
148
|
# Set multipage chunk types
|
147
149
|
set_multipage_attrs(node)
|
148
150
|
|
151
|
+
# FIXME: This can result in a duplicate ID without a warning.
|
149
152
|
# Set the "id" attribute for the Document, using the "docname", which is
|
150
153
|
# based on the file name. Then register the document ID using the
|
151
154
|
# document title. This allows cross-references to refer to (1) the
|
@@ -195,12 +198,13 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
195
198
|
# processed page)
|
196
199
|
def convert_embedded(node)
|
197
200
|
if node.processed
|
198
|
-
# This node can now be handled by
|
201
|
+
# This node (an individual page) can now be handled by
|
202
|
+
# Html5Converter.
|
199
203
|
super
|
200
204
|
else
|
201
205
|
# This node is the original full document which has not yet been
|
202
|
-
# processed; it can be handled by
|
203
|
-
|
206
|
+
# processed; it can be handled by convert_document().
|
207
|
+
convert_document(node)
|
204
208
|
end
|
205
209
|
end
|
206
210
|
|
@@ -216,7 +220,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
216
220
|
previous_page = pages[page_index-1]
|
217
221
|
parent_page = page.parent
|
218
222
|
home_page = doc
|
219
|
-
# NOTE
|
223
|
+
# NOTE: There are some non-breaking spaces (U+00A0) below, in
|
224
|
+
# the "links <<" lines and "links.join" line.
|
220
225
|
if previous_page != parent_page
|
221
226
|
links << %(← Previous: <<#{previous_page.id}>>)
|
222
227
|
end
|
@@ -237,12 +242,12 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
237
242
|
end
|
238
243
|
|
239
244
|
# Generate the actual HTML outline for the TOC. This method is analogous to
|
240
|
-
# Html5Converter
|
245
|
+
# Html5Converter convert_outline().
|
241
246
|
def generate_outline(node, opts = {})
|
242
|
-
#
|
247
|
+
# Do the same as Html5Converter convert_outline() here
|
243
248
|
return unless node.sections?
|
244
|
-
sectnumlevels = opts[:sectnumlevels] || (node.document.
|
245
|
-
toclevels = opts[:toclevels] || (node.document.
|
249
|
+
sectnumlevels = opts[:sectnumlevels] || (node.document.attributes['sectnumlevels'] || 3).to_i
|
250
|
+
toclevels = opts[:toclevels] || (node.document.attributes['toclevels'] || 2).to_i
|
246
251
|
sections = node.sections
|
247
252
|
result = [%(<ul class="sectlevel#{sections[0].level}">)]
|
248
253
|
sections.each do |section|
|
@@ -250,7 +255,17 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
250
255
|
if section.caption
|
251
256
|
stitle = section.captioned_title
|
252
257
|
elsif section.numbered && slevel <= sectnumlevels
|
253
|
-
|
258
|
+
if slevel < 2 && node.document.doctype == 'book'
|
259
|
+
if section.sectname == 'chapter'
|
260
|
+
stitle = %(#{(signifier = node.document.attributes['chapter-signifier']) ? "#{signifier} " : ''}#{section.sectnum} #{section.title})
|
261
|
+
elsif section.sectname == 'part'
|
262
|
+
stitle = %(#{(signifier = node.document.attributes['part-signifier']) ? "#{signifier} " : ''}#{section.sectnum nil, ':'} #{section.title})
|
263
|
+
else
|
264
|
+
stitle = %(#{section.sectnum} #{section.title})
|
265
|
+
end
|
266
|
+
else
|
267
|
+
stitle = %(#{section.sectnum} #{section.title})
|
268
|
+
end
|
254
269
|
else
|
255
270
|
stitle = section.title
|
256
271
|
end
|
@@ -277,12 +292,12 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
277
292
|
end
|
278
293
|
result << %(<li><a href="#{link}">#{stitle}</a>)
|
279
294
|
|
280
|
-
# Finish in a manner similar to Html5Converter
|
295
|
+
# Finish in a manner similar to Html5Converter convert_outline()
|
281
296
|
if slevel < toclevels &&
|
282
297
|
(child_toc_level = generate_outline section,
|
283
|
-
|
284
|
-
|
285
|
-
|
298
|
+
toclevels: toclevels,
|
299
|
+
secnumlevels: sectnumlevels,
|
300
|
+
page_id: opts[:page_id])
|
286
301
|
result << child_toc_level
|
287
302
|
end
|
288
303
|
result << '</li>'
|
@@ -345,8 +360,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
345
360
|
new_document = Document.new([])
|
346
361
|
new_document.mplevel = node.mplevel
|
347
362
|
new_document.id = node.id
|
348
|
-
new_document.
|
349
|
-
new_document.set_attr('toclevels', node.attr(:toclevels))
|
363
|
+
new_document.update_attributes(node.attributes)
|
350
364
|
new_parent = new_document
|
351
365
|
node.sections.each do |section|
|
352
366
|
new_outline_doc(section, new_parent: new_parent,
|
@@ -361,7 +375,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
361
375
|
numbered = node.numbered)
|
362
376
|
new_section.id = node.id
|
363
377
|
new_section.caption = node.caption
|
364
|
-
new_section.title = node.title
|
378
|
+
new_section.title = node.instance_variable_get(:@title)
|
365
379
|
new_section.mplevel = node.mplevel
|
366
380
|
new_parent << new_section
|
367
381
|
new_parent.sections.last.numeral = node.numeral
|
@@ -374,7 +388,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
374
388
|
return new_document
|
375
389
|
end
|
376
390
|
|
377
|
-
# Override Html5Converter
|
391
|
+
# Override Html5Converter convert_outline() to return a custom TOC
|
392
|
+
# outline.
|
378
393
|
def convert_outline(node, opts = {})
|
379
394
|
doc = node.document
|
380
395
|
# Find this node in the @@full_outline skeleton document
|
@@ -495,7 +510,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
495
510
|
%(section cannot be less than the parent section value)
|
496
511
|
section.set_attr('multipage-level', nil)
|
497
512
|
end
|
498
|
-
#
|
513
|
+
# Propagate custom multipage-level value to child node
|
499
514
|
if !section.attr?('multipage-level', nil, false) &&
|
500
515
|
node.attr('multipage-level') != doc.attr('multipage-level')
|
501
516
|
section.set_attr('multipage-level', node.attr('multipage-level'))
|
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.9
|
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-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|