Open marmitar opened 1 year ago
Also, block math is not allowing multiline content. The following does not work:
$$
\begin{align}
x &= 1 \\
y &= 2
\end{align}
$$
The workaround is to write everything in a single line like
$$
\begin{align} x &= 1 \\ y &= 2 \end{align}
$$
I changed the patterns in mistune/plugins/math.py
to:
BLOCK_MATH_PATTERN = r'(?sm)(?!^ {4,})\$\$\s*(?P<math_text>\S.*?)\s*(?<!\\)\$\$'
INLINE_MATH_PATTERN = r'\$\s*(?P<math_text>\S.*?)\s*(?<!\\)\$'
These seem to fix the issues above except $$$$
which is ambiguous and should be avoided (empty block math or a sequence of two empty inline equations?)
The patterns disallow empty formulas to avoid ambiguity, and formulas made only from whitespace.
The dollar sign \$
is allowed both inside and outside math.
Block math can be used like $$here$$
in the middle of text.
Multiline formulas are allowed.
@miguelbarao I've fixed block math plugin for multiline content.
@lepture Thank you. Still, it does not address some of the issues reported above:
$$y = \frac{1}{1-x}$$
should render $$y = \frac{1}{1-x}$$ as is done here in github.
Will mistune force $$
to be in their own separate lines? I'm asking because it's very common to write simple formulas in a single line like the one above.
I was checking the math plugin and found out four incompatibilities with latex compilers (pdfLaTeX and XeLaTeX) and MathJax:
$$
) requires a newline before and after content, effectively changing the delimiters to$$\n
and\n$$
.$$$$
), the regex is done with.+
instead of.*
.\$
).So the following markdown:
Is compiled to:
Whereas it should probably be:
For comparison, here are the latex and MathJax versions:
Latex version
Code: ```latex \documentclass{article} \begin{document} Dollar sign $\$$ \\ Empty $$$$ \\ No newline $$x$$ \end{document} ``` Output: ![image](https://user-images.githubusercontent.com/22567908/207233943-40475223-afae-4e64-810f-3b1e95b4a0df.png)MathJax version
Code: ```htmlDollar sign \(\$\)
Empty $$$$
No newline $$x$$
``` Output: ![image](https://user-images.githubusercontent.com/22567908/207234120-918ffc16-0bb4-4f81-8fa9-a628f23b4d90.png)