Added errorHandler Improve MathJax Performance #83
@ -1,3 +1,4 @@
|
|||||||
|
// mathjax-config.js (New file for configuration)
|
||||||
window.MathJax = {
|
window.MathJax = {
|
||||||
tex: {
|
tex: {
|
||||||
inlineMath: [["\\(", "\\)"]],
|
inlineMath: [["\\(", "\\)"]],
|
||||||
@ -8,9 +9,39 @@ window.MathJax = {
|
|||||||
options: {
|
options: {
|
||||||
ignoreHtmlClass: ".*|",
|
ignoreHtmlClass: ".*|",
|
||||||
processHtmlClass: "arithmatex"
|
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(() => {
|
// In your main JavaScript file (e.g., where you include MathJax)
|
||||||
MathJax.typesetPromise()
|
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);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user