asciidoctor-epub3 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.adoc +22 -0
- data/NOTICE.adoc +53 -0
- data/README.adoc +744 -0
- data/Rakefile +78 -0
- data/bin/adb-push-ebook +25 -0
- data/bin/asciidoctor-epub3 +15 -0
- data/data/fonts/assorted-icons.ttf +0 -0
- data/data/fonts/fontawesome-icons.ttf +0 -0
- data/data/fonts/mplus1mn-bold-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-bolditalic-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-italic-ascii.ttf +0 -0
- data/data/fonts/mplus1mn-regular-ascii-conums.ttf +0 -0
- data/data/fonts/mplus1p-bold-latin-cyrillic.ttf +0 -0
- data/data/fonts/mplus1p-bold-latin-ext.ttf +0 -0
- data/data/fonts/mplus1p-bold-latin.ttf +0 -0
- data/data/fonts/mplus1p-bold-multilingual.ttf +0 -0
- data/data/fonts/mplus1p-light-latin-cyrillic.ttf +0 -0
- data/data/fonts/mplus1p-light-latin-ext.ttf +0 -0
- data/data/fonts/mplus1p-light-latin.ttf +0 -0
- data/data/fonts/mplus1p-light-multilingual.ttf +0 -0
- data/data/fonts/mplus1p-regular-latin-cyrillic.ttf +0 -0
- data/data/fonts/mplus1p-regular-latin-ext.ttf +0 -0
- data/data/fonts/mplus1p-regular-latin.ttf +0 -0
- data/data/fonts/mplus1p-regular-multilingual.ttf +0 -0
- data/data/fonts/notoserif-bold-latin-cyrillic.ttf +0 -0
- data/data/fonts/notoserif-bold-latin-ext.ttf +0 -0
- data/data/fonts/notoserif-bold-latin.ttf +0 -0
- data/data/fonts/notoserif-bold-multilingual.ttf +0 -0
- data/data/fonts/notoserif-bolditalic-latin-cyrillic.ttf +0 -0
- data/data/fonts/notoserif-bolditalic-latin-ext.ttf +0 -0
- data/data/fonts/notoserif-bolditalic-latin.ttf +0 -0
- data/data/fonts/notoserif-bolditalic-multilingual.ttf +0 -0
- data/data/fonts/notoserif-italic-latin-cyrillic.ttf +0 -0
- data/data/fonts/notoserif-italic-latin-ext.ttf +0 -0
- data/data/fonts/notoserif-italic-latin.ttf +0 -0
- data/data/fonts/notoserif-italic-multilingual.ttf +0 -0
- data/data/fonts/notoserif-regular-latin-cyrillic.ttf +0 -0
- data/data/fonts/notoserif-regular-latin-ext.ttf +0 -0
- data/data/fonts/notoserif-regular-latin.ttf +0 -0
- data/data/fonts/notoserif-regular-multilingual.ttf +0 -0
- data/data/images/default-avatar.jpg +0 -0
- data/data/images/default-avatar.png +0 -0
- data/data/images/default-avatar.svg +67 -0
- data/data/images/default-cover-large.png +0 -0
- data/data/images/default-cover.png +0 -0
- data/data/images/default-cover.svg +53 -0
- data/data/images/default-headshot.jpg +0 -0
- data/data/images/default-headshot.png +0 -0
- data/data/samples/asciidoctor-epub3-readme.adoc +744 -0
- data/data/samples/asciidoctor-js-extension.adoc +46 -0
- data/data/samples/asciidoctor-js-introduction.adoc +91 -0
- data/data/samples/i18n.adoc +161 -0
- data/data/samples/images/asciidoctor-js-chrome-extension.png +0 -0
- data/data/samples/images/avatars/graphitefriction.png +0 -0
- data/data/samples/images/avatars/mogztter.png +0 -0
- data/data/samples/images/avatars/mojavelinux.png +0 -0
- data/data/samples/images/correct-text-justification.png +0 -0
- data/data/samples/images/incorrect-text-justification.png +0 -0
- data/data/samples/images/screenshots/chapter-title-day.png +0 -0
- data/data/samples/images/screenshots/chapter-title.png +0 -0
- data/data/samples/images/screenshots/figure-admonition.png +0 -0
- data/data/samples/images/screenshots/section-title-paragraph.png +0 -0
- data/data/samples/images/screenshots/sidebar.png +0 -0
- data/data/samples/images/screenshots/table.png +0 -0
- data/data/samples/images/screenshots/text.png +0 -0
- data/data/samples/sample-book.adoc +20 -0
- data/data/samples/sample-content.adoc +168 -0
- data/data/styles/color-palette.css +28 -0
- data/data/styles/epub3-css3-only.css +161 -0
- data/data/styles/epub3-fonts.css +94 -0
- data/data/styles/epub3.css +1293 -0
- data/lib/asciidoctor-epub3.rb +5 -0
- data/lib/asciidoctor-epub3/converter.rb +859 -0
- data/lib/asciidoctor-epub3/core_ext/string.rb +7 -0
- data/lib/asciidoctor-epub3/font_icon_map.rb +376 -0
- data/lib/asciidoctor-epub3/packager.rb +466 -0
- data/lib/asciidoctor-epub3/spine_item_processor.rb +72 -0
- data/lib/asciidoctor-epub3/version.rb +5 -0
- data/scripts/generate-font-subsets.pe +225 -0
- metadata +192 -0
data/Rakefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path '../lib/asciidoctor-epub3/version', __FILE__
|
3
|
+
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
default_tasks = []
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'bundler/gem_tasks'
|
10
|
+
|
11
|
+
task :commit_release do
|
12
|
+
Bundler::GemHelper.new.send :guard_clean
|
13
|
+
sh %(git commit --allow-empty -a -m 'Release #{Asciidoctor::Epub3::VERSION}')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Enhance the release task to create an explicit commit for the release
|
17
|
+
Rake::Task[:release].enhance [:commit_release]
|
18
|
+
rescue LoadError
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'rdoc/task'
|
23
|
+
Rake::RDocTask.new do |t|
|
24
|
+
t.rdoc_dir = 'rdoc'
|
25
|
+
t.title = %(Asciidoctor EPUB3 #{Asciidoctor::Epub3::VERSION})
|
26
|
+
t.main = %(README.adoc)
|
27
|
+
t.rdoc_files.include 'README.adoc', 'LICENSE.adoc', 'NOTICE.adoc', 'lib/**/*.rb', 'bin/**/*'
|
28
|
+
end
|
29
|
+
rescue LoadError
|
30
|
+
end
|
31
|
+
|
32
|
+
=begin NOT CURRENTLY IN USE
|
33
|
+
begin
|
34
|
+
require 'rake/testtask'
|
35
|
+
Rake::TestTask.new do |t|
|
36
|
+
t.libs << 'test'
|
37
|
+
t.pattern = 'test/**/*_test.rb'
|
38
|
+
t.verbose = true
|
39
|
+
t.warning = true
|
40
|
+
if RUBY_VERSION >= '2'
|
41
|
+
t.options = '--tty=no'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
default_tasks << :test
|
45
|
+
rescue LoadError
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
require 'cucumber'
|
50
|
+
require 'cucumber/rake/task'
|
51
|
+
CUKE_RESULTS_FILE = 'feature-results.html'
|
52
|
+
ARUBA_TMP_DIR = 'tmp'
|
53
|
+
CLEAN << CUKE_RESULTS_FILE if File.file? CUKE_RESULTS_FILE
|
54
|
+
CLEAN << ARUBA_TMP_DIR if File.directory? ARUBA_TMP_DIR
|
55
|
+
desc 'Run features'
|
56
|
+
Cucumber::Rake::Task.new :features do |t|
|
57
|
+
opts = %(features --format html -o #{CUKE_RESULTS_FILE} --format progress -x --tags ~@pending)
|
58
|
+
opts = %(#{opts} --tags #{ENV['TAGS']}) if ENV['TAGS']
|
59
|
+
t.cucumber_opts = opts
|
60
|
+
t.fork = false
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
64
|
+
Cucumber::Rake::Task.new 'features:wip' do |t|
|
65
|
+
#t.cucumber_opts = %(features --format html -o #{CUKE_RESULTS_FILE} --format pretty -x -s --tags @wip)
|
66
|
+
t.cucumber_opts = %(features --format html -o #{CUKE_RESULTS_FILE} --format progress -x --tags @wip)
|
67
|
+
t.fork = false
|
68
|
+
end
|
69
|
+
|
70
|
+
default_tasks << :features
|
71
|
+
task :cucumber => :features
|
72
|
+
task 'cucumber:wip' => 'features:wip'
|
73
|
+
task :wip => 'features:wip'
|
74
|
+
rescue LoadError
|
75
|
+
end
|
76
|
+
=end
|
77
|
+
|
78
|
+
task :default => default_tasks unless default_tasks.empty?
|
data/bin/adb-push-ebook
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ADB = ENV['ADB'] || 'adb'
|
4
|
+
|
5
|
+
unless ::File.executable? ADB
|
6
|
+
warn %(adb-push-ebook: `adb` not found.\nPlease set the ADB environment variable or add `adb` to your PATH.)
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'open3'
|
11
|
+
require 'shellwords'
|
12
|
+
|
13
|
+
docname = ARGV[0] || '_output/sample-book'
|
14
|
+
|
15
|
+
targets = {
|
16
|
+
'epub' => '/sdcard/',
|
17
|
+
'mobi' => '/sdcard/Android/data/com.amazon.kindle/files/'
|
18
|
+
}
|
19
|
+
|
20
|
+
targets.each {|(ext, target)|
|
21
|
+
file = %(#{docname}.#{ext})
|
22
|
+
Open3.popen2e(Shellwords.join [ADB, 'push', file, target]) {|input, output, wait_thr|
|
23
|
+
output.each {|line| puts line }
|
24
|
+
} if File.file? file
|
25
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.join File.dirname(__FILE__), '../lib/asciidoctor-epub3'
|
4
|
+
require 'asciidoctor/cli'
|
5
|
+
|
6
|
+
options = Asciidoctor::Cli::Options.new backend: 'epub3'
|
7
|
+
# FIXME This is a really bizarre API. Please make me simpler.
|
8
|
+
if (options.parse! ARGV) == 0
|
9
|
+
exit 0
|
10
|
+
else
|
11
|
+
invoker = Asciidoctor::Cli::Invoker.new options
|
12
|
+
GC.start
|
13
|
+
invoker.invoke!
|
14
|
+
exit invoker.code
|
15
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="125"
|
13
|
+
height="125"
|
14
|
+
id="svg3896"
|
15
|
+
version="1.1"
|
16
|
+
inkscape:version="0.48.4 r9939"
|
17
|
+
sodipodi:docname="default-avatar.svg">
|
18
|
+
<defs
|
19
|
+
id="defs3898" />
|
20
|
+
<sodipodi:namedview
|
21
|
+
id="base"
|
22
|
+
pagecolor="#ffffff"
|
23
|
+
bordercolor="#666666"
|
24
|
+
borderopacity="1.0"
|
25
|
+
inkscape:pageopacity="0.0"
|
26
|
+
inkscape:pageshadow="2"
|
27
|
+
inkscape:zoom="1.4385429"
|
28
|
+
inkscape:cx="57.476305"
|
29
|
+
inkscape:cy="126.28564"
|
30
|
+
inkscape:document-units="px"
|
31
|
+
inkscape:current-layer="layer1"
|
32
|
+
showgrid="false"
|
33
|
+
inkscape:window-width="2560"
|
34
|
+
inkscape:window-height="1337"
|
35
|
+
inkscape:window-x="0"
|
36
|
+
inkscape:window-y="49"
|
37
|
+
inkscape:window-maximized="1" />
|
38
|
+
<metadata
|
39
|
+
id="metadata3901">
|
40
|
+
<rdf:RDF>
|
41
|
+
<cc:Work
|
42
|
+
rdf:about="">
|
43
|
+
<dc:format>image/svg+xml</dc:format>
|
44
|
+
<dc:type
|
45
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
46
|
+
<dc:title />
|
47
|
+
</cc:Work>
|
48
|
+
</rdf:RDF>
|
49
|
+
</metadata>
|
50
|
+
<g
|
51
|
+
inkscape:label="Layer 1"
|
52
|
+
inkscape:groupmode="layer"
|
53
|
+
id="layer1"
|
54
|
+
transform="translate(0,-927.36218)">
|
55
|
+
<text
|
56
|
+
xml:space="preserve"
|
57
|
+
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#242422;fill-opacity:1;stroke:none;font-family:FontAwesome;-inkscape-font-specification:FontAwesome"
|
58
|
+
x="5.9285712"
|
59
|
+
y="1041.2908"
|
60
|
+
id="text3904"
|
61
|
+
sodipodi:linespacing="125%"><tspan
|
62
|
+
sodipodi:role="line"
|
63
|
+
id="tspan3906"
|
64
|
+
x="5.9285712"
|
65
|
+
y="1041.2908"></tspan></text>
|
66
|
+
</g>
|
67
|
+
</svg>
|
Binary file
|
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
2
|
+
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 1050 1600">
|
3
|
+
<defs>
|
4
|
+
<filter id="filter3874" color-interpolation-filters="sRGB">
|
5
|
+
<feGaussianBlur stdDeviation="0.01 5" in="SourceGraphic"/>
|
6
|
+
</filter>
|
7
|
+
<filter id="filter4056" color-interpolation-filters="sRGB">
|
8
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="3" result="result6"/>
|
9
|
+
<feColorMatrix in="SourceGraphic" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 " result="result7"/>
|
10
|
+
<feComposite operator="in" result="fbSourceGraphic" in2="result7" in="result6"/>
|
11
|
+
<feColorMatrix values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0" result="fbSourceGraphicAlpha" in="fbSourceGraphic"/>
|
12
|
+
<feGaussianBlur in="fbSourceGraphic" stdDeviation="3" result="result6"/>
|
13
|
+
<feColorMatrix in="fbSourceGraphic" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 " result="result7"/>
|
14
|
+
<feComposite operator="in" in2="result7" in="result6"/>
|
15
|
+
</filter>
|
16
|
+
<filter id="filter4098" color-interpolation-filters="sRGB">
|
17
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="3" result="result6"/>
|
18
|
+
<feColorMatrix in="SourceGraphic" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 " result="result7"/>
|
19
|
+
<feComposite operator="in" result="fbSourceGraphic" in2="result7" in="result6"/>
|
20
|
+
<feColorMatrix values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0" result="fbSourceGraphicAlpha" in="fbSourceGraphic"/>
|
21
|
+
<feGaussianBlur in="fbSourceGraphic" stdDeviation="3" result="result6"/>
|
22
|
+
<feColorMatrix in="fbSourceGraphic" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 " result="result7"/>
|
23
|
+
<feComposite operator="in" in2="result7" in="result6"/>
|
24
|
+
</filter>
|
25
|
+
</defs>
|
26
|
+
<metadata>
|
27
|
+
<rdf:RDF>
|
28
|
+
<cc:Work rdf:about="">
|
29
|
+
<dc:format>image/svg+xml</dc:format>
|
30
|
+
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
31
|
+
<dc:title/>
|
32
|
+
</cc:Work>
|
33
|
+
</rdf:RDF>
|
34
|
+
</metadata>
|
35
|
+
<rect style="enable-background:accumulate;fill-rule:nonzero;color:#000000;fill:#333332;" height="1600" width="1050" y="0" x="0"/>
|
36
|
+
<rect style="enable-background:accumulate;fill-rule:nonzero;color:#000000;fill:#264e2e;" height="20" width="1050" y="468" x="0"/>
|
37
|
+
<path style="filter:url(#filter4056);fill:#264e2e;" d="m525,349.3-495,25c127.6,50,67.95,230,40,240l455-10,455,10c-27.95-10-87.65-190,40-240l-495-25z"/>
|
38
|
+
<path style="filter:url(#filter4098);fill:#57ad68;" d="m525,379.3-460,5c93.17,34.67,55,190,40,205h420,420c-15-15-53.17-170.3,40-205l-460-5z"/>
|
39
|
+
<path style="fill:#333332;" d="m95,394.3c55.42,25.11,45.36,131.3,35,165l395,15,395-15c-10.36-33.66-20.42-139.9,35-165l-430,5-430-5z"/>
|
40
|
+
<rect style="enable-background:accumulate;fill-rule:nonzero;color:#000000;filter:url(#filter3874);fill:#264e2e;" height="169.5" width="1050" y="1435" x="0"/>
|
41
|
+
<rect style="enable-background:accumulate;fill-rule:nonzero;color:#000000;fill:#57ad68;" height="6" width="1050" y="1453" x="0"/>
|
42
|
+
<g transform="translate(1.2573242e-5,-10)">
|
43
|
+
<text style="font-size:86px;stroke-width:3;writing-mode:lr-tb;fill:#b3b3b1;letter-spacing:-4px;text-anchor:start;line-height:100%;word-spacing:0px;stroke:#b3b3b1;font-stretch:normal;stroke-miterlimit:4;font-family:'M+ 1p';font-variant:normal;stroke-dasharray:none;font-weight:bold;font-style:normal;text-align:start;" y="529.82001" x="162.99142" xml:space="preserve"><tspan y="529.82001" x="162.99142">Asciidoctor</tspan></text>
|
44
|
+
<text style="font-size:86px;stroke-width:3;writing-mode:lr-tb;fill:#b3b3b1;letter-spacing:-4px;text-anchor:start;line-height:100%;word-spacing:0px;stroke:#b3b3b1;font-stretch:normal;stroke-miterlimit:4;font-family:'M+ 1p';font-variant:normal;stroke-dasharray:none;font-weight:bold;font-style:normal;text-align:start;" xml:space="preserve" y="529.82001" x="632.99139"><tspan x="632.99139" y="529.82001">EPUB3</tspan></text>
|
45
|
+
</g>
|
46
|
+
<g transform="translate(1.2573242e-5,-10)">
|
47
|
+
<text style="font-size:86px;font-family:'M+ 1p';writing-mode:lr-tb;fill:#ffffff;letter-spacing:-4px;text-anchor:start;line-height:100%;word-spacing:0px;font-stretch:normal;font-variant:normal;font-weight:bold;font-style:normal;text-align:start;" xml:space="preserve" y="529.82001" x="162.99142"><tspan x="162.99142" y="529.82001">Asciidoctor</tspan></text>
|
48
|
+
<text style="font-size:86px;font-family:'M+ 1p';writing-mode:lr-tb;fill:#ffffff;letter-spacing:-4px;text-anchor:start;line-height:100%;word-spacing:0px;font-stretch:normal;font-variant:normal;font-weight:bold;font-style:normal;text-align:start;" y="529.82001" x="632.99139" xml:space="preserve"><tspan y="529.82001" x="632.99139">EPUB3</tspan></text>
|
49
|
+
</g>
|
50
|
+
<g transform="translate(0,547.6378)">
|
51
|
+
<path style="stroke-linejoin:miter;stroke:#122616;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-width:32;fill:none;" d="m11.87,3098,1021,0"/>
|
52
|
+
</g>
|
53
|
+
</svg>
|
Binary file
|
Binary file
|
@@ -0,0 +1,744 @@
|
|
1
|
+
= Asciidoctor EPUB3: A _native_ EPUB3 converter for AsciiDoc
|
2
|
+
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
|
3
|
+
:project-name: Asciidoctor EPUB3
|
4
|
+
:project-handle: asciidoctor-epub3
|
5
|
+
:project-uri: https://github.com/asciidoctor/{project-handle}
|
6
|
+
:project-repo-uri: {project-uri}
|
7
|
+
:project-issues-uri: {project-repo-uri}/issues
|
8
|
+
:rvm-uri: http://rvm.io
|
9
|
+
:asciidoctor-uri: http://asciidoctor.org
|
10
|
+
:idpf-uri: http://www.idpf.org/
|
11
|
+
:epub-uri: http://www.idpf.org/epub/30/spec/epub30-overview.html
|
12
|
+
:epubcheck-uri: https://github.com/idpf/epubcheck
|
13
|
+
ifdef::env-github[]
|
14
|
+
:base-uri: link:
|
15
|
+
endif::[]
|
16
|
+
ifndef::env-github[]
|
17
|
+
:base-uri: {project-repo-uri}/blob/master/
|
18
|
+
endif::[]
|
19
|
+
:notice-uri: {base-uri}NOTICE.adoc
|
20
|
+
:license-uri: {base-uri}LICENSE.adoc
|
21
|
+
:worklog-uri: {base-uri}WORKLOG.adoc
|
22
|
+
:imagesdir: data/samples/images
|
23
|
+
:experimental:
|
24
|
+
|
25
|
+
{project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 and KF8/MOBI e-book formats.
|
26
|
+
|
27
|
+
== Introduction
|
28
|
+
|
29
|
+
{project-name} is not merely a converter from AsciiDoc to EPUB3 and KF8/MOBI, but rather a tool to help you create aesthetic, professional, _easy-to-read_ e-books.
|
30
|
+
Let's face it, many of the technical e-books out there--especially those produced from software documentation--are *_hideous_*.
|
31
|
+
The Asciidoctor project wants to disrupt the status quo.
|
32
|
+
|
33
|
+
ifdef::env-github[]
|
34
|
+
.An excerpt from an e-book produced by {project-name} shown in Day, Night and Sepia mode.
|
35
|
+
image::screenshots/text.png[]
|
36
|
+
endif::[]
|
37
|
+
|
38
|
+
=== Project Mission
|
39
|
+
|
40
|
+
The {project-name} project aims to produce EPUB3 documents that meet the following objectives:
|
41
|
+
|
42
|
+
[itemized,subject-stop=.]
|
43
|
+
Fully Semantic::
|
44
|
+
Produce deeply semantic XHTML5 documents, including use of the recommended `epub:type` attribute.
|
45
|
+
Exceptional Readability::
|
46
|
+
Readers should be drawn into the text so that they read and absorb it, not scared away from it.
|
47
|
+
Maximize the readability of the text using carefully crafted styles, focusing on:
|
48
|
+
- Custom, readable fonts with strong UTF-8 character support
|
49
|
+
- Sufficient line spacing and margins
|
50
|
+
- Modular font size scale
|
51
|
+
- Subtle, pleasing colors with good contrast
|
52
|
+
- A responsive design that scales well from small to large screens
|
53
|
+
- Widowed and orphaned content avoided where possible
|
54
|
+
Complete & Accurate Metadata::
|
55
|
+
Fully populate the EPUB3 package metadata using information in the AsciiDoc source document.
|
56
|
+
Consistent Rendering::
|
57
|
+
Render consistently across a broad range of EPUB3 (and select EPUB2+) readers and respond to any size screen.
|
58
|
+
Polish, Polish & More Polish::
|
59
|
+
Add polish to the final product such as font-based icons and callout numbers.
|
60
|
+
|
61
|
+
We believe that the e-books produced by {project-name} are the _very best_ output you can expect to find in digital publishing today.
|
62
|
+
Of course, there's always room for improvement, so we'll continue to work with you to achieve and maintain this goal.
|
63
|
+
|
64
|
+
=== Notable Features
|
65
|
+
|
66
|
+
* Direct AsciiDoc to EPUB3 conversion
|
67
|
+
* Direct AsciiDoc to KF8/MOBI conversion
|
68
|
+
* Highly-aesthetic and readable styles with optimized text legibility
|
69
|
+
* EPUB3 metadata, manifest and spine (assembled by Gepub)
|
70
|
+
* Document metadata (title, authors, subject, keywords, etc.)
|
71
|
+
* Internal cross reference links
|
72
|
+
* Syntax highlighting with CodeRay or Pygments (must use inline styles)
|
73
|
+
* Unicode callout numbers
|
74
|
+
* Page breaks avoided in block content (so much as it's supported by the reader)
|
75
|
+
* Orphan section titles avoided (so much as it's supported by the reader)
|
76
|
+
* Table border settings honored
|
77
|
+
* Support for SVG images in the content
|
78
|
+
|
79
|
+
=== Project Status
|
80
|
+
|
81
|
+
CAUTION: {project-name} is currently _alpha_ software.
|
82
|
+
Use accordingly.
|
83
|
+
Although the bulk of AsciiDoc content is rendered, there's still work needed to fill in gaps where rendering is incomplete or unstyled.
|
84
|
+
Once it's battle tested, the project will be moved into the Asciidoctor organization on GitHub.
|
85
|
+
|
86
|
+
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.
|
87
|
+
We may explore the use of fixed layout documents in the future if the need arises.
|
88
|
+
|
89
|
+
=== Planned Features and Work In Progress
|
90
|
+
|
91
|
+
See {worklog-uri}[WORKLOG.adoc].
|
92
|
+
|
93
|
+
== Converter Workflow
|
94
|
+
|
95
|
+
{project-name} takes a single, logical AsciiDoc document as input and converts it to an EPUB3 publication archive (often described as a “website in a box”).
|
96
|
+
Using the EPUB3 publication as the “digital master”, {project-name} can then produce a KF8/MOBI, the file format required by Amazon Kindle.
|
97
|
+
The conversion to KF8/MOBI is performed by sending the EPUB3 through http://www.amazon.com/gp/feature.html?docId=1000765211[KindleGen].
|
98
|
+
|
99
|
+
An EPUB3 archive is typically structured with the contents of each “chapter” in a separate XHTML file.
|
100
|
+
The converter must therefore “chunk” the source document into multiple XHTML files to put in the EPUB3 archive.
|
101
|
+
Other converters tend to handle this task by automatically slicing up the XHTML output at predetermined heading levels.
|
102
|
+
Asciidoctor takes a different approach.
|
103
|
+
|
104
|
+
=== Declaring the Spine
|
105
|
+
|
106
|
+
Asciidoctor relies on top-level include directives (i.e., include directives in the master document) to indicate where the chapter splits should occur.
|
107
|
+
In other words, you must be explicit.
|
108
|
+
Asciidoctor will not try to guess.
|
109
|
+
If your AsciiDoc document is not structured in this way, you'll need to change it to use the {project-name} converter properly.
|
110
|
+
|
111
|
+
You can think of the master document as the spine of the book and the include directives the individual items being bound together.
|
112
|
+
The target of each include directive in the master document is parsed and rendered as a separate AsciiDoc document, with certain options and attributes being passed down from the master to ensure consistent behavior.
|
113
|
+
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).
|
114
|
+
|
115
|
+
If the master document does not contain any include directives, then the converter treats the document as the sole chapter in the EPUB3 archive and automatically produces a navigation file that references it.
|
116
|
+
|
117
|
+
Eventually, we envision introducing a dedicated block macro to represent a spine item so that we don't overload the meaning of the include directive.
|
118
|
+
However, for the time being, the include directive will suit this purpose.
|
119
|
+
|
120
|
+
== Prerequisites
|
121
|
+
|
122
|
+
All that's needed to use {project-name} is Ruby 1.9.3 or better and a few RubyGems, which we'll explain how to install in the next section.
|
123
|
+
|
124
|
+
To check if you have Ruby available, use the `ruby` command to query the version installed:
|
125
|
+
|
126
|
+
$ ruby --version
|
127
|
+
|
128
|
+
If you're using {rvm-uri}[RVM], we recommend creating a new gemset to work with {project-name}:
|
129
|
+
|
130
|
+
$ rvm use @asciidoctor-epub3 --create
|
131
|
+
|
132
|
+
We like RVM because it keeps the dependencies required by various projects isolated ;)
|
133
|
+
|
134
|
+
== Getting Started
|
135
|
+
|
136
|
+
{project-name} isn't yet published as a RubyGem itself, so you'll need to get the source code.
|
137
|
+
|
138
|
+
=== Retrieve the project
|
139
|
+
|
140
|
+
You can retrieve {project-name} in one of two ways:
|
141
|
+
|
142
|
+
. Clone the git repository
|
143
|
+
. Download a zip archive of the repository
|
144
|
+
|
145
|
+
==== Option 1: Fetch Using `git clone`
|
146
|
+
|
147
|
+
If you want to clone the git repository, simply copy the {project-repo-uri}[GitHub repository URL] and pass it to the `git clone` command:
|
148
|
+
|
149
|
+
$ git clone https://github.com/asciidoctor/asciidoctor-epub3
|
150
|
+
|
151
|
+
Next, change to the project directory:
|
152
|
+
|
153
|
+
$ cd asciidoctor-epub3
|
154
|
+
|
155
|
+
==== Option 2: Download the Archive
|
156
|
+
|
157
|
+
If you want to download a zip archive, click on the btn:[icon:cloud-download[\] Download Zip] button on the right-hand side of the repository page on GitHub.
|
158
|
+
Once the download finishes, extract the archive, open a console and change to that directory.
|
159
|
+
|
160
|
+
We'll now leverage the project configuration to install the necessary dependencies.
|
161
|
+
|
162
|
+
=== Install the Dependencies
|
163
|
+
|
164
|
+
The dependencies needed to use {project-name} are defined in the [file]_Gemfile_ at the root of the project.
|
165
|
+
We can use Bundler to install the dependencies for us.
|
166
|
+
|
167
|
+
To check if you have Bundler available, use the `bundle` command to query the version installed:
|
168
|
+
|
169
|
+
$ bundle --version
|
170
|
+
|
171
|
+
If it's not installed, use the `gem` command to install it.
|
172
|
+
|
173
|
+
$ gem install bundle
|
174
|
+
|
175
|
+
Then use the `bundle` command to install the project dependencies:
|
176
|
+
|
177
|
+
$ bundle install
|
178
|
+
|
179
|
+
=== Build and Install the Gem
|
180
|
+
|
181
|
+
Now that the dependencies are installed, you can build and install the Gem.
|
182
|
+
|
183
|
+
Use the Rake build tool to build the Gem:
|
184
|
+
|
185
|
+
$ rake build
|
186
|
+
|
187
|
+
The build will report that it built the Gem into the [path]_pkg_ directory.
|
188
|
+
|
189
|
+
Finally, install the Gem.
|
190
|
+
|
191
|
+
$ gem install pkg/asciidoctor-epub3-1.0.0.dev.gem
|
192
|
+
|
193
|
+
You're now ready to use {project-name}!
|
194
|
+
Let's get an AsciiDoc document ready to convert to EPUB3.
|
195
|
+
|
196
|
+
=== Prepare an AsciiDoc Document
|
197
|
+
|
198
|
+
If you don't already have an AsciiDoc document, you can use the [file]_sample-book.adoc_ file and its chapters found in the [path]_data/samples_ directory of this project.
|
199
|
+
|
200
|
+
.Master file named sample-book.adoc
|
201
|
+
```asciidoc
|
202
|
+
= Asciidoctor EPUB3: Sample Book
|
203
|
+
Author Name
|
204
|
+
v1.0, 2014-04-15
|
205
|
+
:doctype: book
|
206
|
+
:producer: Asciidoctor
|
207
|
+
:keywords: Asciidoctor, samples, e-book, EPUB3, KF8, MOBI, Asciidoctor.js
|
208
|
+
:copyright: CC-BY-SA 3.0
|
209
|
+
:imagesdir: images
|
210
|
+
|
211
|
+
\include::asciidoctor-epub3-readme.adoc[]
|
212
|
+
|
213
|
+
\include::sample-content.adoc[]
|
214
|
+
|
215
|
+
\include::asciidoctor-js-introduction.adoc[]
|
216
|
+
|
217
|
+
\include::asciidoctor-js-extension.adoc[]
|
218
|
+
```
|
219
|
+
|
220
|
+
=== EPUB-related AsciiDoc Attributes
|
221
|
+
|
222
|
+
The metadata in the generated EPUB3 file is populated from attributes in the AsciiDoc document.
|
223
|
+
The names of the attributes and the metadata elements to which they map are documented in this section.
|
224
|
+
|
225
|
+
The term [term]_package metadata_ in Table 1 is in reference to the http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem[<metadata> element] in the EPUB3 package document (e.g., [file]_package.opf_).
|
226
|
+
The `dc` namespace prefix is in reference to the http://dublincore.org/documents/2004/12/20/dces[Dublin Core Metadata Element Set].
|
227
|
+
|
228
|
+
.AsciiDoc attributes that control the EPUB3 metadata (i.e., package.opf)
|
229
|
+
[cols="1m,3"]
|
230
|
+
|===
|
231
|
+
|Name |Description
|
232
|
+
|
233
|
+
|id
|
234
|
+
|Populates the *required* unique identifier (`<dc:identifier>`) in the package metadata.
|
235
|
+
An id will be generated automatically from the doctitle if not specified.
|
236
|
+
The recommended practice is to identify the document by means of a string or number conforming to a formal identification system.
|
237
|
+
|
238
|
+
|lang
|
239
|
+
|Populates the content language / locale (`<dc:language>`) in the package metadata.
|
240
|
+
|
241
|
+
|scripts
|
242
|
+
|Controls the font subsets that are selected based on the specified scripts (e.g., alphabets). (values: *latin*, latin-ext, latin-cyrillic or multilingual)
|
243
|
+
|
244
|
+
|revdate
|
245
|
+
|Populates the publication date (`<dc:date>`) in the package metadata.
|
246
|
+
The date should be specified in a parsable format, such as `2014-01-01`.
|
247
|
+
|
248
|
+
|doctitle
|
249
|
+
|Populates the title (`<dc:title>`) in the package metadata.
|
250
|
+
The title is added to the metadata in plain text format.
|
251
|
+
|
252
|
+
|author
|
253
|
+
|Populates the contributors (`<dc:contributor>`) in the package metadata.
|
254
|
+
The authors in each chapter document are aggregated together with the authors in the master file.
|
255
|
+
|
256
|
+
|username
|
257
|
+
|Used to resolve an avatar for the author that is displayed in the header of a chapter.
|
258
|
+
The avatar image should be located at the path _$${imagesdir}/avatars/{username}.png$$_, where
|
259
|
+
`{username}` is the value of this attribute.
|
260
|
+
|
261
|
+
|producer
|
262
|
+
|Populates the publisher (`<dc:publisher>`) in the package metadata.
|
263
|
+
|
264
|
+
|creator
|
265
|
+
|Populates the creator (`<dc:creator>`) in the package metadata.
|
266
|
+
If the creator is not specified, the value of the producer attribute is used.
|
267
|
+
|
268
|
+
|description
|
269
|
+
|Populates the description (`<dc:description>`) in the package metadata.
|
270
|
+
|
271
|
+
|keywords
|
272
|
+
|Populates the subjects (i.e., `<dc:subject>`) in the package metadata.
|
273
|
+
The keywords should be represented as comma-separated values (CSV).
|
274
|
+
|
275
|
+
|front-cover-image
|
276
|
+
|Populates the front cover image and the image on the cover page (EPUB3 only) in the package metadata.
|
277
|
+
The image is also added to the e-book archive.
|
278
|
+
May be specified as a path or inline image macro.
|
279
|
+
Using the inline image macro is preferred as it allows the height and width to be specified.
|
280
|
+
|
281
|
+
|copyright
|
282
|
+
|Populates the rights statement (`<dc:rights>`) in the package metadata.
|
283
|
+
|
284
|
+
|source
|
285
|
+
|Populates the source reference (`<dc:source>`) in the package metadata.
|
286
|
+
The recommended practice is to identify the referenced resource by means of a string or number conforming to a formal identification system.
|
287
|
+
|
288
|
+
|epub-properties
|
289
|
+
|An optional override of the properties attribute for this document's item in the manifest.
|
290
|
+
_Only applies to a chapter document._
|
291
|
+
|
292
|
+
|doctype
|
293
|
+
|Effectively ignored.
|
294
|
+
The master document is assumed to be a book and each chapter an article.
|
295
|
+
|===
|
296
|
+
|
297
|
+
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`.
|
298
|
+
You can use these attributes in a preprocessor directive if you only want to show certain content to readers using a particular device.
|
299
|
+
For instance, if you want to display a message to readers on Kindle, you can use:
|
300
|
+
|
301
|
+
----
|
302
|
+
\ifdef::ebook-format-kf8[Hello Kindle reader!]
|
303
|
+
----
|
304
|
+
|
305
|
+
With that out of the way, it's time to convert the AsciiDoc document directly to EPUB3.
|
306
|
+
|
307
|
+
== Performing the Conversion
|
308
|
+
|
309
|
+
You can convert AsciiDoc documents to EPUB3 and KF8/MOBI from the commandline using the `asciidoctor-epub3` script provided with the {project-name} project.
|
310
|
+
|
311
|
+
=== Convert AsciiDoc to EPUB3
|
312
|
+
|
313
|
+
Converting an AsciiDoc document to EPUB3 is as simple as passing your document to the `asciidoctor-epub3` command.
|
314
|
+
This command should be available on your PATH if you installed the `asciidoctor-epub3` gem.
|
315
|
+
Otherwise, you can find the command in the [path]_bin_ folder of the project.
|
316
|
+
We also recommend specifying an output directory using the `-D` option flag.
|
317
|
+
|
318
|
+
$ asciidoctor-epub3 -D output data/samples/sample-book.adoc
|
319
|
+
|
320
|
+
When the script completes, you'll see the file [file]_sample-book.epub_ appear in the [path]_output_ directory.
|
321
|
+
Open that file with an EPUB3 reader to view the result.
|
322
|
+
|
323
|
+
Below are several screenshots of this sample book as it appears on an Android phone.
|
324
|
+
|
325
|
+
.An example of a chapter title and abstract shown side-by-side in Day and Night mode
|
326
|
+
image::screenshots/chapter-title.png[]
|
327
|
+
|
328
|
+
.An example of a section title followed by paragraph text separated by a literal block
|
329
|
+
image::screenshots/section-title-paragraph.png[]
|
330
|
+
|
331
|
+
.An example of a figure and an admonition
|
332
|
+
image::screenshots/figure-admonition.png[]
|
333
|
+
|
334
|
+
.An example of a sidebar
|
335
|
+
image::screenshots/sidebar.png[]
|
336
|
+
|
337
|
+
.An example of a table
|
338
|
+
image::screenshots/table.png[]
|
339
|
+
|
340
|
+
NOTE: The `asciidoctor-epub3` command is a temporary solution for invoking the {project-name} converter.
|
341
|
+
We plan to remove this script once we have completed proper integration with the `asciidoctor` command.
|
342
|
+
|
343
|
+
TIP: As another example, point `asciidoctor-epub3` at the https://github.com/opendevise/github-guides-asciidoc[GitHub Guides] that we've ported to AsciiDoc, then compare the output to the real https://guides.github.com[GitHub Guides].
|
344
|
+
|
345
|
+
=== Validate the EPUB3 Archive
|
346
|
+
|
347
|
+
Next, let's validate the EPUB3 archive to ensure it built correctly.
|
348
|
+
|
349
|
+
.EPUB3 with validation
|
350
|
+
$ asciidoctor-epub3 -D output -a ebook-validate data/samples/sample-book.adoc
|
351
|
+
|
352
|
+
.Validation success
|
353
|
+
----
|
354
|
+
Epubcheck Version 3.0.1
|
355
|
+
|
356
|
+
Validating against EPUB version 3.0
|
357
|
+
No errors or warnings detected.
|
358
|
+
----
|
359
|
+
|
360
|
+
If the EPUB3 archive contains any errors, they will be output in your terminal.
|
361
|
+
|
362
|
+
.EPUB Standard & Validator
|
363
|
+
****
|
364
|
+
The electronic publication (EPUB) standard is developed by the {idpf-uri}[International Digital Publishing Forum (IDPF)].
|
365
|
+
{epub-uri}[EPUB 3.0], released in October 2011, is the latest version of this standard.
|
366
|
+
|
367
|
+
An EPUB3 archive contains:
|
368
|
+
|
369
|
+
* a package document (metadata, file manifest, spine)
|
370
|
+
* a navigation document (table of contents)
|
371
|
+
* one or more content documents
|
372
|
+
* assets (images, fonts, stylesheets, etc.)
|
373
|
+
|
374
|
+
The IDPF also supports {epubcheck-uri}[EpubCheck].
|
375
|
+
EpubCheck parses and validates the file against the EPUB schema.
|
376
|
+
****
|
377
|
+
|
378
|
+
If you want to browse the contents of the EPUB3 file that is generated, or preview the XHTML files in a regular web browser, add the `-a ebook-extract` flag to the `asciidoctor-epub3` command.
|
379
|
+
The EPUB3 file will be extracted to a directory adjacent to the generated file, but without the file extension.
|
380
|
+
|
381
|
+
$ asciidoctor-epub3 -D output -a ebook-extract data/samples/sample-book.adoc
|
382
|
+
|
383
|
+
In this example, the contents of the EPUB3 will be extracted to the [path]_output/sample-book_ directory.
|
384
|
+
|
385
|
+
=== Convert AsciiDoc to KF8/MOBI
|
386
|
+
|
387
|
+
Creating a KF8/MOBI archive directly from an AsciiDoc document is done with the same generation script (`asciidoctor-epub3`).
|
388
|
+
You just need to specify the format (`-a ebook-format`) as `kf8`.
|
389
|
+
|
390
|
+
$ asciidoctor-epub3 -D output -a ebook-format=kf8 data/samples/sample-book.adoc
|
391
|
+
|
392
|
+
When the script completes, you'll see the file [file]_sample-book.mobi_ appear in the [path]_output_ directory.
|
393
|
+
|
394
|
+
KindleGen does mandatory validation so you don't need to run the `validate` command after converting to KF8/MOBI.
|
395
|
+
|
396
|
+
.What is KF8?
|
397
|
+
****
|
398
|
+
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.
|
399
|
+
The format is close enough to EPUB3 that it's safe to think of it simply as an EPUB3 implementation under most circumstances.
|
400
|
+
You can read more about the format on the http://www.amazon.com/gp/feature.html?docId=1000729511[Kindle Format 8 page].
|
401
|
+
|
402
|
+
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.
|
403
|
+
That's why we refer to the format in this project as KF8/MOBI.
|
404
|
+
****
|
405
|
+
|
406
|
+
=== Command Arguments
|
407
|
+
|
408
|
+
*-h, --help* ::
|
409
|
+
Show the usage message
|
410
|
+
|
411
|
+
*-D, --destination-dir* ::
|
412
|
+
Writes files to specified directory (defaults to the current directory)
|
413
|
+
|
414
|
+
*-a ebook-extract* ::
|
415
|
+
Extracts the EPUB3 to a folder in the destination directory after the file is generated
|
416
|
+
|
417
|
+
*-a ebook-format=<format>* ::
|
418
|
+
Specifies the e-book format to generate (epub3 or kf8, default: epub3)
|
419
|
+
|
420
|
+
*-a ebook-validate* ::
|
421
|
+
Runs Epubcheck 3.0.1 to validate output file against the EPUB3 specification
|
422
|
+
|
423
|
+
*-v, --version* ::
|
424
|
+
Display the program version
|
425
|
+
|
426
|
+
=== EPUB3 Archive Structure
|
427
|
+
|
428
|
+
Here's a sample manifest of files found in an EPUB3 document produced by Asciidoctor EPUB3.
|
429
|
+
|
430
|
+
....
|
431
|
+
META-INF/
|
432
|
+
container.xml
|
433
|
+
OEBPS/
|
434
|
+
fonts/
|
435
|
+
font-awesome.ttf
|
436
|
+
font-icons.ttf
|
437
|
+
mplus-1mn-latin-bold.ttf
|
438
|
+
mplus-1mn-latin-light.ttf
|
439
|
+
mplus-1mn-latin-medium.ttf
|
440
|
+
mplus-1mn-latin-regular.ttf
|
441
|
+
mplus-1p-latin-bold.ttf
|
442
|
+
mplus-1p-latin-light.ttf
|
443
|
+
mplus-1p-latin-regular.ttf
|
444
|
+
noto-serif-bold-italic.ttf
|
445
|
+
noto-serif-bold.ttf
|
446
|
+
noto-serif-italic.ttf
|
447
|
+
noto-serif-regular.ttf
|
448
|
+
images/
|
449
|
+
avatars/
|
450
|
+
default.png
|
451
|
+
figure-01.png
|
452
|
+
figure-02.png
|
453
|
+
styles/
|
454
|
+
epub3-css3-only.css
|
455
|
+
epub3.css
|
456
|
+
chapter-01.xhtml
|
457
|
+
chapter-02.xhtml
|
458
|
+
...
|
459
|
+
cover.xhtml
|
460
|
+
nav.xhtml
|
461
|
+
package.opf
|
462
|
+
toc.ncx
|
463
|
+
mimetype
|
464
|
+
....
|
465
|
+
|
466
|
+
== Working with Images
|
467
|
+
|
468
|
+
Images that your AsciiDoc document references should be saved in the directory defined in the `imagesdir` attribute, which defaults to the directory of the document.
|
469
|
+
{project-name} will discover all local image references and insert the images into the EPUB3 archive at the same relative path.
|
470
|
+
|
471
|
+
The sample book contains placeholder images for an author avatar and a book cover.
|
472
|
+
|
473
|
+
// TODO explain the avatar and book cover images
|
474
|
+
|
475
|
+
=== Changing the Cover Image
|
476
|
+
|
477
|
+
E-book readers have different image resolution and file size limits regarding a book's cover.
|
478
|
+
Kindle covers tend to be 1050x1600 (16:9 resolution), which is the size of the sample cover provided with {project-name}.
|
479
|
+
To ensure your cover displays correctly, you'll want to review the documentation or publisher guidelines for the application you're targeting.
|
480
|
+
|
481
|
+
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.
|
482
|
+
|
483
|
+
Feel free to use the SVG of the sample cover in the [path]_data/images_ folder as a template for creating your own cover.
|
484
|
+
Once your image is ready, you can replace the placeholder cover image by defining the `front-cover-image` attribute in the header of the master document.
|
485
|
+
|
486
|
+
----
|
487
|
+
:front-cover-image: image:cover.png[width=1050,height=1600]
|
488
|
+
----
|
489
|
+
|
490
|
+
The image is resolved relative to the directory specified in the `imagesdir` attribute, which defaults to the document directory.
|
491
|
+
The image can be in any format, though we recommend using PNG or JPG as they are the most portable formats.
|
492
|
+
|
493
|
+
IMPORTANT: You should always specify the dimensions of the cover image.
|
494
|
+
This ensures the viewer will preserve the aspect ratio if it needs to be scaled to fit the screen.
|
495
|
+
If you don't specify a width and height, then the dimensions are assumed to be 1050x1600.
|
496
|
+
|
497
|
+
== About the Theme
|
498
|
+
|
499
|
+
EPUB3 and KF8/MOBI files are styled using CSS3.
|
500
|
+
However, each e-book reader honors a reduced set of CSS3 styles, and the styles they allow and how they implement them are rarely documented.
|
501
|
+
All we've got to say is _thank goodness for CSS hacks, media queries and years of CSS experience!_
|
502
|
+
|
503
|
+
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 reader applications and to degrade gracefully in select EPUB2 readers.
|
504
|
+
The theme maintains readability regardless of the e-book reader's background mode (i.e., day, night or sepia) or the display device's pixel density and screen resolution.
|
505
|
+
|
506
|
+
The theme's CSS files are located in the [path]_data/style_ directory.
|
507
|
+
|
508
|
+
IMPORTANT: {project-name} only provides one theme, and, at this time, you can not replace it with a custom theme using the `stylesheet` attribute.
|
509
|
+
|
510
|
+
=== Fonts
|
511
|
+
|
512
|
+
{project-name} embeds a set of fonts and font icons.
|
513
|
+
The theme's fonts are located in the [path]_data/fonts_ directory.
|
514
|
+
|
515
|
+
The M+ Outline fonts are used for titles, headings, literal (monospace) text, and annotation numbers.
|
516
|
+
The body text uses Noto Serif.
|
517
|
+
Admonition icons and the end-of-chapter mark are from the Font Awesome icon font.
|
518
|
+
Refer to the {notice-uri}[NOTICE.adoc] file for further information about the fonts.
|
519
|
+
|
520
|
+
// TODO document command to generate the M+ 1p latin fonts
|
521
|
+
|
522
|
+
=== The text justification hack
|
523
|
+
|
524
|
+
Many of the EPUB3 readers use the http://webkit.org[WebKit browser engine] to render the content and apply the CSS formatting and styles.
|
525
|
+
Generally speaking, WebKit is a great engine that brings a lot of consistency and power to the e-book reader landscape.
|
526
|
+
It also brings along the same set of bugs.
|
527
|
+
|
528
|
+
One of the bugs in WebKit causes rich text to be justified incorrectly.
|
529
|
+
In particular, when the value of the `text-align` property is `justify`, WebKit drops the space between formatted text (bold, italic, hyperlink, etc) and non-formatted text, causing the words to be unevenly spaced across the line.
|
530
|
+
You can see an example of this problem in the screenshot below.
|
531
|
+
|
532
|
+
.WebKit justifying rich text incorrectly
|
533
|
+
image::incorrect-text-justification.png[]
|
534
|
+
|
535
|
+
It's not terrible, but just enough to disrupt a reader's flow.
|
536
|
+
Here's how we expect the text to look:
|
537
|
+
|
538
|
+
.WebKit justifying rich text correctly after the “word joiner hack” is applied
|
539
|
+
image::correct-text-justification.png[]
|
540
|
+
|
541
|
+
After some time in the tech lab and some dumb luck, we found a way to trick WebKit into justifying the text correctly!
|
542
|
+
We call it the “word joiner hack”.
|
543
|
+
|
544
|
+
Here's the HTML source of the first sentence from the screenshots:
|
545
|
+
|
546
|
+
```xml
|
547
|
+
<strong><a href="...">Fork</a> the repository</stong> <span>and clone it locally.</span>
|
548
|
+
```
|
549
|
+
|
550
|
+
WebKit treats the space following an inline element as insignificant and thus fails to account for it when justifying the text.
|
551
|
+
|
552
|
+
At first glance, you might think to add a normal space character before the closing tag of the inline element (e.g., `<a href="...">Fork </a>`).
|
553
|
+
However, that would cause any underline beneath links to extend past the end of the word.
|
554
|
+
|
555
|
+
At second glance, you might think to add a zero-width space character immediately following the element (e.g., `<a href="...">Fork</a>​`).
|
556
|
+
However, that's problematic if the next character is a period or other punctuation because it introduces a wrap opportunity where there shouldn't be one.
|
557
|
+
|
558
|
+
Reflecting on the problem of the zero-width space brings us to either the http://www.fileformat.info/info/unicode/char/FEFF/index.htm[zero-width no-break space] character (e.g., `<a href="...">Fork</a>`) or the http://www.fileformat.info/info/unicode/char/2060/index.htm[word joiner] character (e.g., `<a href="...">Fork</a>⁠`).
|
559
|
+
Like the zero-width space, these characters occupy no space.
|
560
|
+
However, instead of introducing a wrap opportunity, they prevent one.
|
561
|
+
|
562
|
+
But here's the clincher.
|
563
|
+
If the character following a zero-width non-break space or a word joiner is a normal space (e.g., `<a href="...">Fork</a> the`), then it behaves just like a regular space.
|
564
|
+
We've covered all the scenarios!
|
565
|
+
Hey WebKit, you've been Unicode punked!
|
566
|
+
|
567
|
+
*UPDATE:* The zero-width no-break space was deprecated in favor of the word joiner.
|
568
|
+
However, as we've discovered, font support for the word joiner is absymal, whereas the zero-width no-break space is supported everywhere we've checked.
|
569
|
+
Therefore, we've decided to go with the zero-width no-break space to avoid nasty rectangle outlines from font bombing your content.
|
570
|
+
|
571
|
+
_By adding the +++<del>word joiner</del>+++ zero-width no-break space character immediately after any inline element, we can trick WebKit into justifying the text properly, as shown in the second screenshot above._
|
572
|
+
|
573
|
+
NOTE: You won't see `` anywhere in the HTML source.
|
574
|
+
That's because we use the actual Unicode character so that any regular expressions being applied to the text still work as expected.
|
575
|
+
|
576
|
+
Although the fix may seem minor enhancement, it plays an important role in reaching one of the core objectives of this converter: to make the text in the EPUB3 as readable as possible.
|
577
|
+
|
578
|
+
=== Device-specific Styles
|
579
|
+
|
580
|
+
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 http://www.idpf.org/epub/301/spec/epub-contentdocs.html#app-epubReadingSystem[epubReadingSystem] JavaScript object.
|
581
|
+
This enhancement allows you to use styles targeted specifically at that reader.
|
582
|
+
|
583
|
+
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.
|
584
|
+
|
585
|
+
,===
|
586
|
+
Reader,body class name
|
587
|
+
|
588
|
+
Gitden,gitden-reader
|
589
|
+
Namo PubTreeViewer,namo-epub-library
|
590
|
+
Readium,epub-js-viewer
|
591
|
+
iBooks,ibooks
|
592
|
+
Google Books,gb-reader-container (div)
|
593
|
+
,===
|
594
|
+
|
595
|
+
== Pushing to Android
|
596
|
+
|
597
|
+
While it's certainly possible to view the EPUB3 on your desktop/laptop, you'll probably want to test it where it's most likely going to be read--on a reading device such as a smartphone or a tablet.
|
598
|
+
Assuming you have an Android device available, transferring the EPUB3 to the device is easy once you get a bit of setup out of the way.
|
599
|
+
|
600
|
+
You transfer files from your computer to an Android phone over a USB connection using a command from the Android SDK Tools called `adb`.
|
601
|
+
Follow these steps to get it setup:
|
602
|
+
|
603
|
+
. Download the Android SDK Tools zip from the table labeled *SDK Tools Only* on the http://developer.android.com/sdk/index.html[Get the Android SDK] page
|
604
|
+
. Extract the archive
|
605
|
+
. Locate the path to the `adb` command (Hint: Look in the platform-tools folder)
|
606
|
+
. Set the environment variable named ADB to the path of the `adb` command
|
607
|
+
|
608
|
+
$ export ADB=~/apps/android-sdk/platform-tools/adb
|
609
|
+
|
610
|
+
Now you can use the `adb-push-ebook` script provided by {project-name} to push the EPUB3 and KF8/MOBI files to your Android device.
|
611
|
+
|
612
|
+
.Publish both EPUB3 and KF8 files to Android device
|
613
|
+
$ adb-push-ebook output/sample-book
|
614
|
+
|
615
|
+
IMPORTANT: Don't include the file extension since the script will check for both the .epub and .mobi files.
|
616
|
+
|
617
|
+
The `adb-push-ebook` script copies the files to the following locations on the device:
|
618
|
+
|
619
|
+
,===
|
620
|
+
File type,Destination on Android device
|
621
|
+
|
622
|
+
*.epub,/sdcard/
|
623
|
+
*.mobi,/sdcard/Android/data/com.amazon.kindle/files/
|
624
|
+
,===
|
625
|
+
|
626
|
+
Amazon Kindle should immediately detect the new file and display it in your “On Device” library.
|
627
|
+
You'll have to manually import the EPUB3 into your reader application of choice.
|
628
|
+
|
629
|
+
== E-book Reader Recommendations and Quirks
|
630
|
+
|
631
|
+
EPUB3 readers will provide the best reading experience when viewing the book generated by {project-name}.
|
632
|
+
Here's a list of some of the readers we know to have good EPUB3 support and the systems on which they run:
|
633
|
+
|
634
|
+
* http://www.amazon.com/gp/feature.html?docId=1000493771[Amazon Kindle] (most platforms)
|
635
|
+
* http://gitden.com/gitdenreader[Gitden] (Android and iOS)
|
636
|
+
* http://www.apple.com/ibooks[iBooks] (iOS, OSX)
|
637
|
+
* https://chrome.google.com/webstore/detail/readium/fepbnnnkkadjhjahcafoaglimekefifl?hl=en-US[Readium] (Chrome)
|
638
|
+
* http://www.kobo.com/apps[Kobo] (Android, iOS, OSX and Windows)
|
639
|
+
* http://www.namo.com/site/namo/menu/5074.do[Namo PubTreeViewer] (Android, iOS and Windows)
|
640
|
+
* http://calibre-ebook.com[Calibre ebook-viewer] (Linux, OSX, Windows)
|
641
|
+
|
642
|
+
IMPORTANT: To get the full experience, ensure that the reader is configured to use the publisher's styles.
|
643
|
+
Different readers word this setting in different ways.
|
644
|
+
Look for the option screen that allows you to set the fonts and font colors and disable it.
|
645
|
+
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.
|
646
|
+
|
647
|
+
When the book is viewed in EPUB2 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.
|
648
|
+
EPUB2 readers, such as Aldiko, don't understand CSS3 styles and therefore miss out on some of subtleties in the formatting.
|
649
|
+
|
650
|
+
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 readers, despite the different CSS implementation rules and limitations unique to each e-book application.
|
651
|
+
Most of these obstacles were addressed using media queries or explicit classes.
|
652
|
+
Some we haven't conquered.
|
653
|
+
Yet.
|
654
|
+
|
655
|
+
The <<_kindle_quirks,Kindle quirks list>> shows you just a few of the constraints we encountered.
|
656
|
+
To see all of the workarounds and why we chose certain style options, check out the code and comments in the [file]_epub3.css_ and [file]_epub3-css-only.css_ files.
|
657
|
+
|
658
|
+
// TODO add http://www.namo.com/site/namo/menu/5074.do[Namo PubTreeViewer] (iOS, Android & Windows) and http://www.kobo.com/apps[Kobo] (iOS, Android, OSX & Windows)
|
659
|
+
|
660
|
+
[[_kindle_quirks]]
|
661
|
+
.Kindle Quirks
|
662
|
+
* overrules margins and line heights like a medieval tyrant
|
663
|
+
* `font-family` can't be set on `<body>`
|
664
|
+
* requires `!important` on text-decoration
|
665
|
+
* `position: relative` isn't permitted
|
666
|
+
* strips (or unwraps) `<header>` tags
|
667
|
+
* `@page` isn't supported
|
668
|
+
* `page-break: avoid` isn't supported
|
669
|
+
* `max-width` isn't supported
|
670
|
+
* `widows` are left in the cold
|
671
|
+
* won't style footers without an explicit class
|
672
|
+
|
673
|
+
////
|
674
|
+
head-stop (default '.')
|
675
|
+
stack-head role (run-in is default)
|
676
|
+
signature role (sets hardbreaks option)
|
677
|
+
|
678
|
+
subject-stop (default ':')
|
679
|
+
////
|
680
|
+
|
681
|
+
////
|
682
|
+
== Device and Application Testing
|
683
|
+
|
684
|
+
{project-name} has been tested on the following devices and applications.
|
685
|
+
|
686
|
+
.Computers
|
687
|
+
|===
|
688
|
+
|Device |OS |Resolution |ppi |Browsers |Readium |Gitden |Kindle
|
689
|
+
|
690
|
+
|Asus
|
691
|
+
|Fedora 17
|
692
|
+
|no x no
|
693
|
+
|
|
694
|
+
|Chrome x
|
695
|
+
|Readium
|
696
|
+
|
697
|
+
Asus, Fedora 20, display resolution, Chrome x, Readium
|
698
|
+
Ideapad Y460 |Fedora 20 |1366 x 768 (16:9) |
|
699
|
+
PC, Windows X,
|
700
|
+
|===
|
701
|
+
|
702
|
+
.Tablets
|
703
|
+
|===
|
704
|
+
Asus Transformer, Android x, display resolution, Aldiko, Kindle, Readium, Readmill
|
705
|
+
Nexus,
|
706
|
+
|===
|
707
|
+
|
708
|
+
.Phones
|
709
|
+
|===
|
710
|
+
HTC Sensation, Android x, display resolution, xxxx
|
711
|
+
Nexus ,
|
712
|
+
|===
|
713
|
+
|
714
|
+
////
|
715
|
+
|
716
|
+
== Contributing
|
717
|
+
|
718
|
+
In the spirit of free software, _everyone_ is encouraged to help improve this project.
|
719
|
+
|
720
|
+
To contribute code, simply fork the project on GitHub, hack away and send a pull request with your proposed changes.
|
721
|
+
|
722
|
+
Feel free to use the {project-issues-uri}[issue tracker] or http://discuss.asciidoctor.org[Asciidoctor mailing list] to provide feedback or suggestions in other ways.
|
723
|
+
|
724
|
+
== Authors
|
725
|
+
|
726
|
+
{project-name} was written by https://github.com/mojavelinux[Dan Allen] and https://github.com/graphitefriction[Sarah White] of OpenDevise on behalf of the Asciidoctor Project.
|
727
|
+
|
728
|
+
== Copyright
|
729
|
+
|
730
|
+
Copyright (C) 2014 OpenDevise Inc. and the Asciidoctor Project.
|
731
|
+
Free use of this software is granted under the terms of the MIT License.
|
732
|
+
|
733
|
+
For the full text of the license, see the {license-uri}[LICENSE.adoc] file.
|
734
|
+
Refer to the {notice-uri}[NOTICE.adoc] file for information about third-party Open Source software in use.
|
735
|
+
|
736
|
+
////
|
737
|
+
== Additional Points of Note
|
738
|
+
|
739
|
+
* uppercase chapter titles to work around line-height limitation in Kindle (1.4 minimum)
|
740
|
+
* circled numbers from M+ 1mn for annotation numbers in listing blocks
|
741
|
+
* avatars for authors
|
742
|
+
* document command to generate the M+ 1p latin fonts
|
743
|
+
* recommended readers (Readium, Gitden, Kindle, etc)
|
744
|
+
////
|