mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
MathJax: Re-render on viewer resize to workaround lack of dynamic reflow with SVG output
This commit is contained in:
parent
5dbbf145af
commit
253a5ed165
Binary file not shown.
@ -21,6 +21,7 @@ class MathJax
|
|||||||
this.math_present = false
|
this.math_present = false
|
||||||
this.math_loaded = false
|
this.math_loaded = false
|
||||||
this.pending_cfi = null
|
this.pending_cfi = null
|
||||||
|
this.hub = null
|
||||||
|
|
||||||
load_mathjax: (script) ->
|
load_mathjax: (script) ->
|
||||||
if this.base == null
|
if this.base == null
|
||||||
@ -35,15 +36,19 @@ class MathJax
|
|||||||
script.type = 'text/javascript'
|
script.type = 'text/javascript'
|
||||||
script.src = 'file://' + this.base + '/MathJax.js'
|
script.src = 'file://' + this.base + '/MathJax.js'
|
||||||
|
|
||||||
script.text = '''
|
script.text = script.text + '''
|
||||||
MathJax.Hub.Config({
|
MathJax.Hub.Config({
|
||||||
positionToHash: false,
|
positionToHash: false,
|
||||||
showMathMenu: false,
|
showMathMenu: false,
|
||||||
extensions: ["tex2jax.js","asciimath2jax.js","mml2jax.js"],
|
extensions: ["tex2jax.js","asciimath2jax.js","mml2jax.js"],
|
||||||
jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"]
|
jax: ["input/TeX","input/MathML","input/AsciiMath","output/SVG"],
|
||||||
|
TeX: {
|
||||||
|
extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
MathJax.Hub.Startup.onload();
|
MathJax.Hub.Startup.onload();
|
||||||
MathJax.Hub.Register.StartupHook("End", window.mathjax.load_finished);
|
MathJax.Hub.Register.StartupHook("End", window.mathjax.load_finished);
|
||||||
|
window.mathjax.hub = MathJax.Hub
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if created
|
if created
|
||||||
@ -71,6 +76,14 @@ class MathJax
|
|||||||
this.math_present = true
|
this.math_present = true
|
||||||
this.load_mathjax(script)
|
this.load_mathjax(script)
|
||||||
|
|
||||||
|
after_resize: () ->
|
||||||
|
if not this.math_present or this.hub == null
|
||||||
|
return
|
||||||
|
# SVG output does not dynamically reflow on resize, so we manually
|
||||||
|
# rerender, this is slow, but neccessary for tables and equation
|
||||||
|
# numbers.
|
||||||
|
this.hub.Queue(["Rerender",this.hub])
|
||||||
|
|
||||||
if window?
|
if window?
|
||||||
window.mathjax = new MathJax()
|
window.mathjax = new MathJax()
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ class Document(QWebPage): # {{{
|
|||||||
if self.in_paged_mode:
|
if self.in_paged_mode:
|
||||||
self.setPreferredContentsSize(QSize())
|
self.setPreferredContentsSize(QSize())
|
||||||
self.switch_to_paged_mode(onresize=True)
|
self.switch_to_paged_mode(onresize=True)
|
||||||
|
self.javascript('window.mathjax.after_resize()')
|
||||||
|
|
||||||
def switch_to_fullscreen_mode(self):
|
def switch_to_fullscreen_mode(self):
|
||||||
self.in_fullscreen_mode = True
|
self.in_fullscreen_mode = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user