mirror of
https://github.com/imapsync/imapsync.git
synced 2025-06-12 15:34:52 +02:00
47 lines
1.3 KiB
Perl
Executable file
47 lines
1.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use WebService::Validator::HTML::W3C;
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This script takes files as arguments and then submits those file
|
|
to the W3C validator. It will print out a line for each
|
|
file stating if it is valid or otherwise. For the invalid files it will
|
|
also print out the errors returned by the validator.
|
|
|
|
=cut
|
|
|
|
my $v = WebService::Validator::HTML::W3C->new(
|
|
# you should probably install a local validator if you
|
|
# are indenting to run this against a lot of files and
|
|
# then uncomment this line and change the uri
|
|
# validator_uri => 'http://localhost/w3c-validator/check',
|
|
detailed => 1
|
|
) or die "failed to init validator object";
|
|
|
|
my $invalid_found = 0 ;
|
|
|
|
for my $file ( @ARGV ) {
|
|
if ( $v->validate_file( $file ) ) {
|
|
if ( $v->is_valid ) {
|
|
print "$file: valid\n";
|
|
} else {
|
|
$invalid_found = 1 ;
|
|
print "$file: invalid\n";
|
|
for my $err ( @{ $v->errors } ) {
|
|
printf(" line: %s, col: %s\n error: %s\n\n",
|
|
$err->line, $err->col, $err->msg);
|
|
}
|
|
}
|
|
} else {
|
|
die "failed to validate $file: " . $v->validator_error . "\n";
|
|
}
|
|
print "\n" . '-' x 60 . "\n";
|
|
# sleep between files so as not to hammer the validator
|
|
sleep 1;
|
|
}
|
|
|
|
exit( $invalid_found ) ;
|
|
|