package uap.pub.fs.pre.utils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class JsoupUtils {
public static String formateHtml(String html) {
Document doc = Jsoup.parse(html);
String styleOld = doc.getElementsByTag("style").html();
String bodyStyle = doc.body().getElementsByTag("body").attr("style");
doc.body().getElementsByTag("body").attr("style", bodyStyle.concat("background-color: #fff;font-family:SimSun"));
styleOld = styleOld.replaceAll("font-family:.+(?=;\\b)", "font-family:SimSun");
doc.getElementsByTag("head").append("");
doc.getElementsByTag("head").append(" ");
doc.getElementsByTag("style").append(styleOld);
String result = doc.html();
result = result.replace("", "");
return result;
}
}