w3c-html-validator 2.0.2 → 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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2025 Individual contributors to w3c-html-validator
3
+ Copyright (c) 2021-2026 Individual contributors to w3c-html-validator
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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,12 +93,16 @@ 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
 
100
- _**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
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
+
104
+ > [!NOTE]
105
+ > _Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
101
106
 
102
107
  ### 6. Configuration File for Ignore Patterns
103
108
  The optional `--ignore-config=FILENAME` flag specifies a configuration file with one string or regex per line.&nbsp;
@@ -121,6 +126,7 @@ The optional `--default-rules` flag causes HTML validation messages to be skippe
121
126
  Default ignore list:
122
127
  | Pattern | Level | Explanation |
123
128
  | ------------------------ | ----------- | ----------- |
129
+ | `with computed level` | **error** | It's ridiculous that adding an `<aside>` with an `<h2>` breaks the outer flow's outline. |
124
130
  | `Section lacks heading.` | **warning** | Rule is sensible for traditional print publishing but absurd for modern UI components not burning in nested `<div>` hell. |
125
131
 
126
132
  If there is an additional W3C validation message you think is ridiculous, open an issue with a note explaining why the message should be ignored.&nbsp;
@@ -136,7 +142,7 @@ Example call to the `validate()` function:
136
142
  import { w3cHtmlValidator } from 'w3c-html-validator';
137
143
 
138
144
  const options = { filename: 'docs/index.html' };
139
- w3cHtmlValidator.validate(options).then(console.log);
145
+ w3cHtmlValidator.validate(options).then(console.log); //outputs the resutls object
140
146
  ```
141
147
  To display formatted output, replace `console.log` with `w3cHtmlValidator.reporter`:
142
148
  ```typescript
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v2.0.2 ~~ 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.0.2 ~~ 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,19 +8,22 @@ import log from 'fancy-log';
8
8
  import request from 'superagent';
9
9
  import slash from 'slash';
10
10
  const w3cHtmlValidator = {
11
- version: '2.0.2',
11
+ version: '2.2.0',
12
+ checkUrl: 'https://validator.w3.org/nu/',
12
13
  defaultIgnoreList: [
13
- 'Section lacks heading.'
14
+ 'with computed level',
15
+ 'Section lacks heading.',
14
16
  ],
15
17
  assert(ok, message) {
16
18
  if (!ok)
17
19
  throw new Error(`[w3c-html-validator] ${message}`);
18
20
  },
19
21
  cli() {
20
- const validFlags = ['continue', 'default-rules', 'delay', 'dry-run', 'exclude',
22
+ const validFlags = ['check-url', 'continue', 'default-rules', 'delay', 'dry-run', 'exclude',
21
23
  'ignore', 'ignore-config', 'note', 'quiet', 'trim'];
22
24
  const cli = cliArgvUtil.parse(validFlags);
23
25
  const files = cli.params.length ? cli.params.map(cliArgvUtil.cleanPath) : ['.'];
26
+ const checkUrl = cli.flagMap.checkUrl ?? w3cHtmlValidator.checkUrl;
24
27
  const excludeList = cli.flagMap.exclude?.split(',') ?? [];
25
28
  const ignore = cli.flagMap.ignore ?? null;
26
29
  const ignoreConfig = cli.flagMap.ignoreConfig ?? null;
@@ -62,7 +65,7 @@ const w3cHtmlValidator = {
62
65
  return rawLines.map(line => isRegex.test(line) ? new RegExp(line.slice(1, -1)) : line);
63
66
  };
64
67
  const ignoreMessages = getIgnoreMessages();
65
- const options = (filename) => ({ filename, ignoreMessages, defaultRules, dryRun });
68
+ const options = (filename) => ({ filename, checkUrl, ignoreMessages, defaultRules, dryRun });
66
69
  const handleResults = (results) => w3cHtmlValidator.reporter(results, reporterOptions);
67
70
  const getReport = (filename) => w3cHtmlValidator.validate(options(filename)).then(handleResults);
68
71
  const processFile = (filename, i) => globalThis.setTimeout(() => getReport(filename), i * delay);
@@ -70,7 +73,7 @@ const w3cHtmlValidator = {
70
73
  },
71
74
  validate(options) {
72
75
  const defaults = {
73
- checkUrl: 'https://validator.w3.org/nu/',
76
+ checkUrl: w3cHtmlValidator.checkUrl,
74
77
  defaultRules: false,
75
78
  dryRun: false,
76
79
  filename: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w3c-html-validator",
3
- "version": "2.0.2",
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",
@@ -58,16 +58,16 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "chalk": "~5.6",
61
- "cli-argv-util": "~1.3",
61
+ "cli-argv-util": "~1.4",
62
62
  "fancy-log": "~2.0",
63
- "glob": "~12.0",
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",
69
69
  "@types/fancy-log": "~2.0",
70
- "@types/node": "~24.10",
70
+ "@types/node": "~25.0",
71
71
  "@types/superagent": "~8.1",
72
72
  "add-dist-header": "~1.6",
73
73
  "assert-deep-strict-equal": "~1.2",
@@ -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.47"
82
+ "typescript-eslint": "~8.53"
83
83
  }
84
84
  }