Parsing color in commonmark-java, rendering content from Jira

I am using commonmark-java 1.15.1 to render Atlassian Jira commonmark as HTML. I get the Jira commonmark from the Jira API.

The commonmark content I get from the API sometimes contains color markup. For example: {color:#00b8d9}Some text{color} some other text.

The color span markup is reproduced literally in the HTML output. For example: <p>{color:#00b8d9}Some text{color} some other text</p>.

Is this something I can handle by adding a commonmark-java extension? Or do I need to write a custom span handler for the color markup? At a minimum, I’d like to suppress the markup in the output HTML.

Does anyone have experience or advice? Or is there documentation other than the Javadoc that might cover this situation?



That’s not standard CommonMark. I’m surprised that Atlassian is publishing their Java CommonMark library under the auspices of “org.commonmark”, which seems to me misleading people to believe that this library is official and produced by //cc @jgm @codinghorror Perhaps I make a minor quibble?

@pdesjardins, My guess is you should look at the Atlassian extensions for their library, specifically:

1 Like

Hmm, I’m not sure – as long as it is compliant with the base spec, adding ‘extra’ on top is probably OK?

@codinghorror not so much the extension but that they publish it with the Java package name of org.commonmark.* rather than com.atlassian.commonmark.* which is what they should do.

Companies use their reversed Internet domain name to begin their package names—for example, com.example.mypackage for a package named mypackage created by a programmer at

Java rules for package naming

Not only is this misleading, it prevents from publishing a Java implementation under its own name. That they are a commercial org doing this bothers me too. I would open an issue with them but it’s not my call.

I can do it; where do we open the issue?

Probably at the library’s repo?

You might illustrate the issue with this excerpt from their README:

Parse and render to HTML

import org.commonmark.node.*;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

Parser parser = Parser.builder().build();
Node document = parser.parse("This is *Sparta*");
HtmlRenderer renderer = HtmlRenderer.builder().build();
renderer.render(document);  // "<p>This is <em>Sparta</em></p>\n"

This uses the parser and renderer with default options. Both builders have methods for configuring their behavior:

OK thanks for collecting all that info and bringing this to our attention, I have opened an issue on their github repository:

1 Like

Their proposed resolution was not what I was expecting!

1 Like

This has been transferred – thank you @robinst! :clap: