summaryrefslogtreecommitdiff
path: root/t/comment.t
blob: 303449ebaa9bd71b20d2a0f234a16a304bcd054e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Test::More tests => 1;

use strict;
use HTML::Parser;

my $p = HTML::Parser->new(api_version => 3);
my @com;
$p->handler(comment => sub { push(@com, shift) }, "token0");
$p->handler(default => sub { push(@com, shift() . "[" . shift() . "]") }, "event, text");

$p->parse("<foo><><!><!-><!--><!---><!----><!-----><!------>");
$p->parse("<!--+--");
$p->parse("\n\n");
$p->parse(">");
$p->parse("<!a'b>");
$p->parse("<!--foo--->");
$p->parse("<!--foo---->");
$p->parse("<!--foo----->-->");
$p->parse("<foo>");
$p->parse("<!3453><!-3456><!FOO><>");
$p->eof;

my $com = join(":", @com);
is($com, "start_document[]:start[<foo>]:text[<>]::-:><!-::-:--:+:a'b:foo-:foo--:foo---:text[-->]:start[<foo>]:3453:-3456:FOO:text[<>]:end_document[]");