public static String clean ( String bodyHtml , String baseUri , Whitelist whitelist ) { Document dirty = parseBodyFragment ( bodyHtml , baseUri ) ; Cleaner cleaner = new Cleaner ( whitelist ) ; Document clean = cleaner . clean ( dirty ) ; return clean . body ( ) . html ( ) ; }
Get safe HTML from untrusted input HTML by parsing input HTML and filtering it through a white - list of permitted tags and attributes .