Paul McCann
Mon, 17 Jan 2005 16:07:31 -0800
Hi John,
you wrote...
> my question is, how can I create the same sort of script which will
> use HTML::Tidy?
>
> Both the module and the library are installed and running OK on my
> Mac, but I can't seem to get it to work, in fact I can't even figure
> out from the documentation how to get any output from it at all!
I think HTML::Tidy doesn't offer what you're seeking: looks like it's a
validation tool, not a "pretty-print" tool. So your output is empty if things
are well in the world of your html, and warnings/errors if there are problems
validating the string HTML::Tidy is fed.
The following works as a filter in BBEdit, but (as above) I don't think
it'll do what you're seeking!
Do the items in the "Markup->Tidy" submenu do what you're seeking? I'm
pretty sure they hook into a copy of HTML Tidy that's embedded in BBEdit.
Cheers,
Paul
------------------------------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use HTML::Tidy;
local $/;
my $input=<>;
my $dummyfilename='input';
my $tidy = new HTML::Tidy;
$tidy->parse($dummyfilename, $input );
for my $message ( $tidy->messages ) {
print $message->as_string;
}
------------------------------------------------------------------------------