Skip to content

Instantly share code, notes, and snippets.

Created October 5, 2012 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/3837258 to your computer and use it in GitHub Desktop.
Save anonymous/3837258 to your computer and use it in GitHub Desktop.
HTML4 comment parsing issue with Mojo::DOM
#!/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&#39;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