#!/usr/bin/bash

in=$1
tmp=mktemp

extract_html_element $in div id scroll-content > $tmp

tidy5 -m $tmp &> /dev/null

sed -e 's/class="footnote"><sup>\([0-9]\+\) *<\/sup>/class="footnote"><a id="fn\1" href="#ref\1">\1<\/a>./g' \
	-e 's/class="footnote">\([0-9]\+\)/class="footnote"><a id="fn\1" href="#ref\1">\1<\/a>./g' \
	-e 's/<sup>\([0-9]\+\)<\/sup>/<sup><a id="ref\1" href="#fn\1">\1<\/a><\/sup>/g' \
	-e 's/<\/\?subhead[^>]*>//g' \
	$tmp

