diff options
author | Vitaly Takmazov | 2019-01-23 13:27:40 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-01-23 13:27:40 +0300 |
commit | c16598a545c8ee2d36c183affbc2906cbef4f128 (patch) | |
tree | 035c1a19899191c0cd8aea37a490a9a747362b5b /src/main/java/com/juick/util | |
parent | e4f45130797df9dc94d10fd1c79ad8952c6390c1 (diff) |
quote formatting fixes and more test cases
Diffstat (limited to 'src/main/java/com/juick/util')
-rw-r--r-- | src/main/java/com/juick/util/MessageUtils.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/com/juick/util/MessageUtils.java b/src/main/java/com/juick/util/MessageUtils.java index 72c9bd04..dd9db293 100644 --- a/src/main/java/com/juick/util/MessageUtils.java +++ b/src/main/java/com/juick/util/MessageUtils.java @@ -144,12 +144,11 @@ public class MessageUtils { } public static String formatMessage(String msg) { + msg = msg.replaceAll("&", "&"); msg = msg.replaceAll("<", "<"); msg = msg.replaceAll(">", ">"); - // > citate - msg = msg.replaceAll(citateRegex, "<q>$1</q>"); - msg = msg.replaceAll("</q><q>", "\n"); + // -- // — msg = msg.replaceAll("((?<=\\s)|(?<=\\A))\\-\\-?((?=\\s)|(?=\\Z))", "$1—$2"); @@ -207,6 +206,10 @@ public class MessageUtils { m.appendTail(sb); msg = sb.toString(); + // > citate + msg = msg.replaceAll(citateRegex, "<q>$1</q>"); + msg = msg.replaceAll("</q><q>", "\n"); + msg = msg.replaceAll("\n", "<br/>\n"); return msg; } |