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,362,943
Community Members
 
Community Events
168
Community Groups

Method to Convert Jira Wiki Format to HTML

Hi,

Can you please advise how I can convert the Jira Wiki format into HTML? I am using the Jira Java Rest Client API.

I have obtained the field value as follows:

String BusinessNeedWikiFormat = jiraIssue.getFieldByName("Business Need").toString();

Sting BusinessNeedHtmlFormat = ?

Is there a method that I can use to convert this value into HTML?

Thanks,

-Angela

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
ConradR Rising Star Feb 07, 2013
EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType(EventPublisher.class);
        VelocityRequestContextFactory velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory.class);
        AtlassianWikiRenderer wikiRenderer = new AtlassianWikiRenderer(eventPublisher, velocityRequestContextFactory);

        String html = wikiRenderer.render("*I am bold*", null);

Oops sorry Conrad ;-)

Hi Conrad,

Thank you very much for the information :-). I have implemented the code in my application however I am seeing the following error:

java.lang.IllegalStateException: ComponentAccessor has not been initialised.

It is failing on the following line:

EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType (EventPublisher.class);

Can you please advise how to resolve?

Thanks Conrad, it worked perfectly for me ;)

But AtlassianWikiRenderer is provided by jira-core and it is not a good way to work...

Hope Atlassian will expose a public method to get HTML from wiki content :P

hi can someone help me with AtlassianWikiRenderer cannot find this method. but i already imported import com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer

here is my code

import java.lang.*
import javax.mail.internet.*;
import javax.mail.*
import javax.activation.*
import javax.mail.Multipart;

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.attachment.Attachment;
import com.atlassian.jira.issue.AttachmentManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.util.AttachmentUtils;
import com.atlassian.jira.util.PathUtils;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.gzipfilter.org.apache.commons.lang.StringUtils
import groovy.text.GStringTemplateEngine;
import com.atlassian.event.api.EventPublisher
import com.atlassian.jira.util.velocity.VelocityRequestContextFactory
import com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer
import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin
import org.springframework.beans.factory.DisposableBean

 

 

 

EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType(EventPublisher.class);
VelocityRequestContextFactory velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory.class);
AtlassianWikiRenderer wikiRenderer = new AtlassianWikiRenderer(eventPublisher, velocityRequestContextFactory);

Hi Conard

How can we access the AtlassianWikiRenderer ? I am using .NET client for Rest API via webservice reference but the AtlassianWikiRenderer is not available also I have tried the Atlassian SDK library for .NET but that too does not provide the AtlassianWikiRenderer functionality.

Can you please tell me how can I utilize this functionality in .NET application?

Like Angela; My intention is to convert the wiki format text received from the api to html.

Thanks a lot

Best Regards,

Sp

ConradR Rising Star Feb 17, 2013

There is an undocumented rest resource:

/rest/api/1.0/render

Body:

{"rendererType":"atlassian-wiki-renderer","unrenderedMarkup":"*test*"}

Response:

<p><b>test</b></p>

This resource is used by Jira when you click the preview button in wiki-renderer fields.

Hi Conrad,

Is this working?

Thank you.

Hi again.

It's working fine.

 

There is a problem with that REST service. On JIRA Cloud it doesn't work with JWT token authentication. So, there is an issue opened since 2014 and nothing was made until now.

 

You can see it here: https://jira.atlassian.com/browse/JRA-38731.

Thanks.

Conrand,

Does below code will extract all the Description with color / Table everything.

My challenge is not able to get the Images from Story, I am trying to convert Images from JIRA to my JAVA application.

Please help I am stuck from many days.

EventPublisher eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType(EventPublisher.class);
        VelocityRequestContextFactory velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory.class);
        AtlassianWikiRenderer wikiRenderer = new AtlassianWikiRenderer(eventPublisher, velocityRequestContextFactory);

        String html = wikiRenderer.render("*I am bold*", null);


TAGS

Atlassian Community Events