asciidoctor-multipage 0.0.13 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/asciidoctor-multipage +28 -0
- data/lib/asciidoctor-multipage/version.rb +3 -0
- data/lib/asciidoctor-multipage.rb +29 -8
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 586429962868adbdfa2f14a85ea6438b62b8d33708258e76c33e2ce22b408c05
|
4
|
+
data.tar.gz: '09a2a625effa351a139dca939db85e822d1b8ddb5f5b52c79260202c7a6e3137'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df280fb5bf8a4b23084e25ae5ca4217b06d05b225a05e5f267ccca243f0e762612712e50bbadc3690f98d65159c614c6ffb4bb260f2f91ec203ffe486c758c2
|
7
|
+
data.tar.gz: e2f1e882b5a9c2ef2cb8c68805dc64815522003e96acbae4a2d40552fc6f1ab9a3725947420a529af2fa5ac7ebd0bd7177f3ef6263a7b3e13e8636fe07f7619a
|
@@ -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
|
@@ -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
|
@@ -157,6 +158,11 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
157
158
|
# This node is the original full document which has not yet been
|
158
159
|
# processed; this is the entry point for the extension.
|
159
160
|
|
161
|
+
# Save a reference to the root document in the converter
|
162
|
+
# instance. This will be used to set the @requires_stylesheet
|
163
|
+
# variable on the root document in the write method.
|
164
|
+
@root_doc = node
|
165
|
+
|
160
166
|
# Turn off extensions to avoid running them twice.
|
161
167
|
# FIXME: DocinfoProcessor, InlineMacroProcessor, and Postprocessor
|
162
168
|
# extensions should be retained. Is this possible with the API?
|
@@ -262,14 +268,14 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
262
268
|
# NOTE: There are some non-breaking spaces (U+00A0) below, in
|
263
269
|
# the "links <<" lines and "links.join" line.
|
264
270
|
if previous_page != parent_page
|
265
|
-
links << %(← #{doc.attr('multipage-nav-previous-label') || "Previous"}: <<#{previous_page.id}>>)
|
271
|
+
links << %(← #{doc.attr('multipage-nav-previous-label') || "Previous"}: <<#{previous_page.id},#{previous_page.captioned_title}>>)
|
266
272
|
end
|
267
|
-
links << %(↑ #{doc.attr('multipage-nav-up-label') || "Up"}: <<#{parent_page.id}>>)
|
268
|
-
links << %(⌂ #{doc.attr('multipage-nav-home-label') || "Home"}: <<#{home_page.id}>>) if home_page != parent_page
|
273
|
+
links << %(↑ #{doc.attr('multipage-nav-up-label') || "Up"}: <<#{parent_page.id},#{parent_page.captioned_title}>>)
|
274
|
+
links << %(⌂ #{doc.attr('multipage-nav-home-label') || "Home"}: <<#{home_page.id},#{home_page.captioned_title}>>) if home_page != parent_page
|
269
275
|
end
|
270
276
|
if page_index != pages.length-1
|
271
277
|
next_page = pages[page_index+1]
|
272
|
-
links << %(#{doc.attr('multipage-nav-next-label') || "Next"}: <<#{next_page.id}>> →)
|
278
|
+
links << %(#{doc.attr('multipage-nav-next-label') || "Next"}: <<#{next_page.id},#{next_page.captioned_title}>> →)
|
273
279
|
end
|
274
280
|
block = Asciidoctor::Block.new(parent = doc,
|
275
281
|
context = :paragraph,
|
@@ -356,9 +362,17 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
356
362
|
else
|
357
363
|
attrs = node.role ? %( class="#{node.role}") : ''
|
358
364
|
unless (text = node.text)
|
359
|
-
refid = node.attributes['refid']
|
360
|
-
|
361
|
-
|
365
|
+
if AbstractNode === (ref = (@refs ||= node.document.catalog[:refs])[refid = node.attributes['refid']] || (refid.nil_or_empty? ? (top = get_root_document node) : nil))
|
366
|
+
if (@resolving_xref ||= (outer = true)) && outer
|
367
|
+
if (text = ref.xreftext node.attr 'xrefstyle', nil, true)
|
368
|
+
text = text.gsub DropAnchorRx, '' if text.include? '<a'
|
369
|
+
else
|
370
|
+
text = top ? '[^top]' : %([#{refid}])
|
371
|
+
end
|
372
|
+
@resolving_xref = nil
|
373
|
+
else
|
374
|
+
text = top ? '[^top]' : %([#{refid}])
|
375
|
+
end
|
362
376
|
else
|
363
377
|
text = %([#{refid}])
|
364
378
|
end
|
@@ -396,7 +410,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
396
410
|
# applicable for the current page.
|
397
411
|
def new_outline_doc(node, new_parent:nil, for_page:nil)
|
398
412
|
if node.class == Document
|
399
|
-
new_document = Document.new([])
|
413
|
+
new_document = Document.new([], {:doctype => node.doctype})
|
400
414
|
new_document.mplevel = node.mplevel
|
401
415
|
new_document.id = node.id
|
402
416
|
new_document.update_attributes(node.attributes)
|
@@ -413,6 +427,7 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
413
427
|
level = node.level,
|
414
428
|
numbered = node.numbered)
|
415
429
|
new_section.id = node.id
|
430
|
+
new_section.sectname = node.sectname
|
416
431
|
new_section.caption = node.caption
|
417
432
|
new_section.title = node.instance_variable_get(:@title)
|
418
433
|
new_section.mplevel = node.mplevel
|
@@ -584,6 +599,12 @@ class MultipageHtml5Converter < Asciidoctor::Converter::Html5Converter
|
|
584
599
|
::File.open(outfile, 'w') do |f|
|
585
600
|
f.write(doc.convert)
|
586
601
|
end
|
602
|
+
if (doc.syntax_highlighter and
|
603
|
+
doc.syntax_highlighter.write_stylesheet? doc)
|
604
|
+
root_doc = doc.mp_root.instance_variable_get(:@root_doc)
|
605
|
+
root_doc.syntax_highlighter.instance_variable_set(
|
606
|
+
:@requires_stylesheet, true)
|
607
|
+
end
|
587
608
|
end
|
588
609
|
end
|
589
610
|
end
|
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.16
|
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:
|
11
|
+
date: 2022-06-09 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
|