asciidoctor-epub3 1.5.0.alpha.12 → 1.5.0.alpha.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +56 -1
- data/Gemfile +10 -6
- data/LICENSE +21 -0
- data/NOTICE.adoc +3 -3
- data/README.adoc +62 -151
- data/asciidoctor-epub3.gemspec +9 -6
- data/data/fonts/awesome/LICENSE.txt +34 -0
- data/data/fonts/awesome/fa-solid-900.ttf +0 -0
- data/data/fonts/awesome/icons.yml +20935 -0
- data/data/fonts/awesome/shims.yml +298 -0
- data/data/styles/epub3-css3-only.css +3 -8
- data/data/styles/epub3-fonts.css +1 -1
- data/data/styles/epub3.css +22 -15
- data/lib/asciidoctor-epub3.rb +0 -1
- data/lib/asciidoctor-epub3/converter.rb +1062 -236
- data/lib/asciidoctor-epub3/font_icon_map.rb +22 -371
- data/lib/asciidoctor-epub3/version.rb +1 -1
- metadata +80 -38
- data/.yardopts +0 -12
- data/LICENSE.adoc +0 -25
- data/data/fonts/fontawesome-icons.ttf +0 -0
- data/lib/asciidoctor-epub3/packager.rb +0 -722
- data/lib/asciidoctor-epub3/spine_item_processor.rb +0 -92
@@ -1,92 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Asciidoctor
|
4
|
-
module Epub3
|
5
|
-
class SpineItemProcessor < Extensions::IncludeProcessor
|
6
|
-
include ::Asciidoctor::Logging
|
7
|
-
|
8
|
-
def initialize document
|
9
|
-
@document = document
|
10
|
-
end
|
11
|
-
|
12
|
-
# NOTE only fires for includes in spine document if registered directly on the instance of the spine document
|
13
|
-
def process doc, reader, target, _attributes
|
14
|
-
spine_doc = doc
|
15
|
-
# TODO: allow URI value
|
16
|
-
unless ::File.file? (include_file = (spine_doc.normalize_system_path target, reader.dir, nil, target_name: 'include file'))
|
17
|
-
logger.warn %(#{reader.line_info}: include file not found: #{include_file})
|
18
|
-
return
|
19
|
-
end
|
20
|
-
inherited_attrs = spine_doc.attributes.dup
|
21
|
-
# QUESTION should we keep backend-epub3 for convenience?
|
22
|
-
%w(backend-epub3 backend-epub3-doctype-book docdir docfile docname doctitle outfilesuffix spine).each {|key| inherited_attrs.delete key }
|
23
|
-
if (leveloffset = inherited_attrs['leveloffset'])
|
24
|
-
leveloffset = inherited_attrs['leveloffset'] = %(#{leveloffset}@) unless leveloffset.end_with? '@'
|
25
|
-
end
|
26
|
-
|
27
|
-
# parse header to get author information
|
28
|
-
spine_item_doc_meta = ::Asciidoctor.load_file include_file,
|
29
|
-
safe: spine_doc.safe,
|
30
|
-
backend: 'epub3-xhtml5',
|
31
|
-
doctype: :article,
|
32
|
-
parse_header_only: true,
|
33
|
-
attributes: leveloffset ? { 'leveloffset' => leveloffset } : nil
|
34
|
-
|
35
|
-
# blank out author information if present in sub-document
|
36
|
-
# 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
|
37
|
-
if spine_item_doc_meta.attr? 'author'
|
38
|
-
%w(author firstname lastname email authorinitials authors authorcount).each {|key| inherited_attrs.delete key }
|
39
|
-
idx = 1
|
40
|
-
while inherited_attrs.key? %(author_#{idx})
|
41
|
-
%W[author_#{idx} firstname_#{idx} lastname_#{idx} email_#{idx} authorinitials_#{idx}].each {|key| inherited_attrs.delete key }
|
42
|
-
idx += 1
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# REVIEW: reaching into converter to resolve document id feels like a hack; should happen in Asciidoctor parser
|
47
|
-
# also, strange that "id" doesn't work here
|
48
|
-
idprefix = (spine_doc.attr 'idprefix') || (spine_item_doc_meta.attr 'idprefix')
|
49
|
-
idseparator = (spine_doc.attr 'idseparator') || (spine_item_doc_meta.attr 'idseparator')
|
50
|
-
inherited_attrs['css-signature'] = DocumentIdGenerator.generate_id spine_item_doc_meta, idprefix, idseparator
|
51
|
-
inherited_attrs['docreldir'] = ::File.dirname target
|
52
|
-
|
53
|
-
# NOTE can't assign spine document as parent since there's too many assumptions in the Asciidoctor processor
|
54
|
-
spine_item_doc = ::Asciidoctor.load_file include_file,
|
55
|
-
# setting base_dir breaks if outdir is not a subdirectory of spine_doc.base_dir
|
56
|
-
#base_dir: spine_doc.base_dir,
|
57
|
-
# NOTE won't write to correct directory if safe mode is :secure
|
58
|
-
safe: spine_doc.safe,
|
59
|
-
backend: 'epub3-xhtml5',
|
60
|
-
doctype: :article,
|
61
|
-
header_footer: true,
|
62
|
-
catalog_assets: true,
|
63
|
-
attributes: inherited_attrs
|
64
|
-
|
65
|
-
# restore attributes to those defined in the document header
|
66
|
-
spine_item_doc.restore_attributes
|
67
|
-
|
68
|
-
# FIXME: core should register document ID if specified
|
69
|
-
unless (refs = spine_item_doc.references)[:ids].include? spine_item_doc.id
|
70
|
-
spine_item_doc.register :ids, [spine_item_doc.id, (spine_item_doc.attr 'docreftext') || spine_item_doc.doctitle]
|
71
|
-
end
|
72
|
-
|
73
|
-
refs[:spine] = spine_doc
|
74
|
-
refs[:spine_items] = ((spine_doc.references[:spine_items] ||= []) << spine_item_doc)
|
75
|
-
# NOTE if there are attribute assignments between the include directives,
|
76
|
-
# then this ordered list is not continguous, so bailing on the idea
|
77
|
-
#reader.replace_line %(. link:#{::File.basename(spine_item_doc.attr 'outfile')}[#{spine_item_doc.doctitle}])
|
78
|
-
nil
|
79
|
-
end
|
80
|
-
|
81
|
-
# handles? should get the attributes on include directive as the second argument
|
82
|
-
def handles? target
|
83
|
-
(@document.attr? 'spine') && (ASCIIDOC_EXTENSIONS.include? ::File.extname(target))
|
84
|
-
end
|
85
|
-
|
86
|
-
# FIXME: this method shouldn't be required
|
87
|
-
def update_config config
|
88
|
-
(@config ||= {}).update config
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|