如何使用Atlassian原生API将JIRA wiki标记转换为HTML程序?

问题描述 投票:2回答:1

我试图从JIRA获取问题的描述,将其置于Confluence存储格式模板中,以便在Confluence中创建页面。但我找不到将描述原始数据呈现为存储格式可识别格式的方法。这是一个具体的例子:对于JIRA中的一个问题,有以下描述:

enter image description here

我通过调用com.atlassian.jira.issue.Issue.getDescription()得到的描述字符串是:

{color:#14892c}Recently Updated{color}
h1. *_As you and your team create content this area will fill up and display the latest updates._*

如果我没有弄错,我得到的字符串是它的wiki模板表示。直接以存储格式插入它将无法被模板引擎识别,因此无法正确呈现。

我已经尝试使用<ac:rich-text-body>来封装字符串,但它不起作用。似乎我必须将wiki表示转换为HTML或XHTML。如何在Java代码中实现这一点?

java jira confluence wiki-markup
1个回答
2
投票

要将JIRA wiki标记转换为JIRA的HTML呈现输出:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.ComponentManager;

public String renderWikiMarkup(Issue issue) {
    RendererManager rendererManager = ComponentManager.getComponent(RendererManager.class);
    JiraRendererPlugin renderer = rendererManager.getRendererForType("atlassian-wiki-renderer");
    String output = renderer.render(issue.description, issue.getIssueRenderContext());
    return output;
}
© www.soinside.com 2019 - 2024. All rights reserved.