ttext = ttext.trim();
boolean maxLengthExceeded = false;
- if (ttext.contains("<br>"))
+ boolean hasBr = false;
+ for (String br : new String[] { "<br>", "<br/>" })
{
- String[] htmllines = ttext.split("<br>");
- for (String line : htmllines)
+ hasBr = true;
+ if (ttext.contains(br))
{
- maxLengthExceeded = line.length() > 60;
- if (maxLengthExceeded)
+ String[] htmllines = ttext.split(br);
+ StringBuilder sb = new StringBuilder();
+ for (String line : htmllines)
{
- break;
+ line = line.replaceAll("\\s+", " ");
+ line = line.trim();
+ if (line.length() == 0 || line.equals(" "))
+ {
+ continue;
+ }
+ maxLengthExceeded = line.length() > 60;
+ if (sb.length() > 0)
+ {
+ sb.append(br);
+ }
+ sb.append(line);
}
+ ttext = sb.toString();
}
}
- else
+ if (!hasBr)
{
+ ttext = ttext.replaceAll("\\s+", " ");
+ ttext = ttext.trim();
maxLengthExceeded = ttext.length() > 60;
}
// + "<style> p.ttip {width:350px;margin:-14px 0px -14px
// 0px;padding:2px;overflow-wrap:break-word;}"
// + "</style><p class=\"ttip\">"
- + ttext + " </div>"
+ + ttext + "</div>"
// + "</p>"
+ ((enclose ? "</html>" : ""));
}