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

NAME

6       HTML::Tidy - (X)HTML validation in a Perl object
7

VERSION

9       Version 1.08
10

SYNOPSIS

12           use HTML::Tidy;
13
14           my $tidy = HTML::Tidy->new( {config_file => 'path/to/config'} );
15           $tidy->ignore( type => TIDY_WARNING );
16           $tidy->parse( "foo.html", $contents_of_foo );
17
18           for my $message ( $tidy->messages ) {
19               print $message->as_string;
20           }
21

DESCRIPTION

23       "HTML::Tidy" is an HTML checker in a handy dandy object.  It's meant as
24       a replacement for HTML::Lint.  If you're currently an HTML::Lint user
25       looking to migrate, see the section "Converting from HTML::Lint".
26

EXPORTS

28       Message types "TIDY_WARNING" and "TIDY_ERROR".
29
30       Everything else is an object method.
31

METHODS

33       new()
34
35       Create an HTML::Tidy object.
36
37           my $tidy = HTML::Tidy->new();
38
39       Optionally you can give a hashref of configuration parms.
40
41           my $tidy = HTML::Tidy->new( {config_file => 'path/to/tidy.cfg'} );
42
43       This configuration file will be read and used when you clean or parse
44       an HTML file.
45
46       You can also pass options directly to libtidy.
47
48           my $tidy = HTML::Tidy->new( {
49                                           output_xhtml => 1,
50                                           tidy_mark => 0,
51                                       } );
52
53       See <http://tidy.sourceforge.net/docs/quickref.html> or "tidy
54       -help-config" for the list of options supported by libtidy.
55
56       The following options are not supported by "HTML::Tidy": quiet
57
58       messages()
59
60       Returns the messages accumulated.
61
62       clear_messages()
63
64       Clears the list of messages, in case you want to print and clear, print
65       and clear.  If you don't clear the messages, then each time you call
66       parse() you'll be accumulating more in the list.
67
68       ignore( parm => value [, parm => value ] )
69
70       Specify types of messages to ignore.  Note that the ignore flags must
71       be set before calling "parse()".  You can call "ignore()" as many times
72       as necessary to set up all your restrictions; the options will stack
73       up.
74
75       * type => TIDY_(WARNINGâŽȘERROR)
76           Specifies the type of messages you want to ignore, either warnings
77           or errors.  If you wanted, you could call ignore on both and get no
78           messages at all.
79
80               $tidy->ignore( type => TIDY_WARNING );
81
82       * text => qr/regex/
83       * text => [ qr/regex1/, qr/regex2/, ... ]
84           Checks the text of the message against the specified regex or
85           regexes, and ignores the message if there's a match.  The value for
86           the text parm may be either a regex, or a reference to a list of
87           regexes.
88
89               $tidy->ignore( text => qr/DOCTYPE/ );
90               $tidy->ignore( text => [ qr/unsupported/, qr/proprietary/i ] );
91
92       parse( $filename, $str [, $str...] )
93
94       Parses a string, or list of strings, that make up a single HTML file.
95
96       The $filename parm is only used as an identifier for your use.  The
97       file is not actually read and opened.
98
99       Returns true if all went OK, or false if there was some problem calling
100       tidy, or parsing tidy's output.
101
102       clean( $str [, $str...] )
103
104       Cleans a string, or list of strings, that make up a single HTML file.
105
106       Returns the cleaned string as a single string.
107
108       libtidy_version()
109
110           $version = HTML::Tidy->libtidy_version();
111           # for example -> "1 September 2005"
112           $version = HTML::Tidy->libtidy_version( { numeric => 1 } );
113           # for example -> 20050901
114
115       Returns the version of the underling tidy library.
116

INSTALLING LIBTIDY

118       HTML::Tidy requires that "libtidy" be installed on your system.  You
119       can obtain libtidy through your distribution's package manager (make
120       sure you install the development package with headers), or from the
121       libtidy website at <http://tidy.sourceforge.net/src/tidy_src.tgz>.
122

CONVERTING FROM "HTML::Lint"

124       HTML::Tidy is different from HTML::Lint in a number of crucial ways.
125
126       * It's not pure Perl
127           "HTML::Tidy" is mostly a happy wrapper around libtidy.  Tidy's home
128           page is at <http://tidy.sourceforge.net>.
129
130       * The real work is done by someone else
131           Changes to libtidy may come down the pipe that I don't have control
132           over.  That's the price we pay for having it do a darn good job.
133
134       * It's no longer bundled with its "Test::" counterpart
135           HTML::Lint came bundled with "Test::HTML::Lint", but
136           Test::HTML::Tidy is a separate distribution.  This saves the people
137           who don't want the "Test::" framework from pulling it in, and all
138           its prerequisite modules.
139

BUGS & FEEDBACK

141       Please report any bugs or feature requests to "bug-html-tidy at
142       rt.cpan.org", or through the web interface at
143       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Tidy>.  I will be
144       notified, and then you'll automatically be notified of progress on your
145       bug as I make changes.
146

SUPPORT

148       You can find documentation for this module with the perldoc command.
149
150           perldoc HTML::Tidy
151
152       You can also look for information at:
153
154       * AnnoCPAN: Annotated CPAN documentation
155           <http://annocpan.org/dist/HTML-Tidy>
156
157       * CPAN Ratings
158           <http://cpanratings.perl.org/d/HTML-Tidy>
159
160       * RT: CPAN's request tracker
161           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Tidy>
162
163       * Search CPAN
164           <http://search.cpan.org/dist/HTML-Tidy>
165
166       * Subversion source code repository
167           <http://code.google.com/p/html-tidy/source>
168

ACKNOWLEDGEMENTS

170       Thanks to Jonathan Rockway and Robert Bachmann for contributions.
171

AUTHOR

173       Andy Lester, "<andy at petdance.com>"
174
176       Copyright (C) 2005-2007 by Andy Lester
177
178       This library is free software; you can redistribute it and/or modify it
179       under the same terms as Perl itself, either Perl version 5.8.1 or, at
180       your option, any later version of Perl 5 you may have available.
181
182
183
184perl v5.8.8                       2008-03-14                     HTML::Tidy(3)
Impressum