.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::Tidy 3pm" .TH HTML::Tidy 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME HTML::Tidy \- (X)HTML validation in a Perl object .SH VERSION .IX Header "VERSION" Version 1.60 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use HTML::Tidy; \& \& my $tidy = HTML::Tidy\->new( {config_file => \*(Aqpath/to/config\*(Aq} ); \& $tidy\->ignore( type => TIDY_WARNING, type => TIDY_INFO ); \& $tidy\->parse( "foo.html", $contents_of_foo ); \& \& for my $message ( $tidy\->messages ) { \& print $message\->as_string; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`HTML::Tidy\*(C'\fR is an HTML checker in a handy dandy object. It's meant as a replacement for HTML::Lint. If you're currently an HTML::Lint user looking to migrate, see the section "Converting from HTML::Lint". .SH EXPORTS .IX Header "EXPORTS" Message types \f(CW\*(C`TIDY_ERROR\*(C'\fR, \f(CW\*(C`TIDY_WARNING\*(C'\fR and \f(CW\*(C`TIDY_INFO\*(C'\fR. .PP Everything else is an object method. .SH METHODS .IX Header "METHODS" .SS \fBnew()\fP .IX Subsection "new()" Create an HTML::Tidy object. .PP .Vb 1 \& my $tidy = HTML::Tidy\->new(); .Ve .PP Optionally you can give a hashref of configuration parms. .PP .Vb 1 \& my $tidy = HTML::Tidy\->new( {config_file => \*(Aqpath/to/tidy.cfg\*(Aq} ); .Ve .PP This configuration file will be read and used when you clean or parse an HTML file. .PP You can also pass options directly to tidyp. .PP .Vb 4 \& my $tidy = HTML::Tidy\->new( { \& output_xhtml => 1, \& tidy_mark => 0, \& } ); .Ve .PP See \f(CW\*(C`tidyp \-help\-config\*(C'\fR for the list of options supported by tidyp. .PP The following options are not supported by \f(CW\*(C`HTML::Tidy\*(C'\fR: .IP \(bu 4 quiet .SS \fBmessages()\fP .IX Subsection "messages()" Returns the messages accumulated. .SS \fBclear_messages()\fP .IX Subsection "clear_messages()" Clears the list of messages, in case you want to print and clear, print and clear. If you don't clear the messages, then each time you call \&\fBparse()\fR you'll be accumulating more in the list. .SS "ignore( parm => value [, parm => value ] )" .IX Subsection "ignore( parm => value [, parm => value ] )" Specify types of messages to ignore. Note that the ignore flags must be set \fBbefore\fR calling \f(CWparse()\fR. You can call \f(CWignore()\fR as many times as necessary to set up all your restrictions; the options will stack up. .IP \(bu 4 type => TIDY_INFO|TIDY_WARNING|TIDY_ERROR .Sp Specifies the type of messages you want to ignore, either info or warnings or errors. If you wanted, you could call ignore on all three and get no messages at all. .Sp .Vb 1 \& $tidy\->ignore( type => TIDY_WARNING ); .Ve .IP \(bu 4 text => qr/regex/ .IP \(bu 4 text => [ qr/regex1/, qr/regex2/, ... ] .Sp Checks the text of the message against the specified regex or regexes, and ignores the message if there's a match. The value for the \fItext\fR parm may be either a regex, or a reference to a list of regexes. .Sp .Vb 2 \& $tidy\->ignore( text => qr/DOCTYPE/ ); \& $tidy\->ignore( text => [ qr/unsupported/, qr/proprietary/i ] ); .Ve .ie n .SS "parse( $filename, $str [, $str...] )" .el .SS "parse( \f(CW$filename\fP, \f(CW$str\fP [, \f(CW$str\fP...] )" .IX Subsection "parse( $filename, $str [, $str...] )" Parses a string, or list of strings, that make up a single HTML file. .PP The \fR\f(CI$filename\fR\fI\fR parm is only used as an identifier for your use. The file is not actually read and opened. .PP Returns true if all went OK, or false if there was some problem calling tidy, or parsing tidy's output. .ie n .SS "clean( $str [, $str...] )" .el .SS "clean( \f(CW$str\fP [, \f(CW$str\fP...] )" .IX Subsection "clean( $str [, $str...] )" Cleans a string, or list of strings, that make up a single HTML file. .PP Returns the cleaned string as a single string. .SS \fBtidyp_version()\fP .IX Subsection "tidyp_version()" .SS \fBlibtidyp_version()\fP .IX Subsection "libtidyp_version()" Returns the version of the underling tidyp library. .SH "INSTALLING TIDYP" .IX Header "INSTALLING TIDYP" \&\f(CW\*(C`HTML::Tidy\*(C'\fR requires that \f(CW\*(C`tidyp\*(C'\fR be installed on your system. You can obtain tidyp through your distribution's package manager (make sure you install the development package with headers), or from the tidyp Git repository at . .ie n .SH "CONVERTING FROM ""HTML::Lint""" .el .SH "CONVERTING FROM \f(CWHTML::Lint\fP" .IX Header "CONVERTING FROM HTML::Lint" \&\f(CW\*(C`HTML::Tidy\*(C'\fR is different from \f(CW\*(C`HTML::Lint\*(C'\fR in a number of crucial ways. .IP \(bu 4 It's not pure Perl .Sp \&\f(CW\*(C`HTML::Tidy\*(C'\fR is mostly a happy wrapper around tidyp. .IP \(bu 4 The real work is done by someone else .Sp Changes to tidyp may come down the pipe that I don't have control over. That's the price we pay for having it do a darn good job. .IP \(bu 4 It's no longer bundled with its \f(CW\*(C`Test::\*(C'\fR counterpart .Sp HTML::Lint came bundled with \f(CW\*(C`Test::HTML::Lint\*(C'\fR, but Test::HTML::Tidy is a separate distribution. This saves the people who don't want the \f(CW\*(C`Test::\*(C'\fR framework from pulling it in, and all its prerequisite modules. .SH "BUGS & FEEDBACK" .IX Header "BUGS & FEEDBACK" Please report any bugs or feature requests at the issue tracker on github . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .PP Please do NOT use . .SH SUPPORT .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc HTML::Tidy .Ve .PP You can also look for information at: .IP \(bu 4 HTML::Tidy's issue queue at github .Sp .IP \(bu 4 AnnoCPAN: Annotated CPAN documentation .Sp .IP \(bu 4 CPAN Ratings .Sp .IP \(bu 4 search.cpan.org .Sp .IP \(bu 4 Git source code repository .Sp .SH ACKNOWLEDGEMENTS .IX Header "ACKNOWLEDGEMENTS" Thanks to Rufus Cable, Jonathan Rockway, and Robert Bachmann for contributions. .SH AUTHOR .IX Header "AUTHOR" Andy Lester, \f(CW\*(C`\*(C'\fR .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (C) 2005\-2017 by Andy Lester .PP This library is free software. You mean modify or distribute it under the Artistic License v2.0.