Feature request: math #208

Closed
opened this issue Aug 29, 2016 · 9 comments

krey commented Aug 29, 2016 • edited

 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 commented Sep 15, 2016

 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.
Author

krey commented Sep 15, 2016

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

JasonYao commented Sep 15, 2016

 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.
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
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 = """ """ 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  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 commented Mar 7, 2017 • edited

 @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 commented Jun 23, 2017

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

ludaavics commented Mar 9, 2018

 @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 commented May 29, 2019

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