w3c-html-validator 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/bin/cli.js +6 -2
- package/dist/w3c-html-validator.d.ts +1 -1
- package/dist/w3c-html-validator.js +2 -2
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -63,31 +63,33 @@ Command-line flags:
|
|
|
63
63
|
### 4. Example CLI usage
|
|
64
64
|
Examples:
|
|
65
65
|
- `html-validator`<br>
|
|
66
|
-
|
|
66
|
+
Validates all HTML files in the project.
|
|
67
67
|
|
|
68
68
|
- `html-validator docs --exclude=build,tmp`<br>
|
|
69
|
-
|
|
69
|
+
Validates all HTML files in the **docs** folder except files which have "build" or "tmp" anywhere in their pathname or filename.
|
|
70
70
|
|
|
71
71
|
- `html-validator docs '--ignore=Trailing slash on void elements'`<br>
|
|
72
|
-
|
|
72
|
+
Allows the ugly slashes of self-closing tags despite XHTML being a hideous scourge on the web.
|
|
73
73
|
|
|
74
74
|
- `html-validator docs '--ignore=/^Duplicate ID/'`<br>
|
|
75
|
-
|
|
75
|
+
Uses a regex (regular expression) to skip all HTML validation messages that start with "Duplicate ID".
|
|
76
76
|
|
|
77
77
|
- `html-validator docs '--ignore=/^Duplicate ID|^Section lacks|^Element .blockquote. not allowed/'`<br>
|
|
78
|
-
|
|
78
|
+
Uses a regex with "or" operators (`|`) to skip multiple HTML validation messages.
|
|
79
79
|
|
|
80
|
-
- `html-validator docs --ignore-config=
|
|
81
|
-
Similar to the pervious command but
|
|
80
|
+
- `html-validator docs --ignore-config=spec/ignore-config.txt`<br>
|
|
81
|
+
Similar to the pervious command but strings and regexes are stored in a configuration file (see the _Ignore Configuration File_ section below).
|
|
82
82
|
|
|
83
83
|
- `html-validator --quiet`<br>
|
|
84
|
-
|
|
84
|
+
Suppresses all the "pass" status messages.
|
|
85
85
|
|
|
86
86
|
- `html-validator docs --delay=200`<br>
|
|
87
|
-
|
|
87
|
+
Validates all HTML files in the "docs" folder at a rate of 1 file per 200 ms (default is 500 ms).
|
|
88
88
|
|
|
89
89
|
- `html-validator docs --trim=30 --continue`<br>
|
|
90
|
-
|
|
90
|
+
Truncates validation messages to 30 characters and does not abort CI if validation fails.
|
|
91
|
+
|
|
92
|
+
_**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
|
|
91
93
|
|
|
92
94
|
### 5. Ignore Configuration File
|
|
93
95
|
The optional `--ignore-config=FILENAME` flag specifies a configuration file with one string or regex per line.
|
package/bin/cli.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
//
|
|
18
18
|
// Contributors to this project:
|
|
19
19
|
// $ cd w3c-html-validator
|
|
20
|
+
// $ npm install
|
|
21
|
+
// $ npm test
|
|
20
22
|
// $ node bin/cli.js spec --continue
|
|
21
23
|
|
|
22
24
|
// Imports
|
|
@@ -35,10 +37,12 @@ const delay = Number(cli.flagMap.delay) || 500; //default half second de
|
|
|
35
37
|
const trim = Number(cli.flagMap.trim) || null;
|
|
36
38
|
|
|
37
39
|
// Validator
|
|
40
|
+
const globOptions = { ignore: '**/node_modules/**/*' };
|
|
38
41
|
const keep = (filename) => !filename.includes('node_modules/');
|
|
39
|
-
const readFolder = (folder) => globSync(folder + '**/*.html',
|
|
42
|
+
const readFolder = (folder) => globSync(folder + '**/*.html', globOptions);
|
|
40
43
|
const expandFolder = (file) => fs.lstatSync(file).isDirectory() ? readFolder(file + '/') : file;
|
|
41
|
-
const
|
|
44
|
+
const getAllPaths = () => files.map(file => globSync(file, globOptions)).flat();
|
|
45
|
+
const getFilenames = () => getAllPaths().map(expandFolder).flat().filter(keep).sort();
|
|
42
46
|
const list = files.length ? getFilenames() : readFolder('');
|
|
43
47
|
const excludes = cli.flagMap.exclude?.split(',') ?? [];
|
|
44
48
|
const filenames = list.filter(name => !excludes.find(exclude => name.includes(exclude)));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//! w3c-html-validator v1.
|
|
1
|
+
//! w3c-html-validator v1.6.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import log from 'fancy-log';
|
|
6
6
|
import request from 'superagent';
|
|
7
7
|
const w3cHtmlValidator = {
|
|
8
|
-
version: '1.
|
|
8
|
+
version: '1.6.0',
|
|
9
9
|
validate(options) {
|
|
10
10
|
const defaults = {
|
|
11
11
|
checkUrl: 'https://validator.w3.org/nu/',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3c-html-validator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"html-validator": "bin/cli.js",
|
|
21
21
|
"w3c-html-validator": "bin/cli.js"
|
|
22
22
|
},
|
|
23
|
-
"repository":
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/center-key/w3c-html-validator.git"
|
|
26
|
+
},
|
|
24
27
|
"homepage": "https://github.com/center-key/w3c-html-validator",
|
|
25
28
|
"bugs": "https://github.com/center-key/w3c-html-validator/issues",
|
|
26
29
|
"docs": "https://github.com/center-key/w3c-html-validator#readme",
|
|
@@ -88,15 +91,15 @@
|
|
|
88
91
|
"devDependencies": {
|
|
89
92
|
"@types/fancy-log": "~2.0",
|
|
90
93
|
"@types/glob": "~8.1",
|
|
91
|
-
"@types/node": "~20.
|
|
94
|
+
"@types/node": "~20.8",
|
|
92
95
|
"@types/superagent": "~4.1",
|
|
93
|
-
"@typescript-eslint/eslint-plugin": "~6.
|
|
94
|
-
"@typescript-eslint/parser": "~6.
|
|
96
|
+
"@typescript-eslint/eslint-plugin": "~6.9",
|
|
97
|
+
"@typescript-eslint/parser": "~6.9",
|
|
95
98
|
"add-dist-header": "~1.3",
|
|
96
99
|
"assert-deep-strict-equal": "~1.1",
|
|
97
100
|
"copy-file-util": "~1.1",
|
|
98
101
|
"copy-folder-util": "~1.1",
|
|
99
|
-
"eslint": "~8.
|
|
102
|
+
"eslint": "~8.53",
|
|
100
103
|
"jshint": "~2.13",
|
|
101
104
|
"merge-stream": "~2.0",
|
|
102
105
|
"mocha": "~10.2",
|