# clean up html file produced by latex2html

undef $/;
$_ = <>;

# Remove extra "=" signs at start
s/\n\s*=\s*\n\s*<P>\s*\n\s*=\s*\n\s*<P>//gi;

# Remove extra <p> tags near section headings
$ws  = "[ \t\n]*";
$lab = '<a name=\w+>[^<>]+</a>';
$sec = "<h[123456]>$ws$lab$ws</h[123456]>";
s/($sec)$ws<p>/$1\n/gio;
s/($sec)$ws($lab)$ws<p>/$1\n$2/gio;

# Remove junky contents of xref destinations
s|(<a name=\w+>)&#\d+;(</a>)|$1 $2|gi;

print;
