forked from center-key/w3c-html-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.js
More file actions
21 lines (17 loc) · 906 Bytes
/
examples.js
File metadata and controls
21 lines (17 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env node
////////////////////////
// W3C HTML Validator //
// Examples //
////////////////////////
// Command to run:
// $ node examples.js
import { w3cHtmlValidator } from './dist/w3c-html-validator.js';
// Formatted output
const customReporter = (results) => w3cHtmlValidator.reporter(results, { maxMessageLen: 80 });
w3cHtmlValidator.validate({ website: 'https://pretty-print-json.js.org/' }).then(w3cHtmlValidator.reporter);
w3cHtmlValidator.validate({ filename: 'spec/html/valid.html' }).then(w3cHtmlValidator.reporter);
w3cHtmlValidator.validate({ filename: 'spec/html/invalid.html' }).then(customReporter);
// JSON output
const sleep = (data) => new Promise(resolve => setTimeout(() => resolve(data), 1000));
const log = (results) => console.log('\nValidatorResults:', results);
w3cHtmlValidator.validate({ filename: 'spec/html/invalid.html' }).then(sleep).then(log);