Skip to content

Instantly share code, notes, and snippets.

@ole-treichel
Created February 4, 2019 11:56
Show Gist options
  • Save ole-treichel/f43f7ff9f23782a2d723d9a8a3a43256 to your computer and use it in GitHub Desktop.
Save ole-treichel/f43f7ff9f23782a2d723d9a8a3a43256 to your computer and use it in GitHub Desktop.
const libtidy = require('libtidy')
let options = {
indent: true,
indentSpaces: 2,
markup: true,
doctype: 'omit',
showBodyOnly: true
}
const fs = require('fs')
const html = fs.readFileSync('./test.html').toString()
libtidy.tidyBuffer(html, options, (errlog, output) => {
if (errlog) {
console.log(errlog)
}
console.log(output)
fs.writeFileSync(`${Date.now()}-cleaned-tidy.html`, output.output.toString())
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment