{"id":16739304,"url":"https://github.com/olehdutchenko/node-w3c-validator","last_synced_at":"2025-03-21T22:31:32.470Z","repository":{"id":22586589,"uuid":"96180387","full_name":"OlehDutchenko/node-w3c-validator","owner":"OlehDutchenko","description":"Wrapper for The Nu Html Checker (v.Nu)","archived":false,"fork":false,"pushed_at":"2023-08-05T08:12:17.000Z","size":763,"stargazers_count":27,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:34:54.204Z","etag":null,"topics":["checker","cli","html","html5","nodejs","reporting","vnu","w3c-validator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OlehDutchenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-07-04T05:56:37.000Z","updated_at":"2023-04-11T15:20:51.000Z","dependencies_parsed_at":"2023-12-01T06:46:37.164Z","dependency_job_id":null,"html_url":"https://github.com/OlehDutchenko/node-w3c-validator","commit_stats":{"total_commits":98,"total_committers":8,"mean_commits":12.25,"dds":0.6020408163265306,"last_synced_commit":"34536c93540893d64f53f8e3c8e11709581102ad"},"previous_names":["dutchenkooleg/node-w3c-validator"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fnode-w3c-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fnode-w3c-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fnode-w3c-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OlehDutchenko%2Fnode-w3c-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OlehDutchenko","download_url":"https://codeload.github.com/OlehDutchenko/node-w3c-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880187,"owners_count":20525505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checker","cli","html","html5","nodejs","reporting","vnu","w3c-validator"],"created_at":"2024-10-13T00:50:07.122Z","updated_at":"2025-03-21T22:31:32.192Z","avatar_url":"https://github.com/OlehDutchenko.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-w3c-validator\n\n![node](https://img.shields.io/badge/node-6.3.1-yellow.svg)\n[![npm](https://img.shields.io/badge/npm-install-orange.svg)](https://www.npmjs.com/package/node-w3c-validator)\n[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dutchenkoOleg/node-w3c-validator/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/dutchenkoOleg/node-w3c-validator.svg?branch=master)](https://travis-ci.org/dutchenkoOleg/node-w3c-validator)\n\n\u003e _Wrapper for [The Nu Html Checker (v.Nu)](https://www.npmjs.com/package/vnu-jar)_\n\n[![js happiness style](https://cdn.rawgit.com/JedWatson/happiness/master/badge.svg)](https://github.com/JedWatson/happiness)\n\n---\n\n## Attention\n\n\u003e You need to install the \"Java\" for working with `node-w3c-validator`  \n\u003e Visit https://java.com for downloading the \"Java\" if you not have it\n\n\n---\n\n## Table of Contents\n\n1. [CLI](https://github.com/dutchenkoOleg/node-w3c-validator#cli)\n   - [Options](https://github.com/dutchenkoOleg/node-w3c-validator#options)\n1. [Node.js API](https://github.com/dutchenkoOleg/node-w3c-validator#nodejs-api)\n    - [nodeW3CValidator()](https://github.com/dutchenkoOleg/node-w3c-validator#nodew3cvalidatorpathto-options-done)\n    - [nodeW3CValidator.writeFile()](https://github.com/dutchenkoOleg/node-w3c-validator#nodew3cvalidatorwritefilefilepath-outputdata-done)\n    - [Usage Example](https://github.com/dutchenkoOleg/node-w3c-validator#usage-example)\n1. [Errors and Warnings suppressing](https://github.com/dutchenkoOleg/node-w3c-validator#errors-and-warnings-suppressing)\n1. [Changelog](https://github.com/dutchenkoOleg/node-w3c-validator#changelog)\n1. [Contributing](https://github.com/dutchenkoOleg/node-w3c-validator#contributing)\n    - [Contributors 💪](https://github.com/dutchenkoOleg/node-w3c-validator#contributors-)\n1. [Code of Conduct](https://github.com/dutchenkoOleg/node-w3c-validator#code-of-conduct)\n\n---\n\n## CLI\n\nInstall as global package\n\n```shell\nnpm i -g node-w3c-validator\n```\n\nUsage\n\n```shell\nnode-w3c-validator -i ./dist/*.html -f html -o ./reports/result.html -s\n```\n\nYou may pass a [glob](https://www.npmjs.com/package/glob) pattern too\n\n```shell\nnode-w3c-validator -i ./dist/**/*.html -f html -o ./reports/result.html -s\n```\n\n### Options\n\n#### `-i, --input \u003cpath\u003e`\n\nValidate input path.\n\ndefault: `process.cwd()`\n\n#### `--exclude \u003cpath\u003e`\n\nExclude from input path.\n\ndefault: `unset`\n\n#### `-a, --asciiquotes`\n\nSpecifies whether ASCII quotation marks are substituted for Unicode smart\nquotation marks in messages.\n\ndefault: `unset`\n\n#### `-e, --errors-only`\n\nSpecifies that only error-level messages and non-document-error messages are reported (so that warnings and info messages are not reported).\n\ndefault: `unset`, _all message reported, including warnings \u0026 info messages_\n\n#### `-q, --exit-zero-always`\n\nMakes the checker exit zero even if errors are reported for any documents\n\n#### `-f, --format \u003cformat\u003e`\n\nSpecifies the output format for reporting the results\n\ndefault: `unset`\npossible values: `gnu | xml | json | text | html | lint`  \n\n\u003e `lint` format is available from 1.4.0 version.  \n\u003e `lint` format is designed for convenient error output to the terminal.  \n\u003e it uses a [eslint-formatter-pretty](https://github.com/sindresorhus/eslint-formatter-pretty#readme) under the hood\n\n\n![lint format screenshot](https://raw.githubusercontent.com/dutchenkoOleg/node-w3c-validator/master/tests/assets/lint-format-screenshot-upd.png)\n\n\n#### `--filterfile \u003cfilename\u003e`\n\nSpecifies a filename. Each line of the file contains either a regular expression or starts with \"#\" to indicate the line is a comment. Any error message or warning message that matches a regular expression in the file is filtered out (dropped/suppressed)\n\ndefault: `unset`, _checker does no message filtering_\n\n#### `--filterpattern \u003cpattern\u003e`\n\nSpecifies a regular-expression pattern. Any error message or warning message that matches the pattern is filtered out (dropped/suppressed)\n\ndefault: `unset`, _checker does no message filtering_\n\n#### `-s, --skip-non-html`\n\nSkip documents that don’t have `*.html`, `*.htm`, `*.xhtml`, or `*.xht` extensions.\n\ndefault: `unset`, _all documents found are checked, regardless of extension_\n\n#### `-H, --html`\n\nForces any `*.xhtml` or `*.xht` documents to be parsed using the HTML parser.\n\ndefault: `unset`, _XML parser is used for `*.xhtml` and `*.xht` documents_\n\n#### `--no-langdetect`\n\nDisables language detection, so that documents are not checked for missing or mislabeled html[lang] attributes.\n\ndefault: `unset`, _language detection \u0026 html[lang] checking are performed_\n\n#### `--no-stream`\n\nForces all documents to be be parsed in buffered mode instead of streaming mode (causes some parse errors to be treated as non-fatal document errors instead of as fatal document errors).\n\ndefault: `unset`, _non-streamable parse errors cause fatal document errors_\n\n#### `-v, --verbose`\n\nSpecifies \"verbose\" output. (Currently this just means that the names of\nfiles being checked are written to stdout.)\n\ndefault: `unset`, _output is not verbose_\n\n#### `-V, --version`\n\nShows the current version number.\n\n#### `-o, --output \u003cpath\u003e`\n\nWrite reporting result to the path\n\n#### `-b, --buffersize \u003csize\u003e`\n\nIncrease [maxBuffer](https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_child_process_exec_command_options_callback) size to prevent [`!!! OUTPUT ERROR` or `Unexpected end of JSON input` errors](https://github.com/dutchenkoOleg/node-w3c-validator/issues/3). This is because [child_process stdout being truncated](https://github.com/nodejs/node/issues/19218) when validator check a lot of files.\n\n##### CLI `-b, --buffersize`\n\n```bash\n# increase buffer size (1024 * 500)\nnode-w3c-validator -i static/**/*.html -b 500\n```\n\n##### Node.js API `exec.buffersize`\n\n```js\n// increase buffer size (1024 * 500)\nnodeW3CValidator(validatePath, {\n    format: 'html',\n    exec: {\n        buffersize: 1024 * 500\n    }\n}, function (err, output) {\n    // ...\n});\n```\n\n---\n\n## Node.js API\n\nInstall in your project\n\n```shell\nnpm i --save-dev node-w3c-validator\n```\n\n### nodeW3CValidator(pathTo, options, done);\n\n_Parameters:_\n\nName | Data type | Description\n --- | --- | ---\n `pathTo` | `string` | The path to the folder or directly to the file, for verification, also it can be url to the Web document\n `options` | `Object` | Options for validating, sеe description below\n `done` | `Function` | Validation callback, sеe description below\n\n\n#### `options`\n\nYou can use all available options from [CLI / Options](#cli). Only change props name to the camelCase style,\n exeception `--no-stream` and `--no-langdetect` they must be declared without `no` part\n\n_example_\n\n- `--errors-only` - `errorsOnly: true`\n- `--no-langdetect` - `langdetect: false`\n- `--format json` - `format: 'json'`\n\n_an exception_\n\n`--buffersize 500`\n\ntransforms to\n\n```js\nexec: {\n    buffersize: 1024 * 500\n}\n```\n\n\n#### `done(err, output)`\n\nValidation callback.\n\n_Parameters:_\n\nName | Data type | Description\n --- | --- | ---\n `err` | `Error / null` | if no errors - will be `null`, otherwise - Error object\n `output` | `string` | string with reporting result, if no errors - can be as empty string\n\n### nodeW3CValidator.writeFile(filePath, outputData[, done])\n\nWrite file\n\n_Parameters:_\n\nName | Data type | Argument | Description\n --- | --- | --- | ---\n `filePath` | `string` |  | relative path to saving a file\n `outputData` | `string / Buffer` |  | file output content\n `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)\n\n### Usage Example\n\n```js\n// imports\nconst nodeW3CValidator = require('node-w3c-validator');\n\n// paths\nconst validatePath = './dist/*.html';\n// or directly to the file - './dist/index.html'\n// or a glob pattern - './dist/**/*.html'\nconst resultOutput = './reports/result.html';\n\n// validate\nnodeW3CValidator(validatePath, {\n    format: 'html',\n    skipNonHtml: true,\n    verbose: true\n}, function (err, output) {\n    if (err === null) {\n        return;\n    }\n    nodeW3CValidator.writeFile(resultOutput, output);\n});\n```\n\n---\n\n\n## Errors and Warnings suppressing\n\nYou can ignore some errors or warnings by suppressing them.  \n_**Note!** This feature can be used only on `html`, `json` and `lint` formats._\n\nYou need to specify `nodeW3Cvalidator` field in your project `package.json` file.\n\nHere can be two arrays, for errors (`suppressErrors`) and warnigns(`suppressWarnings`).  \nValues must be a string parts or fully value of \"unwanted\" message.  \nUnder the hood - node-w3c-validator will use `String.protorype.includes`  \nmethod for filtering messages.\n\nFor example, you receive warning message:\n\n```text\nThe “type” attribute for the “style” element is not needed and should be omitted.\n```\n\nNow you can suppress it\n\n```json\n{\n  \"nodeW3Cvalidator\": {\n    \"suppressErrors\": [],\n    \"suppressWarnings\": [\n      \"The “type” attribute for the “style” element is not needed and should be omitted.\"\n    ]\n  }\n}\n```\n\nOr like this with a part of message:\n\n```json\n{\n  \"nodeW3Cvalidator\": {\n    \"suppressErrors\": [],\n    \"suppressWarnings\": [\n      \"is not needed and should be omitted\"\n    ]\n  }\n}\n```\n\n---\n\n## Changelog\n\nSee [Releases history](https://github.com/dutchenkoOleg/node-w3c-validator/releases)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/dutchenkoOleg/node-w3c-validator/blob/master/CONTRIBUTING.md)\n\n#### Contributors 💪\n\n- Michael Kühnel [@mischah](https://github.com/mischah)\n- Debjeet Biswas [@detj](https://github.com/detj)\n- Yunus Gaziev [@yunusga](https://github.com/yunusga)\n- WezomDev [@WezomDev](https://github.com/WezomDev)\n\n## Code of Conduct\n\nPlease read [CODE_OF_CONDUCT.md](https://github.com/dutchenkoOleg/node-w3c-validator/blob/master/CODE_OF_CONDUCT.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fnode-w3c-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folehdutchenko%2Fnode-w3c-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folehdutchenko%2Fnode-w3c-validator/lists"}