w3c-html-validator 2.1.0 → 2.2.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 CHANGED
@@ -58,6 +58,7 @@ You can also install **w3c-html-validator** globally (`--global`) and then run i
58
58
  Command-line flags:
59
59
  | Flag | Description | Value |
60
60
  | ----------------- | ------------------------------------------------------------------- | ---------- |
61
+ | `--check-url` | W3C validation API endpoint (example: `http://localhost/nu/`). | **string** |
61
62
  | `--continue` | Report messages but do not throw an error if validation failed. | N/A |
62
63
  | `--default-rules` | Apply additional built-in opinionated ignore list. | N/A |
63
64
  | `--delay` | Debounce pause in milliseconds between each file validation. | **number** |
@@ -92,11 +93,14 @@ Command-line flags:
92
93
  Skip all HTML validation messages in the built-in opinionated ignore list and also suppresses all the "pass" status messages.
93
94
 
94
95
  - `html-validator docs --delay=200`<br>
95
- Validates all HTML files in the "docs" folder at a rate of 1 file per 200 ms (default is 500 ms).
96
+ Validates all HTML files in the **docs** folder at a rate of 1 file per 200 ms (default is 500 ms).
96
97
 
97
98
  - `html-validator docs --trim=30 --continue`<br>
98
99
  Truncates validation messages to 30 characters and does not abort CI if validation fails.
99
100
 
101
+ - `html-validator docs --check-url=http://localhost/nu/ --delay=0`<br>
102
+ Uses a locally hosted W3C validator, such as the [docker-validator-w3c](https://github.com/netresearch/docker-validator-w3c) server.
103
+
100
104
  > [!NOTE]
101
105
  > _Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
102
106
 
@@ -138,7 +142,7 @@ Example call to the `validate()` function:
138
142
  import { w3cHtmlValidator } from 'w3c-html-validator';
139
143
 
140
144
  const options = { filename: 'docs/index.html' };
141
- w3cHtmlValidator.validate(options).then(console.log);
145
+ w3cHtmlValidator.validate(options).then(console.log); //outputs the resutls object
142
146
  ```
143
147
  To display formatted output, replace `console.log` with `w3cHtmlValidator.reporter`:
144
148
  ```typescript
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v2.1.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v2.2.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  export type ValidatorSettings = {
4
4
  html: string | null;
@@ -46,6 +46,7 @@ export type ReporterSettings = {
46
46
  };
47
47
  declare const w3cHtmlValidator: {
48
48
  version: string;
49
+ checkUrl: string;
49
50
  defaultIgnoreList: string[];
50
51
  assert(ok: unknown, message: string | null): void;
51
52
  cli(): void;
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v2.1.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v2.2.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  import { cliArgvUtil } from 'cli-argv-util';
4
4
  import { globSync } from 'glob';
@@ -8,7 +8,8 @@ import log from 'fancy-log';
8
8
  import request from 'superagent';
9
9
  import slash from 'slash';
10
10
  const w3cHtmlValidator = {
11
- version: '2.1.0',
11
+ version: '2.2.0',
12
+ checkUrl: 'https://validator.w3.org/nu/',
12
13
  defaultIgnoreList: [
13
14
  'with computed level',
14
15
  'Section lacks heading.',
@@ -18,10 +19,11 @@ const w3cHtmlValidator = {
18
19
  throw new Error(`[w3c-html-validator] ${message}`);
19
20
  },
20
21
  cli() {
21
- const validFlags = ['continue', 'default-rules', 'delay', 'dry-run', 'exclude',
22
+ const validFlags = ['check-url', 'continue', 'default-rules', 'delay', 'dry-run', 'exclude',
22
23
  'ignore', 'ignore-config', 'note', 'quiet', 'trim'];
23
24
  const cli = cliArgvUtil.parse(validFlags);
24
25
  const files = cli.params.length ? cli.params.map(cliArgvUtil.cleanPath) : ['.'];
26
+ const checkUrl = cli.flagMap.checkUrl ?? w3cHtmlValidator.checkUrl;
25
27
  const excludeList = cli.flagMap.exclude?.split(',') ?? [];
26
28
  const ignore = cli.flagMap.ignore ?? null;
27
29
  const ignoreConfig = cli.flagMap.ignoreConfig ?? null;
@@ -63,7 +65,7 @@ const w3cHtmlValidator = {
63
65
  return rawLines.map(line => isRegex.test(line) ? new RegExp(line.slice(1, -1)) : line);
64
66
  };
65
67
  const ignoreMessages = getIgnoreMessages();
66
- const options = (filename) => ({ filename, ignoreMessages, defaultRules, dryRun });
68
+ const options = (filename) => ({ filename, checkUrl, ignoreMessages, defaultRules, dryRun });
67
69
  const handleResults = (results) => w3cHtmlValidator.reporter(results, reporterOptions);
68
70
  const getReport = (filename) => w3cHtmlValidator.validate(options(filename)).then(handleResults);
69
71
  const processFile = (filename, i) => globalThis.setTimeout(() => getReport(filename), i * delay);
@@ -71,7 +73,7 @@ const w3cHtmlValidator = {
71
73
  },
72
74
  validate(options) {
73
75
  const defaults = {
74
- checkUrl: 'https://validator.w3.org/nu/',
76
+ checkUrl: w3cHtmlValidator.checkUrl,
75
77
  defaultRules: false,
76
78
  dryRun: false,
77
79
  filename: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w3c-html-validator",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Check the markup validity of HTML files using the W3C validator",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -62,7 +62,7 @@
62
62
  "fancy-log": "~2.0",
63
63
  "glob": "~13.0",
64
64
  "slash": "~5.1",
65
- "superagent": "~10.2"
65
+ "superagent": "~10.3"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@eslint/js": "~9.39",
@@ -79,6 +79,6 @@
79
79
  "rimraf": "~6.1",
80
80
  "run-scripts-util": "~1.3",
81
81
  "typescript": "~5.9",
82
- "typescript-eslint": "~8.51"
82
+ "typescript-eslint": "~8.53"
83
83
  }
84
84
  }