mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
E-book viewer: Fix errors when viewing books with mathematics that are split over multiple internal files. Fixes #1919033 [Unhandled mathjax loading related error in Viewer](https://bugs.launchpad.net/calibre/+bug/1919033)
This commit is contained in:
parent
de1dfc28e5
commit
f2d92d2060
@ -31,12 +31,27 @@ def load_mathjax(src):
|
|||||||
document.head.appendChild(script)
|
document.head.appendChild(script)
|
||||||
|
|
||||||
|
|
||||||
|
standalone_proceed_data = {
|
||||||
|
'link_uid': None,
|
||||||
|
'proceed': None,
|
||||||
|
'event_listender_added': False,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def standalone_proceed():
|
||||||
|
if standalone_proceed_data.proceed:
|
||||||
|
postprocess(standalone_proceed_data.link_uid)
|
||||||
|
standalone_proceed_data.proceed()
|
||||||
|
standalone_proceed_data.proceed = None
|
||||||
|
|
||||||
|
|
||||||
def apply_mathjax(mathjax_files, link_uid, proceed):
|
def apply_mathjax(mathjax_files, link_uid, proceed):
|
||||||
if runtime.is_standalone_viewer:
|
if runtime.is_standalone_viewer:
|
||||||
document.documentElement.addEventListener("calibre-mathjax-typeset-done", def(ev):
|
if not standalone_proceed_data.event_listender_added:
|
||||||
postprocess(link_uid)
|
standalone_proceed_data.event_listender_added = True
|
||||||
proceed()
|
document.documentElement.addEventListener("calibre-mathjax-typeset-done", standalone_proceed)
|
||||||
)
|
standalone_proceed_data.link_uid = link_uid
|
||||||
|
standalone_proceed_data.proceed = proceed
|
||||||
load_mathjax(f'{runtime.FAKE_PROTOCOL}://{runtime.SANDBOX_HOST}/mathjax/startup.js')
|
load_mathjax(f'{runtime.FAKE_PROTOCOL}://{runtime.SANDBOX_HOST}/mathjax/startup.js')
|
||||||
return
|
return
|
||||||
window.MathJax = v'{}'
|
window.MathJax = v'{}'
|
||||||
@ -65,7 +80,7 @@ def apply_mathjax(mathjax_files, link_uid, proceed):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# also do any changes in pdf-mathjax-loader.js for the standalone
|
# also do any changes in pdf-mathjax-loader.js for the standalone
|
||||||
# viewer/editor/pdf outpu
|
# viewer/editor/pdf output
|
||||||
window.MathJax.loader = {
|
window.MathJax.loader = {
|
||||||
'load': v"['input/tex-full', 'input/asciimath', 'input/mml', 'output/chtml']",
|
'load': v"['input/tex-full', 'input/asciimath', 'input/mml', 'output/chtml']",
|
||||||
'require': def (url):
|
'require': def (url):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user