]>
Commit | Line | Data |
---|---|---|
67e78ff2 | 1 | package TestUtils; |
2 | ||
3 | use HTML::PrettyPrinter; | |
4 | use FileHandle; | |
5 | use File::Slurp; | |
6 | ||
7 | require Exporter; | |
8 | @ISA=qw(Exporter); | |
bd96fdbe | 9 | @EXPORT = qw(ptree html_dir strip_ws); |
67e78ff2 | 10 | |
11 | sub html_dir { | |
12 | 't/html/' | |
13 | } | |
14 | ||
15 | sub ptree { | |
16 | my $tree = shift or die 'must supply tree'; | |
17 | my $out = shift or die 'must supply outfile'; | |
18 | ||
19 | my $hpp = HTML::PrettyPrinter->new | |
20 | (tabify => 0, allow_forced_nl => 1, quote_attr => 1); | |
21 | my $lines = $hpp->format($tree); | |
22 | ||
23 | write_file $out, @$lines; | |
24 | join '', @$lines; | |
25 | } | |
26 | ||
bd96fdbe TB |
27 | sub strip_ws { |
28 | my($str)=@_; | |
29 | ||
30 | $str =~ s/\s+//g; | |
31 | $str; | |
32 | } | |
67e78ff2 | 33 | |
34 | ||
35 | 1; |