/
Converting HTML to Wikimarkup

Converting HTML to Wikimarkup

The script below takes the response that has a property called description in HTML format and convert that to wikimarkup.

import com.atlassian.jira.component.ComponentAccessor import groovy.lang.GroovyClassLoader import com.fasterxml.jackson.databind.ObjectMapper //load the class Class DefaultWysiwygConverter = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter"); ObjectMapper mapper = new ObjectMapper() //response is passed in from the parent action def payload = mapper.readValue(response, HashMap.class) String descHtml = payload.description //get description from json body def converter = DefaultWysiwygConverter.newInstance() String descWiki = converter.convertXHtmlToWikiMarkup(descHtml) return descWiki

Example payload

{ "description":"<b>This text is bold</b>" }

Output *This text is bold*

 

Related content

Comment a ticket with line breaks
Comment a ticket with line breaks
More like this
Groovy Variables
Groovy Variables
More like this
Checklist items mapping
Checklist items mapping
More like this
Escape JSON chars in URL or body
Escape JSON chars in URL or body
More like this
Auto populate Jira servicedesk organisation from a group
Auto populate Jira servicedesk organisation from a group
More like this
Send SOAP message
Send SOAP message
More like this