gulp-w3cjs = function (options) { options = options || {}; // I typo'd this and didn't want to break BC if (typeof options.uri === 'string') { options.url = options.uri; } if (typeof options.url === 'string') { w3cjs.setW3cCheckUrl(options.url); } return through.obj(function (file, enc, callback) { if (file.isNull()) { return callback(null, file); } if (file.isStream()) { return callback(new gutil.PluginError('gulp-w3cjs', 'Streaming not supported')); } w3cjs.validate({ proxy: options.proxy ? options.proxy : undefined, input: file.contents, callback: function (res) { file.w3cjs = { success: handleMessages(file, res.messages, options), messages: res.messages }; callback(null, file); } }); }); }
n/a
function reporter() { return through.obj(function(file, enc, cb) { cb(null, file); if (file.w3cjs && !file.w3cjs.success) { throw new gutil.PluginError('gulp-w3cjs', 'HTML validation error(s) found'); } }); }
...
```javascript
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).
...
function setW3cCheckUrl(newW3cCheckUrl) { w3cCheckUrl = newW3cCheckUrl; }
...
## 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._
...