commonmark/cmark

[Feature] Support math environment via $ and $$ like LaTeX

j7168908jx opened this issue · 3 comments

Can we start a branch or anything to have another version that supports math inline and display style rendering just like LaTeX syntax?

So this line $f(x) = 1$ or $$ g(x)=2 $$

shall render directly as if typing LaTeX.

I was originally working on letting my self-hosted GitLab server accept LaTeX dollar expressions starting with $ or $$.
This is done by taking dollar as a special char as well as other special chars.

My solution: https://github.com/j7168908jx/commonmarker

Suggested from gjtorikian/commonmarker#80

This is currently a draft though. Some defections might exist in my current implementation.

If anyone would like this to be better implemented, I can check deeper into my code and try to meet up the requirements to merge into commonmark. Thanks anyway!

jgm commented

For comparison, here is the syntax I use for the math extension in commonmark-hs. It is compatible with what pandoc does.
https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/math.md

Your implementation is not compatible, because it allows opening/closing $ delimiters for inline math to be followed/preceded by spaces. I think that's going to end up capturing dollar signs meant for currency.

I think that if we added something like this to cmark, we'd want two new node types, one for inline math and one for display math.

But since we're not adding extensions yet to cmark, this isn't pressing.