Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathjax support in github using a Chrome browser plugin?

Tags:

github

r

mathjax

I'd like Mathjax to work on all my github pages (e.g., Markdown displayed on github, issue trackers). I have a lot of files generated from R Markdown that also have equations.

While I'd love github to provide optional support for Mathjax, I thought a more realistic aim would be to have some browser plugin that detects that I'm on a github page and automatically runs the mathjax script.

  • Are there any browser plugins for the Chrome browser that automatically run a MathJaX script on specified URLs (e.g., http*github*)?

Initial thoughts

There's quite a long discussion on MathOverflow. However, the discussion includes discussion of a range of technologies (not just MathJax) and many of the solutions are specific to the Firefox browser.

like image 851
Jeromy Anglim Avatar asked Jun 29 '12 04:06

Jeromy Anglim


People also ask

Does GitHub support MathJax?

GitHub supports Latex/MathJax since May 2022.

How do I use MathJax on GitHub?

you can use Mathjax on Github Page by adding next code in tag in your html code. sorry, adding code is "vincenttam.github.io/javascripts/MathJaxLocal.js" after cdn.mathjax.org/mathjax/latest/…

Is MathJax open source?

MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.


1 Answers

Here is a GreaseMonkey script that should do what you want: Run MathJax in Github. It should work in all the major browser (though some need plugins to run GreaseMonkey scripts; see the installation instructions for this question for details).

This script only loads MathJax on pages that contain TeX or MathML markup (it does a very simple test for that, which certainly could be made more sophisticated). Note that the default delimiters are \(...\) for in-line math and \[...\] or $$...$$ for displayed math. In particular, single-dollars aren't enable as math delimiters (since they occur too frequently in ordinary non-math text). If you wanted to enable single-dollar delimiters, you would need to edit the script to add a MathJax configuration script prior to loading MathJax.js itself.

The script is set to trigger on http://github.com/* and https://github.com/*. Not all the GreaseMonkey implementations provide for pattern matching in the host part of the URL, but if yours does, you can make it more sophisticated so that it will get subdomains of github as well.

Hope that does what you need.

Edit: The script now enables $...$ for in-line math, as requested by the asker.

like image 169
Davide Cervone Avatar answered Nov 09 '22 02:11

Davide Cervone