petdance / html-lint

HTML::Lint, the Perl module for HTML checking
10 stars 19 forks source link

Does not support HTML5 #36

Open Gilwyad opened 9 years ago

Gilwyad commented 9 years ago
#!/usr/bin/perl -w

use strict;
use HTML::Lint;

my $lint = HTML::Lint->new();

my $data = q^

<!DOCTYPE html>
<html lang="en">
<head>
<title>html5 test</title>
</head>
<body>
<header>menu</header>
<time datetime="2015-01-25 21:56:23+00:00"></time>
</body>
</html>

^;

$lint->parse( $data );

foreach my $error ( $lint->errors ) {
    print $error->as_string, "\n";
}

prints the following errors when executed:

 (9:1) Unknown element <header>
 (10:1) Unknown element <time>

Is this module strictly for HTML4? Will 5 be ever supported? Or how can I ignore HTML5 elements?

What can I use to validate HTML5?

petdance commented 9 years ago

HTML::Lint only supports HTML4. Chances are that it will never support HTML5. The W3C is updating the tidy tool to support HTML5, so that might be a place to look. https://github.com/htacg/tidy-html5

Gilwyad commented 9 years ago

I'm assuming you mean only supports HTML4 and might never support HTML5.

Thanks, I ended up using HTML::Lint::Pluggable::HTML5, works perfectly with Test::WWW::Mechanize autolint.

my $lint = HTML::Lint::Pluggable->new();       # plugin system for HTML::Lint
$lint -> load_plugin("HTML5");                 # loads HTML::Lint::Pluggable::HTML5
$lint -> load_plugin("TinyEntitesEscapeRule"); # loads HTML::Lint::Pluggable::TinyEntitesEscapeRule

my $mech = Test::WWW::Mechanize->new(
                                     autolint => $lint,
                                     cookie_jar => undef
                                    );
petdance commented 6 years ago

Please take a look at https://github.com/petdance/html-tidy5