Added errorHandler Improve MathJax Performance #83

Open
Vinay-Khanagavi wants to merge 2 commits from Vinay-Khanagavi/blender-developer-docs:main into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit fa0b0009a3 - Show all commits

View File

@ -1,3 +1,4 @@
// mathjax-config.js (New file for configuration)
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
@ -8,9 +9,39 @@ window.MathJax = {
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
},
// Enable MathML output (refer to MathJax docs for customization)
mml: {
output: {
font: "mathjax" // Or any preferred font
}
},
startup: {
ready() {
MathJax.startup.defaultReady();
MathJax.Config({
showErrorMessages: true,
});
}
},
errorHandler: (errors) => {
console.error("MathJax encountered errors:", errors);
// Additional error handling to display user-friendly messages
}
};
document$.subscribe(() => {
MathJax.typesetPromise()
})
// In your main JavaScript file (e.g., where you include MathJax)
document$.subscribe(debounce(() => {
const mathElements = document.querySelectorAll('.arithmatex');
MathJax.typesetPromise(mathElements);
}, 250));
// Debounce function (You can use a library like Lodash or implement your own)
function debounce(func, wait) {
let timeout;
return function() {
const context = this, args = arguments;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
};
}