I am using the following code and I am trying to print the following code into HTML:
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
import com.opensymphony.util.TextUtils
import com.atlassian.jira.issue.comments.*
import org.w3c.dom.*;
import javax.xml.parsers.*;
import groovy.xml.*
import grrovy.util.*;
import org.xml.sax.InputSource;
import java.io.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
def commentManager = ComponentAccessor.getCommentManager()
Comment comment = commentManager.getLastComment(issue)
if(comment != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MMM/yy HH:mm", Locale.ENGLISH)
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
//the line below retrieves {color:#de350b}duchesse{color}
def body = comment.body
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
String html = "<html><body><h1></h1><h1>"+body+"</h1></body></html>";
System.out.println(html); // original
Document doc2 = Jsoup.parse(html); // pretty print HTML
System.out.println(doc2.toString());
return doc2
}
My output is under the form: {color:#de350b}duchesse{color} but I would like the output to be in real displayable HTML which in this case means that only "duchesse" should be displayed in red instead of {color:#de350b}duchesse{color}.
How can I fix this?