1package TestUtils;
2
3use HTML::PrettyPrinter;
4use FileHandle;
5use File::Slurp;
6
7use Carp qw(carp cluck croak confess);
8
9require Exporter;
10@ISA=qw(Exporter);
11@EXPORT = qw(ptree html_dir);
12
13sub html_dir {
14  't/html/'
15}
16
17sub ptree {
18  my $tree = shift or confess 'must supply tree';
19  my $out = shift or confess 'must supply outfile';
20
21  my $hpp = HTML::PrettyPrinter->new
22    (tabify => 0, allow_forced_nl => 1, quote_attr => 1);
23  my $lines = $hpp->format($tree);
24
25  write_file $out, @$lines;
26  join '', @$lines;
27}
28
29
30
311;
32