From 4dc588fcf77dbf1c6bbcfebd00b64f8c32a4e206 Mon Sep 17 00:00:00 2001 From: Sciguymjm Date: Fri, 6 May 2016 14:52:37 -0400 Subject: [PATCH] Added basic markdown support --- .../norbipeti/thebuttonmc/ChatProcessing.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/io/github/norbipeti/thebuttonmc/ChatProcessing.java b/src/io/github/norbipeti/thebuttonmc/ChatProcessing.java index defce15..8759d1f 100644 --- a/src/io/github/norbipeti/thebuttonmc/ChatProcessing.java +++ b/src/io/github/norbipeti/thebuttonmc/ChatProcessing.java @@ -96,6 +96,30 @@ public class ChatProcessing { formattedmessage = formattedmessage.replace("§r", "§" + currentchannel.DisplayName.charAt(1)); String suggestmsg = formattedmessage; + boolean cont = true; + while (cont) { + + int first_under = formattedmessage.indexOf("_"); + if (first_under != -1 && formattedmessage.indexOf("_", first_under) != -1) // underline + { + formattedmessage = formattedmessage.replaceFirst("_", "§n").replaceFirst("_", "§r"); + continue; + } + + + int first_bold = formattedmessage.indexOf("**"); + if (first_bold != -1 && formattedmessage.indexOf("**", first_bold) != -1) // bold + { + formattedmessage = formattedmessage.replaceFirst("\\*\\*", "§l").replaceFirst("\\*\\*", "§r"); + continue; + } + int first = formattedmessage.indexOf('*'); + if (first != -1 && formattedmessage.indexOf('*', first) != -1) { + formattedmessage = formattedmessage.replaceFirst("\\*", "§o").replaceFirst("\\*", "§r"); + continue; + } + cont = false; + } // URLs + Rainbow text String[] parts = formattedmessage.split("\\s+");