View Single Post
Old 11-28-2012, 03:51 AM   #5
rrt began at the beginning.
Posts: 10
Karma: 10
Join Date: Nov 2012
Device: none
Sorry, I was imprecise. When I said that Calibre generates an empty TOC, I meant that it generates a TOC with just one entry, for the entire document. Here's a shell script to remove the offending TOC entry; however, it's a horrible hack, and what I'm really after is a way to avoid generating it in the first place:

# remove-epub-toc
# Remove the TOC from an EPUB
# (Designed to work with Calibre-generated EPUBs with a single section; see FIXMEs for generalization)
# Reuben Thomas 27th November 2012

# Shell function from atool(1)
aunpack () {
TMP=`mktemp /tmp/aunpack.XXXXXXXXXX`
atool -x --save-outdir=$TMP "$@"
DIR="`cat $TMP`"
[ "$DIR" != "" -a -d "$DIR" ] && cd "$DIR"
rm $TMP


# FIXME: edit the XML properly rather than grepping
# FIXME: ensure identifiers are correct, computed if necessarily

aunpack -F zip "$book"
rm *_split_000.html
sed -i -e 's/split_000/split_001/' toc.ncx
grep -v html2 content.opf >
mv content.opf
apack -F zip "$book" .
mv "$book" ..
cd ..
rm -rf "$DIR"
rrt is offline   Reply With Quote