Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mathematics #23

Closed
jeanm opened this issue Jun 26, 2017 · 6 comments
Closed

Mathematics #23

jeanm opened this issue Jun 26, 2017 · 6 comments

Comments

@jeanm
Copy link

jeanm commented Jun 26, 2017

A commonly requested feature is the ability to input mathematics using LaTeX syntax without the markdown parser getting confused and messing it all up. All the parser needs to do is leave the maths alone, without interpreting underscores/askerisks/escapes, and rendering can then be delegated to something like MathJax or KaTeX. It would certainly be a nice feature for scientists, or people needing to describe algorithms etc.

A while ago I made a summary table of all the ways this syntax extension has been implemented in other markdown software, available here: https://github.com/cben/mathdown/wiki/Math-in-MarkDown#appendix-summary-table. I'd say probably the right answer is to do what pandoc does, and have $ ... $ to delimit inline formulae, and $$ ... $$ for display-mode.

@kivikakk
Copy link
Owner

I have indeed seen this feature request a number of times across a number of channels!

My primary goal for comrak is to implement GFM-compatible CommonMark and to leave it at that, but I think it could be valuable to implement experimental extensions (such as math). There's a number of threads on the CommonMark forums about implementing math in CommonMark, either directly or as an extension.

I don't have the time to implement such an extension myself, but I would welcome a PR.

@DemiMarie
Copy link
Contributor

I think that when math is enabled, we should use something like ${ to open math and }$ to close it. This is compatible (the opening { and closing } are simply ignored by TeX) and avoids many false positives on things such as item prices. In such cases, $ should be somehow escaped to avoid problems, and there should be a way to escape it in Markdown input.

@jeanm
Copy link
Author

jeanm commented Aug 6, 2017

No other parser uses this syntax. Is it really worth introducing something nonstandard?

The pandoc author claims that, with some simple heuristics, false positives are simply not an issue: https://talk.commonmark.org/t/ignore-latex-like-math-mode-or-parse-it/1926/6. My experience has matched his so far.

@DemiMarie
Copy link
Contributor

@jeanm You are probably correct. In that case Comrak will need to wrap $ in a <span> tag.

@digitalmoksha
Copy link
Collaborator

Working on support for this in #366

@digitalmoksha
Copy link
Collaborator

#366 is merged, implementing regular dollar math as well as code math. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants