www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 8803b00446ce19a45c166d427934974fa4c2e87d
parent 96a3bc7d923597cc21f6974cbb02435a1ec045b6
Author: Frédéric Wang <fred.wang@free.fr>
Date:   Mon, 25 Mar 2013 16:57:05 +0100

Ignore linebreak attribute on mspace when dimensional attributes are set. Fix issue #388.

Diffstat:
Munpacked/jax/element/mml/jax.js | 11++++++++++-
Munpacked/jax/output/HTML-CSS/autoload/multiline.js | 12++++++++++--
Munpacked/jax/output/SVG/autoload/multiline.js | 12++++++++++--
3 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/unpacked/jax/element/mml/jax.js b/unpacked/jax/element/mml/jax.js @@ -638,7 +638,16 @@ MathJax.ElementJax.mml.Augment({ depth: "0ex", linebreak: MML.LINEBREAK.AUTO }, - hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)} + hasDimAttr: function () { + return (this.hasValue("width") || this.hasValue("height") || + this.hasValue("depth")); + }, + hasNewline: function () { + // The MathML spec says that the linebreak attribute should be ignored + // if any dimensional attribute is set. + return (!this.hasDimAttr() && + this.Get("linebreak") === MML.LINEBREAK.NEWLINE); + } }); MML.ms = MML.mbase.Subclass({ diff --git a/unpacked/jax/output/HTML-CSS/autoload/multiline.js b/unpacked/jax/output/HTML-CSS/autoload/multiline.js @@ -1,3 +1,5 @@ +/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/jax/output/HTML-CSS/autoload/multiline.js @@ -594,6 +596,12 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { HTMLbetterBreak: function (info,state) { if (info.values && info.values.id === this.spanID) {return false} var values = this.getValues("linebreak"); + var linebreakValue = values.linebreak; + if (!linebreakValue || this.hasDimAttr()) { + // The MathML spec says that the linebreak attribute should be ignored + // if any dimensional attribute is set. + linebreakValue = MML.LINEBREAK.AUTO; + } // // Get the default penalty for this location // @@ -609,8 +617,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { // Get the penalty for this type of break and // use it to modify the default penalty // - var linebreak = PENALTY[values.linebreak||MML.LINEBREAK.AUTO]; - if (values.linebreak === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit) + var linebreak = PENALTY[linebreakValue]; + if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit) {linebreak = [(w+PENALTY.spaceoffset)*PENALTY.spacefactor]} if (!(linebreak instanceof Array)) { // for breaks past the width, don't modify penalty diff --git a/unpacked/jax/output/SVG/autoload/multiline.js b/unpacked/jax/output/SVG/autoload/multiline.js @@ -1,3 +1,5 @@ +/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/jax/output/SVG/autoload/multiline.js @@ -541,6 +543,12 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { SVGbetterBreak: function (info,state) { if (info.values && info.values.last === this) {return false} var values = this.getValues("linebreak"); + var linebreakValue = values.linebreak; + if (!linebreakValue || this.hasDimAttr()) { + // The MathML spec says that the linebreak attribute should be ignored + // if any dimensional attribute is set. + linebreakValue = MML.LINEBREAK.AUTO; + } // // Get the default penalty for this location // @@ -555,8 +563,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { // Get the penalty for this type of break and // use it to modify the default penalty // - var linebreak = PENALTY[values.linebreak||MML.LINEBREAK.AUTO]; - if (values.linebreak === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit*1000) + var linebreak = PENALTY[linebreakValue]; + if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit*1000) {linebreak = [(w+PENALTY.spaceoffset)*PENALTY.spacefactor]} if (!(linebreak instanceof Array)) { // for breaks past the width, don't modify penalty