##
sub escapeHTML {
my ( $escape, $text ) = @_;
return '' unless defined $escape ;
$escape =~ s/&/&/g;
$escape =~ s/"/"/g;
$escape =~ s/</g;
$escape =~ s/>/>/g;
# these next optional escapes make text look the same when rendered in HTML
# without wrapping in tags
if ( $text ) {
$escape =~ s/\t/ /g; # tabs to 4 spaces
$escape =~ s/( {2,})/" " x length $1/eg; # whitespace escapes
$escape =~ s/\n/
\n/g; # newlines to
}
$escape =~ s/([^\000-\177])/'' . (sprintf "%3d", ord $1) . ';'/eg;
return $escape;
}
##