How can convert wiki markup to HTML using the JIRA Python API?

Tim Baker November 20, 2012

I'm trying to pull release notes from JIRA tickets via the Python API and then display them on my company's web site. I am able to retrieve the field containing wiki markup, but am unsure how to convert this to HTML.

I've seen several wiki-to-HTML Python libraries during my Googling, but none seem to be an exact fit for the JIRA wiki markup.

I appreciate any help that is provided!

3 answers

1 accepted

4 votes
Answer accepted
Tim Baker November 26, 2012

I read through the REST API documentation and found a reference to expandable properties. This appeared promising, so I read through the JIRA Python code until I found it in the issue constructor. I was able to do the following:

renderedIssue = jira.issue('TEST-17', expand='renderedFields')
     print renderedIssue.renderedFields.description

In my example above, the description was displayed in HTML rather than the JIRA wiki markup.

Note that I'd tried expanding rendered fields in jira.search_issues -- this is supported in the Python code -- but there appears to be a bug that always returns an empty object in issue.renderedFields (I confirmed this by examining the raw JSON). Thus, I have to retrieve the key from my query results and use jira.issue to retrieve an issue object that has a populated renderedFields object.

I've logged a bug for jira.search_issues at https://jira.atlassian.com/browse/JRA-30718.

jiri husak February 26, 2019

Many thanks for answer, works well for me.

Jiri Vperi February 27, 2019

actually the current implementation seems it doesn't support the expand argument. I created a wrapper around the get function"

 

def issue_with_expand(jira, key, expand):
url = 'rest/api/2/issue/{0}?expand={1}'.format(key, expand)
return jira.get(url)
Chris McQueen June 21, 2019

Hi! Is there any update on this issue? Im trying to display all JIRA- issues with an array in python. For this I don't want to have to call them explicitly! Further help on the search_issues would be a great help to me!

Thanks so much!

Chris

Matt Keenan June 15, 2020

I was enthralled to encounter the expand=renderedFields functionality for lettings Jira itself convert from wiki->HTML. For me even the jira.search worked.

However this does not work for items in the changelog, and I was wondering if there is something other than writing a custom python RE style parser to perform the conversion myself.

e.g. Let's presume the most recent changelog entry updated description to :
Some Bold Description Text

myissue = jira.issue("TEST-17", expand="changelog,renderedFields")
recent_update = myissue.changelog.histories[-1].items[-1]
print recent_update.field
print recent_update.toString
print myissue.fields.description
print myissue.renderedFields.description

The output of the above will be:

description
*Some Bold Description Text*
*Some Bold Description Text*
<p><b>Style</b></p>

Is there a means of rendering the changelog toString field ?

0 votes
Tim Baker November 25, 2012

I've opened an OnDemand support ticket for this and will provide an update once I have a solution.

vishwamitra mishra July 1, 2020

Hi, is there any solution available for this?

0 votes
Tim Baker November 20, 2012

In addition, we're using some of the optional macros, such as the anchor, code, quote, no-format, panel, and color macros. We put a lot of effort into making our release notes look nice. If there's a solution that doesn't only convert the basic wiki markup but the macros too, that would be fantastic.

Suggest an answer

Log in or Sign up to answer