NAME
HTML::Lint - check for HTML errors in a string or file
SYNOPSIS
my $lint = HTML::Lint->new;
$lint->parse( $data );
$lint->parse_file( $filename );
my $error_count = $lint->errors;
foreach my $error ( $lint->errors ) {
print $error->as_string, "\n";
}
HTML::Lint also comes with a wrapper program called weblint that handles linting from the command line:
$ weblint http://www.cnn.com/
http://www.cnn.com/ (395:83) <IMG> tag has no HEIGHT and WIDTH attributes.
http://www.cnn.com/ (395:83) <IMG> does not have ALT text defined
http://www.cnn.com/ (396:217) Unknown element <nobr>
http://www.cnn.com/ (396:241) </nobr> with no opening <nobr>
http://www.cnn.com/ (842:7) target attribute in <a> is repeated
And finally, you can also get Apache::Lint that passes any mod_perl-generated code through HTML::Lint and get it dumped into your Apache error_log.
[Mon Jun 3 14:03:31 2002] [warn] /foo.pl (1:45) </p> with no opening <p>
[Mon Jun 3 14:03:31 2002] [warn] /foo.pl (1:49) Unknown element <gronk>
[Mon Jun 3 14:03:31 2002] [warn] /foo.pl (1:56) Unknown attribute "x" for tag <table>
VERSION
Version 1.10
$Header: /cvsroot/html-lint/html-lint/lib/HTML/Lint.pm,v 1.26 2002/07/18 03:56:47 petdance Exp $
EXPORTS
None. It's all object-based.
METHODS
HTML::Lint
is based on the HTML::Parser module. Any method call that works with HTML::Parser
will work in <HTML::Lint>. However, you'll probably only want to use the parse()
or parse_file()
methods.
- new()
-
Create an HTML::Lint object, which inherits from HTML::Parser. The
new
method takes no arguments. - errors()
-
In list context,
errors
returns all of the errors found in the parsed text. In scalar context, it returns the number of errors found. - clear_errors()
-
Clears the list of errors, in case you want to print and clear, print and clear.
newfile( $filename )
Call newfile()
whenever you switch to another file in a batch of linting. Otherwise, the object thinks everything is from the same file.
SEE ALSO
HTML::Lint::Error, HTML::Parser
TODO
Allow a "check this string" method for building into tests.
Check for attributes that require values
For instance, BGCOLOR should be BGCOLOR="something", but if it's just BGCOLOR, that's a problem. (Plus, that crashes IE OSX)
Check form validity: Are any fields duplicated on the form?
Add link checking
Handle obsolete tags
Create a .t file for each potential error message
Anything like <BR> or <P> inside of <A>
<TABLE>s that have no rows.
Form fields that aren't in a FORM
Check for valid entities, and that they end with semicolons
DIVs with nothing in them.
HEIGHT= that have percents in them.
Check for goofy stuff like:
<b><li></b><b>Hello Reader - Spanish Level 1 (K-3)</b>
LICENSE
This code may be distributed under the same terms as Perl itself.
Please note that these modules are not products of or supported by the employers of the various contributors to the code.
AUTHOR
Andy Lester, <andy@petdance.com>
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 137:
You forgot a '=back' before '=head2'
- Around line 358:
=back without =over