diff --git a/www/js/app.js b/www/js/app.js index 1eb36aab..b8afb0bb 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -3078,23 +3078,25 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'cook /[^\\](\$\$?)((?:\\\$|(?!\1)[\s\S])+)\1/.test(htmlArticle) : false; //Replace all TeX SVGs with MathJax scripts 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, '&'); - // Change any mbox commands to fbox (because KaTeX doesn't support mbox) - math = math.replace(/mbox{/g, 'fbox{'); - return ''; - }); // Deal with any newer MathML blocks htmlArticle = htmlArticle.replace(/(]+alttext=(["']))((?:[^"']|[\s\S](?!\2))+?)(\2(?:[^<]|<(?!\/math))+(?:[^<]|<(?!img))+)]+?class=["'][^"']*?mwe-math-fallback-image[^>]+>/ig, - function (_p0, p1, _p2, math, p4) { - // Remove any rogue ampersands in MathJax due to double escaping (by Wikipedia) - math = math.replace(/&/g, '&'); - // Change any mbox commands to fbox (because KaTeX doesn't support mbox) - math = math.replace(/mbox{/g, 'fbox{'); - return p1 + math + p4 + ''; - }); + function (_p0, p1, _p2, math, p4) { + // Remove any rogue ampersands in MathJax due to double escaping (by Wikipedia) + math = math.replace(/&/g, '&'); + // Change any mbox commands to fbox (because KaTeX doesn't support mbox) + math = math.replace(/mbox{/g, 'fbox{'); + return p1 + math + p4 + ''; + }); + // Older math blocks + 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, '&'); + // Change any mbox commands to fbox (because KaTeX doesn't support mbox) + math = math.replace(/mbox{/g, 'fbox{'); + return ''; + }); + } params.containsMathTex = params.useMathJax ? /