asciidoctor-epub3 1.5.0.alpha.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/CHANGELOG.adoc +199 -0
  4. data/Gemfile +16 -0
  5. data/LICENSE.adoc +25 -0
  6. data/NOTICE.adoc +54 -0
  7. data/README.adoc +1001 -0
  8. data/Rakefile +5 -0
  9. data/asciidoctor-epub3.gemspec +42 -0
  10. data/bin/adb-push-ebook +35 -0
  11. data/bin/asciidoctor-epub3 +30 -0
  12. data/data/fonts/assorted-icons.ttf +0 -0
  13. data/data/fonts/fontawesome-icons.ttf +0 -0
  14. data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
  15. data/data/fonts/mplus1mn-bolditalic-ascii.ttf +0 -0
  16. data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
  17. data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
  18. data/data/fonts/mplus1p-bold-latin-cyrillic.ttf +0 -0
  19. data/data/fonts/mplus1p-bold-latin-ext.ttf +0 -0
  20. data/data/fonts/mplus1p-bold-latin.ttf +0 -0
  21. data/data/fonts/mplus1p-bold-multilingual.ttf +0 -0
  22. data/data/fonts/mplus1p-light-latin-cyrillic.ttf +0 -0
  23. data/data/fonts/mplus1p-light-latin-ext.ttf +0 -0
  24. data/data/fonts/mplus1p-light-latin.ttf +0 -0
  25. data/data/fonts/mplus1p-light-multilingual.ttf +0 -0
  26. data/data/fonts/mplus1p-regular-latin-cyrillic.ttf +0 -0
  27. data/data/fonts/mplus1p-regular-latin-ext.ttf +0 -0
  28. data/data/fonts/mplus1p-regular-latin.ttf +0 -0
  29. data/data/fonts/mplus1p-regular-multilingual.ttf +0 -0
  30. data/data/fonts/notoserif-bold-latin-cyrillic.ttf +0 -0
  31. data/data/fonts/notoserif-bold-latin-ext.ttf +0 -0
  32. data/data/fonts/notoserif-bold-latin.ttf +0 -0
  33. data/data/fonts/notoserif-bold-multilingual.ttf +0 -0
  34. data/data/fonts/notoserif-bolditalic-latin-cyrillic.ttf +0 -0
  35. data/data/fonts/notoserif-bolditalic-latin-ext.ttf +0 -0
  36. data/data/fonts/notoserif-bolditalic-latin.ttf +0 -0
  37. data/data/fonts/notoserif-bolditalic-multilingual.ttf +0 -0
  38. data/data/fonts/notoserif-italic-latin-cyrillic.ttf +0 -0
  39. data/data/fonts/notoserif-italic-latin-ext.ttf +0 -0
  40. data/data/fonts/notoserif-italic-latin.ttf +0 -0
  41. data/data/fonts/notoserif-italic-multilingual.ttf +0 -0
  42. data/data/fonts/notoserif-regular-latin-cyrillic.ttf +0 -0
  43. data/data/fonts/notoserif-regular-latin-ext.ttf +0 -0
  44. data/data/fonts/notoserif-regular-latin.ttf +0 -0
  45. data/data/fonts/notoserif-regular-multilingual.ttf +0 -0
  46. data/data/images/default-avatar.jpg +0 -0
  47. data/data/images/default-avatar.png +0 -0
  48. data/data/images/default-avatar.svg +67 -0
  49. data/data/images/default-cover.svg +53 -0
  50. data/data/images/default-headshot.jpg +0 -0
  51. data/data/images/default-headshot.png +0 -0
  52. data/data/styles/color-palette.css +28 -0
  53. data/data/styles/epub3-css3-only.css +226 -0
  54. data/data/styles/epub3-fonts.css +94 -0
  55. data/data/styles/epub3.css +1266 -0
  56. data/lib/asciidoctor-epub3.rb +11 -0
  57. data/lib/asciidoctor-epub3/converter.rb +951 -0
  58. data/lib/asciidoctor-epub3/ext.rb +4 -0
  59. data/lib/asciidoctor-epub3/ext/asciidoctor.rb +3 -0
  60. data/lib/asciidoctor-epub3/ext/asciidoctor/logging_shim.rb +33 -0
  61. data/lib/asciidoctor-epub3/ext/core.rb +3 -0
  62. data/lib/asciidoctor-epub3/ext/core/string.rb +9 -0
  63. data/lib/asciidoctor-epub3/font_icon_map.rb +378 -0
  64. data/lib/asciidoctor-epub3/packager.rb +722 -0
  65. data/lib/asciidoctor-epub3/spine_item_processor.rb +92 -0
  66. data/lib/asciidoctor-epub3/version.rb +7 -0
  67. metadata +237 -0
@@ -0,0 +1,92 @@
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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asciidoctor
4
+ module Epub3
5
+ VERSION = '1.5.0.alpha.12'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-epub3
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.0.alpha.12
5
+ platform: ruby
6
+ authors:
7
+ - Dan Allen
8
+ - Sarah White
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-02-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 13.0.0
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 13.0.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.79.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.79.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
70
+ - !ruby/object:Gem::Dependency
71
+ name: asciidoctor
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.5.3
77
+ - - "<"
78
+ - !ruby/object:Gem::Version
79
+ version: 3.0.0
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.5.3
87
+ - - "<"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ - !ruby/object:Gem::Dependency
91
+ name: epubcheck-ruby
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 4.2.2.0
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 4.2.2.0
104
+ - !ruby/object:Gem::Dependency
105
+ name: gepub
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.0
118
+ - !ruby/object:Gem::Dependency
119
+ name: kindlegen
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 3.0.3
125
+ - - "<="
126
+ - !ruby/object:Gem::Version
127
+ version: 3.0.5
128
+ type: :runtime
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 3.0.3
135
+ - - "<="
136
+ - !ruby/object:Gem::Version
137
+ version: 3.0.5
138
+ description: 'An extension for Asciidoctor that converts AsciiDoc documents to EPUB3
139
+ and KF8/MOBI (Kindle) e-book archives.
140
+
141
+ '
142
+ email: dan@opendevise.com
143
+ executables:
144
+ - asciidoctor-epub3
145
+ - adb-push-ebook
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - ".yardopts"
150
+ - CHANGELOG.adoc
151
+ - Gemfile
152
+ - LICENSE.adoc
153
+ - NOTICE.adoc
154
+ - README.adoc
155
+ - Rakefile
156
+ - asciidoctor-epub3.gemspec
157
+ - bin/adb-push-ebook
158
+ - bin/asciidoctor-epub3
159
+ - data/fonts/assorted-icons.ttf
160
+ - data/fonts/fontawesome-icons.ttf
161
+ - data/fonts/mplus1mn-bold-ascii.ttf
162
+ - data/fonts/mplus1mn-bolditalic-ascii.ttf
163
+ - data/fonts/mplus1mn-italic-ascii.ttf
164
+ - data/fonts/mplus1mn-regular-ascii-conums.ttf
165
+ - data/fonts/mplus1p-bold-latin-cyrillic.ttf
166
+ - data/fonts/mplus1p-bold-latin-ext.ttf
167
+ - data/fonts/mplus1p-bold-latin.ttf
168
+ - data/fonts/mplus1p-bold-multilingual.ttf
169
+ - data/fonts/mplus1p-light-latin-cyrillic.ttf
170
+ - data/fonts/mplus1p-light-latin-ext.ttf
171
+ - data/fonts/mplus1p-light-latin.ttf
172
+ - data/fonts/mplus1p-light-multilingual.ttf
173
+ - data/fonts/mplus1p-regular-latin-cyrillic.ttf
174
+ - data/fonts/mplus1p-regular-latin-ext.ttf
175
+ - data/fonts/mplus1p-regular-latin.ttf
176
+ - data/fonts/mplus1p-regular-multilingual.ttf
177
+ - data/fonts/notoserif-bold-latin-cyrillic.ttf
178
+ - data/fonts/notoserif-bold-latin-ext.ttf
179
+ - data/fonts/notoserif-bold-latin.ttf
180
+ - data/fonts/notoserif-bold-multilingual.ttf
181
+ - data/fonts/notoserif-bolditalic-latin-cyrillic.ttf
182
+ - data/fonts/notoserif-bolditalic-latin-ext.ttf
183
+ - data/fonts/notoserif-bolditalic-latin.ttf
184
+ - data/fonts/notoserif-bolditalic-multilingual.ttf
185
+ - data/fonts/notoserif-italic-latin-cyrillic.ttf
186
+ - data/fonts/notoserif-italic-latin-ext.ttf
187
+ - data/fonts/notoserif-italic-latin.ttf
188
+ - data/fonts/notoserif-italic-multilingual.ttf
189
+ - data/fonts/notoserif-regular-latin-cyrillic.ttf
190
+ - data/fonts/notoserif-regular-latin-ext.ttf
191
+ - data/fonts/notoserif-regular-latin.ttf
192
+ - data/fonts/notoserif-regular-multilingual.ttf
193
+ - data/images/default-avatar.jpg
194
+ - data/images/default-avatar.png
195
+ - data/images/default-avatar.svg
196
+ - data/images/default-cover.svg
197
+ - data/images/default-headshot.jpg
198
+ - data/images/default-headshot.png
199
+ - data/styles/color-palette.css
200
+ - data/styles/epub3-css3-only.css
201
+ - data/styles/epub3-fonts.css
202
+ - data/styles/epub3.css
203
+ - lib/asciidoctor-epub3.rb
204
+ - lib/asciidoctor-epub3/converter.rb
205
+ - lib/asciidoctor-epub3/ext.rb
206
+ - lib/asciidoctor-epub3/ext/asciidoctor.rb
207
+ - lib/asciidoctor-epub3/ext/asciidoctor/logging_shim.rb
208
+ - lib/asciidoctor-epub3/ext/core.rb
209
+ - lib/asciidoctor-epub3/ext/core/string.rb
210
+ - lib/asciidoctor-epub3/font_icon_map.rb
211
+ - lib/asciidoctor-epub3/packager.rb
212
+ - lib/asciidoctor-epub3/spine_item_processor.rb
213
+ - lib/asciidoctor-epub3/version.rb
214
+ homepage: https://github.com/asciidoctor/asciidoctor-epub3
215
+ licenses:
216
+ - MIT
217
+ metadata: {}
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: 2.3.0
227
+ required_rubygems_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">"
230
+ - !ruby/object:Gem::Version
231
+ version: 1.3.1
232
+ requirements: []
233
+ rubygems_version: 3.1.2
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats
237
+ test_files: []