#!/bin/sh
d=$(mktemp -d)
bsdtar xf "$@" -C$d
t=$(fd -e ncx . $d)
xml_grep content $t | uniq | grep content | cut -d\" -f2 |\
sed -e 's#.*#&
#' -e 's#">[^/<]*/#">#'\
-e 's/\.xhtml/\.html/g' > $(dirname $t)/index.html
fd -e xhtml . $d -x mv {} {.}.html
if test -z $BROWSER; then
BROWSER=netsurf
fi
eval $BROWSER $(dirname $t)/index.html
rm -rf $d