marp-core icon indicating copy to clipboard operation
marp-core copied to clipboard

[v4] Math syntax: GFM vs Pandoc based

Open yhatt opened this issue 3 years ago • 0 comments

Marp Core is following a lot of features from GitHub Flavored Markdown, such as table and strikethrough. And today, GitHub has started Math support powered by MathJax: $ax^2+bc+c$ https://github.blog/2022-05-19-math-support-in-markdown/

$$ I_{xx}=\int\int_Ry^2f(x,y)\cdot{}dydx $$

$$ f(x) = \int_{-\infty}^\infty \hat f(\xi),e^{2 \pi i \xi x} ,d\xi $$

Marp has already supported MathJax math rendering, and in upcoming stable release v3, MathJax will become a default math library on behalf of KaTeX.

On the other hand, Marp's math syntax spec is actually based on tex_math_dollars Pandoc extension, and it has some of heuristic parsing:

The opening $ must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus, $20,000 and $30,000 won’t parse as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won’t be treated as math delimiters.

— https://pandoc.org/MANUAL.html#extension-tex_math_dollars

GitHub's Math syntax parsing is just simpler than Marp/Pandoc, and all of these rules are not applicable to GitHub Flavored Markdown. For example, backslash-escape \$ is working in Marp but not in GitHub. GitHub docs is instructing to use <span> raw HTML tag to escape (https://docs.github.com/ja/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions#writing-dollar-signs-in-line-with-and-within-mathematical-expressions):

To split <span>$</span>100 in half, we calculate $100/2$

Following GFM spec might make high compatibility with Markdown document, that have popular syntax used by a familiar platform.

This is just an idea, and not yet decided to take GFM spec. If changed, we should work carefully because exist math slides may become broken.

yhatt avatar May 20 '22 11:05 yhatt