- commit
- 869bc11
- parent
- 54e26d6
- author
- cruft
- date
- 2009-11-18 22:38:27 -0700 MST
ePub version which works on Sony Reader
M
Makefile
+4,
-1
1@@ -26,8 +26,11 @@ horrors2.mdwn: horrors2.ltx $(STORIES)
2 ./toxhtml.py > $@
3
4 horrors2.xhtml: horrors2.mdwn head.xhtml foot.xhtml
5- cat head.xhtml > $@
6 markdown $< >> $@
7+
8+book.xhtml: horrors2.xhtml
9+ cat head.xhtml > $@
10+ cat $< >> $@
11 cat foot.xhtml >> $@
12
13 book.epub: horrors2.xhtml
M
mkepub
+41,
-7
1@@ -1,9 +1,35 @@
2 #! /bin/sh
3
4-cat horrors2.xhtml > epub/book.xhtml
5+kersplit () {
6+ first=1
7+ # Add an extra line to chop
8+ parts=$( (cat horrors2.xhtml; echo) | sed -n '/class="part/=;$=')
9+ for part in $parts; do
10+ fn=$1; shift
11+ cat head.xhtml > $fn
12+ last=$(expr $part - 1)
13+ sed -n "${first},${last}p" horrors2.xhtml >> $fn
14+ cat foot.xhtml >> $fn
15+ first=$part
16+ done
17+}
18+
19+xhtml="epub/book.xhtml epub/part1.xhtml epub/part2.xhtml epub/part3.xhtml epub/part4.xhtml epub/part5.xhtml epub/part6.xhtml epub/part7.xhtml"
20+kersplit $xhtml
21+
22+
23 rm -rf epub/art
24-mkdir epub/art
25-cp art/*.png art/*.jpg epub/art
26+if true; then
27+ mkdir epub/art
28+ for i in art/*.png; do
29+ echo $i
30+ pngtopnm $i | pnmscale -xysize 800 600 | pnmtopng > epub/$i
31+ done
32+ for i in art/*.jpg; do
33+ echo $i
34+ jpegtopnm $i | pnmscale -xysize 800 600 | pnmtojpeg > epub/$i
35+ done
36+fi
37 cp style.css epub/
38
39
40@@ -27,17 +53,19 @@ cat > content.opf <<EOF
41
42 <manifest>
43 EOF
44+rm spine
45 find . -type f | sed 's#./##' | while read fn; do
46 b=$(basename $fn)
47 id=thing$count
48 count=$(expr $count + 1)
49 case "$b" in
50- META-INF/*|MANIFEST|mimetype|content.opf)
51+ META-INF/*|MANIFEST|mimetype|content.opf|spine)
52 continue
53 ;;
54- book.xhtml)
55- id=book
56+ *.xhtml)
57+ id=$(basename $b .xhtml)
58 type=application/xhtml+xml
59+ echo $id >> spine
60 ;;
61 *.css)
62 type=image/css
63@@ -65,7 +93,13 @@ cat >> content.opf <<EOF
64 </manifest>
65
66 <spine toc="ncx">
67- <itemref idref="book" />
68+EOF
69+sort spine | while read id; do
70+ # "book" sorts before "part*" :)
71+ echo " <itemref idref=\"$id\" />" >> content.opf
72+done
73+rm spine
74+cat >> content.opf <<EOF
75 </spine>
76 </package>
77 EOF
+2,
-1
1@@ -17,7 +17,8 @@
2
3 body {
4 max-width: 40em;
5- font-family: Antykwa Torunska;
6+ font-family: "Antykwa Torunska";
7+ text-align: justify;
8 }
9
10 img {