#!/usr/bin/perl -w

# Fix stupd html which is embedded in mailman mbox which you download
# this is a filter. Use it like this:
#
# mailman2mbox.pl < mbox > mbox-new
#
# 2003-09-04 Dobrica Pavlinusic <dpavlin@rot13.org>
#

my $first = 1;

while(<STDIN>) {
	if ($first) {
		chomp;
		$first = 0;
		next if ($_ eq ""); # skip first empty line
		$_ .= "\n";
	}

	s,^</*PRE>,,g;
	s,<A HREF="[^"]*">(.+?)</A>,$1,g;

	# fix quoting
	s,^&gt;<i>,>,;
	s,^</I>(&gt;[^<]*)<i>,$1,;
	s,^</I>,,;

	s/&lt;/</g;
	s/&gt;/>/g;
	s/&quot;/"/g;
	s/&amp;/&/g;
	s/(<[^>]+) at ([^>]+>)/$1\@$2/g;
	print;
}
