org.jsoup.examples.HtmlToPlainText Java Examples
The following examples show how to use
org.jsoup.examples.HtmlToPlainText.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Corrector.java From zest-writer with GNU General Public License v3.0 | 5 votes |
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(); }
Example #2
Source File: HtmlToPlainTextTransformer.java From quickperf with Apache License 2.0 | 4 votes |
public String convertHtmlToPlainText(String html) { HtmlToPlainText htmlToPlainText = new HtmlToPlainText(); Document jsoupDocument = Jsoup.parse(html); jsoupDocument.select("p").prepend("<br>"); return htmlToPlainText.getPlainText(jsoupDocument); }
Example #3
Source File: ElementOperator.java From zongtui-webcrawler with GNU General Public License v2.0 | 4 votes |
@Override public String operate(Element element) { return new HtmlToPlainText().getPlainText(element); }
Example #4
Source File: ElementOperator.java From xsoup with MIT License | 4 votes |
@Override public String operate(Element element) { return new HtmlToPlainText().getPlainText(element); }