0

I'm making a PySide GUI that submits to Jira. Prior to submission, it would be ideal if I could show the user a "ticket preview" so they know roughly what the ticket will look like or if they made any syntax errors that would cause issues in Jira. To do that, I imagine that I would have to convert their raw text to a png file. I haven't found a way to make that conversion and would like any suggestions people could give.

Example

Imagine a submission text box that looks like this:

{panel:title=Test|borderStyle=none|titleBGColor=#f7d6c1|bgColor=#fdf4ee}
Hello, World!
{panel}

I should be able to take that text into Python and somehow render an image so that looks as it should in Jira. For reference, this is how Jira renders it:

A panel, rendered by Jira

This is the .png that I'm trying to generate, basically.

What I Tried

It's not a great substitute but I was thinking maybe I could use jira2markdown to convert Jira markdown -> common markdown -> pygments -> png. Unfortunately, information is lost when you go from Jira markdown -> common markdown using jira2markdown. The example text below

{panel:title=Test|borderStyle=none|titleBGColor=#f7d6c1|bgColor=#fdf4ee}
Hello, World!
{panel}

converts to

> **Test**
> Hello, World!

It removes all background, foreground, and text colors in that case.

So anyway, I'm mostly just looking for an approximation though an ideal "as it looks in Jira" render would be awesome as well. Does anyone know of a way that I could achieve this effect?

ColinKennedy
  • 828
  • 7
  • 24
  • Easiest way I can think of is maybe convert the JIRA code to HTML, then display it as a html file in browser. This was my approach for a similar project with confluence, but confluence already stores pages in a XHTML format so it was very easy. Here's the JIRA reference: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all – mrblue6 Mar 14 '23 at 17:36
  • Definitely depends on how complex your JIRA issues are, if it's only a few simple things, this shouldn't be too hard. But if theres a lot of content in the issue this might take a long time to get a good solution – mrblue6 Mar 14 '23 at 17:38
  • Thank you for the suggestion, I hadn't thought to go straight to HTML and then render it. I'll definitely look into that. By any chance, would you know offhand if either of these resources I found online can do it? https://community.atlassian.com/t5/Jira-questions/convert-jira-ADF-formatted-description-in-HTML-format/qaq-p/1750152 I was thinking maybe I could call that REST command via Python. Or somehow use Jira's engine to do it https://stackoverflow.com/questions/37570491/how-to-convert-jira-wiki-markup-to-html-programmly-using-atlassian-native-api. Not sure how I'd do it this way tho. – ColinKennedy Mar 15 '23 at 03:54
  • The Atlassian post link looks like it could help you. It seems they had an endpoint for an editor which now no longer exists, but there is still an old version linked on that post that you could use. Definitely go and read all the comments in depth, but this [post](https://community.atlassian.com/t5/Jira-questions/Is-there-documentation-for-api-atlassian-com-pf-editor-service/qaq-p/1743002) summarises it quite well. – mrblue6 Mar 15 '23 at 14:35
  • From David Bakkers' comments on that post, looks like you'd be able to go from markdown (which I think refers to the format you have now) to ADF and then from ADF to HTML. [This](https://bitbucket.org/atlassian/atlaskit-mk-2/src/master/packages/editor/editor-markdown-transformer/) is the slightly outdated version they refer to. It seems to have no documentation anywhere, but doesn't look too complex – mrblue6 Mar 15 '23 at 14:55

0 Answers0