Skip to content

🚦 w3cjs wrapper for gulp to validate your HTML

License

Notifications You must be signed in to change notification settings

chqy24/gulp-w3cjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-w3cjs NPM version Build Status Dependency Status

w3cjs wrapper for gulp to validate your HTML

Usage

First, install gulp-w3cjs as a development dependency:

npm install --save-dev gulp-w3cjs

Then, add it to your gulpfile.js:

var w3cjs = require('gulp-w3cjs');

gulp.task('w3cjs', function () {
	gulp.src('src/*.html')
		.pipe(w3cjs())
		.pipe(w3cjs.reporter());
});

Custom Reporting

The results are also added onto each file object under w3cjs, containing success (Boolean) and messages (Array).

Example usage

var w3cjs = require('gulp-w3cjs');
var through2 = require('through2');

gulp.task('example', function () {
	gulp.src('src/*.html')
		.pipe(w3cjs())
		.pipe(through2.obj(function(file, enc, cb){
			cb(null, file);
			if (!file.w3cjs.success){
				throw new Error('HTML validation error(s) found');
			}
		}));
});

Example output

HTML Error: index.html Line 5, Column 19: Element title must not be empty.
    <title></title>

.../gulpfile.js:11
                                throw new Error('HTML validation error(s) found');
                                      ^
Error: HTML validation error(s) found

API

w3cjs(options)

options.url

URL to the w3c validator. Use if you want to use a local validator. This is the same thing as w3cjs.setW3cCheckUrl().

options.proxy

Http address of the proxy server if you are running behind a firewall, e.g. http://proxy:8080

options.doctype and options.charset were dropped in 1.0.0. Use 0.3.0 if you need them.

w3cjs.setW3cCheckUrl(url)

Same as options.url. SEt's the URL to the w3c validator.

License

MIT License

About

🚦 w3cjs wrapper for gulp to validate your HTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.8%
  • HTML 4.2%