How do I convert HTML into Jira Wiki..?

Nico K July 3, 2018

I will be importing data from an existing ALM tool into Jira and the Description in the ALM tool is stored in HTML. Since I cannot send the HTML via the Jira REST API I want to know if there is a way to Send the REST API HTML or Ask the REST API to convert HTML to the wiki markdown format supported by Jira.

 

I know you can get the HTML from Jira again as a rendered field, but my need is to move data into Jira but try to keep as much of the formatting as possible.

4 answers

2 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2018
Nico K July 5, 2018

Thank you. Is there no JIRA REST API Call where the Atlassian Jira solution can take HTML and give me back the correct markdown it needs..?

Seems odd that it would not have this since it does render back HTML as a rendered field when you get items (issues).

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2018

I am not aware of such Rest Api

Phil_Dimeski October 11, 2018

Has this issue been resolved. I am stuck in the same situation. @Alexey Matveev you said you are aware of such Rest API do you mind sharing it?

Michael Cowan April 19, 2021

I am also curious.. I have HTML that I want to convert and post into a Jira Item .. do I have to write my own tag parser?

Anastasiya Gubina April 25, 2021

@Michael Cowan , search for the Java package https://docs.atlassian.com/atlassian-renderer/. It will do the thing.

Michael Cowan April 26, 2021

@Anastasiya Gubina This feels like a mean joke :). I got my hopes up.  That tool appears deleted? All the links are empty and don't go anywhere? Do you have another links, or am I missing something?

Anastasiya Gubina April 26, 2021

@Michael Cowan , I believe this is just an automatically generated documentation by Maven. https://docs.atlassian.com/atlassian-renderer/8.0/project-info.html

This is how our developers included the dependency in the pom.xml file:

<dependency>
            <groupId>com.atlassian.renderer</groupId>
            <artifactId>atlassian-renderer</artifactId>
            <version>8.0.5</version>
</dependency>


There are not so much information about this lib which is bad. However, it does convert HTML to ADF.

Michael Cowan April 26, 2021

Thank you for the follow up .. I will check it out! 

Just checking .. is that the same as this?
https://www.codota.com/code/java/classes/com.atlassian.renderer.RenderContext

Anastasiya Gubina April 26, 2021

@Michael Cowan , yeah looks like the same package.

Satheesh JM July 20, 2021

@Anastasiya Gubina Which class in the atlassian-renderer library are you using to convert HTML to ADF? 
Is it possible to share a sample snippet please? 

Anastasiya Gubina July 20, 2021

@Satheesh JM , unfortunately, I cannot share a code snippet because of NDA. As far I understand you can use com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter class from the atlassian-renderer library and call convertXHtmlToWikiMarkup method on the object of that class. 

Satheesh JM July 20, 2021

@Anastasiya Gubina oh I did try out that class.. 
but it converts to only jiraMarkup right? 

You had mentioned "However, it does convert HTML to ADF", so I thought there was a separate class which converts html to the ADF format (https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/)

Anastasiya Gubina July 20, 2021

As far as I know, there is no such method in the Jira Cloud API. That's why people in this thread discuss the usage of the additional library.

Satheesh JM July 20, 2021

I just ended up using the V2 api to send markup instead of the document

0 votes
Daniel Brown July 13, 2022

If you're using Python, I like this tool: https://pypi.org/project/html2jirawiki/
I literally plugged it into my import script, and it converted the HTML from Wrike to Jira Wiki.  Love it!

0 votes
Akash Ingole August 18, 2021

You can use text formatting notations -

Like in place of <h1></h1> You will have to send "h1. Creating of an issue using project keys and issue type names using the REST API" as description.

https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all&error=login_required&error_description=Login+required&state=b082ac30-a6e7-486f-affd-e73f5af60425

 

Hope this helps !

0 votes
Satheesh JM July 20, 2021

Ok This is what I ended up doing for my use case..

I used the atlassian renderer library

<dependency>
            <groupId>com.atlassian.renderer</groupId>
            <artifactId>atlassian-renderer</artifactId>
            <version>8.0.32</version>
</dependency>




First I converted html to Markup first using

new DefaultWysiwygConverter().convertXHtmlToWikiMarkup(html);

 
Then instead of using the v3 jira API, I used the v2 API as the v2 API accepts markup 
(https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comments/#api-rest-api-2-issue-issueidorkey-comment-post)

Szymon Kaczmarek July 30, 2021

I tried the same thing but now I have following error:

java.lang.NoClassDefFoundError: com/opensymphony/util/TextUtils

Same like here. I tried adding

com.opensymphony.xwork

 but with no luck. Did you have any similar problems?

Satheesh JM July 30, 2021

@Szymon Kaczmarek 
Yeah I got some similar errors, which were mainly because of dependency conflicts with other libs. 
Here's my final pom.xml


<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>

<!--atlassian-renderer:8.0.32 is not part of the central repo. to work around that, all these other repos are needed -->
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>jcenter</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>atlassian-3rdparty</id>
<name>Atlassian 3rd-P Old Repository</name>
<url>https://maven.atlassian.com/3rdparty/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>mulesoft</id>
<name>Mulesoft</name>
<url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
</repository>

</repositories>
<dependencies>
.
.
.
<dependency>
<groupId>com.atlassian.renderer</groupId>
<artifactId>atlassian-renderer</artifactId>
<version>8.0.32</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17-atlassian-3</version>
</dependency>
.
.
.
</dependencies>

 

 

for me the dependency conflict was in log4j library so I explicitly added it. 
you will need to figure out all the conflicting dependencies... 

Szymon Kaczmarek July 30, 2021

It works! Thank you!

boardtc
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2021

The steps I used:

  1. Download zip file from https://github.com/Qazzian/html2jira
  2. Extract to a utility directory C:\Users\joebloggs\Utils\html2jira\html2jira-master
  3. Copy your HTML file, your_file.tml. to html2jira-master directory
  4. Ensure Python is installed on your machine, e.g. install Anaconda
  5. python html2jira.py your_file.html > jira.txt
  6. Paste the contents of jira.txt into your jira comment
tim nixon May 10, 2023

Does not handle tables, too bad

Suggest an answer

Log in or Sign up to answer