tweaks to MathJax setup & customizations from mathjax-users list

Some fixes, cleanup, and modernization
This commit is contained in:
Brion Vibber 2012-03-12 20:41:43 +00:00
parent 430b958d1a
commit c89a0003f1
3 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,6 @@
MathJax.Hub.Config({ MathJax.Hub.Config({
extensions: ["wiki2jax.js","TeX/texvc.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"], extensions: ["wiki2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js"],
jax: ["input/TeX","output/HTML-CSS"], jax: ["input/TeX","output/HTML-CSS"],
TeX: {extensions: ["noErrors.js","noUndefined.js","AMSmath.js","AMSsymbols.js"]} TeX: {extensions: ["noErrors.js","noUndefined.js","AMSmath.js","AMSsymbols.js","texvc.js"]}
}); });
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-texvc_HTML.js"); MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-texvc_HTML.js");

View File

@ -113,16 +113,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
}, },
macros: { macros: {
sgn: ['NamedOp',0], sgn: 'NamedFn',
textcolor: ['Macro','\\color{#1}',1], textcolor: ['Macro','\\color{#1}',1],
bold: ['Macro','{\\boldsymbol #1}',1] // boldsymbol bold: ['Macro','\\boldsymbol'] // boldsymbol
} }
}); });
}); });
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { MathJax.Hub.Startup.signal.Post("TeX texvc Ready");
MathJax.Hub.Startup.signal.Post("TeX texvc Ready");
});
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/texvc.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/texvc.js");

View File

@ -16,10 +16,9 @@ MathJax.Extension.wiki2jax = {
PreProcess: function (element) { PreProcess: function (element) {
if (!this.configured) { if (!this.configured) {
MathJax.Hub.Insert(this.config,(MathJax.Hub.config.wiki2jax||{})); this.config = MathJax.Hub.CombineConfig("wiki2jax", this.config);
if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)} if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)}
if (typeof(this.config.previewTeX) !== "undefined" && !this.config.previewTeX)
{this.config.preview = "none"} // backward compatibility for previewTeX parameter
this.previewClass = MathJax.Hub.config.preRemoveClass; this.previewClass = MathJax.Hub.config.preRemoveClass;
this.configured = true; this.configured = true;
} }
@ -31,7 +30,7 @@ MathJax.Extension.wiki2jax = {
ConvertMath: function (node) { ConvertMath: function (node) {
var parent = node.parentNode, var parent = node.parentNode,
mode = parent.tagName === "DD" && parent.firstChild === parent.lastChild ? "; mode=display" : "", mode = parent.tagName === "DD" && parent.childNodes.length === 1 ? "; mode=display" : "",
tex; tex;
if (node.nodeName == 'IMG') { if (node.nodeName == 'IMG') {
tex = node.alt; tex = node.alt;
@ -46,6 +45,7 @@ MathJax.Extension.wiki2jax = {
if (parent.firstChild === node) tex = "\\displaystyle{"+tex+"}"; if (parent.firstChild === node) tex = "\\displaystyle{"+tex+"}";
} }
// @fixme auto-enable the 'color' extension and drop this
var i; var i;
while ((i = tex.search(/\\color{/)) != -1) { while ((i = tex.search(/\\color{/)) != -1) {
var braces = 0; var braces = 0;
@ -61,8 +61,7 @@ MathJax.Extension.wiki2jax = {
var script = document.createElement("script"); var script = document.createElement("script");
script.type = "math/tex" + mode; script.type = "math/tex" + mode;
if (MathJax.Hub.Browser.isMSIE) {script.text = tex} MathJax.HTML.setScript(script, tex);
else {script.appendChild(document.createTextNode(tex))}
if (node.nextSibling) {parent.insertBefore(script,node.nextSibling)} if (node.nextSibling) {parent.insertBefore(script,node.nextSibling)}
else {parent.appendChild(script)} else {parent.appendChild(script)}
@ -80,7 +79,7 @@ MathJax.Extension.wiki2jax = {
} }
}, },
filterTeX: function (tex) {return tex} filterPreview: function (tex) {return tex}
}; };