Support table of contents button for org-mode file previews
## Problem When viewing `.org` (org-mode) ~~or `.rst` (reStructuredText)~~ files in preview mode, the "Table of contents" button is not shown in the file header. It only appears for Markdown (`.md`) files. |Markup| Screenshot | |-|-| | Markdown | ![markdown-toc](/uploads/0582f6d32128d1e92d88feea2bf32a35/markdown-toc.png){width=565 height=211} | | Org | ![org-toc](/uploads/f29da970a72c13ce46f66c1a8d4169c7/org-toc.png){width=567 height=72} | | ~~RST~~ | ~~![rst-toc](/uploads/a7ff0af6c063ae98b0116fa148ce97cd/rst-toc.png){width=576 height=58}~~ | GitHub already supports a table of contents for org-mode ~~and reStructuredText~~ file views, so similar support in GitLab would be very helpful. ## Possible approach - Add a filter to [`MarkupPipeline`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/banzai/pipeline/markup_pipeline.rb) so that org-mode ~~and rst~~ headings receive the same heading anchor information that Markdown gets - [`_header_content.html.haml`](https://gitlab.com/gitlab-org/gitlab/-/blob/0d4392f7eefe68fefaae1e9f6e4317b797e481cc/app/views/projects/blob/_header_content.html.haml#L2) only outputs the table of contents container for files matching `Gitlab::MarkupHelper.gitlab_markdown?`; expand this to also include `.org` ~~and `.rst`~~ ## Related - #15405+ - #251204+ EDIT: Scoped down to org-mode only. `.rst` support is out of scope for this issue.
issue