Java HTML Parse Jsoup clean(String html)

Here you can find the source of clean(String html)

Description

clean

License

Open Source License

Declaration

public static String clean(String html) 

Method Source Code


//package com.java2s;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;

public class Main {
    private static Whitelist whitelist;

    public static String clean(String html) {
        if (html == null || html.trim().length() < 1) {
            return "";
        }//from w ww .j  a  v  a2  s.  c om
        return Jsoup.clean(html, getWhitelist());
    }

    private static Whitelist getWhitelist() {
        if (whitelist == null) {
            Whitelist user_content_filter = Whitelist.relaxed();
            user_content_filter.addTags("embed", "object", "param", "span", "div");
            user_content_filter.addAttributes(":all", "style", "class", "id", "name");
            user_content_filter.addAttributes("object", "width", "height", "classid", "codebase");
            user_content_filter.addAttributes("param", "name", "value");
            user_content_filter.addAttributes("embed", "src", "quality", "width", "height", "allowFullScreen",
                    "allowScriptAccess", "flashvars", "name", "type", "pluginspage");
            whitelist = user_content_filter;
        }
        return whitelist;
    }
}

Related

  1. br2nl(String html)
  2. clean(String html, Whitelist whitelist)
  3. cleanHTML(final String html)
  4. cleanHtmlCode(String html)
  5. cleanHtmlFromString(String stringToClean)