html-validator-cli
Version:
CLI for validating html using validator.w3.org/nu
111 lines (75 loc) • 2.42 kB
Markdown
[](https://travis-ci.org/zrrrzzt/html-validator-cli)
[](https://coveralls.io/github/zrrrzzt/html-validator-cli?branch=master)
[](https://github.com/feross/standard)
# html-validator-cli
CLI for validating html using [validator.w3.org/nu](http://validator.w3.org/nu/)
Requires Node >= 8.15.3 for older versions use v5.0.0
Sends ```Page is valid```to ```STDOUT``` and exits with code 0 if page is valid.
Sends ```Page is not valid``` to ```STDOUT``` and exits with code 1 if page is not valid.
Sends ```Page not found``` to ```STDOUT``` and exits with code 1 if page is not found.
## Installation
```
$ npm i html-validator-cli -g
```
## Usage
```
$ html-validator <url>
```
With file
```
$ html-validator --file=<path-to-file>
```
With data
```
$ html-validator --data=data
```
Optional pass in format for returned data.
Valid options: json, html, xhtml, xml, gnu and text (default).
```
$ 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'
```
Optional pass in strings to ignore
```
$ html-validator <url> --ignore='Error: Stray end tag “div”.' --ignore='Error: Stray end tag “body”.'
```
Optional pass in headers
```
$ html-validator <url> --headers='{"foo":"doo"}'
```
To get full result from validator use --verbose
```
$ html-validator <url> --verbose
```
Optional, only get errors use --quiet
```
$ html-validator <url> --quiet
```
Validate a local document without setting up a tunnel
```
$ html-validator <local-url> --islocal
```
returns array of error messages
```JavaScript
[
{
"type": "error",
"lastLine": 8,
"lastColumn": 32,
"firstColumn": 27,
"message": "Stray end tag “div”.",
"extract": "aaaad code</div></p>\n<",
"hiliteStart": 10,
"hiliteLength": 6
}
]
```
## Related
- [site-validator-cli](https://github.com/p1ho/site-validator-cli) CLI for validating a whole site or multiple pages
- [html-validator](https://github.com/zrrrzzt/html-validator) API for this module
## License
[MIT](LICENSE)