use HTML::TokeParser::Simple;
use HTML::Entities;
use File::Copy;
my $new_html = '';
my $orig_html = shift || die "Usage: $0 some.html";
copy( $orig_html, "${orig_html}.bak")
or die "Could not copy ($orig_html): $!";
my $parser = HTML::TokeParser::Simple->new($orig_html);
while (my $token = $parser->get_token) {
if ($token->is_tag) {
$new_html .= $token->as_is;
next;
}
$new_html .= encode_entities($token->as_is);
}
open OUTPUT "> $orig_html" or die "Cannot open ($orig_html) for writing: $!";
print OUTPUT $new_html;
close OUTPUT;