From a3ac8282d469920797f15a5ba87283df9224199e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Dec 2018 18:39:39 +0530 Subject: [PATCH] Fix loading of mathjax files --- src/calibre/gui2/viewer2/mathjax.py | 6 +++--- src/calibre/gui2/viewer2/web_view.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/viewer2/mathjax.py b/src/calibre/gui2/viewer2/mathjax.py index ce9cafbe30..b48e384175 100644 --- a/src/calibre/gui2/viewer2/mathjax.py +++ b/src/calibre/gui2/viewer2/mathjax.py @@ -25,14 +25,14 @@ function monkeypatch(mathjax_files) { var name = ans.replace(/^\\//g, ''); if (name.startsWith('../fonts')) name = name.slice(3); ans = mathjax_files[name]; - if (!ans) ans = ''; + if (!ans) ans = name; if (typeof ans !== 'string') { mathjax_files[name] = window.URL.createObjectURL(ans); ans = mathjax_files[name]; } if (ans === name && !name.startsWith('blob:')) { - if (ans.endsWith('.eot') || ans.endsWith('.otf')) return ''; - console.log('WARNING: Failed to resolve MathJax file: ' + mathjax_name); + if (ans.endsWith('.eot') || ans.endsWith('.otf')) ans = ''; + else console.log('WARNING: Failed to resolve MathJax file: ' + mathjax_name); } return ans; } diff --git a/src/calibre/gui2/viewer2/web_view.py b/src/calibre/gui2/viewer2/web_view.py index 92f851181a..9f97fd92f6 100644 --- a/src/calibre/gui2/viewer2/web_view.py +++ b/src/calibre/gui2/viewer2/web_view.py @@ -119,6 +119,7 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler): rq.fail(rq.RequestFailed) return if 'MathJax.js' in name: + # raw = open(os.path.expanduser('~/work/mathjax/unpacked/MathJax.js')).read() raw = monkeypatch_mathjax(raw.decode('utf-8')).encode('utf-8') self.send_reply(rq, mt, raw)