Support math code block rendering in non-Markdown markup

Follow-up to Add syntax highlighting and Mermaid rendering f... (!236244 - merged).

Problem

GitLab's Markdown renders math equations using ````math blocks, but non-Markdown markup math code blocks were rendered as plain code blocks instead.

GitHub already supports math rendering for non-Markdown markup files, so similar support in GitLab would be very helpful.

What this MR does

Extends MathFilter's selector with pre[data-canonical-lang="math"] and auto-assigns data-math-style="display" to matching <pre> elements.

Screenshots

Visually confirmed rendering on GDK-in-a-box with non-Markdown markup files.

Before :

image

After :

image

Sources

org:

#+begin_src math
\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
#+end_src

RST:

.. code:: math

   \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)

Textile:

bc[math]. \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)

Math rendering limitations

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.
  • Backend engineer, but fairly new to Rails — feedback on Rails conventions welcome.
Edited by skkzsh

Merge request reports

Loading