Skip to content

Commit ac25fd1

Browse files
committed
Restore epub target
1 parent 2bc453e commit ac25fd1

24 files changed

+461
-31
lines changed

Diff for: Makefile

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CHAPTERS := $(basename $(shell ls [0-9][0-9]_*.md) .md)
22

33
SVGS := $(wildcard img/*.svg)
44

5-
all: html book.pdf book_mobile.pdf
5+
all: html book.pdf book_mobile.pdf book.epub
66

77
html: $(foreach CHAP,$(CHAPTERS),html/$(CHAP).html) html/js/acorn_codemirror.js \
88
code/skillsharing.zip code/solutions/20_3_a_public_space_on_the_web.zip html/js/chapter_info.js
@@ -58,3 +58,20 @@ img/generated/%.pdf: img/%.svg
5858

5959
pdf/%.tex: %.md
6060
node src/render_latex.js $< > $@
61+
62+
book.epub: epub/titlepage.xhtml epub/toc.xhtml epub/hints.xhtml $(foreach CHAP,$(CHAPTERS),epub/$(CHAP).xhtml) \
63+
epub/content.opf.src epub/style.css src/add_images_to_epub.js
64+
rm -f $@
65+
grep '<img' epub/*.xhtml | sed -e 's/.*src="\([^"]*\)".*/\1/' | xargs -I{} cp --parents "{}" epub
66+
node src/add_images_to_epub.js
67+
cd epub; zip -X ../$@ mimetype
68+
cd epub; zip -X ../$@ -r * -x mimetype -x content.opf.src
69+
70+
epub/%.xhtml: %.md src/render_html.js
71+
node src/render_html.js --epub $< > $@
72+
73+
epub/hints.xhtml: $(foreach CHAP,$(CHAPTERS),$(CHAP).md) src/extract_hints.js src/render_html.js
74+
node src/extract_hints.js | node src/render_html.js --epub - > $@
75+
76+
epubcheck: book.epub
77+
epubcheck book.epub 2>&1 | grep -v 'img/.*\.svg'

Diff for: epub/META-INF/container.xml

+6
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>

Diff for: epub/content.opf.src

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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">2018-02-25T22:07:00Z</meta>
15+
</metadata>
16+
<manifest>
17+
<item id="titlepage" href="titlepage.xhtml" media-type="application/xhtml+xml"/>
18+
<item id="frontmatter" href="frontmatter.xhtml" media-type="application/xhtml+xml"/>
19+
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml"/>
20+
<item id="c00_intro" href="00_intro.xhtml" media-type="application/xhtml+xml"/>
21+
<item id="c01_values" href="01_values.xhtml" media-type="application/xhtml+xml"/>
22+
<item id="c02_program_structure" href="02_program_structure.xhtml" media-type="application/xhtml+xml" properties="svg"/>
23+
<item id="c03_functions" href="03_functions.xhtml" media-type="application/xhtml+xml"/>
24+
<item id="c04_data" href="04_data.xhtml" media-type="application/xhtml+xml" properties="svg"/>
25+
<item id="c05_higher_order" href="05_higher_order.xhtml" media-type="application/xhtml+xml"/>
26+
<item id="c06_object" href="06_object.xhtml" media-type="application/xhtml+xml" properties="svg"/>
27+
<item id="c07_robot" href="07_robot.xhtml" media-type="application/xhtml+xml"/>
28+
<item id="c08_error" href="08_error.xhtml" media-type="application/xhtml+xml"/>
29+
<item id="c09_regexp" href="09_regexp.xhtml" media-type="application/xhtml+xml" properties="svg"/>
30+
<item id="c10_modules" href="10_modules.xhtml" media-type="application/xhtml+xml"/>
31+
<item id="c11_async" href="11_async.xhtml" media-type="application/xhtml+xml" properties="svg"/>
32+
<item id="c12_language" href="12_language.xhtml" media-type="application/xhtml+xml" properties="svg"/>
33+
<item id="c13_browser" href="13_browser.xhtml" media-type="application/xhtml+xml"/>
34+
<item id="c14_dom" href="14_dom.xhtml" media-type="application/xhtml+xml" properties="svg"/>
35+
<item id="c15_event" href="15_event.xhtml" media-type="application/xhtml+xml"/>
36+
<item id="c16_game" href="16_game.xhtml" media-type="application/xhtml+xml" properties="svg"/>
37+
<item id="c17_canvas" href="17_canvas.xhtml" media-type="application/xhtml+xml" properties="svg"/>
38+
<item id="c18_http" href="18_http.xhtml" media-type="application/xhtml+xml"/>
39+
<item id="c19_paint" href="19_paint.xhtml" media-type="application/xhtml+xml" properties="svg"/>
40+
<item id="c20_node" href="20_node.xhtml" media-type="application/xhtml+xml"/>
41+
<item id="c21_skillsharing" href="21_skillsharing.xhtml" media-type="application/xhtml+xml"/>
42+
<item id="c_hints" href="hints.xhtml" media-type="application/xhtml+xml"/>
43+
<item id="style" href="style.css" media-type="text/css"/>
44+
<item id="font.cinzel.bold" href="font/cinzel_bold.otf" media-type="application/vnd.ms-opentype"/>
45+
<item id="font.pt.regular" href="font/pt_mono.otf" media-type="application/vnd.ms-opentype"/>
46+
{{images}}
47+
</manifest>
48+
<spine>
49+
<itemref idref="titlepage" linear="yes"/>
50+
<itemref idref="frontmatter" linear="yes"/>
51+
<itemref idref="toc" linear="yes"/>
52+
<itemref idref="c00_intro" linear="yes"/>
53+
<itemref idref="c01_values" linear="yes"/>
54+
<itemref idref="c02_program_structure" linear="yes"/>
55+
<itemref idref="c03_functions" linear="yes"/>
56+
<itemref idref="c04_data" linear="yes"/>
57+
<itemref idref="c05_higher_order" linear="yes"/>
58+
<itemref idref="c06_object" linear="yes"/>
59+
<itemref idref="c07_robot" linear="yes"/>
60+
<itemref idref="c08_error" linear="yes"/>
61+
<itemref idref="c09_regexp" linear="yes"/>
62+
<itemref idref="c10_modules" linear="yes"/>
63+
<itemref idref="c11_async" linear="yes"/>
64+
<itemref idref="c12_language" linear="yes"/>
65+
<itemref idref="c13_browser" linear="yes"/>
66+
<itemref idref="c14_dom" linear="yes"/>
67+
<itemref idref="c15_event" linear="yes"/>
68+
<itemref idref="c16_game" linear="yes"/>
69+
<itemref idref="c17_canvas" linear="yes"/>
70+
<itemref idref="c18_http" linear="yes"/>
71+
<itemref idref="c19_paint" linear="yes"/>
72+
<itemref idref="c20_node" linear="yes"/>
73+
<itemref idref="c21_skillsharing" linear="yes"/>
74+
<itemref idref="c_hints" linear="yes"/>
75+
</spine>
76+
</package>

Diff for: epub/font/cinzel_bold.otf

125 KB
Binary file not shown.

Diff for: epub/font/pt_mono.otf

78.2 KB
Binary file not shown.

Diff for: epub/frontmatter.xhtml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
<link rel="stylesheet" href="style.css"/>
5+
<title>Eloquent JavaScript</title>
6+
<style>
7+
img.logo { vertical-align: text-top; padding: 0px 4px; border: 0; }
8+
</style>
9+
</head>
10+
<body>
11+
<h1>Eloquent JavaScript</h1>
12+
<p>Written by Marijn Haverbeke.</p>
13+
14+
<p>Licensed under
15+
a <a href="http://creativecommons.org/licenses/by-nc/3.0/">Creative
16+
Commons attribution-noncommercial license</a>. All code in this book
17+
may also be considered licensed under
18+
an <a href="http://opensource.org/licenses/MIT">MIT license</a>.</p>
19+
20+
<p style="font-size: 80%">Illustrations by various artists: Cover
21+
and chapter illustrations by Madalina Tantareanu. Pixel art in
22+
Chapters 7 and 16 by Antonio Perdomo Pastor. Regular expression
23+
diagrams in Chapter 9 generated
24+
with <a href="http://regexper.com">regexper.com</a> by Jeff
25+
Avallone. Village photograph in Chapter 11 by Fabrice Creuzot.
26+
Game concept for Chapter 15
27+
by <a href="http://lessmilk.com">Thomas Palef</a>.</p>
28+
29+
<p style="font-size: 80%">The third edition was made possible
30+
by <a href="https://eloquentjavascript.net/backers3.html">325 financial backers</a>, most
31+
notably <a href="https://nextjournal.com/"><img src="img/nextjournal.png"
32+
alt="Nextjournal" class="logo"/></a>
33+
and <a href="https://www.holbertonschool.com/"><img src="img/holberton.png"
34+
alt="Holberton School" class="logo"/></a>. The second edition was
35+
supported by <a href="https://eloquentjavascript.net/backers.html">454 backers</a>, with
36+
significant contributions
37+
from <a href="http://www.mozilla.org/en-US/"><img src="img/mozilla_mini.png"
38+
alt="Mozilla" class="logo"/></a>,
39+
<a href="http://www.hackreactor.com/"><img src="img/hack_reactor_mini.png"
40+
alt="Hack Reactor" class="logo"/></a>,
41+
and <a href="http://www.ghostery.com/"><img src="img/ghostery_mini.png"
42+
alt="Ghostery" class="logo"/></a>.</p>
43+
44+
<p>A <a href="https://www.amazon.com/Eloquent-JavaScript-2nd-Ed-Introduction/dp/1593275846">paper
45+
version</a> of Eloquent JavaScript, including a bonus chapter, is
46+
being brought out by <a href="http://www.nostarch.com/">No Starch
47+
Press</a>. They also sell a more polished EPUB version that
48+
includes the bonus chapter.</p>
49+
50+
</body>
51+
</html>

Diff for: epub/mimetype

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

Diff for: epub/style.css

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
text-align: left;
22+
}
23+
24+
article {
25+
padding: 2em 0 5em 0;
26+
}
27+
28+
pre {
29+
padding: 5px 0 5px 15px;
30+
line-height: 1.35;
31+
margin: 1rem 0;
32+
position: relative;
33+
font-size: 16px;
34+
}
35+
36+
code, pre {
37+
font-family: 'PT Mono', monospace;
38+
}
39+
40+
code {
41+
font-size: 18px;
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+
font-size: 85%;
73+
}
74+
75+
blockquote p {
76+
color: #333;
77+
}
78+
79+
blockquote p:first-of-type:before {
80+
content: '“';
81+
}
82+
83+
blockquote p:last-of-type:after {
84+
content: '”';
85+
}
86+
87+
p + footer {
88+
margin-top: -.5em;
89+
}
90+
91+
blockquote footer cite {
92+
font-style: italic;
93+
}
94+
95+
blockquote footer:before {
96+
content: '—';
97+
}
98+
99+
figure img {
100+
max-width: 80%;
101+
margin-left: 30px;
102+
}
103+
104+
figure.chapter {
105+
text-align: center;
106+
margin: 3em 0 2em;
107+
}
108+
109+
figure.chapter img {
110+
max-width: 75%;
111+
}
112+
113+
figure.framed img {
114+
border-radius: 50%;
115+
border: 2px solid black;
116+
}
117+
118+
td {
119+
vertical-align: top;
120+
}
121+
122+
td + td {
123+
padding-left: 1em;
124+
}
125+
126+
table {
127+
margin-left: 15px;
128+
}
129+
130+
/* Syntax highlighting */
131+
.cm-keyword {color: #506;}
132+
.cm-atom {color: #106;}
133+
.cm-number {color: #042;}
134+
.cm-def {color: #009;}
135+
.cm-variable-2, .cm-attribute {color: #027;}
136+
.cm-variable-3 {color: #072;}
137+
.cm-comment {color: #740;}
138+
.cm-string {color: #700;}
139+
.cm-string-2 {color: #740;}
140+
.cm-tag {color: #170;}
141+
.cm-keyword {color: #708;}
142+
.cm-atom {color: #219;}
143+
.cm-number {color: #164;}
144+
.cm-def {color: #00f;}

Diff for: epub/titlepage.xhtml

+16
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.jpg" alt="Eloquent JavaScript 3rd edition"/>
14+
</div>
15+
</body>
16+
</html>

Diff for: epub/toc.xhtml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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>Table of Contents</title>
5+
<link rel="stylesheet" href="style.css"/>
6+
<style type="text/css">
7+
ol.toc {
8+
margin: 1em 0;
9+
padding: 0;
10+
}
11+
ol.toc li {
12+
margin: 0 0 0 40px;
13+
padding: 0;
14+
list-style: none;
15+
}
16+
ol.toc span.parttitle {
17+
display: block;
18+
float: right;
19+
margin: -2px 0;
20+
font-weight: normal;
21+
font-size: 90%;
22+
}
23+
span.hidden { visibility: hidden; }
24+
</style>
25+
</head>
26+
27+
<body>
28+
<h1>Table of Contents</h1>
29+
<nav xmlns:epub="http://www.idpf.org/2007/ops" epub:type="toc" id="toc">
30+
<ol class="toc">
31+
<li><span class="hidden">00. </span><a href="00_intro.xhtml">Introduction</a></li>
32+
<li>
33+
<span class="parttitle">(Part 1: Language)</span>
34+
<span class="hidden">0</span>1. <a href="01_values.xhtml">Values, Types, and Operators</a>
35+
</li>
36+
<li><span class="hidden">0</span>2. <a href="02_program_structure.xhtml">Program Structure</a></li>
37+
<li><span class="hidden">0</span>3. <a href="03_functions.xhtml">Functions</a></li>
38+
<li><span class="hidden">0</span>4. <a href="04_data.xhtml">Data Structures: Objects and Arrays</a></li>
39+
<li><span class="hidden">0</span>5. <a href="05_higher_order.xhtml">Higher-order Functions</a></li>
40+
<li><span class="hidden">0</span>6. <a href="06_object.xhtml">The Secret Life of Objects</a></li>
41+
<li><span class="hidden">0</span>7. <a href="07_robot.xhtml">Project: A Robot</a></li>
42+
<li><span class="hidden">0</span>8. <a href="08_error.xhtml">Bugs and Errors</a></li>
43+
<li><span class="hidden">0</span>9. <a href="09_regexp.xhtml">Regular Expressions</a></li>
44+
<li>10. <a href="10_modules.xhtml">Modules</a></li>
45+
<li>11. <a href="11_async.xhtml">Asynchronous Programming</a></li>
46+
<li>12. <a href="12_language.xhtml">Project: A Programming Language</a></li>
47+
<li style="position: relative">
48+
<span class="parttitle">(Part 2: Browser)</span>
49+
13. <a href="13_browser.xhtml">JavaScript and the Browser<span class="parttitle">(Part 2: Browser)</span></a>
50+
</li>
51+
<li>14. <a href="14_dom.xhtml">The Document Object Model</a></li>
52+
<li>15. <a href="15_event.xhtml">Handling Events</a></li>
53+
<li>16. <a href="16_game.xhtml">Project: A Platform Game</a></li>
54+
<li>17. <a href="17_canvas.xhtml">Drawing on Canvas</a></li>
55+
<li>18. <a href="18_http.xhtml">HTTP and Forms</a></li>
56+
<li>19. <a href="19_paint.xhtml">Project: A Pixel Art Editor</a></li>
57+
<li style="position: relative">
58+
<span class="parttitle">(Part 3: Node)</span>
59+
20. <a href="20_node.xhtml">Node.js</a>
60+
</li>
61+
<li>21. <a href="21_skillsharing.xhtml">Project: Skill-Sharing Website</a></li>
62+
<li><span class="hidden">00.</span> <a href="hints.xhtml">Hints to the exercises</a></li>
63+
</ol>
64+
</nav>
65+
</body>
66+
</html>

0 commit comments

Comments
 (0)