diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js index a80ddbff..de283336 100644 --- a/docs/javascripts/mathjax.js +++ b/docs/javascripts/mathjax.js @@ -8,9 +8,35 @@ window.MathJax = { options: { ignoreHtmlClass: ".*|", processHtmlClass: "arithmatex" + }, + mml: { + output: { + font: "mathjax" + } + }, + startup: { + ready() { + MathJax.startup.defaultReady(); + MathJax.Config({ + showErrorMessages: true, + }); + } + }, + errorHandler: (errors) => { + console.error("MathJax encountered errors:", errors); } }; -document$.subscribe(() => { - MathJax.typesetPromise() -}) \ No newline at end of file +document$.subscribe(debounce(() => { + const mathElements = document.querySelectorAll('.arithmatex'); + MathJax.typesetPromise(mathElements); +}, 250)); + +function debounce(func, wait) { + let timeout; + return function() { + const context = this, args = arguments; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; +} \ No newline at end of file