I am looking for a free (as in freedom) HTML indenter (or re-indenter) written in Python (module or command line). I don’t need to filter HTML with a white list. I just want to indent (or re-indent) HTML source to make it more readable. For example, say I have the following code:
<ul><li>Item</li><li>Item
</li></ul>
the output could be something like:
<ul>
<li>Item</li>
<li>Item</li>
</ul>
Note: I am not looking for an interface to a non-Python software (for example Tidy, written in C), but a 100% Python script.
Thanks a lot.
BeautifulSoup has a function called
prettifywhich does this.See this question