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/plaintext.t | |
download | HTML-Parser-tarball-master.tar.gz |
HTML-Parser-3.71HEADHTML-Parser-3.71master
Diffstat (limited to 't/plaintext.t')
-rw-r--r-- | t/plaintext.t | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/t/plaintext.t b/t/plaintext.t new file mode 100644 index 0000000..9a53a78 --- /dev/null +++ b/t/plaintext.t @@ -0,0 +1,58 @@ +use Test::More tests => 3; + +use strict; +use HTML::Parser; + +my @a; +my $p = HTML::Parser->new(api_version => 3); +$p->handler(default => \@a, '@{event, text, is_cdata}'); +$p->parse(<<EOT)->eof; +<xmp><foo></xmp>x<plaintext><foo> +</plaintext> +foo +EOT + +for (@a) { + $_ = "" unless defined; +} + +my $doc = join(":", @a); + +#diag $doc; + +is($doc, "start_document:::start:<xmp>::text:<foo>:1:end:</xmp>::text:x::start:<plaintext>::text:<foo> +</plaintext> +foo +:1:end_document::"); + +@a = (); +$p->closing_plaintext('yep, emulate gecko'); +$p->parse(<<EOT)->eof; +<plaintext><foo> +</plaintext>foo<b></b> +EOT + +for (@a) { + $_ = "" unless defined; +} + +$doc = join(":", @a); + +#diag $doc; + +is($doc, "start_document:::start:<plaintext>::text:<foo> +:1:end:</plaintext>::text:foo::start:<b>::end:</b>::text: +::end_document::"); + +@a = (); +$p->closing_plaintext('yep, emulate gecko (2)'); +$p->parse(<<EOT)->eof; +<plaintext><foo> +foo<b></b> +EOT + +$doc = join(":", map { defined $_ ? $_ : "" } @a); + +is($doc, "start_document:::start:<plaintext>::text:<foo> +foo<b></b> +:1:end_document::"); |