How to convert html to Atlassian markup in java app

jost October 19, 2017

Hi Guys!

I have to implement parser (Java witchout atlassian SDK) which allow me to change my xml to csv to import issues. BUT i have to change description and comment in html to Atlassian wiki format. i found this:

how-do-i-convert-html-code-to-confluence-style-wiki-markup

So i add new dependency to my app:

<dependency>
<groupId>com.atlassian.renderer</groupId>
<artifactId>atlassian-renderer</artifactId>
<version>8.0.5</version>
<systemPath>C:\Users\exo\eclipse-workspace\JiraXMLToCSV\atlassian-renderer-8.0.5.jar</systemPath>
<scope>system</scope>
</dependency>

But now i got this error:


Exception in thread "main" java.lang.NoClassDefFoundError: com/opensymphony/util/TextUtils
at com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter ...

Should i add some additional dependencies? 

 

1 answer

1 accepted

2 votes
Answer accepted
paul-nelson-baker October 25, 2017

I'm not 100% sure how you're using the renderer, but I was able to convert HTML to MarkUp with the following relevant pom sections.

The snippets are below and working on github.

<dependency>
<groupId>com.atlassian.renderer</groupId>
<artifactId>atlassian-renderer</artifactId>
<version>8.0.5</version>
<exclusions>
<!-- This exclusion is necessary if you are in a
situation which
it conflicts, EG: using spring-boot -->
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
 <repository>
<!-- https://developer.atlassian.com/docs/advanced-topics/working-with-maven/atlassian-maven-repositories -->
<id>atlassian-public</id>
<url>https://packages.atlassian.com/maven/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
Dhiral Kaniya June 20, 2018

Does it support the conversion of inline style which embedded in html to the wiki format ?

like if there is html with css for italic text is like as below

    <div><span style="font-style:italic;">Test Italic</span></div>

will the confluence convert above html in the wiki italic style?

paul-nelson-baker June 22, 2018

This kind of question is best just something you try yourself to find out. I wouldn't know off handedly, since I'm just consuming their library not actually writing it.

 It doesn't look like their library supports inline styles, but it does support the <i /> tag. You can see it demonstrated here:

https://github.com/paul-nelson-baker/html-to-jira-markup/commit/03bce3c06681bfac5fd99b0ab136cbe4ef505ec6

You might have to do some data-transformations if you're consuming HTML from another resource.

Like # people like this
Italo Qualisoni [e-Core]
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.
January 17, 2019

Useful stuff! Thanks @paul-nelson-baker for sharing this

iiyama June 5, 2019

Thanks @paul-nelson-baker . Your Code Example work fine but, when i build my plugin for Jira and upload it to Jira, Jira says that my Plugin modules can´t get activated. That happend only with the renderer dependency. Does anybody have the same problem or a solution for this? Thanks

Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 24, 2019

Thanks for sharing :)

Suggest an answer

Log in or Sign up to answer