Can't stop tweaking

Ovid on 2003-06-10T01:11:06

HTML::TokeParser::Simple 2.1 has just been uploaded to the CPAN. A friend asked why I didn't make one of the private methods public and I couldn't see why not, so I did. The $token->rewrite_tag method automatically lowercases the tag name, attribute names, and properly quotes values. It ignores non tags.

# <body alink=#0000ff
#     BGCOLOR=#ffffff class='none'>
$token->rewrite_tag;
print $token->as_is;
# <body alink="#0000ff" bgcolor="#ffffff" class="none">

It will put the entire tag on one line, though.

Thus, to clean up an entire doc:

while (my $token = $parser->get_token) {
    $token->rewrite_tag; # no tag testing required
    print $token->as_is;
}