I'm looking for tools for cleaning up and reformatting #HTML, preferably within or callable from the #Python ecosystem.
I'm not talking about sanitisation for security purposes; I already use NH3 for that. Rather, I want something that can perform tasks like converting manual line breaks to proper paragraph usage, removing empty nodes and superfluous styling, reliably stripping out certain tags while leaving their text content intact, that sort of thing.
It specifically needs to work on markup fragments without requiring an entire document.
No LLMs but machine learning is fine.