Skip to content

Instantly share code, notes, and snippets.

@ryanve
Created November 11, 2017 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanve/4098448d86cc0ec1970d3eeb0656f135 to your computer and use it in GitHub Desktop.
Save ryanve/4098448d86cc0ec1970d3eeb0656f135 to your computer and use it in GitHub Desktop.
Validate HTML file in node using html-validator
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