Is it possible to format HTML automatically with a tool, similar to how ESLint formats JavaScript?
Why does it seem that there aren't many customizable options that you can integrate as part of your development pipeline?
I would wish to format HTML in the following way automatically with a command run from the terminal:
<input
class="input-style"
placeholder="Replace me!"
/>
For example, I could npm run html-lint and it would fix the syntax in HTML files and warn about cases it can't fix.
js-beautify also works on HTML.
npm install js-beautify
js-beautify --type html file.html
Notice all this beautifying makes the file size increase substantially. The indentation is great for revision and editing, but not so much for hosting. For that reason, you might find html-minifier equally useful.
maybe what you are looking for is prettier, this also supports CLI, even you can also make config, see the complete documentation here. Prettier CLI
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With