asciidoctor-multipage 0.0.11 → 0.0.15

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: 37d22229b52f7ecc747f4c4f80fcfe6b3d097d49a0ba7c1e375de6f72280c950
4
- data.tar.gz: 901b657b48543dc3466154c0ba5d00d82d639f1b72a747eae5bb5821cd287cb1
3
+ metadata.gz: 92ae4009df03264cc6ecf2dc5826234151da1125abe9e7cbb01cba9a6f53d08e
4
+ data.tar.gz: 855ad21500928a3d166aa360fec6fe2d332c3b4e3efdbddb5f0402c32c8ee4e2
5
5
  SHA512:
6
- metadata.gz: 52c37d84631c4d9bbdd02a272fd61dd5c5cf26b6a60f2e203378ca0dc669edd731284b13bf5d9fdfae601209ae38ddf9647ad8e7091e7a46b6810cb5beb7e6a6
7
- data.tar.gz: 7bf7e7e32dac50d8619ee1ac52e9bc501c2d1cb5585e391f7501ed2b6e7bd1ab67b265c7e7d1a4e2df5cc95e0077fcdd768faaf76d1b6e886894140b85669bec
6
+ metadata.gz: 307a0f3299bf032d2e043d0593b7b9ecba1de9958646495986a6c6462e8c47e49a1a5eadff5e3f2160a2bd8d7cd029b4d711cbc183c42dccedd55e238bcc1495
7
+ data.tar.gz: 22d1d18fa6e488813cf3836a1d76d085cf216a7f3bc2c5d55aeef8ad9f2d3f8c007f2c4d0896351bbf3d7ba8a8122e40fc7922c15734d1a0dc32a3642b708ea1
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This executable is based on `bin/asciidoctor-pdf` from the
4
+ # asciidoctor/asciidoctor-pdf project. Please consult that file for
5
+ # potential updates.
6
+
7
+ require 'asciidoctor-multipage'
8
+ require 'asciidoctor-multipage/version'
9
+ require 'asciidoctor/cli'
10
+
11
+ options = Asciidoctor::Cli::Options.new backend: 'multipage_html5'
12
+
13
+ # FIXME (from asciidoctor-pdf) provide an API in Asciidoctor for sub-components to print version information
14
+ unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
15
+ $stdout.write %(Asciidoctor Multipage #{AsciidoctorMultipage::VERSION} using )
16
+ options.print_version
17
+ exit 0
18
+ end
19
+
20
+ # FIXME (from bespoke) This is a really bizarre API. Please make me simpler.
21
+ if Integer === (result = options.parse! ARGV)
22
+ exit result
23
+ else
24
+ invoker = Asciidoctor::Cli::Invoker.new options
25
+ GC.start
26
+ invoker.invoke!
27
+ exit invoker.code
28
+ end
@@ -0,0 +1,3 @@
1
+ module AsciidoctorMultipage
2
+ VERSION = "0.0.15"
3
+ end
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
+ require 'asciidoctor'
3
4
  require 'asciidoctor/converter/html5'
4
5
 
5
6
  class Asciidoctor::AbstractBlock
@@ -85,17 +86,11 @@ class Asciidoctor::Section
85
86
  # Sections. The sectnum is saved in section() below.
86
87
  def sectnum(delimiter = '.', append = nil)
87
88
  append ||= (append == false ? '' : delimiter)
88
- if @level == 1
89
- %(#{@numeral}#{append})
90
- elsif @level > 1
91
- if @parent.class == Asciidoctor::Section ||
92
- (@mplevel && @parent.class == Asciidoctor::Document)
89
+ if @level > 1 and @parent.class == Asciidoctor::Section ||
90
+ (@mplevel && @parent.class == Asciidoctor::Document)
93
91
  %(#{@parent.sectnum(delimiter)}#{@numeral}#{append})
94
- else
95
- %(#{@numeral}#{append})
96
- end
97
- else # @level == 0
98
- %(#{Asciidoctor::Helpers.int_to_roman @numeral}#{append})
92
+ else
93
+ %(#{@numeral}#{append})
99
94
  end
100
95
  end
101
96
  end
@@ -268,14 +263,14 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
268
263
  # NOTE: There are some non-breaking spaces (U+00A0) below, in
269
264
  # the "links <<" lines and "links.join" line.
270
265
  if previous_page != parent_page
271
- links << %(← Previous: <<#{previous_page.id}>>)
266
+ links << %(← #{doc.attr('multipage-nav-previous-label') || "Previous"}: <<#{previous_page.id},#{previous_page.captioned_title}>>)
272
267
  end
273
- links << %(↑ Up: <<#{parent_page.id}>>)
274
- links << %(⌂ Home: <<#{home_page.id}>>) if home_page != parent_page
268
+ links << %(↑ #{doc.attr('multipage-nav-up-label') || "Up"}: <<#{parent_page.id},#{parent_page.captioned_title}>>)
269
+ links << %(⌂ #{doc.attr('multipage-nav-home-label') || "Home"}: <<#{home_page.id},#{home_page.captioned_title}>>) if home_page != parent_page
275
270
  end
276
271
  if page_index != pages.length-1
277
272
  next_page = pages[page_index+1]
278
- links << %(Next: <<#{next_page.id}>> →)
273
+ links << %(#{doc.attr('multipage-nav-next-label') || "Next"}: <<#{next_page.id},#{next_page.captioned_title}>> →)
279
274
  end
280
275
  block = Asciidoctor::Block.new(parent = doc,
281
276
  context = :paragraph,
@@ -362,9 +357,17 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
362
357
  else
363
358
  attrs = node.role ? %( class="#{node.role}") : ''
364
359
  unless (text = node.text)
365
- refid = node.attributes['refid']
366
- if AbstractNode === (ref = (@refs ||= node.document.catalog[:refs])[refid])
367
- text = (ref.xreftext node.attr('xrefstyle')) || %([#{refid}])
360
+ if AbstractNode === (ref = (@refs ||= node.document.catalog[:refs])[refid = node.attributes['refid']] || (refid.nil_or_empty? ? (top = get_root_document node) : nil))
361
+ if (@resolving_xref ||= (outer = true)) && outer
362
+ if (text = ref.xreftext node.attr 'xrefstyle', nil, true)
363
+ text = text.gsub DropAnchorRx, '' if text.include? '<a'
364
+ else
365
+ text = top ? '[^top]' : %([#{refid}])
366
+ end
367
+ @resolving_xref = nil
368
+ else
369
+ text = top ? '[^top]' : %([#{refid}])
370
+ end
368
371
  else
369
372
  text = %([#{refid}])
370
373
  end
@@ -402,7 +405,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
402
405
  # applicable for the current page.
403
406
  def new_outline_doc(node, new_parent:nil, for_page:nil)
404
407
  if node.class == Document
405
- new_document = Document.new([])
408
+ new_document = Document.new([], {:doctype => node.doctype})
406
409
  new_document.mplevel = node.mplevel
407
410
  new_document.id = node.id
408
411
  new_document.update_attributes(node.attributes)
@@ -419,6 +422,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
419
422
  level = node.level,
420
423
  numbered = node.numbered)
421
424
  new_section.id = node.id
425
+ new_section.sectname = node.sectname
422
426
  new_section.caption = node.caption
423
427
  new_section.title = node.instance_variable_get(:@title)
424
428
  new_section.mplevel = node.mplevel
@@ -584,7 +588,6 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
584
588
  # Write remaining part/chapter pages
585
589
  outdir = ::File.dirname(target)
586
590
  ext = ::File.extname(target)
587
- target_name = ::File.basename(target, ext)
588
591
  @pages.each do |doc|
589
592
  chapter_target = doc.id + ext
590
593
  outfile = ::File.join(outdir, chapter_target)
@@ -600,6 +603,10 @@ class MultipageHtml5CSS < Asciidoctor::Extensions::DocinfoProcessor
600
603
  at_location :head
601
604
 
602
605
  def process doc
606
+ # Disable this entirely if the multipage-disable-css attribute is set
607
+ if doc.attr('multipage-disable-css')
608
+ return
609
+ end
603
610
  css = []
604
611
  # Style Table Of Contents entry for current page
605
612
  css << %(.toc-current{font-weight: bold;})
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.11
4
+ version: 0.0.15
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-07-01 00:00:00.000000000 Z
11
+ date: 2021-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -89,11 +89,14 @@ dependencies:
89
89
  description: An Asciidoctor extension that generates HTML output using multiple pages
90
90
  email:
91
91
  - writer@owenh.net
92
- executables: []
92
+ executables:
93
+ - asciidoctor-multipage
93
94
  extensions: []
94
95
  extra_rdoc_files: []
95
96
  files:
97
+ - bin/asciidoctor-multipage
96
98
  - lib/asciidoctor-multipage.rb
99
+ - lib/asciidoctor-multipage/version.rb
97
100
  homepage: https://github.com/owenh000/asciidoctor-multipage
98
101
  licenses:
99
102
  - MIT
@@ -116,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  - !ruby/object:Gem::Version
117
120
  version: '0'
118
121
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.7.6.2
122
+ rubygems_version: 3.2.5
121
123
  signing_key:
122
124
  specification_version: 4
123
125
  summary: Asciidoctor multipage HTML output extension