debian-mirror-gitlab/doc/api/markdown.md

48 lines
1.9 KiB
Markdown
Raw Normal View History

2020-06-23 00:09:42 +05:30
---
2022-08-27 11:52:29 +05:30
stage: Plan
group: Project Management
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
---
2021-03-11 19:13:27 +05:30
# Markdown API **(FREE)**
2018-11-08 19:23:39 +05:30
2022-08-27 11:52:29 +05:30
Convert Markdown content to HTML.
2018-11-08 19:23:39 +05:30
Available only in APIv4.
2022-08-27 11:52:29 +05:30
## Required authentication
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/93727) in GitLab 15.3 [with a flag](../administration/feature_flags.md) named `authenticate_markdown_api`. Enabled by default.
FLAG:
On self-managed GitLab, by default this feature is enabled and authentication is required.
To remove the requirement to authenticate, ask an administrator to
[disable the feature flag](../administration/feature_flags.md) named `authenticate_markdown_api`.
On GitLab.com, this feature is available.
2023-04-23 21:23:45 +05:30
All API calls to the Markdown API must be [authenticated](rest/index.md#authentication).
2022-08-27 11:52:29 +05:30
2018-11-08 19:23:39 +05:30
## Render an arbitrary Markdown document
2020-04-08 14:13:33 +05:30
```plaintext
2021-09-30 23:02:18 +05:30
POST /markdown
2018-11-08 19:23:39 +05:30
```
| Attribute | Type | Required | Description |
| --------- | ------- | ------------- | ------------------------------------------ |
2020-01-01 13:55:28 +05:30
| `text` | string | yes | The Markdown text to render |
2020-11-24 15:15:51 +05:30
| `gfm` | boolean | no | Render text using GitLab Flavored Markdown. Default is `false` |
2022-08-27 11:52:29 +05:30
| `project` | string | no | Use `project` as a context when creating references using GitLab Flavored Markdown |
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
```shell
2022-08-27 11:52:29 +05:30
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"
2018-11-08 19:23:39 +05:30
```
Response example:
```json
{ "html": "<p dir=\"auto\">Hello world! <gl-emoji title=\"party popper\" data-name=\"tada\" data-unicode-version=\"6.0\">🎉</gl-emoji></p>" }
```