@@ -25,21 +25,24 @@ window.MathJax = {
2525 document . head . appendChild ( script ) ;
2626} ) ( ) ;
2727
28- function retypesetMathjax ( post )
28+ var retypesetDisabled = false ;
29+
30+ function retypesetMathjax ( )
2931{
30- $ ( post ) . off ( 'DOMSubtreeModified' , postModifiedHandler ) ;
32+ $ ( this ) . off ( 'DOMSubtreeModified' , retypesetMathjax ) ;
33+ if ( retypesetDisabled ) {
34+ setTimeout ( retypesetMathjax , 500 ) ;
35+ return ;
36+ }
37+ retypesetDisabled = true ;
38+ $ ( this ) . on ( 'DOMSubtreeModified' , retypesetMathjax ) ;
3139 window . MathJax . typesetPromise ( ) . then ( ( ) => {
32- $ ( post ) . on ( 'DOMSubtreeModified' , postModifiedHandler ) ;
40+ retypesetDisabled = false ;
3341 } ) . catch ( ( err ) => console . log ( err . message ) ) ;
3442}
3543
36- function postModifiedHandler ( )
37- {
38- retypesetMathjax ( this ) ;
39- }
40-
4144$ ( window ) . on ( 'load' , function ( ) {
4245 $ ( 'article.message, article.resourceBody-main, blockquote.message-body' ) . each ( function ( ) {
43- $ ( this ) . on ( 'DOMSubtreeModified' , postModifiedHandler ) ;
46+ $ ( this ) . on ( 'DOMSubtreeModified' , retypesetMathjax ) ;
4447 } ) ;
4548} ) ;
0 commit comments