html-validator
Advanced tools
Comparing version 0.0.6 to 0.0.7
13
index.js
var request = require('request') | ||
, validUrl = require('valid-url') | ||
, userAgent = 'html-validator v0.0.7' | ||
; | ||
@@ -7,3 +8,6 @@ | ||
var newOpts = { | ||
uri: 'http://html5.validator.nu', | ||
uri: 'http://validator.w3.org/nu/', | ||
headers: { | ||
'User-Agent' : userAgent | ||
}, | ||
qs: {out:opts.format}, | ||
@@ -13,2 +17,6 @@ method: 'GET' | ||
if(opts.validator){ | ||
newOpts.uri = opts.validator; | ||
} | ||
if(opts.url){ | ||
@@ -22,3 +30,4 @@ newOpts.qs.doc = opts.url; | ||
newOpts.headers = { | ||
'Content-Type': 'text/html; charset=utf-8' | ||
'Content-Type': 'text/html; charset=utf-8', | ||
'User-Agent' : userAgent | ||
}; | ||
@@ -25,0 +34,0 @@ } |
{ | ||
"name": "html-validator", | ||
"version": "0.0.6", | ||
"description": "Validate html using validator.nu", | ||
"version": "0.0.7", | ||
"description": "Validate html using validator.w3.org/nu", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Geir Gåsodden", |
#html-validator [](https://travis-ci.org/zrrrzzt/html-validator) | ||
A Node.js module/CLI app for validating html using [validator.nu](http://validator.nu/) | ||
A Node.js module/CLI app for validating html using [validator.w3.org/nu](http://validator.w3.org/nu/) | ||
@@ -28,2 +28,3 @@ ##Module | ||
**validator** You can override the default validator as long as it exposes the same REST interface. | ||
@@ -71,5 +72,24 @@ **url** The url to the page you want to validate. | ||
**validator** You can override the default validator as long as it exposes the same REST interface. | ||
```javascript | ||
var validator = require('html-validator') | ||
, opts = { | ||
url : 'http://url-to-validate.com', | ||
validator: 'http://html5.validator.nu', | ||
format : 'json' | ||
}; | ||
validator(opts, function(err, data){ | ||
if(err) throw err; | ||
console.log(data); | ||
}); | ||
``` | ||
##CLI | ||
Pass in --url or --file and optional --format. | ||
Pass in <url> or --file and optional --format or --validator. | ||
@@ -89,3 +109,3 @@ ###Installation | ||
``` | ||
$ html-validator http://url-to-validate | ||
$ html-validator <url> | ||
``` | ||
@@ -104,3 +124,11 @@ | ||
``` | ||
$ html-validator http://url-to-validate --format=gnu | ||
``` | ||
$ html-validator <url> --format=gnu | ||
``` | ||
Optional pass in another validator. | ||
It needs to expose the same REST interface. | ||
``` | ||
$ html-validator <url> --validator='http://html5.validator.nu' | ||
``` |
5842
94
131