HTML Tidy for PostHTML
HTML Tidy corrects and cleans up HTML and XML documents by fixing markup errors and upgrading legacy code to modern standards.
Install
npm i -D posthtml-tidy
Usage
Options
log [Boolean]
Boolean option which logs tidied html to the console. By default no output is logged.
rules [Object]
If no rules set, tidy will use it's default setup. For rules take a look at the Quick Reference. Multi-word rules separated with a hyphen should be used with camelCase.
const tidy = log: true rules: doctype: 'omit' hideComments: true dropEmptyElements: true // more options...
Input
PostHTML Tidy <!-- Bad format --> Well formatted Bad formatted Even worse formatted
Output
PostHTML Tidy Well formattedBad formattedEven worse formatted
Example using Node API
For general usage and build process integration see PostHTML Docs
const fs = const posthtml = const tidy = /* options */ let html = fs
Input
Well formattedBad formattedEven worser formatted
Output
Well formattedBad formattedEven worser formatted