How to Support Math in Markdown?

Hello, thank you developing brilliant wiki engine.
By the way, I need a wiki system in which math expressions are easily editable.
Specifically, I want to import this markdown notation into xwiki.
I’d like to assign math open/close tag to doller signs only, without lengthy {{mathjax}} tags, simply typing LaTeX code in the wiki page source (as shown by Source button in WYSIWYG editor).
Maybe I need some coding to do it, but the codebase is huge and I’m in stray.
Please guide me to the appropriate API entry point or some documentation or something useful.
Thank you.

Hi, you cannot do that using the XWiki Syntax 2.0+. With that Syntax you can only add new syntax elements with macros, i.e. in this case with the {{mathjax}} (or {{formula}}) macro.

We have support for a GitHub Flavored Markdown syntax in XWiki: GitHub-Flavored CommonMark Syntax 1.0 (

However I’ve tested it and the underlying library we use (flexmark-java doesn’t seem to support math formulas in GH-flavored markdown yet). They seem to support that for Gitlab-flavored MD though, see Extensions · vsch/flexmark-java Wiki · GitHub. To get it, someone would need to add support for it and release a new markdown extension for XWiki though.

Now, if you find {{mathjax}} lengthy, you could introduce a wiki macro (Writing XWiki Rendering Macros in wiki pages ( and name it something like {{x}}. It would simply call the {{mathjax}} macro on the content.

Very thank you for testing markdown.
Short macro rename is nice, but I’m a little of Java coder, so I may try to write a markdown extension. It seems that a shorter path is to write an extension for flexmark-java at the given URL.

But MathJax is (in my understanding) itself a parser written in javascript, which searches expressions bound by pairs of delimiter marks in HTML, and replace them with images.

Now I noticed that it is a way that the whole page is surrounded by single {{mathjax}}{{/mathjax}} pair. The page content is treated as a TeX document, and the delimiter used is not doller sign but inline style \( x^2 \) and display style \[ x^2 \]. This delimiter is short enough but it would be perfect if we can use other xwiki syntax inside mathjax. This way the page content is treated as a single element, and cannot, for example, select intermediate text by editor.

Is there way to change {{mathjax}} macro to inline other macros, as {{box}} macro might do? Though I afraid overlapping parsing might introduce security risk, any ideas?

Everything inside the mathjax macro is handled by the mathjax code and I doubt they’d be interested to add XWiki syntax support :wink:

It could be done but it’s a bit complicated. Right now, we support inplace editing of macros when they contain XWiki markup syntax. The mathjax macro supports it’s own syntax and thus, a special CKEditor editor would need to be developed to parse that content and generate HTML and vice-versa.