summaryrefslogtreecommitdiff
path: root/ekhtml/testsuite/plparser.pl
diff options
context:
space:
mode:
Diffstat (limited to 'ekhtml/testsuite/plparser.pl')
-rw-r--r--ekhtml/testsuite/plparser.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/ekhtml/testsuite/plparser.pl b/ekhtml/testsuite/plparser.pl
new file mode 100644
index 0000000..f7ee4a1
--- /dev/null
+++ b/ekhtml/testsuite/plparser.pl
@@ -0,0 +1,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 $!;
+