@Test public void testHtmlToPlaintext() throws Exception { try (InputStream inputStream = HTMLHelperTest.class .getResourceAsStream("/HTMLHelperTest/NoteFromEMail.html")) { Assert.assertNotNull(inputStream); StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, "UTF-8"); String htmlContent = writer.toString(); HTMLHelper.htmlToPlaintext(htmlContent); HTMLHelper.htmlToPlaintextExt(htmlContent, false); HTMLHelper.htmlToPlaintextExt(htmlContent, true); } }
public static String htmlToPlaintext(String htmlContent) { String result = convertParagraphAndBrElements(htmlContent); result = result.replaceAll("(?i)</li>(?=.)", "\n"); result = result.replaceAll("(?i)<li>(?=.)", "-"); return StringEscapeHelper.removeHtmlMarkup(result); }
HTMLHelper { public static String htmlToPlaintext(String htmlContent) { String result = convertParagraphAndBrElements(htmlContent); result = result.replaceAll("(?i)</li>(?=.)", "\n"); result = result.replaceAll("(?i)<li>(?=.)", "-"); return StringEscapeHelper.removeHtmlMarkup(result); } }
HTMLHelper { public static String htmlToPlaintext(String htmlContent) { String result = convertParagraphAndBrElements(htmlContent); result = result.replaceAll("(?i)</li>(?=.)", "\n"); result = result.replaceAll("(?i)<li>(?=.)", "-"); return StringEscapeHelper.removeHtmlMarkup(result); } private  HTMLHelper(); }
HTMLHelper { public static String htmlToPlaintext(String htmlContent) { String result = convertParagraphAndBrElements(htmlContent); result = result.replaceAll("(?i)</li>(?=.)", "\n"); result = result.replaceAll("(?i)<li>(?=.)", "-"); return StringEscapeHelper.removeHtmlMarkup(result); } private  HTMLHelper(); static String closeBrTags(String htmlContent); static boolean containsNonEmptyTextNodes(String htmlContent); static String convertHTMLListToText(String htmlContent); static String convertXmlSerializedHtmlToLegalHtml(String xmlSerializedHtml); static String encapsulateAttributesInQuotes(String htmlContent); static String htmlToPlaintext(String htmlContent); static String htmlToPlaintextExt(String htmlContent, boolean convertLists); static String plaintextToHTML(String plainText); static String removeComments(String htmlContent); static String removeHeadElement(String htmlContent); static String removeNamespaces(String htmlContent); static String removeUnclosedMetaElements(String htmlContent); static String stripLinebreaks(String htmlContent); }
HTMLHelper { public static String htmlToPlaintext(String htmlContent) { String result = convertParagraphAndBrElements(htmlContent); result = result.replaceAll("(?i)</li>(?=.)", "\n"); result = result.replaceAll("(?i)<li>(?=.)", "-"); return StringEscapeHelper.removeHtmlMarkup(result); } private  HTMLHelper(); static String closeBrTags(String htmlContent); static boolean containsNonEmptyTextNodes(String htmlContent); static String convertHTMLListToText(String htmlContent); static String convertXmlSerializedHtmlToLegalHtml(String xmlSerializedHtml); static String encapsulateAttributesInQuotes(String htmlContent); static String htmlToPlaintext(String htmlContent); static String htmlToPlaintextExt(String htmlContent, boolean convertLists); static String plaintextToHTML(String plainText); static String removeComments(String htmlContent); static String removeHeadElement(String htmlContent); static String removeNamespaces(String htmlContent); static String removeUnclosedMetaElements(String htmlContent); static String stripLinebreaks(String htmlContent); static final Set<String> NODES_TO_REMOVE_WHEN_EMPTY; static final String LINE_TERMINATORS_REGEX_CLASS; }