Help us learn about your current experience with the documentation. Take the survey.

Markdown API

  • 版本:Free, Premium, Ultimate
  • 产品:GitLab.com, GitLab Self-Managed, GitLab Dedicated

将 Markdown 内容转换为 HTML。

仅在 APIv4 中可用。

必需的身份验证

此功能的可用性由一个功能标志控制。 更多信息,请参见历史记录。 此功能可用于测试,但尚未准备好用于生产环境。

所有对 Markdown API 的 API 调用都必须经过身份验证

渲染任意 Markdown 文档

POST /markdown
属性 类型 必需 描述
text string 要渲染的 Markdown 文本
gfm boolean 是否使用 GitLab 风格 Markdown (GitLab Flavored Markdown) 渲染文本。默认为 false
project string 在使用 GitLab 风格 Markdown 创建引用时,将 project 作为上下文
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type:application/json" \
  --data '{"text":"Hello world! :tada:", "gfm":true, "project":"group_example/project_example"}' "https://gitlab.example.com/api/v4/markdown"

响应示例:

{ "html": "<p dir=\"auto\">Hello world! <gl-emoji title=\"party popper\" data-name=\"tada\" data-unicode-version=\"6.0\">🎉</gl-emoji></p>" }