Created
August 2, 2013 13:25
-
-
Save richardneish/6139853 to your computer and use it in GitHub Desktop.
Command line wrapper around the HTML::Lint module. I hacked this up because I couldn't find the included weblint script. Takes HTML from a filename specified on the command line, or from STDIN if the filename is '-'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use HTML::Lint; | |
die "Usage: $0 [<FILENAME> | -]" unless defined $ARGV[0]; | |
my $lint = HTML::Lint->new; | |
$lint->only_types( HTML::Lint::Error::STRUCTURE ); | |
if ($ARGV[0] eq '-') { | |
$lint->parse(join('', <>)); | |
} else { | |
$lint->parse_file( $ARGV[0] ); | |
} | |
my $error_count = $lint->errors; | |
if ($error_count == 0) { | |
print "No errors."; | |
} else { | |
foreach my $error ( $lint->errors ) { | |
print $error->as_string, "\n"; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment