Added errorHandler Improve MathJax Performance #83
@ -1,4 +1,3 @@
|
|||||||
// mathjax-config.js (New file for configuration)
|
|
||||||
window.MathJax = {
|
window.MathJax = {
|
||||||
tex: {
|
tex: {
|
||||||
inlineMath: [["\\(", "\\)"]],
|
inlineMath: [["\\(", "\\)"]],
|
||||||
@ -10,10 +9,9 @@ window.MathJax = {
|
|||||||
ignoreHtmlClass: ".*|",
|
ignoreHtmlClass: ".*|",
|
||||||
processHtmlClass: "arithmatex"
|
processHtmlClass: "arithmatex"
|
||||||
},
|
},
|
||||||
// Enable MathML output (refer to MathJax docs for customization)
|
|
||||||
mml: {
|
mml: {
|
||||||
output: {
|
output: {
|
||||||
font: "mathjax" // Or any preferred font
|
font: "mathjax"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startup: {
|
startup: {
|
||||||
@ -26,17 +24,14 @@ window.MathJax = {
|
|||||||
},
|
},
|
||||||
errorHandler: (errors) => {
|
errorHandler: (errors) => {
|
||||||
console.error("MathJax encountered errors:", errors);
|
console.error("MathJax encountered errors:", errors);
|
||||||
// Additional error handling to display user-friendly messages
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// In your main JavaScript file (e.g., where you include MathJax)
|
|
||||||
document$.subscribe(debounce(() => {
|
document$.subscribe(debounce(() => {
|
||||||
const mathElements = document.querySelectorAll('.arithmatex');
|
const mathElements = document.querySelectorAll('.arithmatex');
|
||||||
MathJax.typesetPromise(mathElements);
|
MathJax.typesetPromise(mathElements);
|
||||||
}, 250));
|
}, 250));
|
||||||
|
|
||||||
// Debounce function (You can use a library like Lodash or implement your own)
|
|
||||||
function debounce(func, wait) {
|
function debounce(func, wait) {
|
||||||
let timeout;
|
let timeout;
|
||||||
return function() {
|
return function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user