Jump to content

User:Sevastien/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sevastien (talk | contribs) at 21:51, 6 October 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// add to User:YOURNAME/common.js to get smooth MathJax rendering
var mathTags = $('.mwe-math-mathml-a11y');
if (mathTags.length > 0){ //only do something when there's math on the page
  window.MathJax = {
    SVG: {blacker: 1}, // clearer SVG output, in case people switch to SVG output
  	AuthorInit: function () {
  	  MathJax.Hub.Register.StartupHook("End",function () { //when MathJax is done...
  	    MathJax.Hub.Queue(
  	    	function(){
  		     mathTags.removeClass('mwe-math-mathml-a11y'); // .. make the span around MathML (now MathJax output) visible
  	    	 $('.mwe-math-fallback-image-inline').addClass('mwe-math-mathml-a11y'); //remove the SVG image thingie
  	    	}
  	    );
  	  });
  	}
  };
  mw.loader.load('https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML');
}