1HTML::Lint(3)         User Contributed Perl Documentation        HTML::Lint(3)
2
3
4

NAME

6       HTML::Lint - check for HTML errors in a string or file
7

VERSION

9       Version 2.06
10

SYNOPSIS

12           my $lint = HTML::Lint->new;
13           $lint->only_types( HTML::Lint::STRUCTURE );
14
15           $lint->parse( $data );
16           $lint->parse_file( $filename );
17
18           my $error_count = $lint->errors;
19
20           foreach my $error ( $lint->errors ) {
21               print $error->as_string, "\n";
22           }
23
24       HTML::Lint also comes with a wrapper program called weblint that
25       handles linting from the command line:
26
27           $ weblint http://www.cnn.com/
28           http://www.cnn.com/ (395:83) <IMG SRC="spacer.gif"> tag has no HEIGHT and WIDTH attributes.
29           http://www.cnn.com/ (395:83) <IMG SRC="goofus.gif"> does not have ALT text defined
30           http://www.cnn.com/ (396:217) Unknown element <nobr>
31           http://www.cnn.com/ (396:241) </nobr> with no opening <nobr>
32           http://www.cnn.com/ (842:7) target attribute in <a> is repeated
33
34       And finally, you can also get Apache::HTML::Lint that passes any
35       mod_perl-generated code through HTML::Lint and get it dumped into your
36       Apache error_log.
37
38           [Mon Jun  3 14:03:31 2002] [warn] /foo.pl (1:45) </p> with no opening <p>
39           [Mon Jun  3 14:03:31 2002] [warn] /foo.pl (1:49) Unknown element <gronk>
40           [Mon Jun  3 14:03:31 2002] [warn] /foo.pl (1:56) Unknown attribute "x" for tag <table>
41

METHODS

43       NOTE: Some of these methods mirror HTML::Parser's methods, but
44       HTML::Lint is not a subclass of HTML::Parser.
45
46   new()
47       Create an HTML::Lint object, which inherits from HTML::Parser.  You may
48       pass the types of errors you want to check for in the "only_types"
49       parm.
50
51           my $lint = HTML::Lint->new( only_types => HTML::Lint::Error::STRUCTURE );
52
53       If you want more than one, you must pass an arrayref:
54
55           my $lint = HTML::Lint->new(
56               only_types => [HTML::Lint::Error::STRUCTURE, HTML::Lint::Error::FLUFF] );
57
58   $lint->parse( $chunk )
59   $lint->parse( $code_ref )
60       Passes in a chunk of HTML to be linted, either as a piece of text, or a
61       code reference.  See HTML::Parser's "parse_file" method for details.
62
63   $lint->parse_file( $file )
64       Analyzes HTML directly from a file. The $file argument can be a
65       filename, an open file handle, or a reference to an open file handle.
66       See HTML::Parser's "parse_file" method for details.
67
68   $lint->eof
69       Signals the end of a block of text getting passed in.  This must be
70       called to make sure that all parsing is complete before looking at
71       errors.
72
73       Any parameters (and there shouldn't be any) are passed through to
74       HTML::Parser's eof() method.
75
76   $lint->errors()
77       In list context, "errors" returns all of the errors found in the parsed
78       text.  Each error is an object of the type HTML::Lint::Error.
79
80       In scalar context, it returns the number of errors found.
81
82   $lint->clear_errors()
83       Clears the list of errors, in case you want to print and clear, print
84       and clear.
85
86   $lint->only_types( $type1[, $type2...] )
87       Specifies to only want errors of a certain type.
88
89           $lint->only_types( HTML::Lint::Error::STRUCTURE );
90
91       Calling this without parameters makes the object return all possible
92       errors.
93
94       The error types are "STRUCTURE", "HELPER" and "FLUFF".  See
95       HTML::Lint::Error for details on these types.
96
97   $lint->gripe( $errcode, [$key1=>$val1, ...] )
98       Adds an error message, in the form of an HTML::Lint::Error object, to
99       the list of error messages for the current object.  The file, line and
100       column are automatically passed to the HTML::Lint::Error constructor,
101       as well as whatever other key value pairs are passed.
102
103       For example:
104
105           $lint->gripe( 'attr-repeated', tag => $tag, attr => $attr );
106
107       Usually, the user of the object won't call this directly, but just in
108       case, here you go.
109
110   $lint->newfile( $filename )
111       Call "newfile()" whenever you switch to another file in a batch of
112       linting.  Otherwise, the object thinks everything is from the same
113       file.  Note that the list of errors is NOT cleared.
114
115       Note that $filename does NOT need to match what's put into parse() or
116       parse_file().  It can be a description, a URL, or whatever.
117
118       HTML::Lint::Parser is a class only for this module.
119

BUGS, WISHES AND CORRESPONDENCE

121       All bugs and requests are now being handled through the Google Code
122       issue tracker at http://code.google.com/p/html-lint/issues/list.  DO
123       NOT send bug reports to http://rt.cpan.org/
124

TODO

126       ·   Check for attributes that require values
127
128       ·   <TABLE>s that have no rows.
129
130       ·   Form fields that aren't in a FORM
131
132       ·   Check for valid entities, and that they end with semicolons
133
134       ·   DIVs with nothing in them.
135
136       ·   HEIGHT= that have percents in them.
137
138       ·   Check for goofy stuff like:
139
140               <b><li></b><b>Hello Reader - Spanish Level 1 (K-3)</b>
141

LICENSE

143       Copyright 2005-2008 Andy Lester, All Rights Reserved.
144
145       This program is free software; you can redistribute it and/or modify it
146       under the same terms as Perl itself.
147
148       Please note that these modules are not products of or supported by the
149       employers of the various contributors to the code.
150

AUTHOR

152       Andy Lester, andy at petdance.com
153
154
155
156perl v5.12.0                      2008-12-18                     HTML::Lint(3)
Impressum