Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,172
Community Members
 
Community Events
168
Community Groups

How do I convert HTML into Jira Wiki..?

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

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).

I am not aware of such Rest Api

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?

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 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?

@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.

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

@Michael Cowan , yeah looks like the same package.

@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? 

@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. 

@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/)

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.

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

0 votes

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!

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 !

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)

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?

@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... 

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

Suggest an answer

Log in or Sign up to answer