使用Confluence 4.0在用户宏中添加Wiki标记



当使用Confluence 4.0时,我如何在用户宏(或其他产生动态输出的东西,在用户宏编辑器中完成)中使用wiki标记。在Confluence 3.5.3中,我有一个包含以下内容的宏,我想迁移:

{info:title=Table of content}
{toc}
{info}

要获得需要为宏编写的XHTML,请遵循以下步骤:

  1. 用你想要的宏创建一个新页面并保存。
  2. 如果您是Confluence管理员或正在开发模式下运行,请打开Tools> View Storage Format页面。
  3. 页面现在将以新的存储格式显示原始输出。

如果你没有访问查看存储格式选项,那么一个解决方案是:

  1. 打开Info (Tools> Info)页面,注意URL中的pageId=
  2. 打开一个新的浏览器窗口,输入以下URL,替换汇流根和页面id变量。

http://{your-confluence-root}/plugins/viewstorage/viewpagestorage.action?pageId={your-page-id}

引用:
Confluence 4.0编辑器FAQ

好了,我知道怎么解决这个问题了。您必须编写XHTML,下面显示了上面的示例在XHTML中的样子:

## @noparams
<ac:macro ac:name="info">
    <ac:parameter ac:name="title">Table of content</ac:parameter>
    <ac:rich-text-body>
        <ac:macro ac:name="toc" />
    </ac:rich-text-body>
</ac:macro>
我发现的另一种肮脏的方法是使用转换标记(将来可能会过时):
## @noparams
<ac:macro ac:name="unmigrated-inline-wiki-markup">
    <ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter>
    <ac:plain-text-body><![CDATA[
        {info}Here you can write wiki markup the old way, until Atlassian removes this transition markup (unmigrated-inline-wiki-markup){info}
    ]]></ac:plain-text-body>
</ac:macro>

您应该在用户宏中动态地将wiki标记呈现为xhtml !下面是一些代码:

## @noparams
#set($globalHelper = $action.getHelper())
#set($renderedhtml = $globalHelper.renderConfluenceMacro("{info}test{info}"))
$renderedhtml

最新更新