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

Math engine support ($$ $$) #80

Closed
glebm opened this issue Oct 16, 2018 · 4 comments
Closed

Math engine support ($$ $$) #80

glebm opened this issue Oct 16, 2018 · 4 comments

Comments

@glebm
Copy link

glebm commented Oct 16, 2018

Kramdown provides math engine support, via $$ (block) and $ (inline).

Implementing an engine is fairly simple. For example, here is my KaTeX implementation: https://github.com/gettalong/kramdown/blob/master/lib/kramdown/converter/math_engine/katex.rb

Is this possible with commonmarker and if so, how?

@gjtorikian
Copy link
Owner

Thanks for the feedback.

I think we are going to explicitly keep this gem bound to the Commonmark spec.

However, please consider using https://github.com/gjtorikian/mathematical, which parses LaTeX symbols and converts them into math-rendered SVGs. You could tie this up with something like https://github.com/jch/html-pipeline to provide a full pass conversion.

Alternative, you are free to create your own custom renderer as a plugin/add-on: https://github.com/gjtorikian/commonmarker#creating-a-custom-renderer

I just want to keep this gem in particular specific to the spec.

@glebm
Copy link
Author

glebm commented Oct 16, 2018

However, please consider using gjtorikian/mathematical,

I'm not looking for a particular math engine.

You could tie this up with something like jch/html-pipeline to provide a full pass conversion.

A solution involving html-pipeline is bound to have quirky edge cases. Consider that: markdown inside $$ should not be processed; $$ inside a code-block should not be processed as math; etc.

Alternative, you are free to create your own custom renderer as a plugin/add-on: gjtorikian/commonmarker#creating-a-custom-renderer

Yes, this is my question. How would I define a custom renderer for $$ $$ / $ $?

There is a lot of results for "math" on CommonMark Discourse: https://talk.commonmark.org/search?q=math

Some of them mention extensions and no-markdown islands but I don't know if any of that was ever implemented. GitLab recently switch to CommonMark and they work around the issue by requiring math tags to be wrapped in backticks:

https://github.com/gitlabhq/gitlabhq/blob/04845fdeae75ba5de7c93992a5d55663edf647e0/lib/banzai/filter/math_filter.rb#L7

Is the custom renderer API powerful enough to support this use case?

@j7168908jx
Copy link

As requested by my boss, I've patched a little to support part of LaTeX math equations (using directly $ ... $ and $$ ... $$). If anyone is interested, please see my forked repo: https://github.com/j7168908jx/commonmarker

@gjtorikian
Copy link
Owner

Honestly that's really cool. You should ask the Commonmark folks to include this as an extension in the spec.

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

No branches or pull requests

3 participants