|
17 | 17 | > Visit https://java.com for download Java if you not have it |
18 | 18 |
|
19 | 19 |
|
| 20 | +--- |
| 21 | + |
| 22 | +## Table of Contents |
| 23 | + |
| 24 | +1. [CLI](https://github.com/dutchenkoOleg/node-w3c-validator#cli) |
| 25 | + - [Options](https://github.com/dutchenkoOleg/node-w3c-validator#options) |
| 26 | +1. [Node.js API](https://github.com/dutchenkoOleg/node-w3c-validator#nodejs-api) |
| 27 | + - [nodeW3CValidator()](https://github.com/dutchenkoOleg/node-w3c-validator#nodew3cvalidatorpathto-options-done) |
| 28 | + - [nodeW3CValidator.writeFile()](https://github.com/dutchenkoOleg/node-w3c-validator#nodew3cvalidatorwritefilefilepath-outputdata-done) |
| 29 | + - [Usage Example](https://github.com/dutchenkoOleg/node-w3c-validator#usage-example) |
| 30 | +1. [Errors and Warnings suppressing](https://github.com/dutchenkoOleg/node-w3c-validator#errors-and-warnings-suppressing) |
| 31 | +1. [Changelog](https://github.com/dutchenkoOleg/node-w3c-validator#changelog) |
| 32 | +1. [Contributing](https://github.com/dutchenkoOleg/node-w3c-validator#contributing) |
| 33 | + - [Contributors 💪](https://github.com/dutchenkoOleg/node-w3c-validator#contributors-) |
| 34 | +1. [Code of Conduct](https://github.com/dutchenkoOleg/node-w3c-validator#code-of-conduct) |
| 35 | + |
20 | 36 | --- |
21 | 37 |
|
22 | 38 | ## CLI |
@@ -229,8 +245,35 @@ Name | Data type | Argument | Description |
229 | 245 | `outputData` | `string / Buffer` | | file output content |
230 | 246 | `done` | `Function` | _optional_ | if exist - it will asynchronous writes output to the filePath. See [fs.writeFile(file, data, callback)](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) |
231 | 247 |
|
| 248 | +### Usage Example |
| 249 | + |
| 250 | +```js |
| 251 | +// imports |
| 252 | +const nodeW3CValidator = require('node-w3c-validator'); |
| 253 | + |
| 254 | +// paths |
| 255 | +const validatePath = './dist/*.html'; |
| 256 | +// or directly to the file - './dist/index.html' |
| 257 | +// or a glob pattern - './dist/**/*.html' |
| 258 | +const resultOutput = './reports/result.html'; |
| 259 | + |
| 260 | +// validate |
| 261 | +nodeW3CValidator(validatePath, { |
| 262 | + format: 'html', |
| 263 | + skipNonHtml: true, |
| 264 | + verbose: true |
| 265 | +}, function (err, output) { |
| 266 | + if (err === null) { |
| 267 | + return; |
| 268 | + } |
| 269 | + nodeW3CValidator.writeFile(resultOutput, output); |
| 270 | +}); |
| 271 | +``` |
| 272 | + |
| 273 | +--- |
| 274 | + |
232 | 275 |
|
233 | | -### Errors and Warnings suppressing |
| 276 | +## Errors and Warnings suppressing |
234 | 277 |
|
235 | 278 | You can ignore some errors or warnings by suppressing them. |
236 | 279 | _**Note!** This feature can be used only on `html`, `json` and `lint` formats._ |
@@ -261,32 +304,6 @@ Now you can suppress it |
261 | 304 | } |
262 | 305 | ``` |
263 | 306 |
|
264 | | - |
265 | | -### Usage Example |
266 | | - |
267 | | -```js |
268 | | -// imports |
269 | | -const nodeW3CValidator = require('node-w3c-validator'); |
270 | | - |
271 | | -// paths |
272 | | -const validatePath = './dist/*.html'; |
273 | | -// or directly to the file - './dist/index.html' |
274 | | -// or a glob pattern - './dist/**/*.html' |
275 | | -const resultOutput = './reports/result.html'; |
276 | | - |
277 | | -// validate |
278 | | -nodeW3CValidator(validatePath, { |
279 | | - format: 'html', |
280 | | - skipNonHtml: true, |
281 | | - verbose: true |
282 | | -}, function (err, output) { |
283 | | - if (err === null) { |
284 | | - return; |
285 | | - } |
286 | | - nodeW3CValidator.writeFile(resultOutput, output); |
287 | | -}); |
288 | | -``` |
289 | | - |
290 | 307 | --- |
291 | 308 |
|
292 | 309 | ## Changelog |
|
0 commit comments