Reputation: 12416
I am trying to automatically indent the HTML5 output. The tool which I tried to use was JTidy, but the problem is that it does not support HTML5 elements and for instance it moves all and to header whereas HTML5 use them in the body.
As HTML is not XML, I cannot use the typical Java XML tools for indenting.
Upvotes: 1
Views: 2325
Reputation:
Most robust solution
It's not Java but HTML Tidy for HTML5 is maintained by W3C and a command line tool making it very flexible. This is a current fork and actively maintained as shown by the commit times on the GitHub home page for the project.
Java Solution
If you can't get the latest version of HTML Tidy for HTML5 that supports HTML5 to work then XML is still an option.
HTML5 certainly is not at all designed to be XML friendly, but it does at least give lip service in the form of an XML serialization for HTML5, which, in this article, I'll call XHTML5 ...
There is an XML serialization of HTML5 allowing you to use any standard XML formatting tools to format it any way you desire.
Upvotes: 2