Created
November 21, 2014 16:49
-
-
Save ahmadia/7ec4ff166464526aca4f to your computer and use it in GitHub Desktop.
Run MathJax in GitHub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Run MathJax in Github | |
// @namespace http://www.mathjax.org/ | |
// @description Runs MathJax on any page in github.com | |
// @include http://github.com/* | |
// @include https://github.com/* | |
// ==/UserScript== | |
/*****************************************************************/ | |
(function () { | |
function LoadMathJax() { | |
if (!window.MathJax) { | |
if (document.body.innerHTML.match(/$|\\\[|\\\(|<([a-z]+:)math/)) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; | |
script.text = [ | |
"MathJax.Hub.Config({", | |
" tex2jax: {inlineMath: [['$','$'],['\\\\\(','\\\\\)']]}", | |
"});" | |
].join("\n"); | |
var parent = (document.head || document.body || document.documentElement); | |
parent.appendChild(script); | |
} | |
} | |
}; | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.text = "(" + LoadMathJax + ")()"; | |
var parent = (document.head || document.body || document.documentElement); | |
setTimeout(function () { | |
parent.appendChild(script); | |
parent.removeChild(script); | |
},0); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't write this, Davide Cervone did: http://www.math.union.edu/~dpvc/transfer/mathjax/mathjax-in-github.user.js