| 1 |
#!perl -T |
| 2 |
|
| 3 |
use warnings; |
| 4 |
use strict; |
| 5 |
|
| 6 |
use Test::More tests => 3; |
| 7 |
|
| 8 |
use HTML::Tidy; |
| 9 |
|
| 10 |
my $args = { newline => 'Lf' }; |
| 11 |
my $tidy = HTML::Tidy->new($args); |
| 12 |
isa_ok( $tidy, 'HTML::Tidy' ); |
| 13 |
$tidy->ignore( type => TIDY_INFO ); |
| 14 |
|
| 15 |
# clean once |
| 16 |
$tidy->ignore( text => qr/DOCTYPE/ ); |
| 17 |
my $html = '<a href="http://www.example.com/"><em>This is a test.</a>'; |
| 18 |
my $clean = $tidy->clean( $html ); |
| 19 |
|
| 20 |
# then verify that it meets tidy's high standards |
| 21 |
$tidy = HTML::Tidy->new($args); # reset messages; |
| 22 |
$tidy->ignore( type => TIDY_INFO ); |
| 23 |
$clean = $tidy->clean($clean); |
| 24 |
my @messages = $tidy->messages( $clean ); |
| 25 |
|
| 26 |
is_deeply( \@messages, [], q{The cleaned stuff shouldn't have any errors} ); |
| 27 |
|
| 28 |
$clean =~ s/"(HTML Tidy|tidyp).+w3\.org"/"Tidy"/; |
| 29 |
|
| 30 |
my $expected = do { local $/ = undef; <DATA> }; |
| 31 |
is( $clean, $expected, 'Cleaned up properly' ); |
| 32 |
|
| 33 |
__DATA__ |
| 34 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
| 35 |
<html> |
| 36 |
<head> |
| 37 |
<meta name="generator" content="Tidy"> |
| 38 |
<title></title> |
| 39 |
</head> |
| 40 |
<body> |
| 41 |
<a href="http://www.example.com/"><em>This is a test.</em></a> |
| 42 |
</body> |
| 43 |
</html> |