how to use jsoup to tidy up the html
jsoup
Solution
Yes, try this:
String html = "<p>The recurrence, in close succession <ul><li>list item 1</li><li>list item 2</li></ul> second part of thisssss";
String clean = Jsoup.clean(html, Whitelist.relaxed());
You can use another Whitelist as well.
Problem
I am using jsoup and it is really nice to tidy up some html, but I have a piece of invalid html as following: ``` <p>The recurrence, in close succession <ul><li>list item 1</li><li>list item 2</li></ul> second part of thisssss ``` What I want to get is : ``` <p>The recurrence, in close succession </p><ul><li>list item 1</li><li>list item 2</li></ul> <p>second part of thisssss</p> ``` So is the jsoup capable of tidying up the html and return this output ? thanks