I have developed a Java application that integrates with Jira, enabling users to create issues in the application’s format, which are then sent to the Jira Server. Conversely, users can initiate issues on the Jira Server, and these will be transferred back to the application. The problem is that the application stores issue descriptions in XHTML format, while Jira uses its own markup. Therefore, I require a conversion tool.
To address this, I opted for the com.atlassian.renderer:atlassian-renderer library, which simplifies the conversion from XHTML to Jira markup as follows:
private DefaultWysiwygConverter myConverter = new DefaultWysiwygConverter();
String jiraMarkup = myConverter.convertXHtmlToWikiMarkup(xhtmlContent);
However, I’m struggling with the reverse conversion, which is significantly more complicated. A direct call to convert back to XHTML results in an error:
String xhtmlContent = myConverter.convertWikiMarkupToXHtml(newJiraMarkup);
The DefaultWysiwygConverter requires an instance of WikiStyleRenderer, but the library does not provide a default implementation. Although there is a V2RendererFacade, its constructor necessitates four parameters, each of which requires specific implementations.
public V2RendererFacade(RendererConfiguration config, LinkRenderer linkRenderer, EmbeddedResourceRenderer resourceRenderer, Renderer renderer) {
this.rendererConfiguration = config;
this.defaultLinkRenderer = linkRenderer;
this.defaultEmbeddedRenderer = resourceRenderer;
this.renderer = renderer;
}
Is there a straightforward approach to achieve this conversion? Any practical examples would be greatly appreciated.