From: | M Hunter <hunter [...] fire.org> |
To: | bug-html-tidy [...] rt.cpan.org |
Subject: | HTML::Tidy usage |
Date: | Mon, 23 Feb 2004 21:44:36 -0700 |
hello Andy et al,
I am trying to use HTML::Tidy within perl. I just installed Version 0.02
and I would like to pass a $scalar of HTML (from $response->content) to tidy
and get warnings, errors and a new tidy converted $scalar.
I have been able to feed HTML::Tidy a small string of HTML and get messages
back, but when the HTML string has no messages I get a segmentation fault.
Further, it's not clear to me how to use HTML::Tidy to convert a string of
HTML.
Here's the code I've been playing with:
======== cut below =========
# Program to use tidylib via HTML::Tidy module
use HTML::Tidy;
my $tidy = HTML::Tidy->new();
my $HTML = q(<html><head><title>HTML Tidy</title><body></p>HTML
tidy</head></body></html>
);
my $filename = '/home/hunter/D/test_tidy.txt';
if ( $tidy->parse_file( $filename, $HTML) ) {
print "Parse OK\n";
if ( $tidy->messages() ) {
my @messages = $tidy->messages();
foreach my $message (@messages) {
print $message->text,"\n";
}
}
print "New HTML: $HTML\n";
}
else { print "Parse NOT OK\n"; }
======= cut above =========
How do I get a copy of $HTML after tidy has been applied to it?
- matt hunter