Skip to content

Add "Table of Contents" [[TOC]] shortcode to Markdown API

Proposal

In Wikis (and recently also in non-wiki Markdown files), GitLab supports the [[_TOC_]] shortcode to dynamically generate a table of contents.

However this shortcode is not supported via the GitLab Markdown Rendering API.

Including this shortcode in an API request to the mentioned API gives the following result, which only renders the underscores as italique formatting:

http https://myGitLabInstance.com/api/v4/markdown PRIVATE-TOKEN:abc123 text='[[_TOC_]]'

{
    "html": "<p data-sourcepos=\"1:1-1:9\">[[<em>TOC</em>]]</p>"
}

For consistency reasons it would be very appreciated if the Markdown API could also implement the TOC functionality and return the same markup as the GitLab Issue/Wiki UI. feature

Edited by 🤖 GitLab Bot 🤖