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

Feature request: math #208

Closed
krey opened this issue Aug 29, 2016 · 16 comments
Closed

Feature request: math #208

krey opened this issue Aug 29, 2016 · 16 comments

Comments

@krey
Copy link

krey commented Aug 29, 2016

While GitHub does not support the insertion of latex into markdown, it would be a very useful feature for grip.
In-browser this can be using MathJax

@JasonYao
Copy link

Why bother if the README file is to be displayed on github anyways? This sounds like it should be a feature request for github's README renderer, not for grip.

@krey
Copy link
Author

krey commented Sep 15, 2016

@JasonYao: I wasn't talking about README files, I'm thinking of .md files in general

@JasonYao
Copy link

Right, I'm saying that if the github .md renderer doesn't render latex code, why would grip want to render it?

The main purpose of grip is to preview .md files and see how they'd look on github, if grip adds this and starts diverging from what github displays, then it defeats the purpose of grip in the first place.

@krey
Copy link
Author

krey commented Sep 15, 2016

@JasonYao: yeah, I guess it depends on what people wanna use this for. I've found that grip is one of the best markdown renderers out there and would like to use it as such.

If you're worried about divergence from github, make the LaTeX feature opt-in

@joeyespo
Copy link
Owner

joeyespo commented Dec 2, 2016

@krey Thanks for the kind words 😄

If you want to use Grip more generally, may I suggest using the Python API to inject the custom pieces you need? Something like:

# gripjax.py

from grip import GitHubRenderer, Grip

MATHJAX_SCRIPT = """
<script async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"></script>
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" onload="javascript:MathJax.Hub.Queue(['Typeset', MathJax.Hub]);">
"""

class MathJaxRenderer(GitHubRenderer):
    def patch(self, html):
        return super(MathJaxRenderer, self).patch(html) + MATHJAX_SCRIPT

Grip(renderer=MathJaxRenderer()).run()

Then run gripjax.py instead of grip.

Note that this is a bit of a hack. Namely, using patch instead of some dedicated scripts option. And the <img> trick so that the MathJax.Hub.Queue code will run on each auto-reload. (See this and this and this.)

I'm considering adding a way to more easily inject styles and scripts using the API or even globally with configuration. Until then, this should work for you. However, I don't plan to hardcode MathJax or any other custom library into this repo.

Hope this helps!

@ludaavics
Copy link

ludaavics commented Mar 7, 2017

@joeyespo Thanks for this!
FWIW, I am in the same boat as @krey and use grip as my go to renderer and this worked like a charm. I would definitely use a "clean" way of adding MathJax support!

@drorata
Copy link

drorata commented Jun 23, 2017

I'll just put it here: github/markup#897

@ludaavics
Copy link

@joeyespo it looks like f17a68a broke this quick fix.
Have you given more thoughts on allowing to inject custom scripts? I see there is now an option for styles, but doesn't look like there is one for scripts -- let me know if missing something.

This is out of my wheelhouse, but happy to work on it to the extent that I can help

@ztlevi
Copy link

ztlevi commented May 29, 2019

It looks like github now support math equations. How can we achieve with grip?

@nh2
Copy link

nh2 commented Nov 15, 2019

It looks like github now support math equations

@ztlevi Is that true? Source or link to how it works?

@nh2
Copy link

nh2 commented Nov 15, 2019

@joeyespo it looks like f17a68a broke this quick fix.

@joeyespo Does the current API still allow injecting custom scripts?

It would be extremely useful for my project to support that.

@ztlevi
Copy link

ztlevi commented Nov 16, 2019

@nh2 I forget where I see it. But I just did a little google, and it turns out Gitlab supports it natively https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#math

@nh2
Copy link

nh2 commented Nov 16, 2019

@ztlevi Ah, that's Gitlab though, not Github.

Still interesting to know Gitlab supports it.

@INFCode
Copy link

INFCode commented Nov 11, 2022

Now GitHub supports math formulas (See this blog). Will this be supported by grip?

@dgilford
Copy link

dgilford commented Mar 9, 2023

It would be great to resurrect this, grip support for math to match GitHub previews would be very useful.

@xrchz
Copy link

xrchz commented May 8, 2024

Why does grip not support LaTeX? This is a feature in GitHub markdown. I thought grip was supposed to emulate GitHub?

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

10 participants