Hi everyone,
I have a ScriptRunner Script which is creating issues based on assets. My problem is that the asset text area field is formatted as an HTML:
Therefore they're also being copied to Issue Descriptions as HTML text without formatting, instead of Jira Wiki Markup.
I need to convert these from HTML to Jira Wiki Markup within this ScriptRunner Cloud script, but I couldn't find a way to do that.
Anyone has done this so far?
Thanks in advance!
Hi Luka,
Unfortunately, Atlassian does not provide a Rest API in Jira Cloud to parse an HTML string into Jira Wiki Markup format.
However, if you know what valid Wiki Markup you need to convert to, you could use the XMLSlurper library provided by Groovy to parse the string and return a new structure using ScriptRunner for Jira Cloud.
I have created a simple example here which will parse the contents of a string containing a list like yours and convert this to a bulleted list in Jira Wiki Markup.
Using this approach, you could parse the value returned from Assets into the correct format before setting it in the issue description.
I hope this helps.
Regards,
Kristian
Hi Luka,
take a look at converter "WysiwygConverter.convertXHtmlToWikiMarkup"
see Documentation: https://developer.atlassian.com/server/confluence/html-to-markup-conversion-for-the-rich-text-editor/
Usage How To:
import com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter;
String fromInsight = "<p><strong>Population</strong></p><ul><li>2021 estimate: <strong>45,605,826</strong></li></ul><p><strong>Area</strong></p><ul><li>Total: <strong>2,780,400 km2</strong></li></ul><p> </p>"
DefaultWysiwygConverter defaultWysiwygConverter = new DefaultWysiwygConverter()
String wikiMarkup = defaultWysiwygConverter.convertXHtmlToWikiMarkup(fromInsight);
I found it here: https://community.atlassian.com/t5/App-Central-questions/Convert-HTML-tags-in-description-field-when-copying-from-Insight/qaq-p/1805629
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.