From 869bc114c19569ec5e70d4764cdd88827935234f Mon Sep 17 00:00:00 2001 From: cruft Date: Wed, 18 Nov 2009 22:38:27 -0700 Subject: [PATCH] ePub version which works on Sony Reader --- Makefile | 5 ++++- mkepub | 48 +++++++++++++++++++++++++++++++++++++++++------- style.css | 3 ++- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 37d78e2..2a474fc 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,11 @@ horrors2.mdwn: horrors2.ltx $(STORIES) ./toxhtml.py > $@ horrors2.xhtml: horrors2.mdwn head.xhtml foot.xhtml - cat head.xhtml > $@ markdown $< >> $@ + +book.xhtml: horrors2.xhtml + cat head.xhtml > $@ + cat $< >> $@ cat foot.xhtml >> $@ book.epub: horrors2.xhtml diff --git a/mkepub b/mkepub index 798bc67..96504f2 100755 --- a/mkepub +++ b/mkepub @@ -1,9 +1,35 @@ #! /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 -mkdir epub/art -cp art/*.png art/*.jpg epub/art +if true; then + 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/ @@ -27,17 +53,19 @@ cat > content.opf < EOF +rm spine find . -type f | sed 's#./##' | while read fn; do b=$(basename $fn) id=thing$count count=$(expr $count + 1) case "$b" in - META-INF/*|MANIFEST|mimetype|content.opf) + META-INF/*|MANIFEST|mimetype|content.opf|spine) continue ;; - book.xhtml) - id=book + *.xhtml) + id=$(basename $b .xhtml) type=application/xhtml+xml + echo $id >> spine ;; *.css) type=image/css @@ -65,7 +93,13 @@ cat >> content.opf < - +EOF +sort spine | while read id; do + # "book" sorts before "part*" :) + echo " " >> content.opf +done +rm spine +cat >> content.opf < EOF diff --git a/style.css b/style.css index 9b83cdc..7446c4c 100644 --- a/style.css +++ b/style.css @@ -17,7 +17,8 @@ body { max-width: 40em; - font-family: Antykwa Torunska; + font-family: "Antykwa Torunska"; + text-align: justify; } img {