The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Valid - tidy/validate HTML

SYNOPSIS

    use FindBin '$Bin';
    use HTML::Valid;
    my $html = <<EOF;
    <ul>
    <li>Shape it up
    <li>Get straight
    <li>Go forward
    <li>Move ahead
    <li>Try to detect it
    <li>It's not too late
    EOF
    my $htv = HTML::Valid->new ();
    my ($output, $errors) = $htv->run ($html);
    print "$output\n";
    print "$errors\n";

outputs

    <!DOCTYPE html>
    <html>
    <head>
    <meta name="generator" content=
    "HTML Tidy for HTML5 for FreeBSD version 5.0.0">
    <title></title>
    </head>
    <body>
    <ul>
    <li>Shape it up</li>
    <li>Get straight</li>
    <li>Go forward</li>
    <li>Move ahead</li>
    <li>Try to detect it</li>
    <li>It's not too late</li>
    </ul>
    </body>
    </html>
    
    line 1 column 1 - Warning: missing <!DOCTYPE> declaration
    line 1 column 1 - Warning: inserting implicit <body>
    line 1 column 1 - Warning: missing </ul>
    line 1 column 1 - Warning: inserting missing 'title' element
    Info: Document content looks like HTML5
    4 warnings, 0 errors were found!
    
    

VERSION

This document describes HTML::Valid version 0.00_04. This corresponds to "HTML Tidy" version 5.0.0.

DESCRIPTION

Validate/repair HTML. This module is based on "HTML Tidy", but not on the Perl module HTML::Tidy.

FUNCTIONS

new

    my $htv = HTML::Valid->new ();

set_filename

    $htv->set_filename ('file.html');

Set the file name for error reporting to file.html.

run

    my ($output, $errors) = $htv->run ($content);

Get the tidy HTML output and errors.

SCRIPT

There is a script called "htmlok" which runs on files and prints errors. It is extremely flaky at the moment.

SEE ALSO

HTML Tidy

This is a program and a library in C for improving HTML. HTML::Valid is based on this project.

Online HTML validators

You may like to try these validators for checking your HTML.

http://www.onlinewebcheck.com/

Commercial HTML validator.

https://validator.w3.org/

W3 Consortium validator.

https://validator.w3.org/nu/

New W3 Consortium validator.

CPAN modules

HTML::Tidy
HTML::Lint

AUTHOR

Ben Bullock <bkb@cpan.org>

COPYRIGHT AND LICENCE

HTML::Valid is based on HTML Tidy, which is under the following copyright:

    Copyright (c) 1998-2008 World Wide Web Consortium
    (Massachusetts Institute of Technology, European Research
    Consortium for Informatics and Mathematics, Keio University).
    All Rights Reserved.

    COPYRIGHT NOTICE:

    This software and documentation is provided "as is," and
    the copyright holders and contributing author(s) make no
    representations or warranties, express or implied, including
    but not limited to, warranties of merchantability or fitness
    for any particular purpose or that the use of the software or
    documentation will not infringe any third party patents,
    copyrights, trademarks or other rights.

    The copyright holders and contributing author(s) will not be held
    liable for any direct, indirect, special or consequential damages
    arising out of any use of the software or documentation, even if
    advised of the possibility of such damage.

    Permission is hereby granted to use, copy, modify, and distribute
    this source code, or portions hereof, documentation and executables,
    for any purpose, without fee, subject to the following restrictions:

    1. The origin of this source code must not be misrepresented.
    2. Altered versions must be plainly marked as such and must
    not be misrepresented as being the original source.
    3. This Copyright notice may not be removed or altered from any
    source or altered source distribution.

The Perl parts of this distribution are copyright (C) 2015 Ben Bullock and may be used under either the above licence terms, or the usual Perl conditions, either the GNU General Public Licence or the Perl Artistic Licence.