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 :
After :
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_srcRST:
.. 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
- Org-mode LaTeX fragments (
\[...\],\(...\),$$...$$,$...$) are out of scope because org-ruby does not support them yet: https://github.com/wallyqs/org-ruby/issues/81 - RST
.. math::directives (#222805) are out of scope and may require additional support ingitlab-markup.
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.
Related
Edited by skkzsh

