Skip to content

Instantly share code, notes, and snippets.

@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>
@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 / 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 / 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 / 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 / gist:5601181
Created May 17, 2013 18:57
MathJax bookmarklet for Springer LaTeX search http://latexsearch.com/
javascript:(function(){ var s=document.createElement('script'); s.setAttribute('src','http://code.jquery.com/jquery.js'); document.getElementsByTagName('body')[0].appendChild(s); $('.img_overflow > img').wrap('<span class="MathJax_Preview" />'); $('.MathJax_Preview').after(function() { tex = $(this).find('img').attr("title"); return " <script type='math/tex'>" + tex + "</" + "script>" ;}); var s=document.create
var id_mathjax_plugin;
(function() {
var mjp = id_mathjax_plugin = {
load_mathjax: function() {
function e(e){var t='.MathJax .mn {background: inherit;} .MathJax .mi {color: inherit;} .MathJax .mo {background: inherit;}',n=e.createElement('style');n.innerText=t;try{n.textContent=t}catch(r){}e.getElementsByTagName('body')[0].appendChild(n);var i=e.createElement('script'),s;i.src='https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js',i.type='text/javascript',s='MathJax.Hub.Config({skipStartupTypeset:true,tex2jax:{inlineMath:[[\'$\',\'$\']],displayMath:[[\'\\\\[\',\'\\\\]\']],processEscapes:true}});MathJax.Hub.Startup.onload();',window.opera?i.innerHTML=s:i.text=s,e.getElementsByTagName('head')[0].appendChild(i)}function t(t){t.MathJax===undefined?e(t.document):t.MathJax.Hub.Queue(new t.Array('Typeset',t.MathJax.Hub))}var n=document.getElementsByTagName('iframe'),r,i;t(window);for(r=0;r<n.length;r++)i=n[r].contentWindow||n[r].contentDocument,i.document||(i=i.parentN
@pkra
pkra / test.svg
Last active August 29, 2015 14:07
svg equation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pkra
pkra / lens-jats-math.xml
Last active August 29, 2015 14:07
Lens: JATS sample for math-related issues.
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD with MathML3 v1.1d1 20130915//EN" "JATS-archivearticle1-mathml3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en" dtd-version="1.1d1">
<front>
<journal-meta>
<publisher>
<publisher-name>American Mathematical Society</publisher-name>
</publisher>
</journal-meta>
<article-meta>
@pkra
pkra / config.js
Created January 2, 2015 21:41
mathjax custom configuration test (mathjax-user group question)
window.MathJax = {
jax: ["input/TeX", "output/HTML-CSS"],
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js",
"TeX/noUndefined.js"],
TeX: {
Macros: {
RR: '{\\bf R}',
bold: ['{\\bf #1}', 1],
pd: ["{\\frac{\\partial #1}{\\partial #2}}",2],
// etc....