Properly handle restarts within the creation of the previews

This commit is contained in:
Davide P. Cervone 2014-08-16 12:59:16 -04:00
parent f0c0c6386e
commit 8ebcd614c3

View File

@ -36,25 +36,16 @@
// after the previews have been created // after the previews have been created
// //
config: HUB.CombineConfig("CHTML-preview",{ config: HUB.CombineConfig("CHTML-preview",{
EqnChunk: 5, EqnChunkFactor: 1, EqnChunkDelay: 100 EqnChunk: 5, EqnChunkFactor: 1, EqnChunkDelay: 150
}), }),
// //
// Ajust the chunking of the output jax // Ajust the chunking of the output jax
// //
Config: function () { Config: function () {
var config = this.config;
HUB.Config({ HUB.Config({
"HTML-CSS": { "HTML-CSS": this.config,
EqnChunk: config.EqnChunk, "SVG": this.config
EqnChunkFactor: config.EqnChunkFactor,
EqnChunkDelay: config.EqnChunkDelay
},
"SVG": {
EqnChunk: config.EqnChunk,
EqnChunkFactor: config.EqnChunkFactor,
EqnChunkDelay: config.EqnChunkDelay
}
}); });
}, },
@ -69,9 +60,17 @@
data.script.parentNode.insertBefore(preview,data.script); data.script.parentNode.insertBefore(preview,data.script);
} }
preview.innerHTML = ""; preview.innerHTML = "";
data.math.root.toCommonHTML(preview); return this.postFilter(preview,data);
return data; return data;
}, },
postFilter: function (preview,data) {
try {
data.math.root.toCommonHTML(preview);
} catch (err) {
if (!err.restart) {throw err} // an actual error
return MathJax.Callback.After(["postFilter",this,preview,data],err.restart);
}
},
// //
// Hook into the inut jax postFilter to create the previews as // Hook into the inut jax postFilter to create the previews as
@ -87,7 +86,7 @@
"[MathJax]/jax/output/CommonHTML/config.js", "[MathJax]/jax/output/CommonHTML/config.js",
"[MathJax]/jax/output/CommonHTML/jax.js" "[MathJax]/jax/output/CommonHTML/jax.js"
); );
jax.postfilterHooks.Add(["Preview",MathJax.Extension["CHTML-preview"]]); jax.postfilterHooks.Add(["Preview",MathJax.Extension["CHTML-preview"]],50);
}); });
} }
} }