Skip to content

Commit c4ef16d

Browse files
committed
Implement suggested workaround for erroneous extension loading with CHTML renderer.
This is an alternate for #2734, and implements the workaround suggested by @dpvc in mathjax/MathJax#3370 (comment).
1 parent 82ac1ff commit c4ef16d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

htdocs/js/MathJaxConfig/mathjax-config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ if (!window.MathJax) {
9898
AM.symbols.splice(i, 0, { input: trigger, ...newTriggers[trigger].symbols });
9999
}
100100

101+
// The following is a workaround for a bug in MathJax when the math renderer is changed.
102+
// Note that this should be removed when we have upgraded to MathJax 4.
103+
const { STATE } = MathJax._.core.MathItem;
104+
const { Menu } = MathJax._.ui.menu.Menu;
105+
const { mathjax } = MathJax._.mathjax;
106+
Menu.prototype.rerender = function (start = STATE.TYPESET) {
107+
this.rerenderStart = Math.min(start, this.rerenderStart);
108+
if (!Menu.loading) {
109+
if (this.rerenderStart <= STATE.COMPILED) this.document.reset({ inputJax: [] });
110+
MathJax.startup.promise.then(() => {
111+
mathjax.handleRetriesFor(() => {
112+
this.document.rerender(this.rerenderStart);
113+
this.rerenderStart = STATE.LAST;
114+
});
115+
});
116+
}
117+
};
118+
101119
return MathJax.startup.defaultReady();
102120
}
103121
},

0 commit comments

Comments
 (0)