diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-05-08 22:21:52 +0000 |
commit | 2f253cfc85ffd55a8acb988e91f0bc5ab348124c (patch) | |
tree | 4734ccd522c71dd455879162006742002f8c1565 /t/pullparser.t | |
download | HTML-Parser-tarball-master.tar.gz |
HTML-Parser-3.71HEADHTML-Parser-3.71master
Diffstat (limited to 't/pullparser.t')
-rw-r--r-- | t/pullparser.t | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/t/pullparser.t b/t/pullparser.t new file mode 100644 index 0000000..80a186b --- /dev/null +++ b/t/pullparser.t @@ -0,0 +1,55 @@ +use Test::More tests => 3; + +use HTML::PullParser; + +my $doc = <<'EOT'; +<title>Title</title> +<style> h1 { background: white } +<foo> +</style> +<H1 ID="3">Heading</H1> +<!-- ignore this --> + +This is a text with a <A HREF="http://www.sol.no" name="l1">link</a>. +EOT + +my $p = HTML::PullParser->new(doc => $doc, + start => 'event,tagname,@attr', + end => 'event,tagname', + text => 'event,dtext', + + ignore_elements => [qw(script style)], + unbroken_text => 1, + boolean_attribute_value => 1, + ); + +my $t = $p->get_token; +is($t->[0], "start"); +is($t->[1], "title"); +$p->unget_token($t); + +my @a; +while (my $t = $p->get_token) { + for (@$t) { + s/\s/./g; + } + push(@a, join("|", @$t)); +} + +my $res = join("\n", @a, ""); +#diag $res; +is($res, <<'EOT'); +start|title +text|Title +end|title +text|.. +start|h1|id|3 +text|Heading +end|h1 +text|...This.is.a.text.with.a. +start|a|href|http://www.sol.no|name|l1 +text|link +end|a +text|.. +EOT + |