james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/6] james-project git commit: JAMES-2018 support ol element
Date Thu, 01 Jun 2017 09:05:03 GMT
JAMES-2018 support ol element


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b4c52152
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b4c52152
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b4c52152

Branch: refs/heads/master
Commit: b4c52152c1bf897fcce846835e92a6ab540cbe2f
Parents: 0172d4b
Author: benwa <btellier@linagora.com>
Authored: Tue May 30 16:56:26 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu Jun 1 16:03:20 2017 +0700

----------------------------------------------------------------------
 .../james/jmap/utils/JsoupHtmlTextExtractor.java |  4 ++++
 .../jmap/utils/JsoupHtmlTextExtractorTest.java   | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/b4c52152/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractor.java
index a3ed036..ffc9a94 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractor.java
@@ -35,6 +35,7 @@ public class JsoupHtmlTextExtractor implements HtmlTextExtractor {
     private static final Logger LOGGER = LoggerFactory.getLogger(JsoupHtmlTextExtractor.class);
     public static final String BR_TAG = "br";
     public static final String UL_TAG = "ul";
+    public static final String OL_TAG = "ol";
     public static final String LI_TAG = "li";
     public static final String P_TAG = "p";
 
@@ -67,6 +68,9 @@ public class JsoupHtmlTextExtractor implements HtmlTextExtractor {
             if (element.tagName().equals(UL_TAG)) {
                 return "\n\n";
             }
+            if (element.tagName().equals(OL_TAG)) {
+                return "\n\n";
+            }
             if (element.tagName().equals(LI_TAG)) {
                 return "\n - ";
             }

http://git-wip-us.apache.org/repos/asf/james-project/blob/b4c52152/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractorTest.java
index 4a413de..97a161f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/JsoupHtmlTextExtractorTest.java
@@ -90,6 +90,25 @@ public class JsoupHtmlTextExtractorTest {
     }
 
     @Test
+    public void toPlainTextShouldHandleOrderedListsWell() {
+        String html = "<ol>Here is my awesome list:" +
+            "  <li>JMAP</li>" +
+            "  <li>IMAP</li>" +
+            "</ol>" +
+            "<p>Followed with some text</p>" +
+            "<p>And some other text</p>";
+        String expectedPlainText = "Here is my awesome list:  \n" +
+            " - JMAP  \n" +
+            " - IMAP\n" +
+            "\n" +
+            "Followed with some text\n" +
+            "\n" +
+            "And some other text\n" +
+            "\n";
+        assertThat(textExtractor.toPlainText(html)).isEqualTo(expectedPlainText);
+    }
+
+    @Test
     public void tableShouldBeWellHandled() {
         String html = " <table style=\"width:100%\">\n" +
             "  <tr>\n" +


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message