Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Convert an issue comment text in wiki format to HTML

Alberto Barón September 13, 2021

Good day!

I am trying to search if there is any possibility to convert the wiki text that JIRA gives us in a comment to HTML. 

 

I mean:

Using scriptRunner, I can check the text that a comment gives us. This text give us a format similar to that:

as*dasdasd* 

{color:#ff5630}  asda{color}

{noformat}asdasd{noformat}

{color:#ff5630}asdadsasd{color}

 

What I want to get its the HTML format , not the wiki format. 

 

In server, the method used to do that is similar to that:

String renderWikiMarkup(Map issue, String data) {
     RendererManager rendererManager = ComponentAccessor.rendererManager
     JiraRendererPlugin renderer = rendererManager.getRendererForType("atlassian-wiki-renderer");
     String output = renderer.render(data, issue.getIssueRenderContext());
     return output
}

 Is there any similar or any endpoint to do that in jira cloud?

Thanks!

 

1 answer

1 vote
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2021

Hello @Alberto Barón ,

The wiki markup formatting is no longer used in Jira cloud and has been replaced by a markdown functionality, and additional details about the change can be seen In the following link noting the details in the Atlassian Status Update:

The second theme is wiki markup generally. To be transparent, we are closing this issue as we have no plans to support wiki markup in the new editor and new issue view. We're supporting markdown across Jira, Confluence, and Bitbucket Cloud to provide a more modern and consistent editing experience. For anyone using multiple Atlassian products, we believe this will provide the best editing experience. You can read more about the changes here.

So noting the removal of markup, I am not sure if Scriptrunner does currently have an equivalent option for markdown, but I can verify that the returned text will only be displayed in text fields as markdown rendered content and cannot display as plain text.

However, if you are looking to pull data from the API for use in an external application or resource the equivalent API call would be:

curl -D- -u {user}:{api_token} -X GET -H "Content-Type: application/json" https://{base_URL}.atlassian.net/rest/api/3/issue/{issueId}/comment/{commentId}?expand=renderedBody

and the renderBody will come back in the HTML encoded text, as an example, a comment on an issue that has the following:

Screen Shot 2021-09-14 at 1.27.19 PM.png

Returns the following in the expanded variable for the renderBody as HTML:

"renderedBody":"<p>line 1 noformatting</p>\n\n<ul>\n\t<li>Bullet 1</li>\n\t<li>bullet 2</li>\n</ul>\n\n\n<ol>\n\t<li>number indent 1</li>\n\t<li>number indent 2</li>\n</ol>\n\n\n<p><b>bold</b></p>\n\n<p><em>italic</em></p>\n\n<p><del>strikethrough</del></p>\n\n<p><font color=\"#ff5630\">RED Text</font></p>\n\n<div class=\"preformatted panel\" style=\"border-width: 1px;\"><div class=\"preformattedContent panelContent\">\n<pre>CODE BLOCK</pre>\n</div></div>\n\n<div class=\"panel\" style=\"background-color: #deebff;border-width: 1px;\"><div class=\"panelContent\" style=\"background-color: #deebff;\">\n<p>Info panel</p>\n</div></div>"

Hope this helps

Regards,
Earl

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events