Handle loading of CommonHTML jax better (do it when we detect it is not present, rather than trying to hook into the input jax require array).
This commit is contained in:
parent
d128cfbd5d
commit
ff6d6935df
|
@ -39,7 +39,7 @@
|
||||||
//
|
//
|
||||||
config: HUB.CombineConfig("CHTML-preview",{
|
config: HUB.CombineConfig("CHTML-preview",{
|
||||||
Chunks: {EqnChunk: 10000, EqnChunkFactor: 1, EqnChunkDelay: 0},
|
Chunks: {EqnChunk: 10000, EqnChunkFactor: 1, EqnChunkDelay: 0},
|
||||||
color: "inherit",
|
color: "inherit!important",
|
||||||
updateTime: 10, updateDelay: 10,
|
updateTime: 10, updateDelay: 10,
|
||||||
messageStyle: "none",
|
messageStyle: "none",
|
||||||
disabled: false
|
disabled: false
|
||||||
|
@ -56,6 +56,7 @@
|
||||||
MathJax.Ajax.Styles({".MathJax_Preview":{color:this.config.color}});
|
MathJax.Ajax.Styles({".MathJax_Preview":{color:this.config.color}});
|
||||||
var update, delay, style, done, saved;
|
var update, delay, style, done, saved;
|
||||||
var config = this.config;
|
var config = this.config;
|
||||||
|
|
||||||
HUB.Register.MessageHook("Begin Math Output",function () {
|
HUB.Register.MessageHook("Begin Math Output",function () {
|
||||||
if (!done && !config.disabled && SETTINGS.CHTMLpreview &&
|
if (!done && !config.disabled && SETTINGS.CHTMLpreview &&
|
||||||
SETTINGS.renderer !== "CommonHTML") {
|
SETTINGS.renderer !== "CommonHTML") {
|
||||||
|
@ -97,25 +98,28 @@
|
||||||
try {
|
try {
|
||||||
data.math.root.toCommonHTML(preview);
|
data.math.root.toCommonHTML(preview);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
//
|
||||||
|
// Load the CommonHTML jax if it is not already loaded
|
||||||
|
//
|
||||||
|
if (!data.math.root.toCommonHTML) {
|
||||||
|
var queue = MathJax.Callback.Queue();
|
||||||
|
HUB.RestartAfter(queue.Push(
|
||||||
|
["Require",MathJax.Ajax,"[MathJax]/jax/output/CommonHTML/config.js"],
|
||||||
|
["Require",MathJax.Ajax,"[MathJax]/jax/output/CommonHTML/jax.js"]
|
||||||
|
));
|
||||||
|
}
|
||||||
if (!err.restart) {throw err} // an actual error
|
if (!err.restart) {throw err} // an actual error
|
||||||
return MathJax.Callback.After(["postFilter",this,preview,data],err.restart);
|
return MathJax.Callback.After(["postFilter",this,preview,data],err.restart);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hook into the inut jax postFilter to create the previews as
|
// Hook into the input jax postFilter to create the previews as
|
||||||
// the input jax are processed.
|
// the input jax are processed.
|
||||||
//
|
//
|
||||||
Register: function (name) {
|
Register: function (name) {
|
||||||
HUB.Register.StartupHook(name+" Jax Require",function () {
|
HUB.Register.StartupHook(name+" Jax Require",function () {
|
||||||
var jax = MathJax.InputJax[name];
|
var jax = MathJax.InputJax[name];
|
||||||
var delay = HUB.config.delayJaxRegistration;
|
|
||||||
HUB.config.delayJaxRegistration = true;
|
|
||||||
HUB.Register.StartupHook(name+" Jax Ready",function () {HUB.config.delayJaxRegistration = delay});
|
|
||||||
jax.require.push(
|
|
||||||
"[MathJax]/jax/output/CommonHTML/config.js",
|
|
||||||
"[MathJax]/jax/output/CommonHTML/jax.js"
|
|
||||||
);
|
|
||||||
jax.postfilterHooks.Add(["Preview",MathJax.Extension["CHTML-preview"]],50);
|
jax.postfilterHooks.Add(["Preview",MathJax.Extension["CHTML-preview"]],50);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user