macosx  

HTML::Tidy Filter for BBEdit?

John Horner
Mon, 17 Jan 2005 01:59:03 -0800

I have a very useful Perl::Tidy Filter in BBEdit, though I'm not quite sure where I got it from.

Essentially it takes input from the selection of the current window, and when invoked, writes Tidy'd code back to the selection.

It's terribly simple, in fact I'll post the entire thing here (minus a couple of comments):

#!/usr/bin/perl -wn
use Perl::Tidy;
BEGIN { my $input_string = ""; my $output_string = ""; }
$input_string .= $_;
END {
    Perl::Tidy::perltidy(
        source      => \$input_string,
        destination => \$output_string,
    );

    print "$output_string\n";
}
__END__

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!

According to http://search.cpan.org/~petdance/HTML-Tidy-1.04/lib/HTML/Tidy.pm the module only has six methods, none of which returns my HTML to me in any form -- am I missing something? The messages say things like "deleting empty <p> tag", but if it doesn't return anything, so what? Should I be using the API for libtidy itself, and if so, how?

------------------------------------------------------------
               "Have You Validated Your Code?"
John Horner                            (+612 / 02) 9333 3488
Senior Developer, ABC Online          http://www.abc.net.au/
------------------------------------------------------------