Skip to content

Instantly share code, notes, and snippets.

@nkgsv
Last active May 2, 2020 14:45
Show Gist options
  • Save nkgsv/db4a65eb27a40f812f22782cab823755 to your computer and use it in GitHub Desktop.
Save nkgsv/db4a65eb27a40f812f22782cab823755 to your computer and use it in GitHub Desktop.
Enable MathJax on any web page
// Add the following bookmarklet:
// javascript:(async function () {var x = await fetch('https://gist.githubusercontent.com/nkgsv/db4a65eb27a40f812f22782cab823755/raw/bc09ef1d4bbabf3dbe9c5db1496161654a88f286/mathjax.js'); x = await x.text(); eval(x);})();
// or simply copy and paste the following code to Developer Console:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML';
document.head.appendChild(script);
var render = function() {
if (window.MathJax === undefined) {
window.setTimeout(render, 100);
} else {
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ["\(","\)"], ['$','$'] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { fonts: ["TeX"] }
});
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
}
}
render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment