in reply to HTML::Tidy help

I don't know about all the configs but you should be able to add into the constructor , change dashes to underscores

my $tidy = HTML::Tidy->new({ tidy_mark => 1, output_xhtml => 1, # yes add_xml_decl => 0, # no wrap => 76, });

Update : This node might be of interest to you ; Re^3: HTML::Tidy and mysterious HTML::Tidy::Document

poj

Replies are listed 'Best First'.
Re^2: HTML::Tidy help
by Anonymous Monk on Feb 02, 2016 at 21:46 UTC

    Thanks poj! All of your help if very much appreciated. I fincally found all of the variables on line and have modified by script as follows:

    use HTML::Tidy; my $call_dir = "Html3"; my $contents_of_file = 1; #my $tidy = HTML::Tidy->new(); my $tidy = HTML::Tidy->new({ tidy_mark => 1, #output_xhtml => 1, # yes output_html => 1, # yes add_xml_decl => 1, # no wrap => 76, error_file => errs.txt, char_encoding => utf8, indent_cdata => 1 }); #my $tidy = HTML::Tidy->new({config_file => 'config3.txt'}); #my $tidy = HTML::Tidy->new( {config_file => 'path/to/config'} ); my @files = glob "$call_dir/*.html"; printf "Got %d files\n", scalar @files; for my $file (@files) { open my $in_fh, '<', $file or die "Could not open $file : $!"; my $contents_of_file = do { local $/;<$in_fh> }; close $in_fh; $tidy->parse( $file, $contents_of_file ); $tidy->clean( $file); #parse( $filename, $str [, $str...] ) #or warn "Error parsing $file :$!"; for my $message ( $tidy->messages ) { #print $message->as_string; } }

    The problem that I have now is that running the common line: find /Users/tlialin/desktop/Tidy_Script/Html3 -type f -name "*.html" -exec tidy -f errors.txt -m -utf8 -i {} \; produces a header that looks like this:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15. +15), see www.w3.org"> <title>Aberdeen%20Animal%20trait%20analysis , News Search | Ask.com</title>

    and the perl script produces this:

    http://www.ask.com/news?q=Aberdeen%2520Animal%2520trait%2520analysis+& +qsrc=167&qo=channelNavigation&o=0&l=dir <!DOCTYPE html> <!--[if IE 7 ]> <html lang='en' class='ie7'> <![endif]--> <!--[if IE 8 ]> <html lang='en' class='ie8'> <![endif]--> <!--[if IE 9 ]> <html lang='en' class='ie9'> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <html lang='en'> <!--<![endif]--> <html> <head> <title>Aberdeen%20Animal%20trait%20analysis , News Search | Ask.com</t +itle>

    I'm now questioning if the perl script is writing anything at all. Ides or suggestion very appreciated

      $tidy->clean( $file); does not clean the file it returns a clean file. You need to do
      open OUT,'>','output.html' or die "$!"; print OUT $tidy->clean( $file);
      poj