mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix loading of mathjax files
This commit is contained in:
parent
bd99a17186
commit
a3ac8282d4
@ -25,14 +25,14 @@ function monkeypatch(mathjax_files) {
|
|||||||
var name = ans.replace(/^\\//g, '');
|
var name = ans.replace(/^\\//g, '');
|
||||||
if (name.startsWith('../fonts')) name = name.slice(3);
|
if (name.startsWith('../fonts')) name = name.slice(3);
|
||||||
ans = mathjax_files[name];
|
ans = mathjax_files[name];
|
||||||
if (!ans) ans = '';
|
if (!ans) ans = name;
|
||||||
if (typeof ans !== 'string') {
|
if (typeof ans !== 'string') {
|
||||||
mathjax_files[name] = window.URL.createObjectURL(ans);
|
mathjax_files[name] = window.URL.createObjectURL(ans);
|
||||||
ans = mathjax_files[name];
|
ans = mathjax_files[name];
|
||||||
}
|
}
|
||||||
if (ans === name && !name.startsWith('blob:')) {
|
if (ans === name && !name.startsWith('blob:')) {
|
||||||
if (ans.endsWith('.eot') || ans.endsWith('.otf')) return '';
|
if (ans.endsWith('.eot') || ans.endsWith('.otf')) ans = '';
|
||||||
console.log('WARNING: Failed to resolve MathJax file: ' + mathjax_name);
|
else console.log('WARNING: Failed to resolve MathJax file: ' + mathjax_name);
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,7 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
|
|||||||
rq.fail(rq.RequestFailed)
|
rq.fail(rq.RequestFailed)
|
||||||
return
|
return
|
||||||
if 'MathJax.js' in name:
|
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')
|
raw = monkeypatch_mathjax(raw.decode('utf-8')).encode('utf-8')
|
||||||
|
|
||||||
self.send_reply(rq, mt, raw)
|
self.send_reply(rq, mt, raw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user