diff --git a/www/js/app.js b/www/js/app.js
index 5f39ad9c..100cd164 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -2424,8 +2424,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'images', 'cookies', 'q', 'trans
htmlArticle = htmlArticle.replace(/href\s*=\s*["']javascript:[^"']+["']/gi, 'href=""');
//MathJax detection:
- params.containsMathTexRaw = params.useMathJax && /stackexchange|askubuntu|superuser|stackoverflow|mathoverflow|serverfault|stackapps/i.test(params.storedFile) ?
- /(\$\$?)((?:\\(?!\\\$)[\s\S]|(?!\1)[\s\S])+)\1(?:[\s<.,;:?!'")([{\]-])/.test(htmlArticle) : false;
+ params.containsMathTexRaw = params.useMathJax &&
+ /stackexchange|askubuntu|superuser|stackoverflow|mathoverflow|serverfault|stackapps/i.test(params.storedFile) ?
+ /[^\\](\$\$?)((?:\\\$|(?!\1)[\s\S])+)\1/.test(htmlArticle) : false;
+ // Below regex is a more complex version, probably erroneous
+ // /(\$\$?)((?:\\(?!\\\$)[\s\S]|(?!\1)[\s\S])+)\1(?:[\s<.,;:?!'")([{\]-])/.test(htmlArticle) : false;
//Simplify any configuration script
//if (params.containsMathTexRaw) htmlArticle = htmlArticle.replace(/(';
- });
- }
+ // if (params.useMathJax) {
+ // htmlArticle = htmlArticle.replace(/
]+?math-fallback-image)[^>]*?alt\s*=\s*(['"])((?:[^"']|(?!\1)[\s\S])+)[^>]+>/ig, function (p0, p1, math) {
+ // // Remove any rogue ampersands in MathJax due to double escaping (by Wikipedia)
+ // math = math.replace(/&/g, '&');
+ // return '';
+ // });
+ // }
params.containsMathTex = params.useMathJax ? /