Experimental Bidi branch. #474, #/610, #627

This commit is contained in:
Frédéric Wang 2013-10-18 10:04:47 +02:00
parent 830502a0a3
commit 932b7e8f7c
6 changed files with 33 additions and 8 deletions

View File

@ -232,7 +232,8 @@ MathJax.ElementJax.mml.Augment({
type: "base", isToken: false, type: "base", isToken: false,
defaults: { defaults: {
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT,
}, },
noInherit: {}, noInherit: {},
noInheritAttribute: { noInheritAttribute: {
@ -428,7 +429,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.AUTO, mathvariant: MML.AUTO,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
}, },
autoDefault: function (name) { autoDefault: function (name) {
if (name === "mathvariant") { if (name === "mathvariant") {
@ -458,7 +460,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.INHERIT, mathvariant: MML.INHERIT,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
} }
}); });
@ -469,6 +472,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
form: MML.AUTO, form: MML.AUTO,
fence: MML.AUTO, fence: MML.AUTO,
separator: MML.AUTO, separator: MML.AUTO,
@ -630,7 +634,8 @@ MathJax.ElementJax.mml.Augment({
mathvariant: MML.INHERIT, mathvariant: MML.INHERIT,
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT mathcolor: MML.INHERIT,
dir: MML.INHERIT
} }
}); });
@ -665,6 +670,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.INHERIT, mathsize: MML.INHERIT,
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
lquote: '"', lquote: '"',
rquote: '"' rquote: '"'
} }
@ -810,6 +816,7 @@ MathJax.ElementJax.mml.Augment({
scriptminsize: "8pt", scriptminsize: "8pt",
mathbackground: MML.INHERIT, mathbackground: MML.INHERIT,
mathcolor: MML.INHERIT, mathcolor: MML.INHERIT,
dir: MML.INHERIT,
infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE, infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE,
decimalseparator: "." decimalseparator: "."
}, },
@ -1226,6 +1233,7 @@ MathJax.ElementJax.mml.Augment({
mathsize: MML.SIZE.NORMAL, mathsize: MML.SIZE.NORMAL,
mathcolor: "", // should be "black", but allow it to inherit from surrounding text mathcolor: "", // should be "black", but allow it to inherit from surrounding text
mathbackground: MML.COLOR.TRANSPARENT, mathbackground: MML.COLOR.TRANSPARENT,
dir: "ltr",
scriptlevel: 0, scriptlevel: 0,
displaystyle: MML.AUTO, displaystyle: MML.AUTO,
display: "inline", display: "inline",

View File

@ -1292,7 +1292,8 @@ junk = null;
formatError: function (err,math,script) { formatError: function (err,math,script) {
var message = err.message.replace(/\n.*/,""); var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["AsciiMath Jax - parse error",message,math,script]); MathJax.Hub.signal.Post(["AsciiMath Jax - parse error",message,math,script]);
return MML.merror(message); var mml = MML.merror(message);
return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml);
}, },
Error: function (message) { Error: function (message) {
throw MathJax.Hub.Insert(Error(message),{asciimathError: true}); throw MathJax.Hub.Insert(Error(message),{asciimathError: true});

View File

@ -267,7 +267,8 @@
formatError: function (err,math,script) { formatError: function (err,math,script) {
var message = err.message.replace(/\n.*/,""); var message = err.message.replace(/\n.*/,"");
MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]); MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]);
return MML.merror(message); var mml = MML.merror(message);
return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml);
}, },
Error: function (message) { Error: function (message) {
// //

View File

@ -2099,7 +2099,8 @@
formatError: function (err,math,display,script) { formatError: function (err,math,display,script) {
var message = err.message.replace(/\n.*/,""); var message = err.message.replace(/\n.*/,"");
HUB.signal.Post(["TeX Jax - parse error",message,math,display,script]); HUB.signal.Post(["TeX Jax - parse error",message,math,display,script]);
return MML.merror(message); var mml = MML.merror(message);
return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml);
}, },
// //

View File

@ -41,6 +41,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
this.HTMLhandleVariant(span,this.HTMLgetVariant(),values.lquote+text+values.rquote); this.HTMLhandleVariant(span,this.HTMLgetVariant(),values.lquote+text+values.rquote);
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
}, },
HTMLquoteRegExp: function (string) { HTMLquoteRegExp: function (string) {

View File

@ -223,7 +223,6 @@
"word-wrap": "normal", "word-wrap": "normal",
"white-space": "nowrap", "white-space": "nowrap",
"float": "none", "float": "none",
"direction": "ltr",
border: 0, padding: 0, margin: 0 border: 0, padding: 0, margin: 0
}, },
@ -1723,6 +1722,11 @@
return span; return span;
}, },
HTMLhandleDir: function (span) {
span.style.direction = this.Get("dir");
return span;
},
HTMLhandleColor: function (span) { HTMLhandleColor: function (span) {
var values = this.getValues("mathcolor","color"); var values = this.getValues("mathcolor","color");
if (this.mathbackground) {values.mathbackground = this.mathbackground} if (this.mathbackground) {values.mathbackground = this.mathbackground}
@ -1973,6 +1977,7 @@
} }
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
} }
}); });
@ -1987,6 +1992,7 @@
if (this.data.join("").length !== 1) {delete span.bbox.skew} if (this.data.join("").length !== 1) {delete span.bbox.skew}
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
} }
}); });
@ -2061,6 +2067,7 @@
// //
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
}, },
CoreParent: function () { CoreParent: function () {
@ -2157,6 +2164,7 @@
if (this.data.join("").length !== 1) {delete span.bbox.skew} if (this.data.join("").length !== 1) {delete span.bbox.skew}
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
} }
}); });
@ -2296,6 +2304,7 @@
} }
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
this.HTMLhandleDir(span);
return span; return span;
}, },
HTMLstretchH: MML.mbase.HTMLstretchH, HTMLstretchH: MML.mbase.HTMLstretchH,
@ -2690,6 +2699,10 @@
// //
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
// //
// Add direction (if any)
//
this.HTMLhandleDir(span);
//
// Make math span be the correct height and depth // Make math span be the correct height and depth
// //
if (math) {HTMLCSS.createRule(span,(math.bbox.h+p)*f,(math.bbox.d+p)*f,0)} if (math) {HTMLCSS.createRule(span,(math.bbox.h+p)*f,(math.bbox.d+p)*f,0)}