X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=42b032d361d930acc942e4f7e753fa07ef70e90c;hb=4966d9f4569d7f2b46aca6ff4629e9a1b1120c98;hp=7046f883847261df7c49dfd639c7eb9558108c64;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 7046f88..42b032d 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -258,7 +258,6 @@ public class FeaturesFile extends AlignFile catch (Exception ex) { System.out.println(line); - ex.printStackTrace(); System.out.println("Error parsing feature file: " + ex +"\n"+line); return false; } @@ -266,32 +265,59 @@ public class FeaturesFile extends AlignFile return true; } - void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) + public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) { + if(removeHTML && sf.getDescription().toUpperCase().indexOf("")==-1) + removeHTML = false; + StringBuffer sb = new StringBuffer(); StringTokenizer st = new StringTokenizer(sf.getDescription(), "<"); String token, link; + int startTag; + String tag=null; while(st.hasMoreElements()) { - token = st.nextToken("<>"); + token = st.nextToken("&>"); if(token.equalsIgnoreCase("html") || token.startsWith("/")) + { continue; + } + + tag = null; + startTag = token.indexOf("<"); + + if (startTag > -1) + { + tag = token.substring(startTag+1); + token = token.substring(0, startTag); + } - if(token.startsWith("a href=")) + if (tag != null && tag.toUpperCase().startsWith("A HREF=")) { - link = token.substring(token.indexOf("\"")+1, token.length()-1); + if(token.length()>0) + sb.append(token); + link = tag.substring(tag.indexOf("\"") + 1, tag.length() - 1); String label = st.nextToken("<>"); - sf.addLink(label+"|"+link); - sb.append(label+"%LINK%"); + sf.addLink(label + "|" + link); + sb.append(label + "%LINK%"); } - else if(token.equalsIgnoreCase("br")) + else if (tag != null && tag.equalsIgnoreCase("br")) sb.append("\n"); + else if (token.startsWith("lt;")) + sb.append("<" + token.substring(3)); + else if (token.startsWith("gt;")) + sb.append(">" + token.substring(3)); + else if (token.startsWith("amp;")) + sb.append("&" + token.substring(4)); else + { sb.append(token); + } } if(removeHTML) sf.description = sb.toString(); + } /** @@ -384,6 +410,10 @@ public class FeaturesFile extends AlignFile out.append(next[j].type+"\t"); else { + if(next[j].links!=null + && next[j].getDescription().indexOf("")==-1) + out.append(""); + out.append(next[j].description+" "); if(next[j].links!=null) { @@ -402,7 +432,12 @@ public class FeaturesFile extends AlignFile + ""); } } + + if (next[j].getDescription().indexOf("") == -1) + out.append(""); } + + out.append("\t"); }