By Alvin Alexander. Last updated: April 22, 2024
I ended up not using this code, but if you wanted to see one way to use JSoup’s OutputSettings (Document.OutputSettings) class to set some parameters before calling JSoup.clean, I hope this is helpful:
// tried some things to improve the html output
val settings: OutputSettings = new OutputSettings
settings.prettyPrint(true) //`true` is default
settings.charset("UTF-8")
settings.outline(true) //this is close to what i want, but too extreme
settings.indentAmount(4)
val cleanHtml: String = Jsoup.clean(html, "", wl, settings)
I can attest that this code works, it’s just not what I need at the moment.
Also, the code shown is written in Scala, but as you can see, it converts easily to Java.

