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

This commit is contained in:
Frédéric Wang 2013-03-25 16:57:05 +01:00
parent 96a3bc7d92
commit 8803b00446
3 changed files with 30 additions and 5 deletions

View File

@ -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({

View File

@ -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

View File

@ -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