MathJax extension for LaTeX equations

I’m cataloging existing syntaxes for this at https://github.com/cben/mathdown/wiki/math-in-markdown (very incomplete so far, edits welcome - it’s a wiki).

There is a tension between what’s convenient for heavy math users (supporting all 4 latex syntaxes wins on least-surprise and muscle memory grounds), and ordinary users.
It’s fine for some syntaxes to be optional but it would be really sweet if there was some portable syntax that’d work with any parser that supports math at all.
Until your post here I was of the opinion that the common syntax better be \(..\) and \[...\] because $...$ really needs some limiting heuristic but agreement on the exact heuristic seems unlikely (even Pandoc’s docs and implementation seem to disagree ;-)).
Specifically, limiting $...$ to one line is a recurring idea — bad heuristic (unlike any inline construct in markdown) but effective damage control.

However if you say escaping brackets is very important and dollars with heuristic are acceptable, I’ll take your opinion over mine.

But then what do you think of kramdown’s syntax?

  • It uses the more robust $$ for both inline and display math.
  • The automatic treatment of math alone in a paragraph as display is kinda elegantly “markdownish”. The best part of this is that display math must stand alone in the source, making it closer to how it’ll look rendered.
  • It has a simple provision for other environments via $$\begin{foo}...\end{foo}$$ which doesn’t require the markdown parser to look for \end{foo}, just same $$.
  • It’s somewhat compatible to any other parser that understands dollar math — worst case all math becomes display…

Alas, no other tool supports kramdown’s syntax now, nor vice versa, so there is currently no portable syntax at all for inline math :frowning:

1 Like