summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/ekhtml/testsuite/plparser.pl
blob: f7ee4a150be040cb43149dfaa7d892e5d1bc5765 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
use HTML::Parser();
use strict;
sub start_handler
{
    my ($tag, $self) = @_;
    print "START: \"".$tag."\"\n";
}

sub end_handler
{
    my ($tag, $self) = @_;
    print "END: \"".$tag."\"\n";
}

sub text_handler
{
    my ($text, $self) = @_;
    print $text;
}

sub comment_handler
{
    my ($text, $self) = @_;
    print "COMMENT: \"";
    foreach my $cur_comment (@$text) {
        print $cur_comment;
    }
    print "\"\n";
}

my $p = HTML::Parser->new(api_version => 3);
$p->handler( start => \&start_handler, "tagname,self");
$p->handler( end => \&end_handler, "tagname,self");
$p->handler( text => \&text_handler, "dtext, self");
$p->handler( comment => \&comment_handler, "tokens, self");
$p->parse_file(shift || die) || die $!;