Skip to content

Commit 61123b2

Browse files
committed
Retypeset Mathjax after post content has been edited
1 parent e58ae54 commit 61123b2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

_files/js/inforge/bbmath/mathjax-loader.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,22 @@ window.MathJax = {
2424
script.async = true;
2525
document.head.appendChild(script);
2626
})();
27+
28+
function retypesetMathjax(post)
29+
{
30+
$(post).off('DOMSubtreeModified', postModifiedHandler);
31+
window.MathJax.typesetPromise().then(() => {
32+
$(post).on('DOMSubtreeModified', postModifiedHandler);
33+
}).catch((err) => console.log(err.message));
34+
}
35+
36+
function postModifiedHandler()
37+
{
38+
retypesetMathjax(this);
39+
}
40+
41+
$(window).on('load', function() {
42+
$('article.message, article.resourceBody-main, blockquote.message-body').each(function() {
43+
$(this).on('DOMSubtreeModified', postModifiedHandler);
44+
});
45+
});

0 commit comments

Comments
 (0)