mathjax plugin updates #531
authorHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 12:53:31 +0000 (08:53 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Tue, 13 Aug 2013 12:53:41 +0000 (08:53 -0400)
examples/math.html
plugin/math/math.js

index 7d3eba2951a122a316fe8a411c8f8524dd7df1ae..867c45eeb3af4b99955c679c659d3082d6c4c52b 100644 (file)
                                transition: 'linear',
 
                                math: {
-                                       // host: 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
-                                       mode: 'TeX-AMS_HTML-full'
+                                       // mathjax: 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
+                                       dialect: 'TeX-AMS_HTML-full'
                                },
 
                                dependencies: [
index d021fdc305736dae7f02a4e0f27a1481412a2bbf..104d0e594c2fa642fcb2999afe04363b72266ec5 100755 (executable)
@@ -7,25 +7,26 @@
 var RevealMath = window.RevealMath || (function(){
 
        var config = Reveal.getConfig().math || {};
-       config.host = config.host || 'http://cdn.mathjax.org/mathjax/latest/MathJax.js';
-       config.mode = config.mode || 'TeX-AMS_HTML-full';
+       config.mathjax = config.mathjax || 'http://cdn.mathjax.org/mathjax/latest/MathJax.js';
+       config.dialect = config.dialect || 'TeX-AMS_HTML-full';
 
-       loadScript( config.host + '?config=' + config.mode, function() {
+       loadScript( config.mathjax + '?config=' + config.dialect, function() {
 
                MathJax.Hub.Config({
                        messageStyle: 'none',
-                       tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }
+                       tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] },
+                       skipStartupTypeset: true
                });
 
-               // Process any math inside of the current slide when navigating,
-               // this is needed since it's not possible to typeset equations
-               // within invisible elements (far future or past).
+               // Typeset followed by an immediate reveal.js layout since
+               // the typesetting process could affect slide height
+               MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub ] );
+               MathJax.Hub.Queue( Reveal.layout );
+
+               // Reprocess equations in slides when they turn visible
                Reveal.addEventListener( 'slidechanged', function( event ) {
 
-                       // This will only typeset equations that have not yet been
-                       // processed, as well as equations that have change since
-                       // last being processed.
-                       MathJax.Hub.Update( event.currentSlide );
+                       MathJax.Hub.Queue( [ 'Typeset', MathJax.Hub, event.currentSlide ] );
 
                } );