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.60
10

SYNOPSIS

12           use HTML::Tidy;
13
14           my $tidy = HTML::Tidy->new( {config_file => 'path/to/config'} );
15           $tidy->ignore( type => TIDY_WARNING, type => TIDY_INFO );
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_ERROR", "TIDY_WARNING" and "TIDY_INFO".
29
30       Everything else is an object method.
31

METHODS

33   new()
34       Create an HTML::Tidy object.
35
36           my $tidy = HTML::Tidy->new();
37
38       Optionally you can give a hashref of configuration parms.
39
40           my $tidy = HTML::Tidy->new( {config_file => 'path/to/tidy.cfg'} );
41
42       This configuration file will be read and used when you clean or parse
43       an HTML file.
44
45       You can also pass options directly to tidyp.
46
47           my $tidy = HTML::Tidy->new( {
48                                           output_xhtml => 1,
49                                           tidy_mark => 0,
50                                       } );
51
52       See "tidyp -help-config" for the list of options supported by tidyp.
53
54       The following options are not supported by "HTML::Tidy":
55
56       ·   quiet
57
58   messages()
59       Returns the messages accumulated.
60
61   clear_messages()
62       Clears the list of messages, in case you want to print and clear, print
63       and clear.  If you don't clear the messages, then each time you call
64       parse() you'll be accumulating more in the list.
65
66   ignore( parm => value [, parm => value ] )
67       Specify types of messages to ignore.  Note that the ignore flags must
68       be set before calling "parse()".  You can call "ignore()" as many times
69       as necessary to set up all your restrictions; the options will stack
70       up.
71
72       ·   type => TIDY_INFO|TIDY_WARNING|TIDY_ERROR
73
74           Specifies the type of messages you want to ignore, either info or
75           warnings or errors.  If you wanted, you could call ignore on all
76           three and get no messages at all.
77
78               $tidy->ignore( type => TIDY_WARNING );
79
80       ·   text => qr/regex/
81
82       ·   text => [ qr/regex1/, qr/regex2/, ... ]
83
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       Parses a string, or list of strings, that make up a single HTML file.
94
95       The $filename parm is only used as an identifier for your use.  The
96       file is not actually read and opened.
97
98       Returns true if all went OK, or false if there was some problem calling
99       tidy, or parsing tidy's output.
100
101   clean( $str [, $str...] )
102       Cleans a string, or list of strings, that make up a single HTML file.
103
104       Returns the cleaned string as a single string.
105
106   tidyp_version()
107   libtidyp_version()
108       Returns the version of the underling tidyp library.
109

INSTALLING TIDYP

111       "HTML::Tidy" requires that "tidyp" be installed on your system.  You
112       can obtain tidyp through your distribution's package manager (make sure
113       you install the development package with headers), or from the tidyp
114       Git repository at <http://github.com/petdance/tidyp>.
115

CONVERTING FROM "HTML::Lint"

117       "HTML::Tidy" is different from "HTML::Lint" in a number of crucial
118       ways.
119
120       ·   It's not pure Perl
121
122           "HTML::Tidy" is mostly a happy wrapper around tidyp.
123
124       ·   The real work is done by someone else
125
126           Changes to tidyp may come down the pipe that I don't have control
127           over.  That's the price we pay for having it do a darn good job.
128
129       ·   It's no longer bundled with its "Test::" counterpart
130
131           HTML::Lint came bundled with "Test::HTML::Lint", but
132           Test::HTML::Tidy is a separate distribution.  This saves the people
133           who don't want the "Test::" framework from pulling it in, and all
134           its prerequisite modules.
135

BUGS & FEEDBACK

137       Please report any bugs or feature requests at the issue tracker on
138       github <http://github.com/petdance/html-tidy/issues>.  I will be
139       notified, and then you'll automatically be notified of progress on your
140       bug as I make changes.
141
142       Please do NOT use <http://rt.cpan.org>.
143

SUPPORT

145       You can find documentation for this module with the perldoc command.
146
147           perldoc HTML::Tidy
148
149       You can also look for information at:
150
151       ·   HTML::Tidy's issue queue at github
152
153           <http://github.com/petdance/html-tidy/issues>
154
155       ·   AnnoCPAN: Annotated CPAN documentation
156
157           <http://annocpan.org/dist/HTML-Tidy>
158
159       ·   CPAN Ratings
160
161           <http://cpanratings.perl.org/d/HTML-Tidy>
162
163       ·   search.cpan.org
164
165           <http://search.cpan.org/dist/HTML-Tidy>
166
167       ·   Git source code repository
168
169           <http://github.com/petdance/html-tidy>
170

ACKNOWLEDGEMENTS

172       Thanks to Rufus Cable, Jonathan Rockway, and Robert Bachmann for
173       contributions.
174

AUTHOR

176       Andy Lester, "<andy at petdance.com>"
177
179       Copyright (C) 2005-2017 by Andy Lester
180
181       This library is free software.  You mean modify or distribute it under
182       the Artistic License v2.0.
183
184
185
186perl v5.28.1                      2019-02-02                     HTML::Tidy(3)
Impressum