ePub version which works on Sony Reader

This commit is contained in:
cruft 2009-11-18 22:38:27 -07:00
parent 54e26d66c4
commit 869bc114c1
3 changed files with 47 additions and 9 deletions

View File

@ -26,8 +26,11 @@ horrors2.mdwn: horrors2.ltx $(STORIES)
./toxhtml.py > $@ ./toxhtml.py > $@
horrors2.xhtml: horrors2.mdwn head.xhtml foot.xhtml horrors2.xhtml: horrors2.mdwn head.xhtml foot.xhtml
cat head.xhtml > $@
markdown $< >> $@ markdown $< >> $@
book.xhtml: horrors2.xhtml
cat head.xhtml > $@
cat $< >> $@
cat foot.xhtml >> $@ cat foot.xhtml >> $@
book.epub: horrors2.xhtml book.epub: horrors2.xhtml

48
mkepub
View File

@ -1,9 +1,35 @@
#! /bin/sh #! /bin/sh
cat horrors2.xhtml > epub/book.xhtml kersplit () {
first=1
# Add an extra line to chop
parts=$( (cat horrors2.xhtml; echo) | sed -n '/class="part/=;$=')
for part in $parts; do
fn=$1; shift
cat head.xhtml > $fn
last=$(expr $part - 1)
sed -n "${first},${last}p" horrors2.xhtml >> $fn
cat foot.xhtml >> $fn
first=$part
done
}
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"
kersplit $xhtml
rm -rf epub/art rm -rf epub/art
mkdir epub/art if true; then
cp art/*.png art/*.jpg epub/art mkdir epub/art
for i in art/*.png; do
echo $i
pngtopnm $i | pnmscale -xysize 800 600 | pnmtopng > epub/$i
done
for i in art/*.jpg; do
echo $i
jpegtopnm $i | pnmscale -xysize 800 600 | pnmtojpeg > epub/$i
done
fi
cp style.css epub/ cp style.css epub/
@ -27,17 +53,19 @@ cat > content.opf <<EOF
<manifest> <manifest>
EOF EOF
rm spine
find . -type f | sed 's#./##' | while read fn; do find . -type f | sed 's#./##' | while read fn; do
b=$(basename $fn) b=$(basename $fn)
id=thing$count id=thing$count
count=$(expr $count + 1) count=$(expr $count + 1)
case "$b" in case "$b" in
META-INF/*|MANIFEST|mimetype|content.opf) META-INF/*|MANIFEST|mimetype|content.opf|spine)
continue continue
;; ;;
book.xhtml) *.xhtml)
id=book id=$(basename $b .xhtml)
type=application/xhtml+xml type=application/xhtml+xml
echo $id >> spine
;; ;;
*.css) *.css)
type=image/css type=image/css
@ -65,7 +93,13 @@ cat >> content.opf <<EOF
</manifest> </manifest>
<spine toc="ncx"> <spine toc="ncx">
<itemref idref="book" /> EOF
sort spine | while read id; do
# "book" sorts before "part*" :)
echo " <itemref idref=\"$id\" />" >> content.opf
done
rm spine
cat >> content.opf <<EOF
</spine> </spine>
</package> </package>
EOF EOF

View File

@ -17,7 +17,8 @@
body { body {
max-width: 40em; max-width: 40em;
font-family: Antykwa Torunska; font-family: "Antykwa Torunska";
text-align: justify;
} }
img { img {