JAL-2920 wrap description in <html/> if it includes <br/>
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 7 Jun 2018 08:55:54 +0000 (09:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 7 Jun 2018 08:55:54 +0000 (09:55 +0100)
src/jalview/ws/dbsources/Uniprot.java
test/jalview/ws/dbsources/UniprotTest.java

index c311ea9..167cd97 100644 (file)
@@ -309,7 +309,9 @@ public class Uniprot extends DbSourceProxyImpl
     /*
      * append variant in standard format if present
      * e.g. p.Arg59Lys
+     * multiple variants are split over lines using <br>
      */
+    boolean asHtml = false;
     if (orig != null && !orig.isEmpty() && variants != null
             && !variants.isEmpty())
     {
@@ -356,7 +358,8 @@ public class Uniprot extends DbSourceProxyImpl
         }
         if (++p != variants.size())
         {
-          sb.append("\n");
+          sb.append("<br/>&nbsp;&nbsp;");
+          asHtml = true;
         }
         else
         {
@@ -369,6 +372,11 @@ public class Uniprot extends DbSourceProxyImpl
     {
       sb.append(description);
     }
+    if (asHtml)
+    {
+      sb.insert(0, "<html>");
+      sb.append("</html>");
+    }
 
     return sb.toString();
   }
index 67d5d62..e927023 100644 (file)
@@ -154,19 +154,22 @@ public class UniprotTest
     assertEquals(42, sf.getBegin());
     assertEquals(42, sf.getEnd());
     Assert.assertEquals(Uniprot.getDescription(sf),
-            "p.Met42Leu" + "\n" + "p.Met42LeuMetVal Foo");
+            "<html>p.Met42Leu" + "<br/>&nbsp;&nbsp;"
+                    + "p.Met42LeuMetVal Foo</html>");
 
     sf = features.get(7);
     assertEquals(42, sf.getBegin());
     assertEquals(43, sf.getEnd());
     Assert.assertEquals(Uniprot.getDescription(sf),
-            "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo");
+            "<html>p.MetLeu42LeuLeu" + "<br/>&nbsp;&nbsp;"
+                    + "p.MetLeu42LeuMetVal Foo</html>");
 
     sf = features.get(8);
     assertEquals(42, sf.getBegin());
     assertEquals(45, sf.getEnd());
     Assert.assertEquals(Uniprot.getDescription(sf),
-            "p.MLML42LeuLeu" + "\n" + "p.MLML42LMVK Foo Too");
+            "<html>p.MLML42LeuLeu" + "<br/>&nbsp;&nbsp;"
+                    + "p.MLML42LMVK Foo Too</html>");
 
     /*
      * Check cross-references
@@ -253,8 +256,9 @@ public class UniprotTest
     uf.setVariation(vars);
     assertEquals("p.Lys23Tyr Hello", Uniprot.getDescription(uf));
 
+    // multiple variants generate an html description over more than one line
     vars.add("W");
-    assertEquals("p.Lys23Tyr\np.Lys23Trp Hello",
+    assertEquals("<html>p.Lys23Tyr<br/>&nbsp;&nbsp;p.Lys23Trp Hello</html>",
             Uniprot.getDescription(uf));
 
     /*