#!/bin/sh -e
# biber2html bibfile.bib [keys...] - display bibliography entries as HTML
if [ "$#" -eq 0 ]; then
echo "Usage: biber2html bibfile.bib [keys...] (default: all)" 1>&2
exit 111
fi
if ! BIBFILE=$(readlink -e "$1"); then
echo "bibliography not found: $1" 1>&2
exit 1
fi
shift
[ "$#" -eq 0 ] && set -- '*'
WRKDIR=$(mktemp -d)
cd $WRKDIR
cat >biber2html.tex <biber2html.cfg <<'EOF'
\Preamble{xhtml,NoFonts,-css,ext=html,charset="utf-8"}
\begin{document}
\EndPreamble
\Configure{emph}{\Protect\HCode{}}{\Protect\HCode{}}
\Configure{textbf}{\Protect\HCode{}}{\Protect\HCode{}}
EOF
pdflatex -interaction=nonstopmode -draftmode -halt-on-error biber2html >/dev/null
biber biber2html >/dev/null
pdflatex -interaction=nonstopmode -draftmode -halt-on-error biber2html >/dev/null
htlatex biber2html.tex biber2html.cfg ' -cunihtf -utf8' '-cvalidate' \
'-interaction=nonstopmode -halt-on-error' >/dev/null
tr -s '\012' ' ' \s*\K.*?(?=
)|\s*\K.*?(?=)' |
paste - - |
sed 's:]*id=[^>]*>::g; s: \?class="url" \?::g;
s:[ \t][ \t]*: :g;
s:ff:ff:g; s:fi:fi:g; s:ffi:ffi:g; s:fl:fl:g; s:’:’:g'
echo $WRKDIR
#rm -r "$WRKDIR"