use strict; use warnings; use Test::More; use HTML::TreeBuilder::LibXML; use Data::Dumper; # list context my $tree = HTML::TreeBuilder::LibXML->new_from_content('
foo
'); my @guts = $tree->guts; is join('|', map {$_->as_HTML} @guts), '
foo
|', 'guts - list context'; # scalar context my $guts = $tree->guts; isa_ok $guts->{node}->ownerDocument, 'XML::LibXML::Document'; is $guts->as_HTML, '
foo
', 'guts - scalar context'; # guts() must return tags from implicit as well my @nodes = HTML::TreeBuilder::LibXML->new_from_content('head tag
body tag
')->guts; is join('|', map {$_->as_HTML} @nodes), 'head tag|
body tag
'; # guts must include text and comments @nodes = HTML::TreeBuilder::LibXML->new_from_content('head tag
body tag
some text')->guts; is join('|', map {$_->as_HTML} @nodes), "head tag|\n|
body tag
|\n| some text"; # guts must include DOCTYPE if its not implicit my $html_with_dtd = "\n
html5
\n"; $guts = HTML::TreeBuilder::LibXML->new_from_content($html_with_dtd)->guts; isa_ok $guts->{node}->ownerDocument->internalSubset, 'XML::LibXML::Dtd', "doctype"; is $guts->parent->as_HTML, $html_with_dtd, "document with doctype"; done_testing;