Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to convert wiki markup to HTML programmly?

Qing LIANG June 1, 2016

Hello,

 

I am trying to get the description of an issue from JIRA to put it in a Confluence Storage Format template in order to create a page in Confluence. But I could't find a way to render the description raw data to a storage format recognizable format. Here is a concrete example : 

For an issue in JIRA with following description : 

image2016-6-1 15:4:31.png

The description string I get by calling com.atlassian.jira.issue.Issue.getDescription() is :

{color:#14892c}Recently Updated{color}
h1. *_As you and your team create content this area will fill up and display the latest updates._*

If I don't make it wrong, the string I got is its wiki template representation. Insert it directly in Storage format will not be recognized by the template engine so will not be properly rendered.

 

I have tried using <ac:rich-text-body> to enclose the string but it doesn't work. Seems to I have to convert the wiki representation to HTML, or XHTML. How can I achieve this in Java code?

 

Thanks

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2016

Confluence has a function to render wiki markup format:

https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/themes/GlobalHelper.html#renderConfluenceMacro-java.lang.String-

But the problem is that Confluence wiki markup is slightly different from JIRA wiki markup.  For example, the {color section of the wiki markup will try to render a Confluence macro called "color", which doesn't exist (although one option would be to write this macro, or to replace this macro in an intermediate step in your code before rendering the rest of the markup).

Another option would be to render the markup in JIRA first (since I assume you are getting the content directly from JIRA) and then simply put that in the code for the page (since the page code is basically html anyways).

https://answers.atlassian.com/questions/282947

There's no real easy answer for this... Another option might even be to call the wikirenderer via REST.  Perhaps there is also some way on the backend using the Application Links whereby the rendered text can be inserted into Confluence

Sorry that it's not a definitive answer, but at least maybe it gives you a few ideas.

 

Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2018
TAGS
AUG Leaders

Atlassian Community Events