Add syntax highlighting and Mermaid rendering for org-mode files

Problem

org-mode files in repositories rendered without syntax highlighting or Mermaid diagram support. GitHub has rendered org-mode source blocks with syntax highlighting since around 2010, but this was not supported in GitLab (#32207 (closed)).

What does this MR do?

  • Updated CodeLanguageFilter to handle bare <pre lang="python">code</pre> output produced by org-ruby (without a <code> wrapper). This enables syntax highlighting for #+begin_src blocks in org-mode files.
  • Added MermaidFilter to MarkupPipeline. This enables Mermaid diagram rendering for #+begin_src mermaid in org-mode files.
  • As a side effect, reStructuredText and Textile files also renders Mermaid diagrams (reST and Textile source blocks already had syntax highlighting).
  • As a further side effect, code blocks in .rdoc and .creole files gain Mermaid rendering (if the underlying markup parser produces a <pre><code> shape, or <pre lang> that the new wrapping logic normalizes). Based on current testing, .wiki and .mediawiki content does not produce Mermaid‑renderable code blocks with this pipeline.

Screenshots

Manually verified rendering in GDK-in-a-box.

org-mode — syntax highlighting + Mermaid

Before (gitlab.com) After (GDK-in-a-box)
org-highlight-before org-highlight
org-mermaid-before org-mermaid

Source:

#+BEGIN_SRC python
def function():
    s = "Python code"
    print s
#+END_SRC

#+BEGIN_SRC mermaid
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
#+END_SRC

reStructuredText — Mermaid

Before (gitlab.com) After (GDK-in-a-box)
rst-mermaid-before rst-mermaid

Source:

.. code:: mermaid

   graph TD;
       A-->B;
       A-->C;
       B-->D;
       C-->D;

Textile — Mermaid

Before (gitlab.com) After (GDK-in-a-box)
image image

Source:

bc[mermaid]. graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;

Notes

  • No docs updates included — this area isn't well covered by existing documentation. If there are specific docs that should be updated, please flag them.
  • First contribution to GitLab — any guidance on process or conventions would be appreciated.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by skkzsh

Merge request reports

Loading