Created
November 11, 2017 02:28
-
-
Save ryanve/4098448d86cc0ec1970d3eeb0656f135 to your computer and use it in GitHub Desktop.
Validate HTML file in node using html-validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs") | |
const validator = require("html-validator") | |
const validateFile = (file) => { | |
fs.readFile(file, "utf-8", (err, content) => { | |
if (err) throw err; | |
console.log("Validating:", file); | |
validator({ | |
data: content, | |
format: "text", | |
}, (err, report) => { | |
if (err) throw err; | |
console.log(file, report); | |
}); | |
}); | |
}; | |
validateFile("index.html"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment