asciidoctor-epub3 1.5.0.alpha.9 → 1.5.0.alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -4
- data/CHANGELOG.adoc +13 -0
- data/Gemfile +11 -8
- data/README.adoc +8 -6
- data/Rakefile +4 -80
- data/asciidoctor-epub3.gemspec +9 -5
- data/bin/adb-push-ebook +4 -3
- data/bin/asciidoctor-epub3 +4 -3
- data/lib/asciidoctor-epub3.rb +2 -0
- data/lib/asciidoctor-epub3/converter.rb +748 -760
- data/lib/asciidoctor-epub3/core_ext/string.rb +2 -0
- data/lib/asciidoctor-epub3/font_icon_map.rb +376 -374
- data/lib/asciidoctor-epub3/packager.rb +507 -512
- data/lib/asciidoctor-epub3/spine_item_processor.rb +77 -75
- data/lib/asciidoctor-epub3/version.rb +5 -3
- metadata +56 -14
@@ -1,88 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Asciidoctor
|
2
|
-
module Epub3
|
3
|
-
class SpineItemProcessor < Extensions::IncludeProcessor
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Epub3
|
5
|
+
class SpineItemProcessor < Extensions::IncludeProcessor
|
6
|
+
def initialize document
|
7
|
+
@document = document
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
# NOTE only fires for includes in spine document if registered directly on the instance of the spine document
|
11
|
+
def process doc, reader, target, _attributes
|
12
|
+
spine_doc = doc
|
13
|
+
# TODO: allow URI value
|
14
|
+
unless ::File.file? (include_file = (spine_doc.normalize_system_path target, reader.dir, nil, target_name: 'include file'))
|
15
|
+
warn %(asciidoctor: WARNING: #{reader.line_info}: include file not found: #{include_file})
|
16
|
+
return
|
17
|
+
end
|
18
|
+
inherited_attrs = spine_doc.attributes.dup
|
19
|
+
# QUESTION should we keep backend-epub3 for convenience?
|
20
|
+
%w(backend-epub3 backend-epub3-doctype-book docdir docfile docname doctitle outfilesuffix spine).each {|key| inherited_attrs.delete key }
|
21
|
+
if (leveloffset = inherited_attrs['leveloffset'])
|
22
|
+
leveloffset = inherited_attrs['leveloffset'] = %(#{leveloffset}@) unless leveloffset.end_with? '@'
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
# parse header to get author information
|
26
|
+
spine_item_doc_meta = ::Asciidoctor.load_file include_file,
|
27
|
+
safe: spine_doc.safe,
|
28
|
+
backend: 'epub3-xhtml5',
|
29
|
+
doctype: :article,
|
30
|
+
parse_header_only: true,
|
31
|
+
attributes: leveloffset ? { 'leveloffset' => leveloffset } : nil
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
# blank out author information if present in sub-document
|
34
|
+
# FIXME this is a huge hack...we need a cleaner way to do this; perhaps an API method that retrieves all the author attribute names
|
35
|
+
if spine_item_doc_meta.attr? 'author'
|
36
|
+
%w(author firstname lastname email authorinitials authors authorcount).each {|key| inherited_attrs.delete key }
|
37
|
+
idx = 1
|
38
|
+
while inherited_attrs.key? %(author_#{idx})
|
39
|
+
%W[author_#{idx} firstname_#{idx} lastname_#{idx} email_#{idx} authorinitials_#{idx}].each {|key| inherited_attrs.delete key }
|
40
|
+
idx += 1
|
41
|
+
end
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
# REVIEW: reaching into converter to resolve document id feels like a hack; should happen in Asciidoctor parser
|
45
|
+
# also, strange that "id" doesn't work here
|
46
|
+
idprefix = (spine_doc.attr 'idprefix') || (spine_item_doc_meta.attr 'idprefix')
|
47
|
+
idseparator = (spine_doc.attr 'idseparator') || (spine_item_doc_meta.attr 'idseparator')
|
48
|
+
inherited_attrs['css-signature'] = DocumentIdGenerator.generate_id spine_item_doc_meta, idprefix, idseparator
|
49
|
+
inherited_attrs['docreldir'] = ::File.dirname target
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
# NOTE can't assign spine document as parent since there's too many assumptions in the Asciidoctor processor
|
52
|
+
spine_item_doc = ::Asciidoctor.load_file include_file,
|
53
|
+
# setting base_dir breaks if outdir is not a subdirectory of spine_doc.base_dir
|
54
|
+
#base_dir: spine_doc.base_dir,
|
55
|
+
# NOTE won't write to correct directory if safe mode is :secure
|
56
|
+
safe: spine_doc.safe,
|
57
|
+
backend: 'epub3-xhtml5',
|
58
|
+
doctype: :article,
|
59
|
+
header_footer: true,
|
60
|
+
catalog_assets: true,
|
61
|
+
attributes: inherited_attrs
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
+
# restore attributes to those defined in the document header
|
64
|
+
spine_item_doc.restore_attributes
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
# FIXME: core should register document ID if specified
|
67
|
+
unless (refs = spine_item_doc.references)[:ids].include? spine_item_doc.id
|
68
|
+
spine_item_doc.register :ids, [spine_item_doc.id, (spine_item_doc.attr 'docreftext') || spine_item_doc.doctitle]
|
69
|
+
end
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
refs[:spine] = spine_doc
|
72
|
+
refs[:spine_items] = ((spine_doc.references[:spine_items] ||= []) << spine_item_doc)
|
73
|
+
# NOTE if there are attribute assignments between the include directives,
|
74
|
+
# then this ordered list is not continguous, so bailing on the idea
|
75
|
+
#reader.replace_line %(. link:#{::File.basename(spine_item_doc.attr 'outfile')}[#{spine_item_doc.doctitle}])
|
76
|
+
nil
|
77
|
+
end
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
# handles? should get the attributes on include directive as the second argument
|
80
|
+
def handles? target
|
81
|
+
(@document.attr? 'spine') && (ASCIIDOC_EXTENSIONS.include? ::File.extname(target))
|
82
|
+
end
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
# FIXME: this method shouldn't be required
|
85
|
+
def update_config config
|
86
|
+
(@config ||= {}).update config
|
87
|
+
end
|
88
|
+
end
|
85
89
|
end
|
86
90
|
end
|
87
|
-
end
|
88
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-epub3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.alpha.
|
4
|
+
version: 1.5.0.alpha.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -17,14 +17,56 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 12.3.
|
20
|
+
version: 12.3.0
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 12.3.
|
27
|
+
version: 12.3.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.9.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.9.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubocop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.78.0
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.78.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubocop-rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.37.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.37.0
|
28
70
|
- !ruby/object:Gem::Dependency
|
29
71
|
name: asciidoctor
|
30
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,47 +88,47 @@ dependencies:
|
|
46
88
|
- !ruby/object:Gem::Version
|
47
89
|
version: 3.0.0
|
48
90
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
91
|
+
name: concurrent-ruby
|
50
92
|
requirement: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
94
|
- - "~>"
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0
|
96
|
+
version: 1.1.0
|
55
97
|
type: :runtime
|
56
98
|
prerelease: false
|
57
99
|
version_requirements: !ruby/object:Gem::Requirement
|
58
100
|
requirements:
|
59
101
|
- - "~>"
|
60
102
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0
|
103
|
+
version: 1.1.0
|
62
104
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
105
|
+
name: gepub
|
64
106
|
requirement: !ruby/object:Gem::Requirement
|
65
107
|
requirements:
|
66
108
|
- - "~>"
|
67
109
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
110
|
+
version: 1.0.0
|
69
111
|
type: :runtime
|
70
112
|
prerelease: false
|
71
113
|
version_requirements: !ruby/object:Gem::Requirement
|
72
114
|
requirements:
|
73
115
|
- - "~>"
|
74
116
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
117
|
+
version: 1.0.0
|
76
118
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
119
|
+
name: thread_safe
|
78
120
|
requirement: !ruby/object:Gem::Requirement
|
79
121
|
requirements:
|
80
122
|
- - "~>"
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
124
|
+
version: 0.3.0
|
83
125
|
type: :runtime
|
84
126
|
prerelease: false
|
85
127
|
version_requirements: !ruby/object:Gem::Requirement
|
86
128
|
requirements:
|
87
129
|
- - "~>"
|
88
130
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
131
|
+
version: 0.3.0
|
90
132
|
description: 'An extension for Asciidoctor that converts AsciiDoc documents to EPUB3
|
91
133
|
and KF8/MOBI (Kindle) e-book archives.
|
92
134
|
|
@@ -180,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
222
|
- !ruby/object:Gem::Version
|
181
223
|
version: 1.3.1
|
182
224
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.1.2
|
184
226
|
signing_key:
|
185
227
|
specification_version: 4
|
186
228
|
summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats
|