Add comments and use variables for shortcuts to structures
This commit is contained in:
parent
70b8f84a3a
commit
f4f5263e2b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -23,7 +23,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function (TEX) {
|
(function (TEX,HUB,AJAX) {
|
||||||
var TRUE = true, FALSE = false, MML, NBSP = String.fromCharCode(0xA0);
|
var TRUE = true, FALSE = false, MML, NBSP = String.fromCharCode(0xA0);
|
||||||
|
|
||||||
var STACK = MathJax.Object.Subclass({
|
var STACK = MathJax.Object.Subclass({
|
||||||
|
@ -295,7 +295,7 @@
|
||||||
var TEXDEF = {};
|
var TEXDEF = {};
|
||||||
var STARTUP = function () {
|
var STARTUP = function () {
|
||||||
MML = MathJax.ElementJax.mml;
|
MML = MathJax.ElementJax.mml;
|
||||||
MathJax.Hub.Insert(TEXDEF,{
|
HUB.Insert(TEXDEF,{
|
||||||
|
|
||||||
// patterns for letters and numbers
|
// patterns for letters and numbers
|
||||||
letter: /[a-z]/i,
|
letter: /[a-z]/i,
|
||||||
|
@ -1349,9 +1349,9 @@
|
||||||
if (name && !typeof(name) === "string") {name = name.name}
|
if (name && !typeof(name) === "string") {name = name.name}
|
||||||
file = TEX.extensionDir+"/"+file;
|
file = TEX.extensionDir+"/"+file;
|
||||||
if (!file.match(/\.js$/)) {file += ".js"}
|
if (!file.match(/\.js$/)) {file += ".js"}
|
||||||
if (!MathJax.Ajax.loaded[MathJax.Ajax.fileURL(file)]) {
|
if (!AJAX.loaded[AJAX.fileURL(file)]) {
|
||||||
if (name != null) {delete TEXDEF[array || 'macros'][name.replace(/^\\/,"")]}
|
if (name != null) {delete TEXDEF[array || 'macros'][name.replace(/^\\/,"")]}
|
||||||
MathJax.Hub.RestartAfter(MathJax.Ajax.Require(file));
|
HUB.RestartAfter(AJAX.Require(file));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1714,14 +1714,15 @@
|
||||||
MAXBUFFER: 5*1024 // maximum size of TeX string to process
|
MAXBUFFER: 5*1024 // maximum size of TeX string to process
|
||||||
},
|
},
|
||||||
|
|
||||||
prefilterHooks: MathJax.Callback.Hooks(true),
|
prefilterHooks: MathJax.Callback.Hooks(true), // hooks to run before processing TeX
|
||||||
postfilterHooks: MathJax.Callback.Hooks(true),
|
postfilterHooks: MathJax.Callback.Hooks(true), // hooks to run after processing TeX
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert TeX to ElementJax
|
||||||
|
//
|
||||||
Translate: function (script) {
|
Translate: function (script) {
|
||||||
var mml, isError = false;
|
var mml, isError = false, math = script.innerHTML.replace(/^\s+/,"").replace(/\s+$/,"");
|
||||||
var math = script.innerHTML.replace(/^\s+/,"").replace(/\s+$/,"");
|
var display = (script.type.replace(/\n/g," ").match(/(;|\s|\n)mode\s*=\s*display(;|\s|\n|$)/) != null);
|
||||||
var display =
|
|
||||||
(script.type.replace(/\n/g," ").match(/(;|\s|\n)mode\s*=\s*display(;|\s|\n|$)/) != null);
|
|
||||||
var data = {math:math, display:display, script:script};
|
var data = {math:math, display:display, script:script};
|
||||||
this.prefilterHooks.Execute(data); math = data.math;
|
this.prefilterHooks.Execute(data); math = data.math;
|
||||||
try {
|
try {
|
||||||
|
@ -1740,7 +1741,7 @@
|
||||||
},
|
},
|
||||||
prefilterMath: function (data) {
|
prefilterMath: function (data) {
|
||||||
// Konqueror incorrectly quotes these characters in script.innerHTML
|
// Konqueror incorrectly quotes these characters in script.innerHTML
|
||||||
if (MathJax.Hub.Browser.isKonqueror)
|
if (HUB.Browser.isKonqueror)
|
||||||
{data.math = data.math.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}
|
{data.math = data.math.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}
|
||||||
// avoid parsing super- and subscript numbers as a unit
|
// avoid parsing super- and subscript numbers as a unit
|
||||||
data.math = data.math.replace(/([_^]\s*\d)([0-9.,])/g,"$1 $2");
|
data.math = data.math.replace(/([_^]\s*\d)([0-9.,])/g,"$1 $2");
|
||||||
|
@ -1751,13 +1752,25 @@
|
||||||
formatError: function (err,math,display,script) {
|
formatError: function (err,math,display,script) {
|
||||||
return MML.merror(err.message.replace(/\n.*/,""));
|
return MML.merror(err.message.replace(/\n.*/,""));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Produce an error and stop processing this equation
|
||||||
|
//
|
||||||
Error: function (message) {
|
Error: function (message) {
|
||||||
throw MathJax.Hub.Insert(Error(message),{texError: TRUE});
|
throw HUB.Insert(Error(message),{texError: TRUE});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add a user-defined macro to the macro list
|
||||||
|
//
|
||||||
Macro: function (name,def,argn) {
|
Macro: function (name,def,argn) {
|
||||||
TEXDEF.macros[name] = ['Macro'].concat([].slice.call(arguments,1));
|
TEXDEF.macros[name] = ['Macro'].concat([].slice.call(arguments,1));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Combine adjacent <mo> elements that are relations
|
||||||
|
// (since MathML treats the spacing very differently)
|
||||||
|
//
|
||||||
combineRelations: function (mml) {
|
combineRelations: function (mml) {
|
||||||
for (var i = 0, m = mml.data.length; i < m; i++) {
|
for (var i = 0, m = mml.data.length; i < m; i++) {
|
||||||
if (mml.data[i]) {
|
if (mml.data[i]) {
|
||||||
|
@ -1776,9 +1789,12 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add the default filters
|
||||||
|
//
|
||||||
TEX.prefilterHooks.Add(["prefilterMath",TEX]);
|
TEX.prefilterHooks.Add(["prefilterMath",TEX]);
|
||||||
TEX.postfilterHooks.Add(["postfilterMath",TEX]);
|
TEX.postfilterHooks.Add(["postfilterMath",TEX]);
|
||||||
|
|
||||||
TEX.loadComplete("jax.js");
|
TEX.loadComplete("jax.js");
|
||||||
|
|
||||||
})(MathJax.InputJax.TeX);
|
})(MathJax.InputJax.TeX,MathJax.Hub,MathJax.Ajax);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user