w3c-html-validator 1.0.4 → 1.1.1
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.
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
//! w3c-html-validator v1.
|
|
1
|
+
//! w3c-html-validator v1.1.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import log from 'fancy-log';
|
|
6
6
|
import request from 'superagent';
|
|
7
7
|
const w3cHtmlValidator = {
|
|
8
|
-
version: '1.
|
|
8
|
+
version: '1.1.1',
|
|
9
9
|
validate(options) {
|
|
10
|
+
var _a;
|
|
10
11
|
const defaults = {
|
|
11
12
|
checkUrl: 'https://validator.w3.org/nu/',
|
|
12
13
|
ignoreLevel: null,
|
|
@@ -21,8 +22,8 @@ const w3cHtmlValidator = {
|
|
|
21
22
|
if (settings.output !== 'json' && settings.output !== 'html')
|
|
22
23
|
throw Error('[w3c-html-validator] Option "output" must be "json" or "html".');
|
|
23
24
|
const mode = settings.html ? 'html' : settings.filename ? 'filename' : 'website';
|
|
24
|
-
const readFile = () =>
|
|
25
|
-
const inputHtml = settings.html
|
|
25
|
+
const readFile = (filename) => readFileSync(filename, 'utf8').replace(/\r/g, '');
|
|
26
|
+
const inputHtml = (_a = settings.html) !== null && _a !== void 0 ? _a : (settings.filename ? readFile(settings.filename) : null);
|
|
26
27
|
const makePostRequest = () => request.post(settings.checkUrl)
|
|
27
28
|
.set('Content-Type', 'text/html; encoding=utf-8')
|
|
28
29
|
.send(inputHtml);
|
|
@@ -88,9 +89,9 @@ const w3cHtmlValidator = {
|
|
|
88
89
|
throw Error('[w3c-html-validator] Invalid results for reporter(): ' + String(results));
|
|
89
90
|
const messages = (_a = results.messages) !== null && _a !== void 0 ? _a : [];
|
|
90
91
|
const title = (_b = settings.title) !== null && _b !== void 0 ? _b : results.title;
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
log(chalk.gray('w3c-html-validator'), chalk.blue.bold(title),
|
|
92
|
+
const status = results.validates ? chalk.green.bold('✔ pass') : chalk.red.bold('✘ fail');
|
|
93
|
+
const count = results.validates ? '' : '(messages: ' + messages.length + ')';
|
|
94
|
+
log(chalk.gray('w3c-html-validator'), status, chalk.blue.bold(title), chalk.white(count));
|
|
94
95
|
const typeColorMap = {
|
|
95
96
|
error: chalk.red.bold,
|
|
96
97
|
warning: chalk.yellow.bold,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v1.
|
|
1
|
+
//! w3c-html-validator v1.1.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -20,8 +20,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
const fancy_log_1 = __importDefault(require("fancy-log"));
|
|
21
21
|
const superagent_1 = __importDefault(require("superagent"));
|
|
22
22
|
const w3cHtmlValidator = {
|
|
23
|
-
version: '1.
|
|
23
|
+
version: '1.1.1',
|
|
24
24
|
validate(options) {
|
|
25
|
+
var _a;
|
|
25
26
|
const defaults = {
|
|
26
27
|
checkUrl: 'https://validator.w3.org/nu/',
|
|
27
28
|
ignoreLevel: null,
|
|
@@ -36,8 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
37
|
if (settings.output !== 'json' && settings.output !== 'html')
|
|
37
38
|
throw Error('[w3c-html-validator] Option "output" must be "json" or "html".');
|
|
38
39
|
const mode = settings.html ? 'html' : settings.filename ? 'filename' : 'website';
|
|
39
|
-
const readFile = () =>
|
|
40
|
-
const inputHtml = settings.html
|
|
40
|
+
const readFile = (filename) => (0, fs_1.readFileSync)(filename, 'utf8').replace(/\r/g, '');
|
|
41
|
+
const inputHtml = (_a = settings.html) !== null && _a !== void 0 ? _a : (settings.filename ? readFile(settings.filename) : null);
|
|
41
42
|
const makePostRequest = () => superagent_1.default.post(settings.checkUrl)
|
|
42
43
|
.set('Content-Type', 'text/html; encoding=utf-8')
|
|
43
44
|
.send(inputHtml);
|
|
@@ -103,9 +104,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
103
104
|
throw Error('[w3c-html-validator] Invalid results for reporter(): ' + String(results));
|
|
104
105
|
const messages = (_a = results.messages) !== null && _a !== void 0 ? _a : [];
|
|
105
106
|
const title = (_b = settings.title) !== null && _b !== void 0 ? _b : results.title;
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
(0, fancy_log_1.default)(chalk_1.default.gray('w3c-html-validator'), chalk_1.default.blue.bold(title),
|
|
107
|
+
const status = results.validates ? chalk_1.default.green.bold('✔ pass') : chalk_1.default.red.bold('✘ fail');
|
|
108
|
+
const count = results.validates ? '' : '(messages: ' + messages.length + ')';
|
|
109
|
+
(0, fancy_log_1.default)(chalk_1.default.gray('w3c-html-validator'), status, chalk_1.default.blue.bold(title), chalk_1.default.white(count));
|
|
109
110
|
const typeColorMap = {
|
|
110
111
|
error: chalk_1.default.red.bold,
|
|
111
112
|
warning: chalk_1.default.yellow.bold,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3c-html-validator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A package for testing HTML files or URLs against the W3C validator (written in functional TypeScript)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -80,20 +80,20 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/fancy-log": "~2.0",
|
|
83
|
-
"@types/glob": "~
|
|
84
|
-
"@types/node": "~18.
|
|
83
|
+
"@types/glob": "~8.0",
|
|
84
|
+
"@types/node": "~18.7",
|
|
85
85
|
"@types/superagent": "~4.1",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
87
|
-
"@typescript-eslint/parser": "~5.
|
|
88
|
-
"add-dist-header": "~0.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "~5.37",
|
|
87
|
+
"@typescript-eslint/parser": "~5.37",
|
|
88
|
+
"add-dist-header": "~0.2",
|
|
89
89
|
"assert-deep-strict-equal": "~1.0",
|
|
90
|
-
"cpy-cli": "~4.
|
|
91
|
-
"eslint": "~8.
|
|
90
|
+
"cpy-cli": "~4.2",
|
|
91
|
+
"eslint": "~8.23",
|
|
92
92
|
"jshint": "~2.13",
|
|
93
93
|
"merge-stream": "~2.0",
|
|
94
94
|
"mocha": "~10.0",
|
|
95
95
|
"npm-run-all2": "~6.0",
|
|
96
96
|
"rimraf": "~3.0",
|
|
97
|
-
"typescript": "~4.
|
|
97
|
+
"typescript": "~4.8"
|
|
98
98
|
}
|
|
99
99
|
}
|