mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-08 11:48:26 -04:00
parent
cf0dfc73f2
commit
b971457af7
@ -6442,17 +6442,8 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Replace all TeX SVGs with MathJax scripts
|
// Replace all TeX SVGs with MathJax scripts
|
||||||
if (params.useMathJax) {
|
if (params.useMathJax && appstate.wikimediaZimLoaded) {
|
||||||
// Deal with any newer MathML blocks
|
// Make any Wikimedia MathJax compatible with KaTeX
|
||||||
htmlArticle = htmlArticle.replace(/(<math\b[^>]+alttext=(["']))((?:[^"']|[\s\S](?!\2))+?)(\2(?:[^<]|<(?!\/math))+(?:[^<]|<(?!img))+)<img\b[^>]+?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 + '<script type="math/tex">' + math + '</script>';
|
|
||||||
});
|
|
||||||
// Older math blocks
|
|
||||||
htmlArticle = htmlArticle.replace(/<img\s+(?=[^>]+?math-fallback-image)[^>]*?alt\s*=\s*(['"])((?:[^"']|(?!\1)[\s\S])+)[^>]+>/ig,
|
htmlArticle = htmlArticle.replace(/<img\s+(?=[^>]+?math-fallback-image)[^>]*?alt\s*=\s*(['"])((?:[^"']|(?!\1)[\s\S])+)[^>]+>/ig,
|
||||||
function (p0, p1, math) {
|
function (p0, p1, math) {
|
||||||
// Remove any rogue ampersands in MathJax due to double escaping (by Wikipedia)
|
// Remove any rogue ampersands in MathJax due to double escaping (by Wikipedia)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user