Created
October 5, 2012 00:09
-
-
Save anonymous/3837258 to your computer and use it in GitHub Desktop.
HTML4 comment parsing issue with Mojo::DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
use Mojo::DOM; | |
use HTML::TreeBuilder; | |
my $content = <<'EOF'; | |
<html> | |
<body> | |
<!-- This is a valid comment -- > | |
<p>Here's a paragraph</p> | |
</body> | |
</html> | |
EOF | |
{ | |
my $dom = Mojo::DOM->new( $content ); | |
say "Mojo:\n" . $dom; | |
} | |
{ | |
my $dom = HTML::TreeBuilder->new_from_content($content); | |
say "Tree:\n" . $dom->as_HTML('<>&', ' '); | |
} | |
__END__ | |
Mojo: | |
<html> | |
<body> | |
<!-- -- a comment is this valid> | |
<p>Here's a paragraph</p> | |
</!--></body> | |
</html> | |
Tree: | |
<html> | |
<head> | |
</head> | |
<body> | |
<p>Here's a paragraph</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment