asciidoctor-multipage 0.0.1 → 0.0.6

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 +34 -33
  3. metadata +25 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b64a5fbb964951f440f2fa2c0d49cb1df7ace58be958a0e1f4ce280dca9e4591
4
- data.tar.gz: 51c273c008afa11caad90d1b808e65919e2764f092891cd6d149934dcce322ae
3
+ metadata.gz: 1536862b822c7ec9f66f5f53f3b6a9bad7f6983ee5ff1f5c742e718a3cb66a76
4
+ data.tar.gz: f612e848167857d28c7c42f4684355e7082a45379038a5265e472797dae99b11
5
5
  SHA512:
6
- metadata.gz: fc96577284cc71802f971196a99536f2ba3fc87dc97dad4833f40722cb8844819ca5b9132e2f1e63adf16701a9a987d1a14e89c76944b264ff8438f63775ec3e
7
- data.tar.gz: dfee8f462b3cb3d81c9384f04e96fbdcb7c9c621ebdda69152d8dabd8fe55597d34315794aa0065d4d30edc07cf71e02abf3b5433191249e74e9c512ab6f697c
6
+ metadata.gz: c652de15f77d2c32e7574b7edf9351e49623170aada76a8c577b16ade65db6294660fb07dbebe27095b5500167c804a4a3ac70d82383d3d56a84ca9d4c1aeed8
7
+ data.tar.gz: 8db9f9e909ae211891384483624affd6f7c78ada48d78c27b7bb1667c5da4300ab3bc257c233912c1495505d412a7402275579f569bd3524e6f7011f1debb4f2
@@ -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
@@ -77,16 +78,16 @@ class Asciidoctor::Section
77
78
  def sectnum(delimiter = '.', append = nil)
78
79
  append ||= (append == false ? '' : delimiter)
79
80
  if @level == 1
80
- %(#{@number}#{append})
81
+ %(#{@numeral}#{append})
81
82
  elsif @level > 1
82
83
  if @parent.class == Asciidoctor::Section ||
83
84
  (@mplevel && @parent.class == Asciidoctor::Document)
84
- %(#{@parent.sectnum(delimiter)}#{@number}#{append})
85
+ %(#{@parent.sectnum(delimiter)}#{@numeral}#{append})
85
86
  else
86
- %(#{@number}#{append})
87
+ %(#{@numeral}#{append})
87
88
  end
88
89
  else # @level == 0
89
- %(#{Asciidoctor::Helpers.int_to_roman @number}#{append})
90
+ %(#{Asciidoctor::Helpers.int_to_roman @numeral}#{append})
90
91
  end
91
92
  end
92
93
  end
@@ -117,15 +118,11 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
117
118
  page << block
118
119
  end
119
120
 
120
- def convert(node, transform = nil, opts = {})
121
- transform ||= node.node_name
122
- opts.empty? ? (send transform, node) : (send transform, node, opts)
123
- end
124
-
125
121
  # Process Document (either the original full document or a processed page)
126
- def document(node)
122
+ def convert_document(node)
127
123
  if node.processed
128
- # This node can now be handled by Html5Converter.
124
+ # This node (an individual page) can now be handled by
125
+ # Html5Converter.
129
126
  super
130
127
  else
131
128
  # This node is the original full document which has not yet been
@@ -151,6 +148,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
151
148
  # Set multipage chunk types
152
149
  set_multipage_attrs(node)
153
150
 
151
+ # FIXME: This can result in a duplicate ID without a warning.
154
152
  # Set the "id" attribute for the Document, using the "docname", which is
155
153
  # based on the file name. Then register the document ID using the
156
154
  # document title. This allows cross-references to refer to (1) the
@@ -198,14 +196,15 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
198
196
 
199
197
  # Process Document in embeddable mode (either the original full document or a
200
198
  # processed page)
201
- def embedded(node)
199
+ def convert_embedded(node)
202
200
  if node.processed
203
- # This node can now be handled by Html5Converter.
201
+ # This node (an individual page) can now be handled by
202
+ # Html5Converter.
204
203
  super
205
204
  else
206
205
  # This node is the original full document which has not yet been
207
- # processed; it can be handled by document().
208
- document(node)
206
+ # processed; it can be handled by convert_document().
207
+ convert_document(node)
209
208
  end
210
209
  end
211
210
 
@@ -221,7 +220,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
221
220
  previous_page = pages[page_index-1]
222
221
  parent_page = page.parent
223
222
  home_page = doc
224
- # 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.
225
225
  if previous_page != parent_page
226
226
  links << %(← Previous: <<#{previous_page.id}>>)
227
227
  end
@@ -242,12 +242,11 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
242
242
  end
243
243
 
244
244
  # Generate the actual HTML outline for the TOC. This method is analogous to
245
- # Html5Converter outline().
245
+ # Html5Converter convert_outline().
246
246
  def generate_outline(node, opts = {})
247
- # This is the same as Html5Converter outline()
248
247
  return unless node.sections?
249
- sectnumlevels = opts[:sectnumlevels] || (node.document.attr 'sectnumlevels', 3).to_i
250
- toclevels = opts[:toclevels] || (node.document.attr 'toclevels', 2).to_i
248
+ sectnumlevels = opts[:sectnumlevels] || (node.document.attributes['sectnumlevels'] || 3).to_i
249
+ toclevels = opts[:toclevels] || (node.document.attributes['toclevels'] || 2).to_i
251
250
  sections = node.sections
252
251
  result = [%(<ul class="sectlevel#{sections[0].level}">)]
253
252
  sections.each do |section|
@@ -282,12 +281,12 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
282
281
  end
283
282
  result << %(<li><a href="#{link}">#{stitle}</a>)
284
283
 
285
- # Finish in a manner similar to Html5Converter outline()
284
+ # Finish in a manner similar to Html5Converter convert_outline()
286
285
  if slevel < toclevels &&
287
286
  (child_toc_level = generate_outline section,
288
- :toclevels => toclevels,
289
- :secnumlevels => sectnumlevels,
290
- :page_id => opts[:page_id])
287
+ toclevels: toclevels,
288
+ secnumlevels: sectnumlevels,
289
+ page_id: opts[:page_id])
291
290
  result << child_toc_level
292
291
  end
293
292
  result << '</li>'
@@ -298,7 +297,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
298
297
 
299
298
  # Include chapter pages in cross-reference links. This method overrides for
300
299
  # the :xref node type only.
301
- def inline_anchor(node)
300
+ def convert_inline_anchor(node)
302
301
  if node.type == :xref
303
302
  # This is the same as super...
304
303
  if (path = node.attributes['path'])
@@ -369,7 +368,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
369
368
  new_section.title = node.title
370
369
  new_section.mplevel = node.mplevel
371
370
  new_parent << new_section
372
- new_parent.sections.last.number = node.number
371
+ new_parent.sections.last.numeral = node.numeral
373
372
  new_parent = new_section
374
373
  node.sections.each do |section|
375
374
  new_outline_doc(section, new_parent: new_parent,
@@ -379,8 +378,9 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
379
378
  return new_document
380
379
  end
381
380
 
382
- # Override Html5Converter outline() to return a custom TOC outline
383
- def outline(node, opts = {})
381
+ # Override Html5Converter convert_outline() to return a custom TOC
382
+ # outline.
383
+ def convert_outline(node, opts = {})
384
384
  doc = node.document
385
385
  # Find this node in the @@full_outline skeleton document
386
386
  page_node = @@full_outline.find_by(id: node.id).first
@@ -424,7 +424,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
424
424
 
425
425
  # Process a Section. Each Section will either be split off into its own page
426
426
  # or processed as normal by Html5Converter.
427
- def section(node)
427
+ def convert_section(node)
428
428
  doc = node.document
429
429
  if doc.processed
430
430
  # This node can now be handled by Html5Converter.
@@ -491,7 +491,8 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
491
491
  doc = node.document
492
492
  node.mplevel = :root if node.class == Asciidoctor::Document
493
493
  node.sections.each do |section|
494
- # Check custom multipage-level attribute on section
494
+ # Check custom multipage-level attribute on section; warn and
495
+ # discard if invalid
495
496
  if section.attr?('multipage-level', nil, false) &&
496
497
  section.attr('multipage-level').to_i <
497
498
  node.attr('multipage-level').to_i
@@ -499,15 +500,15 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
499
500
  %(section cannot be less than the parent section value)
500
501
  section.set_attr('multipage-level', nil)
501
502
  end
502
- # Propogate custom multipage-level value to child node
503
+ # Propagate custom multipage-level value to child node
503
504
  if !section.attr?('multipage-level', nil, false) &&
504
505
  node.attr('multipage-level') != doc.attr('multipage-level')
505
506
  section.set_attr('multipage-level', node.attr('multipage-level'))
506
507
  end
507
508
  # Set section type
508
- if section.level < section.attr('multipage-level').to_i
509
+ if section.level < section.attr('multipage-level', nil, true).to_i
509
510
  section.mplevel = :branch
510
- elsif section.level == section.attr('multipage-level').to_i
511
+ elsif section.level == section.attr('multipage-level', nil, true).to_i
511
512
  section.mplevel = :leaf
512
513
  else
513
514
  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.1
4
+ version: 0.0.6
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-19 00:00:00.000000000 Z
11
+ date: 2021-02-27 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,30 +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: 1.5.7.1
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
75
+ version: 2.0.11
76
+ - - "<"
67
77
  - !ruby/object:Gem::Version
68
- version: 1.5.7.1
69
- - !ruby/object:Gem::Dependency
70
- name: thread_safe
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">"
74
- - !ruby/object:Gem::Version
75
- version: '0'
78
+ version: '2.1'
76
79
  type: :runtime
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
- - - ">"
83
+ - - ">="
81
84
  - !ruby/object:Gem::Version
82
- version: '0'
85
+ version: 2.0.11
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.1'
83
89
  description: An Asciidoctor extension that generates HTML output using multiple pages
84
90
  email:
85
91
  - writer@owenh.net