MathTran bookmarklet

From Mathtran

Jump to: navigation, search

Create a new bookmark in your web browser (you can do this by bookmarking any random page, then editing the bookmark's properties). Give it a name like "Mathtran this page", and set its URL to be:

javascript:(function(){function searchWithinNode(node,re){var pos,imgnnode,middlebit,endbitskip=0;if(node.nodeType==3){pos=node.data.search(re);if(pos>=0){middlebit=node.splitText(pos);endbit=middlebit.splitText(RegExp.lastMatch.length);imgnode=document.createElement(%22img%22);imgnode.src=%22http://www.mathtran.org/cgi-bin/mathtran?tex=%22 + encodeURI(middlebit.data).replace(%22+%22,%22%252B%22);middlebit.parentNode.replaceChild(imgnode,middlebit);}}else if(node.nodeType==1&& node.childNodes){for (var child=0; child < node.childNodes.length; ++child){searchWithinNode(node.childNodes[child], re);}}}searchWithinNode(document.body, /\$\$(.*?)\$\$/);})();

Then when you are looking at a web page with embedded TeX surrounded by $$ (for example http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations#Notation_used_in_the_calculations), if you select this bookmark, it will replace the TeX with calls to MathTran.

Personal tools