@Test void testHtml2Text() throws MessagingException { OnlyText mailet = new OnlyText(); mailet.init(FakeMailetConfig.builder() .mailetName("Test") .build()); String html; html = "<b>Prova di html</b><br /><p>Un paragrafo</p><LI>e ci mettiamo anche una lista</LI><br>"; assertThat(mailet.html2Text(html)).isEqualTo("Prova di html\nUn paragrafo\n\n* e ci mettiamo anche una lista\n"); html = "<b>Vediamo invece come andiamo con gli entities</b><br />&egrave;&agrave; &amp;grave;<br>"; assertThat(mailet.html2Text(html)).isEqualTo("Vediamo invece come andiamo con gli entities\nèà &grave;\n"); }
public String html2Text(String html) { return decodeEntities(html .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n") .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n") .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ") .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ") .replaceAll("\\<.*?\\>", "")); }
OnlyText extends GenericMailet { public String html2Text(String html) { return decodeEntities(html .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n") .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n") .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ") .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ") .replaceAll("\\<.*?\\>", "")); } }
OnlyText extends GenericMailet { public String html2Text(String html) { return decodeEntities(html .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n") .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n") .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ") .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ") .replaceAll("\\<.*?\\>", "")); }  }
OnlyText extends GenericMailet { public String html2Text(String html) { return decodeEntities(html .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n") .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n") .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ") .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ") .replaceAll("\\<.*?\\>", "")); }  @Override String getMailetInfo(); @Override void init(); @Override void service(Mail mail); String html2Text(String html); String decodeEntities(String data); }
OnlyText extends GenericMailet { public String html2Text(String html) { return decodeEntities(html .replaceAll("\\<([bB][rR]|[dD][lL])[ ]*[/]*[ ]*\\>", "\n") .replaceAll("\\</([pP]|[hH]5|[dD][tT]|[dD][dD]|[dD][iI][vV])[ ]*\\>", "\n") .replaceAll("\\<[lL][iI][ ]*[/]*[ ]*\\>", "\n* ") .replaceAll("\\<[dD][dD][ ]*[/]*[ ]*\\>", " - ") .replaceAll("\\<.*?\\>", "")); }  @Override String getMailetInfo(); @Override void init(); @Override void service(Mail mail); String html2Text(String html); String decodeEntities(String data);  }