Render math in Asciidoc and Markdown with KaTeX
What does this MR do?
Extends gitlab-org/gitlab-ce!4333 to also enable MathJax support for markdown.
This renders mathematics in Markdown or asciidoc using KaTeX library.
\(\) are chosen for display and inline math respectively since these are commonly used in LaTeX.
This MR also introduces a new setting
math_load, which can be either of never, always or auto. In case of never the KaTeX library is never loaded, in case of always it is always loaded and in the case of auto KaTeX will only be loaded if necessary.
The math detection is currently two-fold. During the rendering of markdown or asciidoc, the text is checked for these delimiters. If the text contains these a css and script tag is appended to the page body.
application.js. This listenens on
gitlab:math:typeset in which case it will perform the appropriate action.
Are there points in the code the reviewer needs to double check?
LaTeX code uses ^ and \\ heavily. Based on the discussion here I chose to escape these characters. This is done with a Banzai pre-process filter
Why was this MR needed?
Documentation for scientific software needs mathematics.
What are the relevant issue numbers?
gitlab-org/gitlab-ce#13690 and gitlab-org/gitlab-ce#13180
Screenshots (if relevant)
- CHANGELOG entry added
- Documentation created/updated
- API support added
- Added for this feature/bug
- All builds are passing
- Conform by the merge request performance guides
- Conform by the style guides
Branch has no merge conflicts with
master(if it does - rebase it please)
- Squashed related commits together