From 3fee31b7e467327937db1cd4e3226dea6423bf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Mon, 21 Oct 2013 10:04:39 +0200 Subject: [PATCH] Address review comments #627 --- unpacked/jax/element/mml/jax.js | 14 +++++++++++++- unpacked/jax/input/AsciiMath/jax.js | 3 +-- unpacked/jax/input/MathML/jax.js | 7 ++----- unpacked/jax/input/TeX/jax.js | 3 +-- unpacked/jax/output/HTML-CSS/autoload/mglyph.js | 6 ++---- unpacked/jax/output/HTML-CSS/jax.js | 10 +++------- unpacked/jax/output/SVG/autoload/mglyph.js | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/unpacked/jax/element/mml/jax.js b/unpacked/jax/element/mml/jax.js index 13e46b7f8..d66d1951f 100644 --- a/unpacked/jax/element/mml/jax.js +++ b/unpacked/jax/element/mml/jax.js @@ -223,7 +223,19 @@ MathJax.ElementJax.mml.Augment({ "fontfamily", "fontsize", "fontweight", "fontstyle", "color", "background", "id", "class", "href", "style" - ] + ], + Error: function (message,def) { + var mml = this.merror(message), + dir = MathJax.Localization.fontDirection(), + font = MathJax.Localization.fontFamily(); + if (def) {mml = mml.With(def)} + if (dir || font) { + mml = this.mstyle(mml); + if (dir) {mml.dir = dir} + if (font) {mml.style.fontFamily = "font-family: "+font} + } + return mml; + } }); (function (MML) { diff --git a/unpacked/jax/input/AsciiMath/jax.js b/unpacked/jax/input/AsciiMath/jax.js index 9e31d10b3..1d19bda5b 100644 --- a/unpacked/jax/input/AsciiMath/jax.js +++ b/unpacked/jax/input/AsciiMath/jax.js @@ -1292,8 +1292,7 @@ junk = null; formatError: function (err,math,script) { var message = err.message.replace(/\n.*/,""); MathJax.Hub.signal.Post(["AsciiMath Jax - parse error",message,math,script]); - var mml = MML.merror(message); - return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml); + return MML.Error(message); }, Error: function (message) { throw MathJax.Hub.Insert(Error(message),{asciimathError: true}); diff --git a/unpacked/jax/input/MathML/jax.js b/unpacked/jax/input/MathML/jax.js index eec45be2b..22b2f53da 100644 --- a/unpacked/jax/input/MathML/jax.js +++ b/unpacked/jax/input/MathML/jax.js @@ -77,9 +77,7 @@ mml = this.TeXAtom(match[2]); } else if (!(MML[type] && MML[type].isa && MML[type].isa(MML.mbase))) { MathJax.Hub.signal.Post(["MathML Jax - unknown node type",type]); - var err = MML.merror(_("UnknownNodeType","Unknown node type: %1",type)); - if (MathJax.Localization.fontDirection()) {err = MML.mstyle(err).With({dir: "rtl"})}; - return err; + return MML.Error(_("UnknownNodeType","Unknown node type: %1",type)); } else { mml = MML[type](); } @@ -269,8 +267,7 @@ formatError: function (err,math,script) { var message = err.message.replace(/\n.*/,""); MathJax.Hub.signal.Post(["MathML Jax - parse error",message,math,script]); - var mml = MML.merror(message); - return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml); + return MML.Error(message); }, Error: function (message) { // diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 974ef5e91..19bf4e4e7 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -2099,8 +2099,7 @@ formatError: function (err,math,display,script) { var message = err.message.replace(/\n.*/,""); HUB.signal.Post(["TeX Jax - parse error",message,math,display,script]); - var mml = MML.merror(message); - return (MathJax.Localization.fontDirection() ? MML.mstyle(mml).With({dir: "rtl"}) : mml); + return MML.Error(message); }, // diff --git a/unpacked/jax/output/HTML-CSS/autoload/mglyph.js b/unpacked/jax/output/HTML-CSS/autoload/mglyph.js index 5e736d364..12164e473 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/mglyph.js +++ b/unpacked/jax/output/HTML-CSS/autoload/mglyph.js @@ -45,8 +45,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { } else { if (values.alt === "") {values.alt = LOCALE._(["MathML","BadMglyphFont"],"Bad font: %1",font.family)} - err = MML.merror(values.alt).With({mathsize:"75%"}); - if (LOCALE.fontDirection()) {err = MML.mstyle(err).With({dir: "rtl"})}; + err = MML.Error(values.alt).With({mathsize:"75%"}); this.Append(err); err.toHTML(span); this.data.pop(); span.bbox = err.HTMLspanElement().bbox; } @@ -63,10 +62,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { MathJax.Hub.RestartAfter(img.onload); } if (this.img.status !== "OK") { - err = MML.merror( + err = MML.Error( LOCALE._(["MathML","BadMglyph"],"Bad mglyph: %1",values.src) ).With({mathsize:"75%"}); - if (LOCALE.fontDirection()) {err = MML.mstyle(err).With({dir: "rtl"})}; this.Append(err); err.toHTML(span); this.data.pop(); span.bbox = err.HTMLspanElement().bbox; } else { diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index e881040d8..6ece947af 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -1724,8 +1724,9 @@ }, HTMLhandleDir: function (span) { - span.style.direction = this.Get("dir"); - return span; + var dir = this.Get("dir",true); // only get value if not the default + if (dir) {span.dir = dir} + return span; }, HTMLhandleColor: function (span) { @@ -2305,7 +2306,6 @@ } this.HTMLhandleSpace(span); this.HTMLhandleColor(span); - this.HTMLhandleDir(span); return span; }, HTMLstretchH: MML.mbase.HTMLstretchH, @@ -2699,10 +2699,6 @@ // Add color (if any) // this.HTMLhandleColor(span); - // - // Add direction (if any) - // - this.HTMLhandleDir(span); // // Make math span be the correct height and depth // diff --git a/unpacked/jax/output/SVG/autoload/mglyph.js b/unpacked/jax/output/SVG/autoload/mglyph.js index 5b904bda9..ea6a5022a 100644 --- a/unpacked/jax/output/SVG/autoload/mglyph.js +++ b/unpacked/jax/output/SVG/autoload/mglyph.js @@ -74,7 +74,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { MathJax.Hub.RestartAfter(img.onload); } if (this.img.status !== "OK") { - err = MML.merror( + err = MML.Error( LOCALE._(["MathML","BadMglyph"],"Bad mglyph: %1",values.src) ).With({mathsize:"75%"}); this.Append(err); svg = err.toSVG(); this.data.pop();