Skip to content

Instantly share code, notes, and snippets.

@pkra
pkra / mathjax-node-simple-perf1.js
Created July 2, 2015 20:27
MathJax Node mjsingle test
var mjAPI = require("./lib/mj-single.js");
mjAPI.start();
var start = Date.now();
for (var i = 0; i < 100; i++) {
var input = "\\sqrt{f: X \\to Y }" + i;
console.log("\\[" + input + "\\]");
mjAPI.typeset({
math: input,
format: "TeX", // "inline-TeX", "MathML"
svg: true
@pkra
pkra / mathjax-node-simple-perf2.js
Created July 2, 2015 20:27
MathJax-node mjpage test
var mjAPI = require("./lib/mj-page.js");
var jsdom = require("jsdom").jsdom;
var document = jsdom("<!DOCTYPE html><html lang='en'><head><title>Test</title></head><body>\\[\sqrt{f: X \to Y }0\\]\\[\sqrt{f: X \to Y }1\\]\\[\sqrt{f: X \to Y }2\\]\\[\sqrt{f: X \to Y }3\\]\\[\sqrt{f: X \to Y }4\\]\\[\sqrt{f: X \to Y }5\\]\\[\sqrt{f: X \to Y }6\\]\\[\sqrt{f: X \to Y }7\\]\\[\sqrt{f: X \to Y }8\\]\\[\sqrt{f: X \to Y }9\\]\\[\sqrt{f: X \to Y }10\\]\\[\sqrt{f: X \to Y }11\\]\\[\sqrt{f: X \to Y }12\\]\\[\sqrt{f: X \to Y }13\\]\\[\sqrt{f: X \to Y }14\\]\\[\sqrt{f: X \to Y }15\\]\\[\sqrt{f: X \to Y }16\\]\\[\sqrt{f: X \to Y }17\\]\\[\sqrt{f: X \to Y }18\\]\\[\sqrt{f: X \to Y }19\\]\\[\sqrt{f: X \to Y }20\\]\\[\sqrt{f: X \to Y }21\\]\\[\sqrt{f: X \to Y }22\\]\\[\sqrt{f: X \to Y }23\\]\\[\sqrt{f: X \to Y }24\\]\\[\sqrt{f: X \to Y }25\\]\\[\sqrt{f: X \to Y }26\\]\\[\sqrt{f: X \to Y }27\\]\\[\sqrt{f: X \to Y }28\\]\\[\sqrt{f: X \to Y }29\\]\\[\sqrt{f: X \to Y }30\\]\\[\sqrt{f: X \to Y }31\\]\\[\sqrt{f: X \to Y }32\\]\\[\sqr
<!DOCTYPE html>
<html>
<head>
<title>MathJax AssistiveMML Test Page</title>
<!-- Copyright (c) 2015 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
@pkra
pkra / mathjax-accessiblemenu.html
Last active September 16, 2015 10:35
Development version of MathJax's now-accessible menu
<!DOCTYPE html>
<html>
<head>
<title>MathJax Accessible Menu Test Page</title>
<!-- Copyright (c) 2015 The MathJax Consortium -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
jax: ["input/TeX","output/HTML-CSS"],
@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 / 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