要在Confluence API中保留新行,您可以使用HTML标签
或者使用Markdown语法的换行符号\n
。
以下是使用HTML标签
的代码示例:
import requests
url = "https://your-confluence-url/rest/api/content/{page_id}"
# 在请求正文中使用HTML标签
data = {
"title": "My Page",
"type": "page",
"body": {
"storage": {
"value": "This is the first line.
This is the second line.",
"representation": "storage"
}
}
}
response = requests.put(url, json=data)
以下是使用Markdown语法的换行符号\n
的代码示例:
import requests
url = "https://your-confluence-url/rest/api/content/{page_id}"
# 在请求正文中使用Markdown语法
data = {
"title": "My Page",
"type": "page",
"body": {
"storage": {
"value": "This is the first line.\nThis is the second line.",
"representation": "storage"
}
}
}
response = requests.put(url, json=data)
请注意,{page_id}
应替换为实际的页面ID。
上一篇:保留clang-format中的宏行连续性('\')
下一篇:保留CSV数据的换行