File: comment.t

package info (click to toggle)
libhtml-parser-perl 3.55-1%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 528 kB
  • ctags: 192
  • sloc: ansic: 1,986; perl: 1,935; makefile: 43
file content (24 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (7)
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[]");