use Test::More tests => 1; use strict; use HTML::Parser; my $html = <<'EOT'; This is a <nice> title
EOT my $dump = ""; sub tdump { my @a = @_; for (@a) { $_ = "" unless defined; s/\n/\\n/g; } $dump .= join("|", @a) . "\n"; } my $p = HTML::Parser->new(default_h => [\&tdump, "event,text,dtext,is_cdata"]); $p->parse($html)->eof; #diag $dump; is($dump, <<'EOT'); start_document||| start||| text|\n|\n| start||<undef>|<undef> text|This is a <nice> title|This is a <nice> title| end||| text|\n|\n| comment||| text|\n|\n| start||| text|\n\n|\n\n| start|
|| text|\n\n|\n\n| start||| text|\n\n|\n\n| end||| text|\n\n|\n\n| end||| text|\n|\n| end_document||| EOT