asciidoctor-multipage 0.0.2 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asciidoctor-multipage.rb +37 -20
  3. metadata +26 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28bc704663d2731292d6cf387f3fd9875e377159767800c252c5a818ebc5145c
4
- data.tar.gz: dc8c206b11f8f3e16532f627180927519be4814c461e9fe2317c7e18e69d5e4a
3
+ metadata.gz: d30d8cf7b55d2e9eac4264bcaf1eb908a2e82b22de1446a4003a889c482a8e56
4
+ data.tar.gz: 62f1b710405e4fb9fd680720a4d670069761181a369b541c65a7bda50da6733f
5
5
  SHA512:
6
- metadata.gz: f498a6dfe3e7c36f96fb72b3ec156395f11d018723c90d453f250af503da73035a4e3671919fbf0bf64d52399d7fc17a8416c5f5ea9a0736a7dce0b72e4842d5
7
- data.tar.gz: 22abae6135ca5fe71de43e8ef7c4f2a2dcd98861bb2bb61ddcb24e0bcb350fa0ec982a200eec79997698ecc100c4cf0a080cbebb61651ac0038dffbbab7e5536
6
+ metadata.gz: ec8fc0473fe24f5e10112b4aac65f28fa5a23491e8edabfa8581b54f926201dbeefb3991ec0c1bd1d8fa0f62a1806dd95b610ed0497248c27e53db26e1894f3a
7
+ data.tar.gz: c50107b5d4a5b5d1349b99b72da9458ddb011469146f9a5a36516fda2fc6f3667881afe942fd6465bebebaf174c883971b305fdcfb67b3424878e590ecd1e928
@@ -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 Html5Converter.
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 Html5Converter.
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 document().
203
- document(node)
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, there are some non-breaking spaces (U+00A0) below.
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 outline().
245
+ # Html5Converter convert_outline().
241
246
  def generate_outline(node, opts = {})
242
- # This is the same as Html5Converter outline()
247
+ # Do the same as Html5Converter convert_outline() here
243
248
  return unless node.sections?
244
- sectnumlevels = opts[:sectnumlevels] || (node.document.attr 'sectnumlevels', 3).to_i
245
- toclevels = opts[:toclevels] || (node.document.attr 'toclevels', 2).to_i
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
- stitle = %(#{section.sectnum} #{section.title})
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 outline()
295
+ # Finish in a manner similar to Html5Converter convert_outline()
281
296
  if slevel < toclevels &&
282
297
  (child_toc_level = generate_outline section,
283
- :toclevels => toclevels,
284
- :secnumlevels => sectnumlevels,
285
- :page_id => opts[:page_id])
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>'
@@ -361,7 +376,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
361
376
  numbered = node.numbered)
362
377
  new_section.id = node.id
363
378
  new_section.caption = node.caption
364
- new_section.title = node.title
379
+ new_section.title = node.instance_variable_get(:@title)
365
380
  new_section.mplevel = node.mplevel
366
381
  new_parent << new_section
367
382
  new_parent.sections.last.numeral = node.numeral
@@ -374,7 +389,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
374
389
  return new_document
375
390
  end
376
391
 
377
- # Override Html5Converter outline() to return a custom TOC outline
392
+ # Override Html5Converter convert_outline() to return a custom TOC
393
+ # outline.
378
394
  def convert_outline(node, opts = {})
379
395
  doc = node.document
380
396
  # Find this node in the @@full_outline skeleton document
@@ -486,7 +502,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
486
502
  doc = node.document
487
503
  node.mplevel = :root if node.class == Asciidoctor::Document
488
504
  node.sections.each do |section|
489
- # Check custom multipage-level attribute on section
505
+ # Check custom multipage-level attribute on section; warn and
506
+ # discard if invalid
490
507
  if section.attr?('multipage-level', nil, false) &&
491
508
  section.attr('multipage-level').to_i <
492
509
  node.attr('multipage-level').to_i
@@ -494,15 +511,15 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
494
511
  %(section cannot be less than the parent section value)
495
512
  section.set_attr('multipage-level', nil)
496
513
  end
497
- # Propogate custom multipage-level value to child node
514
+ # Propagate custom multipage-level value to child node
498
515
  if !section.attr?('multipage-level', nil, false) &&
499
516
  node.attr('multipage-level') != doc.attr('multipage-level')
500
517
  section.set_attr('multipage-level', node.attr('multipage-level'))
501
518
  end
502
519
  # Set section type
503
- if section.level < section.attr('multipage-level').to_i
520
+ if section.level < section.attr('multipage-level', nil, true).to_i
504
521
  section.mplevel = :branch
505
- elsif section.level == section.attr('multipage-level').to_i
522
+ elsif section.level == section.attr('multipage-level', nil, true).to_i
506
523
  section.mplevel = :leaf
507
524
  else
508
525
  section.mplevel = :content
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-multipage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
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-01-25 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: appraisal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +70,22 @@ dependencies:
56
70
  name: asciidoctor
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 2.0.12
75
+ version: 2.0.11
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '2.1'
62
79
  type: :runtime
63
80
  prerelease: false
64
81
  version_requirements: !ruby/object:Gem::Requirement
65
82
  requirements:
66
- - - '='
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.0.11
86
+ - - "<"
67
87
  - !ruby/object:Gem::Version
68
- version: 2.0.12
88
+ version: '2.1'
69
89
  description: An Asciidoctor extension that generates HTML output using multiple pages
70
90
  email:
71
91
  - writer@owenh.net