{"id":16143902,"url":"https://github.com/callumacrae/gulp-w3cjs","last_synced_at":"2025-03-16T09:33:24.041Z","repository":{"id":12837455,"uuid":"15512955","full_name":"callumacrae/gulp-w3cjs","owner":"callumacrae","description":":vertical_traffic_light: w3cjs wrapper for gulp to validate your HTML","archived":false,"fork":false,"pushed_at":"2019-04-16T19:54:59.000Z","size":45,"stargazers_count":57,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T06:23:51.997Z","etag":null,"topics":[],"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/callumacrae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-29T18:32:02.000Z","updated_at":"2023-12-01T03:22:18.000Z","dependencies_parsed_at":"2022-09-15T19:00:50.347Z","dependency_job_id":null,"html_url":"https://github.com/callumacrae/gulp-w3cjs","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callumacrae%2Fgulp-w3cjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callumacrae%2Fgulp-w3cjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callumacrae%2Fgulp-w3cjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callumacrae%2Fgulp-w3cjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/callumacrae","download_url":"https://codeload.github.com/callumacrae/gulp-w3cjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809844,"owners_count":20351406,"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":[],"created_at":"2024-10-10T00:10:33.291Z","updated_at":"2025-03-16T09:33:23.778Z","avatar_url":"https://github.com/callumacrae.png","language":"JavaScript","funding_links":[],"categories":["插件","Plugins"],"sub_categories":["代码校验","Linting"],"readme":"# gulp-w3cjs [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]\n\n\u003e [w3cjs](https://github.com/thomasdavis/w3cjs) wrapper for [gulp](https://github.com/wearefractal/gulp) to validate your HTML\n\n## Usage\n\nFirst, install `gulp-w3cjs` as a development dependency:\n\n```shell\nnpm install --save-dev gulp-w3cjs\n```\n\nThen, add it to your `gulpfile.js`:\n\n```javascript\nvar w3cjs = require('gulp-w3cjs');\n\ngulp.task('w3cjs', function () {\n\treturn gulp.src('src/*.html')\n\t\t.pipe(w3cjs())\n\t\t.pipe(w3cjs.reporter());\n});\n```\n\n### Custom Reporting\n\nThe results are also added onto each file object under `w3cjs`, containing `success` (Boolean) and `messages` (Array).\n\n**Example usage**\n\n```javascript\nvar w3cjs = require('gulp-w3cjs');\nvar through2 = require('through2');\n\ngulp.task('example', function () {\n\treturn gulp.src('src/*.html')\n\t\t.pipe(w3cjs())\n\t\t.pipe(through2.obj(function(file, enc, cb){\n\t\t\tcb(null, file);\n\t\t\tif (!file.w3cjs.success){\n\t\t\t\tthrow new Error('HTML validation error(s) found');\n\t\t\t}\n\t\t}));\n});\n```\n\n**Example output**\n\n```shell\nHTML Error: index.html Line 5, Column 19: Element title must not be empty.\n    \u003ctitle\u003e\u003c/title\u003e\n\n.../gulpfile.js:11\n                                throw new Error('HTML validation error(s) found');\n                                      ^\nError: HTML validation error(s) found\n```\n\n## API\n\n### w3cjs(options)\n\n#### options.url\n\nURL to the w3c validator. Use if you want to use a local validator. This is the\nsame thing as `w3cjs.setW3cCheckUrl()`.\n\n#### options.proxy\n\nHttp address of the proxy server if you are running behind a firewall, e.g.  `http://proxy:8080`\n\n_`options.doctype` and `options.charset` were dropped in 1.0.0. Use 0.3.0 if you need them._\n\n#### options.showInfo\n\nDefault: `false`\n\nShow `info` type messages in the output.\n\n#### options.verifyMessage\n\nAllows you to intercept info, warnings or errors, using `options.verifyMessage` methed, returning false will skip the log output. Example usage:\n```js\nreturn gulp.src('index.html')\n\t.pipe(w3cjs({\n\t\tverifyMessage: function(type, message) {\n\n\t\t\t// prevent logging error message\n\t\t\tif(message.indexOf('Element “style” not allowed as child of element') === 0) return false;\n\t\t\t\n\t\t\t// allow message to pass through\n\t\t\treturn true;\n\t\t}\n\t}))\n\t.pipe(w3cjs.reporter())\n```\n\n### w3cjs.setW3cCheckUrl(url)\n\nSame as options.url. SEt's the URL to the w3c validator.\n\n## License\n\n[MIT License](http://en.wikipedia.org/wiki/MIT_License)\n\n[npm-url]: https://npmjs.org/package/gulp-w3cjs\n[npm-image]: https://badge.fury.io/js/gulp-w3cjs.png\n\n[travis-url]: http://travis-ci.org/callumacrae/gulp-w3cjs\n[travis-image]: https://secure.travis-ci.org/callumacrae/gulp-w3cjs.png?branch=master\n\n[depstat-url]: https://david-dm.org/callumacrae/gulp-w3cjs\n[depstat-image]: https://david-dm.org/callumacrae/gulp-w3cjs.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallumacrae%2Fgulp-w3cjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcallumacrae%2Fgulp-w3cjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallumacrae%2Fgulp-w3cjs/lists"}