Skip to content

Instantly share code, notes, and snippets.

@pkra
pkra / wikipedia2mj.js
Last active March 7, 2017 02:10
Bookmarklet for Wikipedia, replacing PNGs on the fly
javascript:(function(){ var s=document.createElement('script');s.setAttribute('src','ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"');document.getElementsByTagName('body')[0].appendChild(s); $('img.tex').wrap('<span class="MathJax_Preview" />');$('.MathJax_Preview').after(function() { tex = $(this).find('img').attr("alt"); return " <script type='math/tex'>" + tex + "</" + "script>" ;});$.getScript('https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');})()
@pkra
pkra / WP2mj.js
Last active December 12, 2015 05:58
A bookmarklet, see https://en.wikipedia.org/wiki/Bookmarklet#Installation A fork of [this](https://gist.github.com/pkra/4574933) (in turn based on https://github.com/dzejkej/mathjax-bookmarklet and http://docs.mathjax.org/en/latest/dynamic.html). Modified for wordpress.com, trying to incorporate [Davide Cervone's answer](http://stackoverflow.com…
javascript:(function(){var images = document.getElementsByTagName('img'), count = 0; for (var i = images.length - 1; i >= 0; i--) { var img = images[i]; if (img.className === "latex") { var script = document.createElement("script"); script.type = "math/tex"; if (window.opera) {script.innerHTML = img.title} else {script.text = img.title} img.parentNode.replaceChild(script,img);count++; }};function a(a){var b=a.createElement('script'),c;b.src='https://c328740.ssl.cf1.rackcdn.com/mathjax/2.1-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js',b.type='text/javascript',c='MathJax.Hub.Config({tex2jax:{inlineMath:[[\'$\',\'$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true}});MathJax.Hub.Startup.onload();',window.opera?b.innerHTML=c:b.text=c,a.getElementsByTagName('head')[0].appendChild(b)}function b(b){b.MathJax===undefined?a(b.document):b.MathJax.Hub.Queue(new b.Array('Typeset',b.MathJax.Hub))}var c=document.getElementsByTagName('iframe'),d,e;b(window);for(d=0;d<c.length;d++)e=c[d].contentWi
@pkra
pkra / accessing_mathjax_mathml.html
Last active December 11, 2015 08:39
A MathJax sample that explains how to programatically access the MathML generated by MathJax. There's currently no public API for it, so this will get easier in the future.
<!DOCTYPE html>
<html>
<!--via Davide Cervone on the MathJax User Group https://groups.google.com/d/msg/mathjax-users/unL8IjcrTto/DjHpH4BbPRcJ -->
<head>
<title>MathJax TeX to MathML Page</title>
<script>
function toMathML(jax,callback) {
var mml;
try {
mml = jax.root.toMathML("");
@pkra
pkra / pic2MJ.js
Last active December 11, 2015 02:48
A MathJax bookmarklet for experimentation. It replaces images with their title -- hoping it's LaTeX source -- and calls MathJax to render the TeX. Note: replaces all images! Based on https://github.com/dzejkej/mathjax-bookmarklet and http://docs.mathjax.org/en/latest/dynamic.html Seems to works on wordpress.com // jetpack-LaTeX-images
javascript:(function(){var images = document.getElementsByTagName('img'), count = 0; for (var i = images.length - 1; i >= 0; i--) { var img = images[i]; var script = document.createElement("script"); script.type = "math/tex"; if (window.opera) {script.innerHTML = img.title} else {script.text = img.title} img.parentNode.replaceChild(script,img);count++; };function a(a){var b=a.createElement('script'),c;b.src='https://c328740.ssl.cf1.rackcdn.com/mathjax/2.1-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js',b.type='text/javascript',c='MathJax.Hub.Config({tex2jax:{inlineMath:[[\'$\',\'$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true}});MathJax.Hub.Startup.onload();',window.opera?b.innerHTML=c:b.text=c,a.getElementsByTagName('head')[0].appendChild(b)}function b(b){b.MathJax===undefined?a(b.document):b.MathJax.Hub.Queue(new b.Array('Typeset',b.MathJax.Hub))}var c=document.getElementsByTagName('iframe'),d,e;b(window);for(d=0;d<c.length;d++)e=c[d].contentWindow||c[d].contentDocument,e.document||(e=e
@pkra
pkra / gist:4390002
Created December 27, 2012 17:12
Render Mathjax Formula in a dynamically rendered element From the MathJax User Group, https://groups.google.com/d/topic/mathjax-users/GlN4tppMxyA/discussion
<html>
<head>
<title>Interactive MathML display</title>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js">
MathJax.Hub.Config({
extensions: ["mml2jax.js"],
jax: ["input/MathML", "output/HTML-CSS"]
});
</script>
</head>