Skip to content

Add MathJax Support - #477

Closed
litao91 wants to merge 30 commits into
pulldown-cmark:masterfrom
litao91:master
Closed

litao91 wants to merge 30 commits into
pulldown-cmark:masterfrom
litao91:master

Conversation

@litao91

@litao91 litao91 commented Sep 9, 2020

Copy link
Copy Markdown

For block math:

$$
.... math content
$$

For inline math:

$items$

It handles inline math in a way the same as pandoc:

Anything between two $ characters will be treated as TeX math. The opening $ must have a character immediately to its right,
while the closing $ must have a character immediately to its left. 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.

@marcusklaas

Copy link
Copy Markdown
Collaborator

Hello and thank you for your pull request. Support for math sequences is one of the longest standing and most highly requested features. There have been long discussions on what the delimiters for inline and block math sequences should be, but we have unfortunately not yet come to a decision. The latex-style you've implemented is certainly a contender, but there are some drawbacks relating to unintended sequences and graceful fallback.

Before we can move forward with any implementation, we'd have to agree on a format (read: delimiters) and a spec. That said, I did have a quick look at the code and the implementation generally looks good. If we do choose to go with dollars, this PR should make an excellent basis.

You have prompted me to try and form a proposal so we can hopefully finally get this sorted. I will include you in future discussion. Thanks again!

@litao91

litao91 commented Sep 9, 2020

Copy link
Copy Markdown
Author

Hi @marcusklaas, actually I've noticed the discussions. I desperately need the math support, so I rushed to implement a basic working version for my personal needs. It's true that I haven't consider too much about the edges cases and this one shouldn't be a complete and sound solution.

I am a heavy markdown user and this is certainly one of the best implementation. It would be perfect if it has any kind of math support.

Thanks

@dkasak dkasak mentioned this pull request Jan 2, 2021
@ollpu

ollpu commented Jul 9, 2021 •

Copy link
Copy Markdown
Collaborator

Any content on a line that starts with $$ is currently ignored, and something like this, which I think is relatively common:

$$ \LaTeX $$

breaks the rest of the document.

Just mentioning to keep track. Hopefully we can get this merged soon!

Edit: Another bug is that math content is not escaped in the HTML renderer. This is left untouched and the <b> is parsed as a tag:

$a<b>c$

@tgross35

Copy link
Copy Markdown

Hey @marcusklaas did you ever put that proposal together? Or what is the status of planning for this?

#6 is a mess of bikeshedding over the delimiter. $...$ and $$...$$ is basically ubiquitous at this point (used by StackExchange, Pandoc, Jupyter, and now GitHub $E=mc^2$) so should definitely be included. Choosing other delimiters shouldn't block implementation work since they could be added later.

Assuming that logic is satisfactory, what is blocking this from being merged? There hasn't been too much of a discussion on KaTeX vs MathJax and pre- vs. post- rendering, but the work here is already mostly done, and could be adapted later if desired.

@litao91 are you interested in doing work to make this mergable, if needed? I see you are at least keeping this branch up to date with upstream

@ollpu ollpu mentioned this pull request Aug 16, 2023
@Martin1887

Copy link
Copy Markdown
Collaborator

Closed in favor of #734.

@Martin1887 Martin1887 closed this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants