W3C html validaton grunt plugin. Validate all files in a directory automatically.
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-html-validation --save-devOne the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-html-validation');In your project's Gruntfile, add a section named html_validation to the data object passed into grunt.initConfig().
grunt.initConfig({
validation: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})Type: Boolean
Default value: 'false'
Resets all the validated files status. When want to revalidate all the validated files -
eg: sudo grunt validate --reset=true
Type: String
Default value: 'validation-staus.json'
Default file for storing validation information.
Type: String
Default value: validation-report.json
Consolidated report in JSON format.
Type: Boolean
Default value: false
When hit by a validation error, html-validator continue validating next file by default and this process continues until all files in the list completes validation. If 'stoponerror' set to true, validator will stop validating next file.
Type: Number
Default value: 3
Number of retries when network error occuers. Default case, after 3 reties validator will move to next file.
Type: String
Default value: ``
Remote base url path. eg: "http://decodize.com/".
Type: Array
Default value: ``
Array of page paths to be validated. When remote files are not present validator will append file names from local folder. 'remotePath' is mandatory when this option is specified.
eg: remoteFiles: ["html/moving-from-wordpress-to-octopress/", "css/site-preloading-methods/"]
you can also provide a file contains array of pages.
remoteFiles: "validation-files.json"
["html/getting-started-with-yeoman-1-dot-0-beta-on-windows",
"html/slidemote-universal-remote-control-for-html5-presentations/",
"html/simple-responsive-image-technique/"]validation: {
options: {
reset: grunt.option('reset') || false,
stoponerror: false,
remotePath: "http://decodize.com/",
remoteFiles: ["html/moving-from-wordpress-to-octopress/",
"css/site-preloading-methods/"], //or
remoteFiles: "validation-files.json" // JSON file contains array of page paths.
},
files: {
src: ['<%= yeoman.app %>/*.html',
'!<%= yeoman.app %>/index.html',
'!<%= yeoman.app %>/modules.html',
'!<%= yeoman.app %>/404.html']
}
}In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Report issues here
- 2013-08-31 v0.1.5 Added remote validation support. Max network error retry count.
- 2013-08-19 v0.1.4 Fixed issues. Added 'stoponerror' option, validation report added.
- 2013-08-05 v0.1.2 Fixed issues.
- 2013-04-20 v0.1.0 Initial release.


