Skip to content

Commit f7ccf5a

Browse files
committed
Add the skeleton of an epub target
1 parent f241462 commit f7ccf5a

11 files changed

Lines changed: 425 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
/toc.txt
1919
/img/generated/*
2020
/img/cover.xcf
21+
/epub/[012]*.xhtml
22+
/epub/img/*
23+
/Eloquent_JavaScript.epub

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ ejs_tex.zip: nostarch/book.tex $(foreach CHAP,$(CHAPTERS),nostarch/$(CHAP).tex)
8383
cd /tmp; zip -r ejs_tex.zip ejs_tex
8484
mv /tmp/ejs_tex.zip $@
8585
rm -rf $(TMPDIR)
86+
87+
Eloquent_JavaScript.epub: epub/titlepage.xhtml epub/toc.xhtml $(foreach CHAP,$(CHAPTERS),epub/$(CHAP).xhtml) epub/content.opf epub/style.css
88+
rm -f $@
89+
cd epub; zip -X ../$@ mimetype
90+
cd epub; zip -X ../$@ -r * -x mimetype
91+
92+
epub/%.xhtml: %.txt asciidoc_epub.conf
93+
asciidoc -f asciidoc_epub.conf --backend=xhtml11 -o $@ $<

asciidoc_epub.conf

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
[miscellaneous]
2+
newline=\n
3+
4+
[attributes]
5+
disable-javascript=True
6+
warnings=False
7+
highlight=False
8+
book_target=True
9+
encoding=UTF-8
10+
sectids!
11+
12+
lsquo=‘
13+
rsquo=’
14+
ldquo=“
15+
rdquo=”
16+
17+
[quotes]
18+
`=#monospaced
19+
20+
[macros]
21+
(?su)(?<!\w)indexsee:\[(?P<attrlist>[^\]]*?)\]=indexsee
22+
\(!html (?P<text>(?:.|\n)*?)!\)=htmlonly
23+
\(!book (?P<text>(?:.|\n)*?)!\)=texonly
24+
(?su)(?<!\()[\\]?\(\(\((?P<attrlist>[^(](?:[^()]|\n)*?)\)\)\)(?!\))=indexterm
25+
(?<!\()[\\]?\(\((?P<attrlist>[^\s\(][^(](?:[^()]|\n)*?)\)\)(?!\))=indexterm2
26+
27+
[replacements]
28+
(\w)\'(\w)=\1’\2
29+
(?<!\\)\.\.\.=...
30+
31+
[source-highlight-block]
32+
<pre{id? id="{id}"}>
33+
|
34+
</pre>
35+
36+
[source-filter-style]
37+
source-style=template="source-highlight-block"
38+
39+
[blockdef-listing]
40+
template::[source-filter-style]
41+
42+
[listingblock]
43+
<pre{id? id="{id}"}>
44+
|
45+
</pre>
46+
47+
[indexsee-inlinemacro]
48+
{empty}
49+
50+
[htmlonly-inlinemacro]
51+
{text}
52+
53+
[texonly-inlinemacro]
54+
{empty}
55+
56+
[header]
57+
<?xml version="1.0" encoding="UTF-8"?>
58+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
59+
<head>
60+
<title>{doctitle}</title>
61+
<link rel="stylesheet" href="style.css"/>
62+
</head>
63+
<body>
64+
<article>
65+
66+
<h1{id? id="{id}"}>{chap_num?<span class="chap_num">Chapter {chap_num}</span>}{doctitle}</h1>
67+
68+
[footer]
69+
</article>
70+
</body>
71+
</html>
72+
73+
[preamble]
74+
|
75+
76+
[paragraph]
77+
<p{id? id="{id}"}>
78+
|
79+
</p>
80+
81+
[tags]
82+
monospaced=<code>|</code>
83+
84+
[literal-inlinemacro]
85+
<code>{passtext}</code>
86+
87+
[sect1]
88+
<h2{id? id="{id}"}>{title}</h2>
89+
|
90+
91+
[sect2]
92+
<h3{id? id="{id}"}>{title}</h3>
93+
|
94+
95+
[sect3]
96+
<h4{id? id="{id}"}>{title}</h4>
97+
|
98+
99+
[quoteblock]
100+
<blockquote>
101+
|
102+
{attribution? <footer>{attribution}{citetitle?, <cite>{citetitle}</cite>}</footer>}
103+
</blockquote>
104+
105+
[image-blockmacro]
106+
<div class="image"{id? id="{id}"}>
107+
<img src="{target}" alt="{alt={target}}"/>
108+
</div>
109+
110+
[table]
111+
<table{id? id="{id}"}>
112+
{headrows#}<thead>
113+
{headrows}
114+
{headrows#}</thead>
115+
{footrows#}<tfoot>
116+
{footrows}
117+
{footrows#}</tfoot>
118+
{bodyrows}
119+
</table>
120+
121+
[tabletags-default]
122+
bodyrow=<tr>|</tr>
123+
headdata=<th>|</th>
124+
bodydata=<td>|</td>
125+
paragraph=|

epub/META-INF/container.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
3+
<rootfiles>
4+
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
5+
</rootfiles>
6+
</container>

epub/content.opf

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="pub-id" prefix="cc: http://creativecommons.org/ns#">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title id="title">Eloquent JavaScript</dc:title>
5+
<meta refines="#title" property="title-type">main</meta>
6+
<dc:creator id="creator">Marijn Haverbeke</dc:creator>
7+
<meta refines="#creator" property="file-as">HAVERBEKE, MARIJN</meta>
8+
<meta refines="#creator" property="role" scheme="marc:relators">aut</meta>
9+
<dc:identifier id="pub-id">net.eloquentjavascript</dc:identifier>
10+
<dc:language>en-US</dc:language>
11+
<dc:rights>This work is shared with the public using the Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0) license.</dc:rights>
12+
<link rel="cc:license" href="http://creativecommons.org/licenses/by-nc/3.0/"/>
13+
<meta property="cc:attributionURL">http://eloquentjavascript.net/</meta>
14+
<meta property="dcterms:modified">2014-09-04T10:47:00Z</meta>
15+
</metadata>
16+
<manifest>
17+
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml"/>
18+
<item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
19+
<item id="c00_intro" href="00_intro.xhtml" media-type="application/xhtml+xml"/>
20+
<item id="c01_values" href="01_values.xhtml" media-type="application/xhtml+xml"/>
21+
<item id="c02_program_structure" href="02_program_structure.xhtml" media-type="application/xhtml+xml"/>
22+
<item id="c03_functions" href="03_functions.xhtml" media-type="application/xhtml+xml"/>
23+
<item id="c04_data" href="04_data.xhtml" media-type="application/xhtml+xml"/>
24+
<item id="c05_higher_order" href="05_higher_order.xhtml" media-type="application/xhtml+xml"/>
25+
<item id="c06_object" href="06_object.xhtml" media-type="application/xhtml+xml"/>
26+
<item id="c07_elife" href="07_elife.xhtml" media-type="application/xhtml+xml"/>
27+
<item id="c08_error" href="08_error.xhtml" media-type="application/xhtml+xml"/>
28+
<item id="c09_regexp" href="09_regexp.xhtml" media-type="application/xhtml+xml"/>
29+
<item id="c10_modules" href="10_modules.xhtml" media-type="application/xhtml+xml"/>
30+
<item id="c11_language" href="11_language.xhtml" media-type="application/xhtml+xml"/>
31+
<item id="c12_browser" href="12_browser.xhtml" media-type="application/xhtml+xml"/>
32+
<item id="c13_dom" href="13_dom.xhtml" media-type="application/xhtml+xml"/>
33+
<item id="c14_event" href="14_event.xhtml" media-type="application/xhtml+xml"/>
34+
<item id="c15_game" href="15_game.xhtml" media-type="application/xhtml+xml"/>
35+
<item id="c16_canvas" href="16_canvas.xhtml" media-type="application/xhtml+xml"/>
36+
<item id="c17_http" href="17_http.xhtml" media-type="application/xhtml+xml"/>
37+
<item id="c18_forms" href="18_forms.xhtml" media-type="application/xhtml+xml"/>
38+
<item id="c19_paint" href="19_paint.xhtml" media-type="application/xhtml+xml"/>
39+
<item id="c20_node" href="20_node.xhtml" media-type="application/xhtml+xml"/>
40+
<item id="c21_skillsharing" href="21_skillsharing.xhtml" media-type="application/xhtml+xml"/>
41+
<item id="style" href="style.css" media-type="text/css"/>
42+
<item id="font.cinzel.bold" href="font/cinzel_bold.otf" media-type="application/vnd.ms-opentype"/>
43+
<item id="font.pt.regular" href="font/pt_mono.otf" media-type="application/vnd.ms-opentype"/>
44+
<item id="cover-image" properties="cover-image" href="img/cover.png" media-type="image/png"/>
45+
</manifest>
46+
<spine>
47+
<itemref idref="titlepage" linear="yes"/>
48+
<itemref idref="c00_intro" linear="yes"/>
49+
<itemref idref="c01_values" linear="yes"/>
50+
<itemref idref="c02_program_structure" linear="yes"/>
51+
<itemref idref="c03_functions" linear="yes"/>
52+
<itemref idref="c04_data" linear="yes"/>
53+
<itemref idref="c05_higher_order" linear="yes"/>
54+
<itemref idref="c06_object" linear="yes"/>
55+
<itemref idref="c07_elife" linear="yes"/>
56+
<itemref idref="c08_error" linear="yes"/>
57+
<itemref idref="c09_regexp" linear="yes"/>
58+
<itemref idref="c10_modules" linear="yes"/>
59+
<itemref idref="c11_language" linear="yes"/>
60+
<itemref idref="c12_browser" linear="yes"/>
61+
<itemref idref="c13_dom" linear="yes"/>
62+
<itemref idref="c14_event" linear="yes"/>
63+
<itemref idref="c15_game" linear="yes"/>
64+
<itemref idref="c16_canvas" linear="yes"/>
65+
<itemref idref="c17_http" linear="yes"/>
66+
<itemref idref="c18_forms" linear="yes"/>
67+
<itemref idref="c19_paint" linear="yes"/>
68+
<itemref idref="c20_node" linear="yes"/>
69+
<itemref idref="c21_skillsharing" linear="yes"/>
70+
<itemref idref="toc" linear="no"/>
71+
</spine>
72+
</package>

epub/font/cinzel_bold.otf

125 KB
Binary file not shown.

epub/font/pt_mono.otf

78.2 KB
Binary file not shown.

epub/mimetype

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

epub/style.css

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
@font-face {
2+
font-family: 'Cinzel';
3+
font-style: normal;
4+
font-weight: 700;
5+
src: url(font/cinzel_bold.otf);
6+
}
7+
8+
@font-face {
9+
font-family: 'PT Mono';
10+
font-style: normal;
11+
font-weight: 400;
12+
src: url(font/pt_mono.otf);
13+
}
14+
15+
body {
16+
font-family: Georgia, 'Nimbus Roman No9 L', 'Century Schoolbook L', serif;
17+
font-size: 20px;
18+
line-height: 1.45;
19+
color: black;
20+
background: white;
21+
}
22+
23+
article {
24+
margin: 0 auto;
25+
max-width: 35em;
26+
padding: 2em 0 5em 0;
27+
}
28+
29+
pre {
30+
padding: 5px 0 5px 15px;
31+
line-height: 1.35;
32+
margin: 1rem 0;
33+
position: relative;
34+
}
35+
36+
code, pre {
37+
font-size: 18px;
38+
font-family: 'PT Mono', monospace;
39+
}
40+
41+
code {
42+
padding: 0 2px;
43+
}
44+
45+
h1, h2, h3 {
46+
font-family: 'Cinzel', Georgia, serif;
47+
font-weight: 700;
48+
margin: 1rem 0;
49+
letter-spacing: 2px;
50+
}
51+
52+
h1 {
53+
font-size: 130%;
54+
}
55+
h2 {
56+
font-size: 115%;
57+
}
58+
h3 {
59+
font-size: 100%;
60+
}
61+
62+
span.chap_num {
63+
display: block;
64+
font-size: 60%;
65+
color: #aaa;
66+
margin-top: -.7em;
67+
}
68+
69+
blockquote {
70+
margin: 0 0 0 3em;
71+
padding: 0;
72+
position: relative;
73+
font-size: 85%;
74+
}
75+
76+
blockquote p {
77+
color: #333;
78+
}
79+
80+
blockquote:before {
81+
content: '“';
82+
position: absolute;
83+
left: -.5em;
84+
}
85+
86+
blockquote footer {
87+
position: relative;
88+
margin-left: 1em;
89+
}
90+
91+
p + footer {
92+
margin-top: -.5em;
93+
}
94+
95+
blockquote footer cite {
96+
font-style: italic;
97+
}
98+
99+
blockquote footer:before {
100+
content: '—';
101+
position: absolute;
102+
left: -1em;
103+
}
104+
105+
div.image img {
106+
max-width: 640px;
107+
margin-left: 30px;
108+
}
109+
110+
td {
111+
vertical-align: top;
112+
}
113+
114+
td + td {
115+
padding-left: 1em;
116+
}
117+
118+
table {
119+
margin-left: 15px;
120+
}

epub/titlepage.xhtml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
3+
<head>
4+
<title>Cover</title>
5+
<link rel="stylesheet" href="style.css"/>
6+
<style type="text/css" title="override_css">
7+
@page {padding: 0pt; margin:0pt}
8+
body { text-align: center; padding:0pt; margin: 0pt; }
9+
</style>
10+
</head>
11+
<body>
12+
<div>
13+
<img src="img/cover.png" alt="cover"/>
14+
</div>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)