Update Safe.js to filter mathsize and not throw error for \mmlToken attributes that are filtered.
This commit is contained in:
parent
25a10d733d
commit
084385b640
|
@ -98,6 +98,17 @@
|
||||||
div1: document.createElement("div"), // for CSS processing
|
div1: document.createElement("div"), // for CSS processing
|
||||||
div2: document.createElement("div"),
|
div2: document.createElement("div"),
|
||||||
|
|
||||||
|
//
|
||||||
|
// Methods called for MathML attribute processing
|
||||||
|
//
|
||||||
|
filter: {
|
||||||
|
"class": "filterClass",
|
||||||
|
id: "filterID",
|
||||||
|
fontsize: "filterFontSize",
|
||||||
|
mathsize: "filterFontSize",
|
||||||
|
style: "filterStyles"
|
||||||
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filter HREF URL's
|
// Filter HREF URL's
|
||||||
//
|
//
|
||||||
|
@ -242,9 +253,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
HUB.Register.StartupHook("TeX Jax Ready",function () {
|
HUB.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
var TEX = MathJax.InputJax.TeX;
|
var TEX = MathJax.InputJax.TeX,
|
||||||
|
PARSE = TEX.Parse, METHOD = SAFE.filter;
|
||||||
|
|
||||||
TEX.Parse.Augment({
|
PARSE.Augment({
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implements \require{name} with filtering
|
// Implements \require{name} with filtering
|
||||||
|
@ -258,11 +270,9 @@
|
||||||
//
|
//
|
||||||
// Controls \mmlToken attributes
|
// Controls \mmlToken attributes
|
||||||
//
|
//
|
||||||
MmlTokenAllow: {
|
MmlFilterAttribute: function (name,value) {
|
||||||
fontsize: (ALLOW.fontsize === "all"),
|
if (METHOD[name]) {value = SAFE[METHOD[name]](value)}
|
||||||
id: (ALLOW.cssIDs === "all"),
|
return value;
|
||||||
"class": (ALLOW.classes === "all"),
|
|
||||||
style: (ALLOW.styles === "all")
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -292,15 +302,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
HUB.Register.StartupHook("MathML Jax Ready",function () {
|
HUB.Register.StartupHook("MathML Jax Ready",function () {
|
||||||
var PARSE = MathJax.InputJax.MathML.Parse;
|
var PARSE = MathJax.InputJax.MathML.Parse,
|
||||||
|
METHOD = SAFE.filter;
|
||||||
var METHOD = {
|
|
||||||
href: "filterURL",
|
|
||||||
"class": "filterClass",
|
|
||||||
id: "filterID",
|
|
||||||
fontsize: "filterFontSize",
|
|
||||||
style: "filterStyles"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filter MathML attributes
|
// Filter MathML attributes
|
||||||
|
|
|
@ -1441,15 +1441,18 @@
|
||||||
"%1 is not a recognized attribute for %2",
|
"%1 is not a recognized attribute for %2",
|
||||||
match[1],type]);
|
match[1],type]);
|
||||||
}
|
}
|
||||||
var value = match[2].replace(/^(['"])(.*)\1$/,"$2");
|
var value = this.MmlFilterAttribute(match[1],match[2].replace(/^(['"])(.*)\1$/,"$2"));
|
||||||
|
if (value) {
|
||||||
if (value.toLowerCase() === "true") {value = true}
|
if (value.toLowerCase() === "true") {value = true}
|
||||||
else if (value.toLowerCase() === "false") {value = false}
|
else if (value.toLowerCase() === "false") {value = false}
|
||||||
def[match[1]] = value;
|
def[match[1]] = value;
|
||||||
def.attrNames.push(match[1]);
|
def.attrNames.push(match[1]);
|
||||||
|
}
|
||||||
attr = attr.substr(match[0].length);
|
attr = attr.substr(match[0].length);
|
||||||
}
|
}
|
||||||
this.Push(this.mmlToken(MML[type](data).With(def)));
|
this.Push(this.mmlToken(MML[type](data).With(def)));
|
||||||
},
|
},
|
||||||
|
MmlFilterAttribute: function (name,value) {return value},
|
||||||
MmlTokenAllow: {
|
MmlTokenAllow: {
|
||||||
fontfamily:1, fontsize:1, fontweight:1, fontstyle:1,
|
fontfamily:1, fontsize:1, fontweight:1, fontstyle:1,
|
||||||
color:1, background:1,
|
color:1, background:1,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user