Java 类org.jsoup.examples.HtmlToPlainText 实例源码

项目:VaadinUtils    文件:GridContainerCSVExport.java   
public String sanitiseValue(final Object value)
{
    String sanitisedValue;

    if (value instanceof String)
    {
        sanitisedValue = new HtmlToPlainText().getPlainText(Jsoup.parse(value.toString()));
    }
    else
    {
        sanitisedValue = value.toString();
    }

    if (sanitisedValue == null)
    {
        sanitisedValue = "";
    }

    return sanitisedValue;
}
项目:zest-writer    文件:Corrector.java   
public String checkHtmlContent(String htmlContent) {
    AnnotatedText markup = makeAnnotatedText(htmlContent);
    StringBuilder bf = new StringBuilder(htmlContent);

    langTool.getAllActiveRules().stream().filter(rule -> rule instanceof SpellingCheckRule).forEach(rule -> ((SpellingCheckRule) rule).acceptPhrases(wordsToIgnore));

    List<RuleMatch> matches = new ArrayList<>();
    try {
        matches = langTool.check(markup);
    }
    catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    int offset = 0;
    for (RuleMatch match : matches) {
        String desc = match.getMessage();
        desc = new HtmlToPlainText().getPlainText(Jsoup.parse(desc));

        if (!match.getSuggestedReplacements().isEmpty()) {
            desc += Configuration.getBundle().getString("ui.alert.correction.tooltip.suggestion")
                    + match.getSuggestedReplacements();
        }
        String before = "<span class=\"error-french\" title=\"" + desc + "\">";
        bf.insert(match.getFromPos() + offset, before);
        offset += before.length();

        String after = "</span> ";
        bf.insert(match.getToPos() + offset, after);
        offset += after.length();

    }
    return bf.toString();
}
项目:zongtui-webcrawler    文件:ElementOperator.java   
@Override
public String operate(Element element) {
    return new HtmlToPlainText().getPlainText(element);
}
项目:xsoup    文件:ElementOperator.java   
@Override
public String operate(Element element) {
    return new HtmlToPlainText().getPlainText(element);
}