commonmark/commonmark-spec

Support parsing latex style (math) equations as in pandoc

jeroen opened this issue · 0 comments

We would be very interested in the ability to parse latex-style math equations in the same syntax as understood by pandoc.

I understand that actually rendering math is out of scope for most implementations, but it would be useful if equations are recognized in the AST. This would make it easy to render them in a subsequent step.

For example, below some markdown that is understood by pandoc. It would be super helpful if the cmark parser would at lest be able to mark the math blocks in the xml representation of the ast, or the html output.

## R Markdown

This is a test

Inline: $E=MC^2$.

## In DisplayMode

Equation 1

$$
\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} \equiv 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }
$$

$$
\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)
$$

## Other examples

With aligned:

\begin{aligned}
\dot{x} & = \sigma(y-x) \\ 
\dot{y} & = \rho x - y - xz \\ 
\dot{z} & = -\beta z + xy 
\end{aligned}

With pmatrix:

\begin{pmatrix} 
a_{11} & a_{12} & a_{13}\\ 
a_{21} & a_{22} & a_{23}\\ 
a_{31} & a_{32} & a_{33} 
\end{pmatrix}