miyuchina / mistletoe

A fast, extensible and spec-compliant Markdown parser in pure Python.
MIT License
791 stars 110 forks source link

How to render aligned math equations? #218

Closed AntixK closed 1 month ago

AntixK commented 1 month ago

Hi,

I am trying to render aligned math equations from markdown to HTML. For example

This is a markdown file.

$$
\begin{align}
f &= ma \\
e &= mc^2
\end{align}
$$

Specifically, the main issue is that the new line in the math block is tokenized as </br> in the output html and Katex fails to render.

Thanks for creating and maintaining this great library!

pbodnar commented 1 month ago

@AntixK, can you share code snippet / are you sure you are using the MathJaxRenderer? For me, it outputs the expected output:

<p>$$
\begin{align}
f &amp;= ma \\
e &amp;= mc^2
\end{align}
$$</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>
AntixK commented 1 month ago

Hi, thanks, that works. I was trying out a custom rendered for math with labels. I missed out the mathjax renderer.