continue;
}
emptyLines = 0;
+ /*
+ * lineComplete tracks whether the block you are parsing is the
+ * first block of the line. this is important because sometimes you
+ * have to add an additional line break.
+ */
boolean lineComplete = true;
while (line.length() > 0) {
int nextKsk = line.indexOf("KSK@");
}
if (linkType == LinkType.SONE) {
if (next > 0) {
- parts.add(new PlainTextPart(line.substring(0, next)));
+ if (lineComplete && !lastLineEmpty) {
+ parts.add(new PlainTextPart("\n" + line.substring(0, next)));
+ } else {
+ parts.add(new PlainTextPart(line.substring(0, next)));
+ }
}
if (line.length() >= (next + 7 + 43)) {
String soneId = line.substring(next + 7, next + 50);
Sone sone = soneProvider.getSone(soneId, false);
- if (sone != null) {
+ if ((sone != null) && (sone.getName() != null)) {
parts.add(new SonePart(sone));
} else {
parts.add(new PlainTextPart(line.substring(next, next + 50)));
parts.add(new PlainTextPart(line.substring(next)));
line = "";
}
+ lineComplete = false;
continue;
}
if (linkType == LinkType.POST) {
String postId = line.substring(next + 7, next + 43);
Post post = postProvider.getPost(postId, false);
if ((post != null) && (post.getSone() != null)) {
- String postText = post.getText();
- postText = postText.substring(0, Math.min(postText.length(), 20)) + "…";
parts.add(new PostPart(post));
} else {
parts.add(new PlainTextPart(line.substring(next, next + 43)));