我的目标是使用提供的 REST API 在 confluence wiki 中创建一个包含表格的页面,该 wiki 用户可以在页面创建后使用 WYSIWYG 编辑器轻松编辑该表格。
我已经将文本拆开并将不同的类别放入一个数组数组中,然后从中生成一个 html 表(一个字符串),效果很好。
但是将此原始 html 表(在 $htmlTable 中)作为内容发布到 REST API
$data = array("type" => "page", "title" => someTitle,
"space" => array("key" => "$uploadSpace"),
"body" => array("storage" => array("value" => "$htmlTable", "representation" => "storage")));
返回 400 statusCode 错误。显然是因为输入没有正确转义,htmlspecialchars
用于将字符串编码为 html,但是我将如何创建一个结构化输入,否则将其转换为 html 表?
我试图通过一个汇合宏来传递我的 html 表,该宏将 html 输入呈现到一个表中以供查看:
$data = array("type" => "page", "title" => someTitle,
"space" => array("key" => "$uploadSpace"),
"body" => array("storage" => array("value" => "<ac:structured-macro ac:name=\"html\"><ac:plain-text-body><![CDATA[$htmlTable]]></ac:plain-text-body></ac:structured-macro>", "representation" => "storage")));
这会在页面上呈现我的 html 表格,但是这无法满足 WYSIWYG 要求中易于编辑的要求,因为 wiki 的用户之后会看到包含在宏中的 html 代码。
非常感谢您提前。