@@ -25,21 +25,24 @@ window.MathJax = {
25
25
document . head . appendChild ( script ) ;
26
26
} ) ( ) ;
27
27
28
- function retypesetMathjax ( post )
28
+ var retypesetDisabled = false ;
29
+
30
+ function retypesetMathjax ( )
29
31
{
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 ) ;
31
39
window . MathJax . typesetPromise ( ) . then ( ( ) => {
32
- $ ( post ) . on ( 'DOMSubtreeModified' , postModifiedHandler ) ;
40
+ retypesetDisabled = false ;
33
41
} ) . catch ( ( err ) => console . log ( err . message ) ) ;
34
42
}
35
43
36
- function postModifiedHandler ( )
37
- {
38
- retypesetMathjax ( this ) ;
39
- }
40
-
41
44
$ ( window ) . on ( 'load' , function ( ) {
42
45
$ ( 'article.message, article.resourceBody-main, blockquote.message-body' ) . each ( function ( ) {
43
- $ ( this ) . on ( 'DOMSubtreeModified' , postModifiedHandler ) ;
46
+ $ ( this ) . on ( 'DOMSubtreeModified' , retypesetMathjax ) ;
44
47
} ) ;
45
48
} ) ;
0 commit comments