diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index d5b9a56ba3..cae1c6c63e 100644 Binary files a/resources/compiled_coffeescript.zip and b/resources/compiled_coffeescript.zip differ diff --git a/src/calibre/ebooks/oeb/display/mathjax.coffee b/src/calibre/ebooks/oeb/display/mathjax.coffee index f45b1082b7..50a75cca6b 100644 --- a/src/calibre/ebooks/oeb/display/mathjax.coffee +++ b/src/calibre/ebooks/oeb/display/mathjax.coffee @@ -21,6 +21,7 @@ class MathJax this.math_present = false this.math_loaded = false this.pending_cfi = null + this.hub = null load_mathjax: (script) -> if this.base == null @@ -35,15 +36,19 @@ class MathJax script.type = 'text/javascript' script.src = 'file://' + this.base + '/MathJax.js' - script.text = ''' + script.text = script.text + ''' MathJax.Hub.Config({ positionToHash: false, showMathMenu: false, 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.Register.StartupHook("End", window.mathjax.load_finished); + window.mathjax.hub = MathJax.Hub ''' if created @@ -71,6 +76,14 @@ class MathJax this.math_present = true 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? window.mathjax = new MathJax() diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 6df5292ed9..6096216b3e 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -280,6 +280,7 @@ class Document(QWebPage): # {{{ if self.in_paged_mode: self.setPreferredContentsSize(QSize()) self.switch_to_paged_mode(onresize=True) + self.javascript('window.mathjax.after_resize()') def switch_to_fullscreen_mode(self): self.in_fullscreen_mode = True