asciidoctor-epub3 1.5.0.alpha.7 → 1.5.0.alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.adoc +16 -0
- data/Gemfile +7 -2
- data/LICENSE.adoc +1 -1
- data/README.adoc +98 -52
- data/Rakefile +6 -3
- data/data/images/default-avatar.jpg +0 -0
- data/data/images/default-avatar.png +0 -0
- data/data/styles/epub3-css3-only.css +34 -0
- data/data/styles/epub3.css +14 -23
- data/lib/asciidoctor-epub3/converter.rb +60 -37
- data/lib/asciidoctor-epub3/packager.rb +32 -15
- data/lib/asciidoctor-epub3/spine_item_processor.rb +6 -1
- data/lib/asciidoctor-epub3/version.rb +1 -1
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 56913840726d5e371d1feb61094894bffeec6b28edd87b2dbfc0ef227732b5af
|
4
|
+
data.tar.gz: 584b561949668e02bb4634f70475e168db89586cb2e63607821c42573395236e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52c30ad5805c595e675b6b69f4bf8e5cef89a0f6143d5438d88c144c33579151f8c58c3bfc6a5119214e7f1eb38ea21585b36e663f87dc7c311650dae918007
|
7
|
+
data.tar.gz: 3e82757ae00356c2932f506bbacd57d89032da96187dac11f51e080d0712d942c97e0801e03e9ec123eb29daff5dff4f3dfb3c2b03d0b3312a99541bb6560d07
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,22 @@
|
|
5
5
|
This document provides a high-level view of the changes to the {project-name} by release.
|
6
6
|
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
|
7
7
|
|
8
|
+
== 1.5.0.alpha.8 (2018-02-20) - @mojavelinux
|
9
|
+
|
10
|
+
* Include inline images in EPUB3 archive (#5)
|
11
|
+
* Allow chapter to begin with level-1 section title by adding support for negative leveloffset (#107)
|
12
|
+
* Don't transform the chapter title to uppercase (rely on CSS only) (#97)
|
13
|
+
* Set correct mimetype for TTF files (#120)
|
14
|
+
* Implement support for the custom xrefstyle for references within a chapter (#132)
|
15
|
+
* Show correct path of front cover image and the current document when missing (#124)
|
16
|
+
* Retain ID of block image (#141)
|
17
|
+
* Retain ID of example block (#143)
|
18
|
+
* Retain ID of admonition block (#146)
|
19
|
+
* Transfer role specified on block image to output (#145)
|
20
|
+
* Handle nil response from pygments.rb (#156)
|
21
|
+
* Invert the colors for the chapter title (use black on white) (#96)
|
22
|
+
* Darken font on Kindle Paperwhite devices (#67)
|
23
|
+
|
8
24
|
== 1.5.0.alpha.7 (2017-04-18) - @mojavelinux
|
9
25
|
|
10
26
|
* generate TOC levels in navigation document based on toclevels attribute (#90)
|
data/Gemfile
CHANGED
@@ -4,7 +4,12 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :optional do
|
7
|
-
gem 'pygments.rb', '1.1.1'
|
8
|
-
gem 'kindlegen', '3.0.3'
|
9
7
|
gem 'epubcheck', '3.0.1'
|
8
|
+
if (ruby_version = Gem::Version.new RUBY_VERSION) < (Gem::Version.new '2.0.0')
|
9
|
+
gem 'kindlegen', '2.9.4'
|
10
|
+
gem 'pygments.rb', '0.6.3'
|
11
|
+
else
|
12
|
+
gem 'kindlegen', '3.0.3'
|
13
|
+
gem 'pygments.rb', '1.1.2'
|
14
|
+
end
|
10
15
|
end
|
data/LICENSE.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.The MIT License
|
2
2
|
....
|
3
|
-
Copyright (C) 2014-
|
3
|
+
Copyright (C) 2014-2018 OpenDevise Inc. and the Asciidoctor Project
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= {project-name}: A _native_ EPUB3 converter for AsciiDoc
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
-
v1.5.0.alpha.
|
3
|
+
v1.5.0.alpha.8, 2018-02-20
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
@@ -36,22 +36,33 @@ endif::[]
|
|
36
36
|
:uri-idpf: http://www.idpf.org/
|
37
37
|
:uri-epub: http://www.idpf.org/epub/31/spec/epub-spec.html
|
38
38
|
:uri-epubcheck: https://github.com/idpf/epubcheck
|
39
|
+
:uri-kindlegen: http://www.amazon.com/gp/feature.html?docId=1000765211
|
40
|
+
:uri-kf8: http://www.amazon.com/gp/feature.html?docId=1000729511
|
41
|
+
:uri-send-to-kindle: https://www.amazon.com/gp/sendtokindle/
|
42
|
+
:uri-metadata-elem: http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem
|
43
|
+
:uri-dc: http://dublincore.org/documents/2004/12/20/dces
|
44
|
+
:uri-github-guides: https://guides.github.com
|
45
|
+
:uri-github-guides-fork: https://github.com/opendevise/github-guides-asciidoc
|
46
|
+
:uri-asciidoctor-i18n: http://asciidoctor.org/docs/user-manual/#builtin-attributes-i18n
|
47
|
+
:uri-epubreadingsystem: http://www.idpf.org/epub/301/spec/epub-contentdocs.html#app-epubReadingSystem
|
48
|
+
:uri-android-sdk: http://developer.android.com/sdk/index.html
|
39
49
|
|
40
50
|
ifdef::status[]
|
41
51
|
image:https://img.shields.io/gem/v/asciidoctor-epub3.svg[Latest Release,link={uri-gem}]
|
42
52
|
image:https://img.shields.io/badge/license-MIT-blue.svg[MIT License,link=#copyright]
|
43
53
|
endif::[]
|
44
54
|
|
45
|
-
{project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 and KF8/MOBI
|
55
|
+
{project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 and KF8/MOBI e-book formats.
|
46
56
|
|
47
57
|
== Introduction
|
48
58
|
|
49
|
-
{project-name} is not merely a converter from AsciiDoc to EPUB3 and KF8/MOBI
|
50
|
-
|
51
|
-
|
59
|
+
{project-name} is not merely a converter from AsciiDoc to EPUB3 and KF8/MOBI.
|
60
|
+
Rather, it's a tool for creating highly aesthetic, professional, _easy-to-read_ e-books.
|
61
|
+
Let's face it, many of the technical e-books out there--especially those produced from software documentation--are *_hideous_*.
|
62
|
+
{project-name} is on a mission to disrupt the status quo.
|
52
63
|
|
53
64
|
ifdef::env-github[]
|
54
|
-
.An excerpt from an
|
65
|
+
.An excerpt from an e-book produced by {project-name} shown in Day, Night and Sepia mode.
|
55
66
|
image::screenshots/text.png[]
|
56
67
|
endif::[]
|
57
68
|
|
@@ -63,22 +74,22 @@ The {project-name} project aims to produce EPUB3 documents that meet the followi
|
|
63
74
|
Fully Semantic::
|
64
75
|
Produce deeply semantic XHTML5 documents, including use of the recommended `epub:type` attribute.
|
65
76
|
Exceptional Readability::
|
66
|
-
Readers should be drawn into the text so that they read and absorb it
|
67
|
-
Maximize the readability of the text using carefully crafted styles
|
77
|
+
Readers should be drawn into the text so that they read and absorb it.
|
78
|
+
Maximize the readability of the text using carefully crafted styles that are focused on:
|
68
79
|
- Custom, readable fonts with strong UTF-8 character support
|
69
80
|
- Sufficient line spacing and margins
|
70
81
|
- Modular font size scale
|
71
82
|
- Subtle, pleasing colors with good contrast
|
72
83
|
- A responsive design that scales well from small to large screens
|
73
84
|
- Widowed and orphaned content avoided where possible
|
74
|
-
Complete
|
85
|
+
Complete and Accurate Metadata::
|
75
86
|
Fully populate the EPUB3 package metadata using information in the AsciiDoc source document.
|
76
87
|
Consistent Rendering::
|
77
|
-
Render consistently across a broad range of EPUB3 (and select EPUB2+)
|
78
|
-
Polish, Polish
|
88
|
+
Render consistently across a broad range of EPUB3 (and select EPUB2+) e-readers and respond to any size screen.
|
89
|
+
Polish, Polish, and More Polish::
|
79
90
|
Add polish to the final product such as font-based icons and callout numbers.
|
80
91
|
|
81
|
-
We believe that the
|
92
|
+
We believe that the e-books produced by {project-name} are the _very best_ output you can expect to find in digital publishing today.
|
82
93
|
Of course, there's always room for improvement, so we'll continue to work with you to achieve and maintain this goal.
|
83
94
|
|
84
95
|
=== Notable Features
|
@@ -86,14 +97,14 @@ Of course, there's always room for improvement, so we'll continue to work with y
|
|
86
97
|
* Direct AsciiDoc to EPUB3 conversion
|
87
98
|
* Direct AsciiDoc to KF8/MOBI conversion
|
88
99
|
* Highly-aesthetic and readable styles with optimized text legibility
|
89
|
-
* Respects font settings (if supported by the
|
100
|
+
* Respects font settings (if supported by the e-reader) without altering headings, code or icons
|
90
101
|
* EPUB3 metadata, manifest and spine (assembled by Gepub)
|
91
102
|
* Document metadata (title, authors, subject, keywords, etc.)
|
92
|
-
* Internal cross reference links
|
103
|
+
* Internal cross reference links
|
93
104
|
* Syntax highlighting with CodeRay or Pygments (must use inline styles)
|
94
105
|
* Unicode callout numbers
|
95
|
-
* Page breaks avoided in block content (so much as it's supported by the
|
96
|
-
* Orphan section titles avoided (so much as it's supported by the
|
106
|
+
* Page breaks avoided in block content (so much as it's supported by the e-reader)
|
107
|
+
* Orphan section titles avoided (so much as it's supported by the e-reader)
|
97
108
|
* Table border settings honored
|
98
109
|
* Support for SVG images in the content
|
99
110
|
|
@@ -106,16 +117,19 @@ Although the bulk of AsciiDoc content is converted, there's still work needed to
|
|
106
117
|
NOTE: {project-name} only produces variable layout (i.e., reflowable) EPUB3 documents since this layout is best suited for the types of documents typically written in AsciiDoc.
|
107
118
|
We may explore the use of fixed layout documents in the future if the need arises.
|
108
119
|
|
120
|
+
ifdef::env-github[]
|
109
121
|
=== Planned Features and Work In Progress
|
110
122
|
|
111
123
|
See <<WORKLOG#,WORKLOG.adoc>>.
|
124
|
+
endif::[]
|
112
125
|
|
113
126
|
== Converter Workflow
|
114
127
|
|
115
|
-
{project-name} takes an aggregate AsciiDoc document and
|
128
|
+
{project-name} takes an aggregate AsciiDoc document and any assets it references as input and produces an EPUB3 publication archive (often described as a “website in a box”).
|
116
129
|
|
117
|
-
{project-name} can also produce
|
118
|
-
The conversion to KF8/MOBI is performed by generating a slightly modified EPUB3 publication
|
130
|
+
{project-name} can also produce KF8/MOBI files, the format required for viewing on Amazon Kindle.
|
131
|
+
The conversion to KF8/MOBI is performed by generating a slightly modified EPUB3 publication, then passing it through the {uri-kindlegen}[KindleGen] application.
|
132
|
+
The EPUB3 publication, which can be thought of as the “digital master”, is altered to adhere to certain Amazon Kindle requirements.
|
119
133
|
|
120
134
|
== Structuring your Manuscript
|
121
135
|
|
@@ -148,13 +162,13 @@ The cross reference (i.e., xref) from one chapter to another must be in the form
|
|
148
162
|
If you want to reference a section in a chapter, update the fragment (i.e., the value that follows the hash) to match the target section ID.
|
149
163
|
The reftext is optional since the reftext of the target is used by default.
|
150
164
|
+
|
151
|
-
TIP: To assign reference text (i.e., reftext)
|
165
|
+
TIP: To assign reference text (i.e., reftext) for a chapter title, set the document attribute `docreftext` in the header for that chapter.
|
152
166
|
+
|
153
167
|
TIP: Rule 2 states that the chapter ID must match the basename of the chapter file.
|
154
168
|
In truth, the chapter ID can be a _derivative of_ the chapter filename.
|
155
169
|
In that case, an attribute reference can be used to prepend a prefix to an inter-document cross reference.
|
156
170
|
For example, if you want each chapter file to begin with `chapter-`, you'd write the xref as `+xref:{chapter-prefix}chapter-id#chapter-id[]+`.
|
157
|
-
You'd then assign an empty value to the `chapter-prefix` attribute when converting to an
|
171
|
+
You'd then assign an empty value to the `chapter-prefix` attribute when converting to an e-book and `chapter-` for all other formats.
|
158
172
|
|
159
173
|
The next section goes into more detail about how to set up the spine document and include the chapter files.
|
160
174
|
|
@@ -185,7 +199,7 @@ The rules for generating a chapter ID from the document title are as follows:
|
|
185
199
|
* prepend an underscore if the ID begins with a number
|
186
200
|
|
187
201
|
You can think of the master document as the spine of the book and the include directives the individual items being bound together.
|
188
|
-
The target of each include directive in the master document is parsed and
|
202
|
+
The target of each include directive in the master document is parsed and converted as a separate AsciiDoc document, with certain options and attributes passed down from the master to ensure consistent behavior.
|
189
203
|
Each resulting XHTML document is then added to the EPUB3 archive as a chapter document and the master document becomes the navigation file (i.e, the table of contents).
|
190
204
|
|
191
205
|
Here's an example showing the structure of a spine document:
|
@@ -243,7 +257,8 @@ To check if you have Ruby available, use the `ruby` command to query the install
|
|
243
257
|
|
244
258
|
== Getting Started
|
245
259
|
|
246
|
-
You can get {project-name} by <<Install the Published Gem,installing the published gem
|
260
|
+
You can get {project-name} by <<Install the Published Gem,installing the published gem>>.
|
261
|
+
ifndef::env-site[You can also <<Development,run the code from source>> if you want to use the development version or participate in development.]
|
247
262
|
|
248
263
|
=== Install the Published Gem
|
249
264
|
|
@@ -252,6 +267,9 @@ You can install the published gem using the following command:
|
|
252
267
|
|
253
268
|
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install asciidoctor-epub3 --pre
|
254
269
|
|
270
|
+
This optional environment variable tells the gem installer to link against the C libraries on the system, if available, instead of compiling the libraries from scratch.
|
271
|
+
This speeds up the installation of Nokogiri considerably.
|
272
|
+
|
255
273
|
If you want to syntax highlight source listings, you'll also want to install CodeRay or Pygments.
|
256
274
|
Choose one (or more) of the following:
|
257
275
|
|
@@ -292,7 +310,7 @@ v1.0, 2014-04-15
|
|
292
310
|
:doctype: book
|
293
311
|
:creator: {author}
|
294
312
|
:producer: Asciidoctor
|
295
|
-
:keywords: Asciidoctor, samples,
|
313
|
+
:keywords: Asciidoctor, samples, e-book, EPUB3, KF8, MOBI, Asciidoctor.js
|
296
314
|
:copyright: CC-BY-SA 3.0
|
297
315
|
:imagesdir: images
|
298
316
|
|
@@ -310,8 +328,8 @@ v1.0, 2014-04-15
|
|
310
328
|
The metadata in the generated EPUB3 file is populated from attributes in the AsciiDoc document.
|
311
329
|
The names of the attributes and the metadata elements to which they map are documented in this section.
|
312
330
|
|
313
|
-
The term [term]_package metadata_ in Table 1 is in reference to the
|
314
|
-
The `dc` namespace prefix is in reference to the
|
331
|
+
The term [term]_package metadata_ in Table 1 is in reference to the {uri-metadata-elem}[<metadata> element] in the EPUB3 package document (e.g., [file]_package.opf_).
|
332
|
+
The `dc` namespace prefix is in reference to the {uri-dc}[Dublin Core Metadata Element Set].
|
315
333
|
|
316
334
|
.AsciiDoc attributes that control the EPUB3 metadata (i.e., package.opf)
|
317
335
|
[cols="1m,3"]
|
@@ -343,7 +361,7 @@ The title is added to the metadata in plain text format.
|
|
343
361
|
The authors in each chapter document are aggregated together with the authors in the master file.
|
344
362
|
|
345
363
|
|username
|
346
|
-
|Used to resolve
|
364
|
+
|Used to resolve an avatar for the author that is displayed in the header of a chapter when the `publication-type` is set to a value other than `book`.
|
347
365
|
The avatar image should be located at the path _\{imagesdir}/avatars/\{username}.jpg_, where `\{username}` is the value of this attribute.
|
348
366
|
|
349
367
|
|producer
|
@@ -351,7 +369,7 @@ The avatar image should be located at the path _\{imagesdir}/avatars/\{username}
|
|
351
369
|
|
352
370
|
|creator
|
353
371
|
|Populates the creator (`<dc:creator>`) in the package metadata.
|
354
|
-
*If the creator is not specified, Asciidoctor is
|
372
|
+
*If the creator is not specified, Asciidoctor is set as the creator with the role "mfr" (an abbreviation for manufacturer).*
|
355
373
|
|
356
374
|
|description
|
357
375
|
|Populates the description (`<dc:description>`) in the package metadata.
|
@@ -362,7 +380,7 @@ The keywords should be represented as comma-separated values (CSV).
|
|
362
380
|
|
363
381
|
|front-cover-image
|
364
382
|
|Populates the front cover image and the image on the cover page (EPUB3 only) in the package metadata.
|
365
|
-
The image is also added to the
|
383
|
+
The image is also added to the e-book archive.
|
366
384
|
The value may be specified as a path or inline image macro.
|
367
385
|
Using the inline image macro is preferred as it allows the height and width to be specified.
|
368
386
|
|
@@ -390,7 +408,7 @@ If set to a value other than book, the byline information (author and avatar) is
|
|
390
408
|
Suggested values include: book (default), anthology, magazine, journal, article.
|
391
409
|
|===
|
392
410
|
|
393
|
-
When using the EPUB3 converter, the `ebook-format` attribute resolves to the name of the
|
411
|
+
When using the EPUB3 converter, the `ebook-format` attribute resolves to the name of the e-book format being generated (epub3 or kf8) and the corresponding attribute `ebook-format-<name>` is defined, where `<name>` is `epub3` or `kf8`.
|
394
412
|
You can use these attributes in a preprocessor directive if you only want to show certain content to readers using a particular device.
|
395
413
|
For instance, if you want to display a message to readers on Kindle, you can use:
|
396
414
|
|
@@ -415,7 +433,7 @@ We also recommend specifying an output directory using the `-D` option flag.
|
|
415
433
|
$ asciidoctor-epub3 -D output data/samples/sample-book.adoc
|
416
434
|
|
417
435
|
When the script completes, you'll see the file [file]_sample-book.epub_ appear in the [path]_output_ directory.
|
418
|
-
Open that file with an EPUB reader (aka
|
436
|
+
Open that file with an EPUB reader (aka e-reader) to view the result.
|
419
437
|
|
420
438
|
Below are several screenshots of this sample book as it appears on an Android phone.
|
421
439
|
|
@@ -437,7 +455,7 @@ image::screenshots/table.png[]
|
|
437
455
|
NOTE: The `asciidoctor-epub3` command is a temporary solution for invoking the {project-name} converter.
|
438
456
|
We plan to remove this script once we have completed proper integration with the `asciidoctor` command.
|
439
457
|
|
440
|
-
TIP: As another example, point `asciidoctor-epub3` at the
|
458
|
+
TIP: As another example, point `asciidoctor-epub3` at the {uri-github-guides-fork}[GitHub Guides] that we've ported to AsciiDoc, then compare the output to the real {uri-github-guides}[GitHub Guides].
|
441
459
|
|
442
460
|
=== Validate the EPUB3 Archive
|
443
461
|
|
@@ -495,12 +513,24 @@ KindleGen does mandatory validation so you don't need to run the `validate` comm
|
|
495
513
|
****
|
496
514
|
Kindle Format 8 (KF8) is Amazon's next generation file format offering a wide range of new features and enhancements--including HTML5 and CSS3 support--that publishers can use to create a broad range of books.
|
497
515
|
The format is close enough to EPUB3 that it's safe to think of it simply as an EPUB3 implementation under most circumstances.
|
498
|
-
You can read more about the format on the
|
516
|
+
You can read more about the format on the {uri-kf8}[Kindle Format 8 page].
|
499
517
|
|
500
518
|
Amazon continues to use the _.mobi_ file extension for KF8 archives, despite the fact that they've switched from the Mobipocket format to the EPUB3-like KF8 format.
|
501
519
|
That's why we refer to the format in this project as KF8/MOBI.
|
502
520
|
****
|
503
521
|
|
522
|
+
=== Tuning Listing Captions
|
523
|
+
|
524
|
+
Unlike the built-in converters, the EPUB3 converter is configured to add a signifier (e.g., `Listing`) at the start the caption for all listing and source blocks that have a title.
|
525
|
+
This behavior is triggered because the `listing-caption` attribute is set by default.
|
526
|
+
|
527
|
+
If you don't want the signifier to be included at the beginning of the caption on listing and source blocks, simply unset the `listing-caption` when invoking Asciidoctor EPUB3.
|
528
|
+
|
529
|
+
$ asciidoctor-epub3 -a listing-caption! book.adoc
|
530
|
+
|
531
|
+
Now the behavior will match that of the built-in converters.
|
532
|
+
For more information about this attribute and other related attributes, see {uri-asciidoctor-i18n}[internationalization and numbering].
|
533
|
+
|
504
534
|
=== Command Arguments
|
505
535
|
|
506
536
|
*-h, --help* ::
|
@@ -586,7 +616,7 @@ The sample book contains placeholder images for an author avatar and a book cove
|
|
586
616
|
|
587
617
|
Ereaders have different image resolution and file size limits regarding a book's cover.
|
588
618
|
Kindle covers tend to be 1050x1600 (16:9 resolution), which is the size of the sample cover provided with {project-name}.
|
589
|
-
To ensure your cover displays correctly, you'll want to review the documentation or publisher guidelines for the reading platform you're targeting.
|
619
|
+
To ensure your cover displays correctly, you'll want to review the documentation or publisher guidelines for the e-reading platform you're targeting.
|
590
620
|
|
591
621
|
WARNING: We've found that if the book cover is more than 1600px on any side, Aldiko will not render it and may even crash.
|
592
622
|
|
@@ -622,7 +652,7 @@ To do so, use an attribute entry to set the value of the `imagesdir` attribute o
|
|
622
652
|
== About the Theme
|
623
653
|
|
624
654
|
EPUB3 and KF8/MOBI files are styled using CSS3.
|
625
|
-
However, each
|
655
|
+
However, each e-reading platform honors a reduced set of CSS3 styles, and the styles they allow and how they implement them are rarely documented.
|
626
656
|
All we've got to say is _thank goodness for CSS hacks, media queries and years of CSS experience!_
|
627
657
|
|
628
658
|
The theme provided with {project-name} has been crafted to display EPUB3 and KF8/MOBI files as consistently as possible across the most common EPUB3 platforms and to degrade gracefully in select EPUB2 platforms.
|
@@ -647,7 +677,7 @@ Refer to the <<NOTICE#,NOTICE>> file for further information about the fonts.
|
|
647
677
|
|
648
678
|
=== Device-specific Styles
|
649
679
|
|
650
|
-
For readers that support JavaScript, {project-name} adds a CSS class to the body element of each chapter that corresponds to the name of the reader as reported by the
|
680
|
+
For readers that support JavaScript, {project-name} adds a CSS class to the body element of each chapter that corresponds to the name of the reader as reported by the {uri-epubreadingsystem}[epubReadingSystem] JavaScript object.
|
651
681
|
This enhancement allows you to use styles targeted specifically at that reader.
|
652
682
|
|
653
683
|
Below you can find the readers that are known to support this feature and the CSS class name that gets added to the body element.
|
@@ -673,7 +703,7 @@ Assuming you have an Android device available, transferring the EPUB3 to the dev
|
|
673
703
|
You transfer files from your computer to an Android phone over a USB connection using a command from the Android SDK Tools called `adb`.
|
674
704
|
Follow these steps to get it setup:
|
675
705
|
|
676
|
-
. Download the Android SDK Tools zip from the table labeled *SDK Tools Only* on the
|
706
|
+
. Download the Android SDK Tools zip from the table labeled *SDK Tools Only* on the {uri-android-sdk}[Get the Android SDK] page
|
677
707
|
. Extract the archive
|
678
708
|
. Locate the path to the `adb` command (Hint: Look in the platform-tools folder)
|
679
709
|
. Set the environment variable named ADB to the path of the `adb` command
|
@@ -697,12 +727,12 @@ File type,Destination on Android device
|
|
697
727
|
,===
|
698
728
|
|
699
729
|
Amazon Kindle should immediately detect the new file and display it in your “On Device” library.
|
700
|
-
You'll have to manually import the EPUB3 into your
|
730
|
+
You'll have to manually import the EPUB3 into your e-reader of choice.
|
701
731
|
|
702
732
|
== E-book Reader Recommendations and Quirks
|
703
733
|
|
704
|
-
EPUB3
|
705
|
-
Here's a list of some of the
|
734
|
+
EPUB3 e-readers will provide the best reading experience when viewing the book generated by {project-name}.
|
735
|
+
Here's a list of some of the e-readers we know to have good EPUB3 support and the systems on which they run:
|
706
736
|
|
707
737
|
* http://www.amazon.com/gp/feature.html?docId=1000493771[Amazon Kindle] (most platforms)
|
708
738
|
* http://gitden.com/gitdenreader[Gitden] (Android and iOS)
|
@@ -710,17 +740,17 @@ Here's a list of some of the ereaders we know to have good EPUB3 support and the
|
|
710
740
|
* https://chrome.google.com/webstore/detail/readium/fepbnnnkkadjhjahcafoaglimekefifl?hl=en-US[Readium] (Chrome)
|
711
741
|
* http://www.kobo.com/apps[Kobo] (Android, iOS, OSX and Windows)
|
712
742
|
* http://www.namo.com/site/namo/menu/5074.do[Namo PubTreeViewer] (Android, iOS and Windows)
|
713
|
-
* http://calibre-ebook.com[Calibre ebook-viewer] (Linux, OSX, Windows)
|
743
|
+
* http://calibre-ebook.com[Calibre (ebook-viewer)] (Linux, OSX, Windows)
|
714
744
|
|
715
|
-
IMPORTANT: To get the full experience, *ensure that the
|
716
|
-
Different
|
745
|
+
IMPORTANT: To get the full experience, *ensure that the e-reader is configured to use the publisher's styles*.
|
746
|
+
Different e-readers word this setting in different ways.
|
717
747
|
Look for the option screen that allows you to set the fonts and font colors and disable it.
|
718
748
|
With publisher's styles active, you'll still be able to adjust the relative size of the fonts and margins and toggle between day, night and sepia mode.
|
719
749
|
|
720
|
-
When the book is viewed in EPUB2
|
721
|
-
EPUB2
|
750
|
+
When the book is viewed in EPUB2 e-readers and Kindle apps/devices which have reached their end-of-life (EOL), the e-book relies on the strong semantics of the HTML and some fallback styles to render properly.
|
751
|
+
EPUB2 e-readers, such as Aldiko, don't understand CSS3 styles and therefore miss out on some of subtleties in the formatting.
|
722
752
|
|
723
|
-
As mentioned in the <<About the Theme,theme section>>, the stylesheet attempts to provide as consistent a reading experience as possible in the common EPUB3
|
753
|
+
As mentioned in the <<About the Theme,theme section>>, the stylesheet attempts to provide as consistent a reading experience as possible in the common EPUB3 e-readers, despite the different CSS implementation rules and limitations unique to each e-book application.
|
724
754
|
Most of these obstacles were addressed using media queries or explicit classes.
|
725
755
|
Some we haven't conquered.
|
726
756
|
Yet.
|
@@ -751,15 +781,29 @@ To see all of the workarounds and why we chose certain style options, check out
|
|
751
781
|
|
752
782
|
WARNING: Don't use it!
|
753
783
|
|
754
|
-
|
784
|
+
{uri-send-to-kindle}[“Send to Kindle”] is a tempting choice for transferring MOBI files to a Kindle device.
|
785
|
+
However, it's utterly broken.
|
786
|
+
If you use this tool, don't be surprised if you see missing font-based icons, default fonts, and other font and style errors in your manuscript.
|
755
787
|
It's known to strip out all the font files and break the encoding of the document.
|
756
788
|
|
757
|
-
|
758
|
-
|
789
|
+
We *strongly* recommend you transfer the file to your device using either a USB cable or a sync service such as Dropbox.
|
790
|
+
Once transferred, Whispersync will detect the new file (usually looking in the Books folder) and add it to the “On Device” library.
|
759
791
|
|
760
|
-
It's
|
792
|
+
It's important to note that “Send to Kindle” is not reflective of the experience readers will have when shopping in the Kindle store.
|
761
793
|
If you use Kindle Direct Publishing (KDP) to publish your book, the integrity of your book will be preserved (to the degree that Amazon allows).
|
762
794
|
|
795
|
+
=== Look Inside
|
796
|
+
|
797
|
+
The Amazon Kindle store has a “Look Inside” feature, which aims to gives readers a glimpse at the contents of the book.
|
798
|
+
Sadly, it does no such thing.
|
799
|
+
Instead, it shows pages from the legacy MOBI document that kindlegen adds to your e-book file, not the higher fidelity KF8 document.
|
800
|
+
Therefore, the preview won't look at all like what the Kindle reader or application will actually show.
|
801
|
+
Custom fonts, font-based icons, and most styles will be missing.
|
802
|
+
|
803
|
+
This situation is unfortunate for authors.
|
804
|
+
What I recommend is to complain loudly to Amazon that they are hurting your sales by displaying a crippled version of your product.
|
805
|
+
Another option is to contact Amazon to opt-out of this so-called feature.
|
806
|
+
|
763
807
|
////
|
764
808
|
head-stop (default '.')
|
765
809
|
stack-head role (run-in is default)
|
@@ -803,6 +847,7 @@ Nexus ,
|
|
803
847
|
|
804
848
|
////
|
805
849
|
|
850
|
+
ifndef::env-site[]
|
806
851
|
== Contributing
|
807
852
|
|
808
853
|
In the spirit of free software, _everyone_ is encouraged to help improve this project.
|
@@ -900,6 +945,7 @@ or
|
|
900
945
|
You're now ready to test drive the development version of {project-name}!
|
901
946
|
|
902
947
|
Jump back to <<Getting Started>> to learn how to create an AsciiDoc document and convert it to EPUB3.
|
948
|
+
endif::[]
|
903
949
|
|
904
950
|
== Authors
|
905
951
|
|
@@ -907,7 +953,7 @@ Jump back to <<Getting Started>> to learn how to create an AsciiDoc document and
|
|
907
953
|
|
908
954
|
== Copyright
|
909
955
|
|
910
|
-
Copyright (C) 2014-
|
956
|
+
Copyright (C) 2014-2018 OpenDevise Inc. and the Asciidoctor Project.
|
911
957
|
Free use of this software is granted under the terms of the MIT License.
|
912
958
|
|
913
959
|
For the full text of the license, see the <<LICENSE#,LICENSE>> file.
|
@@ -921,5 +967,5 @@ Refer to the <<NOTICE#,NOTICE>> file for information about third-party Open Sour
|
|
921
967
|
* circled numbers from M+ 1mn for annotation numbers in listing blocks
|
922
968
|
* avatars for authors
|
923
969
|
* document command to generate the M+ 1p latin fonts
|
924
|
-
* recommended
|
970
|
+
* recommended e-readers (Readium, Gitden, Kindle, etc)
|
925
971
|
////
|
data/Rakefile
CHANGED
@@ -7,14 +7,17 @@ default_tasks = []
|
|
7
7
|
|
8
8
|
begin
|
9
9
|
require 'bundler/gem_tasks'
|
10
|
+
default_tasks << :build
|
10
11
|
|
12
|
+
# Enhance the release task to create an explicit commit for the release
|
13
|
+
#Rake::Task[:release].enhance [:commit_release]
|
14
|
+
|
15
|
+
# NOTE you don't need to push after updating version and committing locally
|
16
|
+
# WARNING no longer works; it's now necessary to get master in a state ready for tagging
|
11
17
|
task :commit_release do
|
12
18
|
Bundler::GemHelper.new.send :guard_clean
|
13
19
|
sh %(git commit --allow-empty -a -m 'Release #{Asciidoctor::Epub3::VERSION}')
|
14
20
|
end
|
15
|
-
|
16
|
-
# Enhance the release task to create an explicit commit for the release
|
17
|
-
Rake::Task[:release].enhance [:commit_release]
|
18
21
|
rescue LoadError
|
19
22
|
end
|
20
23
|
|
Binary file
|
Binary file
|
@@ -104,6 +104,40 @@ body code, body kbd, body pre, pre :not(code) {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
107
|
+
/* Use darker font colors on Kindle Paperwhite */
|
108
|
+
@media amzn-kf8 and (device-height: 1024px) and (device-width: 758px),
|
109
|
+
amzn-kf8 and (device-height: 758px) and (device-width: 1024px) {
|
110
|
+
body p,
|
111
|
+
div.abstract > p,
|
112
|
+
ul, ol, li, dl, dt, dd, footer,
|
113
|
+
div.verse .attribution, table.table th, table.table td,
|
114
|
+
figcaption, caption,
|
115
|
+
h1, h2, h3, h4, h5 {
|
116
|
+
color: #000000;
|
117
|
+
}
|
118
|
+
|
119
|
+
body a:link,
|
120
|
+
div.abstract > p a:link {
|
121
|
+
color: #000000;
|
122
|
+
-webkit-text-fill-color: #000000;
|
123
|
+
}
|
124
|
+
|
125
|
+
body a:visited {
|
126
|
+
color: #333332;
|
127
|
+
-webkit-text-fill-color: #333332;
|
128
|
+
}
|
129
|
+
|
130
|
+
.chapter-header {
|
131
|
+
color: #191918;
|
132
|
+
border-bottom-color: #191918;
|
133
|
+
}
|
134
|
+
|
135
|
+
h1.chapter-title .subtitle,
|
136
|
+
.chapter-header p.byline {
|
137
|
+
color: #000000;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
107
141
|
.chapter-header p.byline {
|
108
142
|
height: auto; /* Aldiko requires this value to be 0; reset it for all others */
|
109
143
|
}
|
data/data/styles/epub3.css
CHANGED
@@ -81,7 +81,7 @@ b, strong {
|
|
81
81
|
|
82
82
|
b.button {
|
83
83
|
font-weight: normal;
|
84
|
-
text-shadow: 1px 0 0 #
|
84
|
+
text-shadow: 1px 0 0 #666665;
|
85
85
|
color: #191918;
|
86
86
|
white-space: nowrap;
|
87
87
|
}
|
@@ -138,6 +138,7 @@ kbd {
|
|
138
138
|
|
139
139
|
img {
|
140
140
|
border: 0;
|
141
|
+
max-width: 100%;
|
141
142
|
}
|
142
143
|
|
143
144
|
mark {
|
@@ -568,7 +569,7 @@ h5 {
|
|
568
569
|
|
569
570
|
font-size: 0.9em;
|
570
571
|
font-weight: 700;
|
571
|
-
text-transform: uppercase;
|
572
|
+
text-transform: uppercase; /* not supported in Adobe Digital Editions */
|
572
573
|
margin-top: 1.11em; /* 1rem */
|
573
574
|
margin-bottom: -0.972em; /* -0.875rem */
|
574
575
|
}
|
@@ -583,10 +584,12 @@ h5 code {
|
|
583
584
|
|
584
585
|
/* Kindle strips (or unwraps) <header> tags, so we use an inner div to style */
|
585
586
|
.chapter-header {
|
586
|
-
background-color: #333332;
|
587
587
|
/* NOTE div must have at least 1px top padding for background to fill */
|
588
|
-
|
588
|
+
/* would like to use vh units for top and bottom padding */
|
589
|
+
/*padding: 0.75em 1.5em 0.25em 1.5em;*/
|
590
|
+
padding: 0.25em 0;
|
589
591
|
margin-bottom: 2.5em;
|
592
|
+
border-bottom: 1px solid #666665;
|
590
593
|
/* TODO maybe what we need to get articles to start in left column
|
591
594
|
-webkit-column-break-before: left;
|
592
595
|
page-break-before: left;
|
@@ -599,16 +602,15 @@ h1.chapter-title {
|
|
599
602
|
margin-top: 3.5em; /* 4.2rem - would like to use 9vh */
|
600
603
|
margin-bottom: 0;
|
601
604
|
padding-bottom: 0.8333em; /* 1.2rem */
|
602
|
-
color: #
|
603
|
-
text-transform: uppercase;
|
605
|
+
color: #666665;
|
606
|
+
text-transform: uppercase; /* not supported in Adobe Digital Editions */
|
604
607
|
word-spacing: -0.075em;
|
605
608
|
letter-spacing: -0.01em;
|
606
|
-
border-bottom: 1px solid #DCDCDE;
|
607
609
|
}
|
608
610
|
|
609
611
|
h1.chapter-title .subtitle {
|
610
612
|
font-weight: 400;
|
611
|
-
color: #
|
613
|
+
color: #333332;
|
612
614
|
display: block;
|
613
615
|
font-size: 1.5em;
|
614
616
|
margin: 0 0 0 0.75em; /* would like to use 2vw */
|
@@ -625,7 +627,7 @@ h1.chapter-title b {
|
|
625
627
|
}
|
626
628
|
|
627
629
|
.chapter-header p.byline {
|
628
|
-
color: #
|
630
|
+
color: #333332;
|
629
631
|
/* float left and height 0 takes this line out of the flow */
|
630
632
|
float: left;
|
631
633
|
height: 0;
|
@@ -728,7 +730,8 @@ figure.image {
|
|
728
730
|
}
|
729
731
|
|
730
732
|
figure.image img {
|
731
|
-
|
733
|
+
display: block;
|
734
|
+
margin: 0 auto;
|
732
735
|
}
|
733
736
|
|
734
737
|
figure.coalesce {
|
@@ -794,7 +797,7 @@ aside.sidebar.titled {
|
|
794
797
|
}
|
795
798
|
|
796
799
|
aside.sidebar > h2 {
|
797
|
-
|
800
|
+
text-transform: uppercase; /* not supported in Adobe Digital Editions */
|
798
801
|
font-size: 1em;
|
799
802
|
/*
|
800
803
|
font-weight: 700;
|
@@ -899,18 +902,6 @@ blockquote footer .context {
|
|
899
902
|
color: #666665;
|
900
903
|
}
|
901
904
|
|
902
|
-
/* Kindle requires text-align: center on surrounding div to align image to center */
|
903
|
-
figure.image div.content {
|
904
|
-
text-align: center;
|
905
|
-
}
|
906
|
-
|
907
|
-
/* in the event the viewer adds display: block to the image */
|
908
|
-
figure.image img {
|
909
|
-
/* max-width not supported in Kindle, need to use a media query to add */
|
910
|
-
/*max-width: 95%;*/
|
911
|
-
margin: 0 auto;
|
912
|
-
}
|
913
|
-
|
914
905
|
pre {
|
915
906
|
text-align: left; /* fix for Namo */
|
916
907
|
margin-top: 1em; /* 0.85rem */
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: utf-8
|
2
2
|
require_relative 'spine_item_processor'
|
3
3
|
require_relative 'font_icon_map'
|
4
4
|
|
@@ -58,8 +58,6 @@ class ContentConverter
|
|
58
58
|
|
59
59
|
XmlElementRx = /<\/?.+?>/
|
60
60
|
CharEntityRx = /&#(\d{2,6});/
|
61
|
-
NamedEntityRx = /&([A-Z]+);/
|
62
|
-
UppercaseTagRx = /<(\/)?([A-Z]+)>/
|
63
61
|
|
64
62
|
FromHtmlSpecialCharsMap = {
|
65
63
|
'<' => '<',
|
@@ -100,22 +98,17 @@ class ContentConverter
|
|
100
98
|
def document node
|
101
99
|
docid = node.id
|
102
100
|
|
103
|
-
if (doctitle = node.doctitle partition: true,
|
104
|
-
title = doctitle.main
|
105
|
-
title_upper = title.upcase
|
101
|
+
if (doctitle = node.doctitle partition: true, use_fallback: true).subtitle?
|
102
|
+
title = %(#{doctitle.main} )
|
106
103
|
subtitle = doctitle.subtitle
|
107
104
|
else
|
108
105
|
# HACK until we get proper handling of title-only in CSS
|
109
|
-
title =
|
106
|
+
title = ''
|
110
107
|
subtitle = doctitle.combined
|
111
108
|
end
|
112
109
|
|
113
|
-
doctitle_sanitized = doctitle.
|
110
|
+
doctitle_sanitized = (node.doctitle sanitize: true, use_fallback: true).to_s
|
114
111
|
subtitle_formatted = subtitle.split.map {|w| %(<b>#{w}</b>) } * ' '
|
115
|
-
# FIXME use uppercase pcdata helper to make less fragile (see logic in Asciidoctor PDF)
|
116
|
-
subtitle_formatted_upper = subtitle_formatted.upcase
|
117
|
-
.gsub(UppercaseTagRx) { %(<#{$1}#{$2.downcase}>) }
|
118
|
-
.gsub(NamedEntityRx) { %(&#{$1.downcase};) }
|
119
112
|
|
120
113
|
if (node.attr 'publication-type', 'book') == 'book'
|
121
114
|
byline = nil
|
@@ -171,7 +164,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
171
164
|
<section class="chapter" title="#{doctitle_sanitized.gsub '"', '"'}" epub:type="chapter" id="#{docid}">
|
172
165
|
#{icon_css_scoped}<header>
|
173
166
|
<div class="chapter-header">
|
174
|
-
#{byline}<h1 class="chapter-title">#{
|
167
|
+
#{byline}<h1 class="chapter-title">#{title}#{subtitle ? %[<small class="subtitle">#{subtitle_formatted}</small>] : ''}</h1>
|
175
168
|
</div>
|
176
169
|
</header>
|
177
170
|
#{content})]
|
@@ -274,6 +267,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
274
267
|
end
|
275
268
|
|
276
269
|
def admonition node
|
270
|
+
id_attr = node.id ? %( id="#{node.id}") : nil
|
277
271
|
if node.title?
|
278
272
|
title = node.title
|
279
273
|
title_sanitized = xml_sanitize title
|
@@ -294,7 +288,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
294
288
|
when 'important', 'warning', 'caution'
|
295
289
|
'warning'
|
296
290
|
end
|
297
|
-
%(<aside class="admonition #{type}"#{title_attr} epub:type="#{epub_type}">
|
291
|
+
%(<aside#{id_attr} class="admonition #{type}"#{title_attr} epub:type="#{epub_type}">
|
298
292
|
#{title_el}<div class="content">
|
299
293
|
#{convert_content node}
|
300
294
|
</div>
|
@@ -302,9 +296,10 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
302
296
|
end
|
303
297
|
|
304
298
|
def example node
|
299
|
+
id_attr = node.id ? %( id="#{node.id}") : nil
|
305
300
|
title_div = node.title? ? %(<div class="example-title">#{node.title}</div>
|
306
301
|
) : nil
|
307
|
-
%(<div class="example">
|
302
|
+
%(<div#{id_attr} class="example">
|
308
303
|
#{title_div}<div class="example-content">
|
309
304
|
#{convert_content node}
|
310
305
|
</div>
|
@@ -344,6 +339,9 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
344
339
|
end
|
345
340
|
|
346
341
|
def quote node
|
342
|
+
id_attr = %( id="#{node.id}") if node.id
|
343
|
+
class_attr = (role = node.role) ? %( class="blockquote #{role}") : ' class="blockquote"'
|
344
|
+
|
347
345
|
footer_content = []
|
348
346
|
if (attribution = node.attr 'attribution')
|
349
347
|
footer_content << attribution
|
@@ -363,7 +361,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
363
361
|
content = (convert_content node).strip.
|
364
362
|
sub(OpenParagraphTagRx, '<p><span class="open-quote">“</span>').
|
365
363
|
sub(CloseParagraphTagRx, '<span class="close-quote">”</span></p>')
|
366
|
-
%(<div
|
364
|
+
%(<div#{id_attr}#{class_attr}>
|
367
365
|
<blockquote>
|
368
366
|
#{content}#{footer_tag}
|
369
367
|
</blockquote>
|
@@ -371,6 +369,9 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
371
369
|
end
|
372
370
|
|
373
371
|
def verse node
|
372
|
+
id_attr = %( id="#{node.id}") if node.id
|
373
|
+
class_attr = (role = node.role) ? %( class="verse #{role}") : ' class="verse"'
|
374
|
+
|
374
375
|
footer_content = []
|
375
376
|
if (attribution = node.attr 'attribution')
|
376
377
|
footer_content << attribution
|
@@ -383,7 +384,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
383
384
|
|
384
385
|
footer_tag = footer_content.size > 0 ? %(
|
385
386
|
<span class="attribution">~ #{footer_content * ', '}</span>) : nil
|
386
|
-
%(<div
|
387
|
+
%(<div#{id_attr}#{class_attr}>
|
387
388
|
<pre>#{node.content}#{footer_tag}</pre>
|
388
389
|
</div>)
|
389
390
|
end
|
@@ -395,9 +396,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
395
396
|
title = node.title
|
396
397
|
title_sanitized = xml_sanitize title
|
397
398
|
title_attr = %( title="#{title_sanitized}")
|
398
|
-
|
399
|
-
title_upper = title.upcase.gsub(NamedEntityRx) { %(&#{$1.downcase};) }
|
400
|
-
title_el = %(<h2>#{title_upper}</h2>
|
399
|
+
title_el = %(<h2>#{title}</h2>
|
401
400
|
)
|
402
401
|
else
|
403
402
|
title_attr = nil
|
@@ -418,14 +417,16 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
418
417
|
frame_class = {
|
419
418
|
'all' => 'table-framed',
|
420
419
|
'topbot' => 'table-framed-topbot',
|
421
|
-
'sides' => 'table-framed-sides'
|
420
|
+
'sides' => 'table-framed-sides',
|
421
|
+
'none' => ''
|
422
422
|
}
|
423
423
|
grid_class = {
|
424
424
|
'all' => 'table-grid',
|
425
425
|
'rows' => 'table-grid-rows',
|
426
|
-
'cols' => 'table-grid-cols'
|
426
|
+
'cols' => 'table-grid-cols',
|
427
|
+
'none' => ''
|
427
428
|
}
|
428
|
-
table_classes = %W(table #{frame_class[
|
429
|
+
table_classes = %W(table #{frame_class[node.attr 'frame'] || frame_class['topbot']} #{grid_class[node.attr 'grid'] || grid_class['rows']})
|
429
430
|
if (role = node.role)
|
430
431
|
table_classes << role
|
431
432
|
end
|
@@ -625,16 +626,14 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
625
626
|
def image node
|
626
627
|
target = node.attr 'target'
|
627
628
|
type = (::File.extname target)[1..-1]
|
629
|
+
id_attr = node.id ? %( id="#{node.id}") : ''
|
628
630
|
img_attrs = [%(alt="#{node.attr 'alt'}")]
|
629
631
|
case type
|
630
632
|
when 'svg'
|
631
633
|
img_attrs << %(style="width: #{node.attr 'scaledwidth', '100%'}")
|
632
634
|
# TODO make this a convenience method on document
|
633
|
-
epub_properties = (node.document.
|
634
|
-
unless epub_properties.include? 'svg'
|
635
|
-
epub_properties << 'svg'
|
636
|
-
node.document.attributes['epub-properties'] = epub_properties
|
637
|
-
end
|
635
|
+
epub_properties = (node.document.attributes['epub-properties'] ||= [])
|
636
|
+
epub_properties << 'svg' unless epub_properties.include? 'svg'
|
638
637
|
else
|
639
638
|
if node.attr? 'scaledwidth'
|
640
639
|
img_attrs << %(style="width: #{node.attr 'scaledwidth'}")
|
@@ -657,7 +656,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
657
656
|
end
|
658
657
|
end
|
659
658
|
=end
|
660
|
-
%(<figure class="image">
|
659
|
+
%(<figure#{id_attr} class="image#{prepend_space node.role}">
|
661
660
|
<div class="content">
|
662
661
|
<img src="#{node.image_uri node.attr('target')}" #{img_attrs * ' '}/>
|
663
662
|
</div>#{node.title? ? %[
|
@@ -692,8 +691,11 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
692
691
|
id_attr = nil unless @xrefs_seen.add? refid
|
693
692
|
refdoc = doc.references[:spine_items].find {|it| refdoc_id == (it.id || (it.attr 'docname')) }
|
694
693
|
if refdoc
|
695
|
-
|
696
|
-
|
694
|
+
# QUESTION should we invoke xreftext for references in other documents?
|
695
|
+
if (refs = refdoc.references[:refs]) && ::Asciidoctor::Document === (ref = refs[refdoc_refid])
|
696
|
+
text ||= (ref.attr 'docreftext') || ref.doctitle
|
697
|
+
elsif (xreftext = refdoc.references[:ids][refdoc_refid])
|
698
|
+
text ||= xreftext
|
697
699
|
else
|
698
700
|
warn %(asciidoctor: WARNING: #{::File.basename(doc.attr 'docfile')}: invalid reference to unknown anchor in #{refdoc_id} chapter: #{refdoc_refid})
|
699
701
|
end
|
@@ -702,10 +704,18 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
702
704
|
end
|
703
705
|
else
|
704
706
|
id_attr = (@xrefs_seen.add? refid) ? %( id="xref-#{refid}") : nil
|
705
|
-
if (
|
706
|
-
|
707
|
+
if (refs = doc.references[:refs])
|
708
|
+
if ::Asciidoctor::AbstractNode === (ref = refs[refid])
|
709
|
+
xreftext = text || ref.xreftext((@xrefstyle ||= (doc.attr 'xrefstyle')))
|
710
|
+
end
|
707
711
|
else
|
708
|
-
|
712
|
+
xreftext = doc.references[:ids][refid]
|
713
|
+
end
|
714
|
+
|
715
|
+
if xreftext
|
716
|
+
text ||= xreftext
|
717
|
+
else
|
718
|
+
# FIXME we get false negatives for reference to bibref when using Asciidoctor < 1.5.6
|
709
719
|
warn %(asciidoctor: WARNING: #{::File.basename(doc.attr 'docfile')}: invalid reference to unknown local anchor (or valid bibref): #{refid})
|
710
720
|
end
|
711
721
|
end
|
@@ -757,8 +767,16 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
757
767
|
%(<i class="#{i_classes * ' '}"></i>)
|
758
768
|
else
|
759
769
|
target = node.image_uri node.target
|
760
|
-
|
761
|
-
|
770
|
+
img_attrs = [%(alt="#{node.attr 'alt'}"), %(class="inline#{node.role? ? " #{node.role}" : ''}")]
|
771
|
+
if target.end_with? '.svg'
|
772
|
+
img_attrs << %(style="width: #{node.attr 'scaledwidth', '100%'}")
|
773
|
+
# TODO make this a convenience method on document
|
774
|
+
epub_properties = (node.document.attributes['epub-properties'] ||= [])
|
775
|
+
epub_properties << 'svg' unless epub_properties.include? 'svg'
|
776
|
+
elsif node.attr? 'scaledwidth'
|
777
|
+
img_attrs << %(style="width: #{node.attr 'scaledwidth'}")
|
778
|
+
end
|
779
|
+
%(<img src="#{target}" #{img_attrs * ' '}/>)
|
762
780
|
end
|
763
781
|
end
|
764
782
|
|
@@ -839,11 +857,16 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
839
857
|
end
|
840
858
|
nil
|
841
859
|
end
|
860
|
+
|
861
|
+
# Prepend a space to the value if it's non-nil, otherwise return empty string.
|
862
|
+
def prepend_space value
|
863
|
+
value ? %( #{value}) : ''
|
864
|
+
end
|
842
865
|
end
|
843
866
|
|
844
867
|
class DocumentIdGenerator
|
845
868
|
ReservedIds = %w(cover nav ncx)
|
846
|
-
CharRefRx = /&(?:([a-zA-Z]{2
|
869
|
+
CharRefRx = /&(?:([a-zA-Z][a-zA-Z]+\d{0,2})|#(\d\d\d{0,4})|#x([\da-fA-F][\da-fA-F][\da-fA-F]{0,3}));/
|
847
870
|
if defined? __dir__
|
848
871
|
InvalidIdCharsRx = /[^\p{Word}]+/
|
849
872
|
LeadingDigitRx = /^\p{Nd}/
|
@@ -94,7 +94,19 @@ module GepubBuilderMixin
|
|
94
94
|
</platform>
|
95
95
|
</display_options>'.to_ios unless format == :kf8
|
96
96
|
|
97
|
-
|
97
|
+
# https://github.com/asciidoctor/asciidoctor-epub3/issues/120
|
98
|
+
#
|
99
|
+
# 'application/x-font-ttf' causes warnings in epubcheck 4.0.2,
|
100
|
+
# "non-standard font type". Discussion:
|
101
|
+
# https://www.mobileread.com/forums/showthread.php?t=231272
|
102
|
+
#
|
103
|
+
# 3.1 spec recommends 'application/font-sfnt', but epubcheck doesn't
|
104
|
+
# implement that yet (warnings). https://idpf.github.io/epub-cmt/v3/
|
105
|
+
#
|
106
|
+
# 3.0 spec recommends 'application/vnd.ms-opentype', this works without
|
107
|
+
# warnings.
|
108
|
+
# http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-core-media-types
|
109
|
+
with_media_type 'application/vnd.ms-opentype' do
|
98
110
|
font_files.each do |font_file|
|
99
111
|
file font_file => ::File.join(DATA_DIR, font_file)
|
100
112
|
end
|
@@ -123,7 +135,7 @@ module GepubBuilderMixin
|
|
123
135
|
width, height = 1050, 1600
|
124
136
|
end
|
125
137
|
else
|
126
|
-
warn %(asciidoctor: ERROR: front cover image not found or readable: #{image_path})
|
138
|
+
warn %(asciidoctor: ERROR: #{::File.basename(doc.attr 'docfile')}: front cover image not found or readable: #{::File.expand_path image_path, workdir})
|
127
139
|
image_path = nil
|
128
140
|
end
|
129
141
|
end
|
@@ -210,7 +222,6 @@ body > svg {
|
|
210
222
|
nil
|
211
223
|
end
|
212
224
|
|
213
|
-
# FIXME add inline images
|
214
225
|
def add_content_images doc, images
|
215
226
|
docimagesdir = (doc.attr 'imagesdir', '.').chomp '/'
|
216
227
|
docimagesdir = (docimagesdir == '.' ? nil : %(#{docimagesdir}/))
|
@@ -218,15 +229,12 @@ body > svg {
|
|
218
229
|
workdir = (workdir = doc.attr 'docdir').nil_or_empty? ? '.' : workdir
|
219
230
|
resources workdir: workdir do
|
220
231
|
images.each do |image|
|
221
|
-
|
222
|
-
imagesdir = (imagesdir == '.' ? nil : %(#{imagesdir}/))
|
223
|
-
image_path = %(#{imagesdir}#{image.attr 'target'})
|
224
|
-
if image_path.start_with? %(#{docimagesdir}jacket/cover.)
|
232
|
+
if (image_path = image[:path]).start_with? %(#{docimagesdir}jacket/cover.)
|
225
233
|
warn %(asciidoctor: WARNING: image path is reserved for cover artwork: #{image_path}; skipping image found in content)
|
226
234
|
elsif ::File.readable? image_path
|
227
235
|
file image_path
|
228
236
|
else
|
229
|
-
warn %(asciidoctor: ERROR: image not found or not readable: #{image_path})
|
237
|
+
warn %(asciidoctor: ERROR: #{::File.basename image[:docfile]}: image not found or not readable: #{::File.expand_path image_path, workdir})
|
230
238
|
end
|
231
239
|
end
|
232
240
|
end
|
@@ -266,7 +274,7 @@ body > svg {
|
|
266
274
|
end
|
267
275
|
|
268
276
|
def add_content doc
|
269
|
-
builder, spine, format = self, @spine, @format
|
277
|
+
builder, spine, format, images = self, @spine, @format, {}
|
270
278
|
workdir = (doc.attr 'docdir').nil_or_empty? ? '.' : workdir
|
271
279
|
resources workdir: workdir do
|
272
280
|
extend GepubResourceBuilderMixin
|
@@ -277,13 +285,21 @@ body > svg {
|
|
277
285
|
builder.add_cover_page doc, self, @book.manifest unless format == :kf8
|
278
286
|
builder.add_front_matter_page doc, self
|
279
287
|
spine.each_with_index do |item, i|
|
288
|
+
docfile = item.attr 'docfile'
|
289
|
+
imagesdir = (item.attr 'imagesdir', '.').chomp '/'
|
290
|
+
imagesdir = (imagesdir == '.' ? '' : %(#{imagesdir}/))
|
280
291
|
file %(#{item.id || (item.attr 'docname')}.xhtml) => (builder.postprocess_xhtml item.convert, format)
|
281
292
|
add_property 'svg' if ((item.attr 'epub-properties') || []).include? 'svg'
|
293
|
+
# QUESTION should we pass the document itself?
|
294
|
+
item.references[:images].each do |target|
|
295
|
+
images[image_path = %(#{imagesdir}#{target})] ||= { docfile: docfile, path: image_path }
|
296
|
+
end
|
282
297
|
# QUESTION reenable?
|
283
298
|
#linear 'yes' if i == 0
|
284
299
|
end
|
285
300
|
end
|
286
301
|
end
|
302
|
+
add_content_images doc, images.values
|
287
303
|
nil
|
288
304
|
end
|
289
305
|
|
@@ -407,7 +423,12 @@ body > svg {
|
|
407
423
|
def select_fonts filename, scripts = 'latin'
|
408
424
|
font_css = ::File.read(filename)
|
409
425
|
font_css = font_css.gsub(/(?<=-)latin(?=\.ttf\))/, scripts) unless scripts == 'latin'
|
410
|
-
|
426
|
+
|
427
|
+
# match CSS font urls in the forms of:
|
428
|
+
# src: url(../fonts/notoserif-regular-latin.ttf);
|
429
|
+
# src: url(../fonts/notoserif-regular-latin.ttf) format("truetype");
|
430
|
+
font_list = font_css.scan(/url\(\.\.\/([^)]+\.ttf)\)/).flatten
|
431
|
+
|
411
432
|
return [font_list, font_css.to_ios]
|
412
433
|
end
|
413
434
|
|
@@ -476,11 +497,9 @@ class Packager
|
|
476
497
|
target = options[:target]
|
477
498
|
dest = File.dirname target
|
478
499
|
|
479
|
-
images = spine.map {|item| item.find_by context: :image }.compact.flatten
|
480
|
-
.uniq {|img| %(#{(img.document.attr 'imagesdir', '.').chomp '/'}/#{img.attr 'target'}) }
|
481
500
|
# FIXME authors should be aggregated already on parent document
|
482
501
|
authors = if doc.attr? 'authors'
|
483
|
-
(doc.attr 'authors').split(GepubBuilderMixin::CsvDelimiterRx).concat(spine.map {|item| item.attr 'author' }).uniq
|
502
|
+
(doc.attr 'authors').split(GepubBuilderMixin::CsvDelimiterRx).concat(spine.map {|item| item.attr 'author' }.compact).uniq
|
484
503
|
else
|
485
504
|
[]
|
486
505
|
end
|
@@ -569,8 +588,6 @@ class Packager
|
|
569
588
|
usernames = spine.map {|item| item.attr 'username' }.compact.uniq
|
570
589
|
add_profile_images doc, usernames
|
571
590
|
end
|
572
|
-
# QUESTION move add_content_images to add_content method?
|
573
|
-
add_content_images doc, images
|
574
591
|
add_content doc
|
575
592
|
end
|
576
593
|
|
@@ -16,13 +16,17 @@ class SpineItemProcessor < Extensions::IncludeProcessor
|
|
16
16
|
inherited_attrs = spine_doc.attributes.dup
|
17
17
|
# QUESTION should we keep backend-epub3 for convenience?
|
18
18
|
%w(backend-epub3 backend-epub3-doctype-book docdir docfile docname doctitle outfilesuffix spine).each {|key| inherited_attrs.delete key }
|
19
|
+
if (leveloffset = inherited_attrs['leveloffset'])
|
20
|
+
leveloffset = inherited_attrs['leveloffset'] = %(#{leveloffset}@) unless leveloffset.end_with? '@'
|
21
|
+
end
|
19
22
|
|
20
23
|
# parse header to get author information
|
21
24
|
spine_item_doc_meta = ::Asciidoctor.load_file include_file,
|
22
25
|
safe: spine_doc.safe,
|
23
26
|
backend: 'epub3-xhtml5',
|
24
27
|
doctype: :article,
|
25
|
-
parse_header_only: true
|
28
|
+
parse_header_only: true,
|
29
|
+
attributes: leveloffset ? { 'leveloffset' => leveloffset } : nil
|
26
30
|
|
27
31
|
# blank out author information if present in sub-document
|
28
32
|
# 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
|
@@ -51,6 +55,7 @@ class SpineItemProcessor < Extensions::IncludeProcessor
|
|
51
55
|
backend: 'epub3-xhtml5',
|
52
56
|
doctype: :article,
|
53
57
|
header_footer: true,
|
58
|
+
catalog_assets: true,
|
54
59
|
attributes: inherited_attrs
|
55
60
|
|
56
61
|
# restore attributes to those defined in the document header
|
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.8
|
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: 2018-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -67,10 +67,8 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.3.6
|
70
|
-
description:
|
71
|
-
and KF8/MOBI (Kindle) e-book archives.
|
72
|
-
|
73
|
-
'
|
70
|
+
description: |
|
71
|
+
An extension for Asciidoctor that converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book archives.
|
74
72
|
email: dan@opendevise.com
|
75
73
|
executables:
|
76
74
|
- asciidoctor-epub3
|
@@ -168,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
166
|
version: 1.3.1
|
169
167
|
requirements: []
|
170
168
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.6
|
169
|
+
rubygems_version: 2.7.6
|
172
170
|
signing_key:
|
173
171
|
specification_version: 4
|
174
172
|
summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats
|