This snippet, based on the synopsis in the docs, runs ok. Add a doctype declaration and it dies.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Tidy;
my $contents = do{local $/; <DATA>};
my $tidy = HTML::Tidy->new(
{config_file => q{c:/perm/tidy/cnf/tidy.cnf}}
) or die qq{new failed: $!\n};
$tidy->ignore(type => TIDY_WARNING);
$tidy->parse(q{foo.html}, $contents)
or die qq{cant parse};;
for my $message ( $tidy->messages ) {
print $message->as_string;
}
my $clean = $tidy->clean($contents)
or die qq{cant clean};
print $clean;
__DATA__
<html>
<head>
<title>title</title>
</head>
<body>
<p>body</p>
</body>
</html>
add a doctype
__DATA__
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>title</title>
</head>
<body>
<p>body</p>
</body>
</html>
produces
cant parse at C:\perm\tidy\html_tidy_02.pl line 14, <DATA> line 1.
Anyone experienced this? Have I made a mistake? Is there a work around?
- win vista
- perl 5.8.8
- HTML::Tidy Version 1.08
- libtidy version 19 September 2007
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.