Skip to content

Instantly share code, notes, and snippets.

@richardneish
Created August 2, 2013 13:25
Show Gist options
  • Save richardneish/6139853 to your computer and use it in GitHub Desktop.
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 '-'.
#!/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