User:Uni.Liu/modern.js

if ((window.unsafeWindow == null ? window : unsafeWindow).MathJax == null) { // // Replace the span with MathJax scripts of type math/tex // var spans = document.getElementsByTagName('span'), count = 0; for (var i = spans.length - 1; i >= 0; i--) { var sp = spans[i]; if (sp.className === "tex") { var script = document.createElement("script"); script.type = "math/tex"; if (/^\s*\$\s*([\S\s]*?)\s*\$\s*$/.test(sp.innerHTML)) {var str = '\\displaystyle '+RegExp.$1; script.text = str.replace(/&lt;/g,' < ').replace(/&gt;/g,' > ').replace(/ /g,'~').replace(/(\\)([NZQRC])($|[^A-Za-z])/g, '\\mathbb $2 $3').replace(/amp;/g,'&') }; sp.parentNode.replaceChild(script,sp); count++; } } if (count) { // // Load MathJax and have it process the page // var script = document.createElement("script"); script.src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"; //TeX-AMS-MML_HTMLorMML-full var config = 'MathJax.Hub.Startup.onload'; if (window.opera) {script.innerHTML = config} else {script.text = config} document.getElementsByTagName("head")[0].appendChild(script); } }