private String htmlize(String msg) {
   StringBuilder sb = new StringBuilder();
   Pattern patMsgCat = Pattern.compile("\\[(.+?)\\].*");
   msg = msg.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
   for (String line : msg.split(lineSep)) {
     Matcher m = patMsgCat.matcher(line);
     String cls = "normal";
     if (m.matches()) {
       cls = m.group(1);
     }
     line = "<span class='" + cls + "'>" + line + "</span>";
     sb.append(line).append("<br>");
   }
   return sb.toString();
 }