Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,641,827
Community Members
 
Community Events
196
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

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.
Jul 03, 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.
Jul 05, 2018 • edited Oct 11, 2018

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

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

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.
Nov 22, 2021 • edited

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

Does not handle tables, too bad

Suggest an answer

Log in or Sign up to answer