Merge remote-tracking branch 'dpvc/issue617' into develop. Issue #617.
This commit is contained in:
commit
c212638e66
|
@ -108,6 +108,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
}
|
||||
this.HTMLhandleSpace(span);
|
||||
this.HTMLhandleColor(span);
|
||||
var bbox = span.bbox;
|
||||
bbox.dx = dx; bbox.s = s; bbox.u = u; bbox.v = v; bbox.delta = delta;
|
||||
bbox.px = dx+base.bbox.w;
|
||||
return span;
|
||||
},
|
||||
HTMLgetScripts: function (stack,s) {
|
||||
|
@ -143,6 +146,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
if (BOX[j]) {
|
||||
BOX[j].bbox.w += s;
|
||||
BOX[j].bbox.rw = Math.max(BOX[j].bbox.w,BOX[j].bbox.rw);
|
||||
BOX[j].bbox.name = (["sub","sup","presub","presup"])[j];
|
||||
this.HTMLcleanBBox(BOX[j].bbox);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -531,6 +531,101 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
MML.mmultiscripts.Augment({
|
||||
HTMLbetterBreak: function (info,state) {
|
||||
if (!this.data[this.base]) {return false}
|
||||
//
|
||||
// Get the current breakpoint position and other data
|
||||
//
|
||||
var index = info.index.slice(0), i = info.index.shift(),
|
||||
W, w, scanW, broken = (info.index.length > 0), better = false;
|
||||
if (!broken) {info.W += info.w; info.w = 0}
|
||||
info.scanW = info.W;
|
||||
//
|
||||
// Get the bounding boxes and the width of the scripts
|
||||
//
|
||||
var bbox = this.HTMLspanElement().bbox,
|
||||
base = this.data[this.base].HTMLspanElement().bbox;
|
||||
var dw = bbox.w - base.w;
|
||||
//
|
||||
// Add in the prescripts
|
||||
//
|
||||
info.scanW += bbox.dx; scanW = info.scanW;
|
||||
//
|
||||
// Check if the base can be broken
|
||||
//
|
||||
if (this.data[this.base].HTMLbetterBreak(info,state)) {
|
||||
better = true; index = [this.base].concat(info.index); W = info.W; w = info.w;
|
||||
if (info.penalty === PENALTY.newline) {better = broken = true}
|
||||
}
|
||||
//
|
||||
// Add in the base if it is unbroken, and add the scripts
|
||||
//
|
||||
if (!broken) {this.HTMLaddWidth(this.base,info,scanW)}
|
||||
info.scanW += dw; info.W = info.scanW;
|
||||
info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
|
||||
return better;
|
||||
},
|
||||
|
||||
HTMLmoveLine: function (start,end,span,state,values) {
|
||||
var SPAN = this.HTMLspanElement(), data = SPAN.bbox, base = data,
|
||||
stack = SPAN.firstChild, box = stack.firstChild, dx, BOX = {};
|
||||
//
|
||||
// Get the boxes for the scripts (if any)
|
||||
//
|
||||
while (box) {
|
||||
if (box.bbox && box.bbox.name) {BOX[box.bbox.name] = box}
|
||||
box = box.nextSibling;
|
||||
}
|
||||
//
|
||||
// If this is the start, move the prescripts, if any.
|
||||
//
|
||||
if (start.length < 1) {
|
||||
if (BOX.presub || BOX.presup) {
|
||||
var STACK = HTMLCSS.createStack(span);
|
||||
if (BOX.presup) {
|
||||
HTMLCSS.addBox(STACK,BOX.presup);
|
||||
HTMLCSS.placeBox(BOX.presup,data.dx-BOX.presup.bbox.w,data.u);
|
||||
}
|
||||
if (BOX.presub) {
|
||||
HTMLCSS.addBox(STACK,BOX.presub);
|
||||
HTMLCSS.placeBox(BOX.presub,data.dx+data.delta-BOX.presub.bbox.w,-data.v);
|
||||
}
|
||||
this.HTMLcombineBBoxes(STACK,span.bbox);
|
||||
span.appendChild(STACK);
|
||||
STACK.style.width = HTMLCSS.Em(data.dx);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Move the proper part of the base
|
||||
//
|
||||
if (this.data[this.base]) {
|
||||
if (start.length > 1) {
|
||||
this.data[this.base].HTMLmoveSlice(start.slice(1),end.slice(1),span,state,values,"paddingLeft");
|
||||
} else {
|
||||
if (end.length <= 1) {this.data[this.base].HTMLmoveSpan(span,state,values)}
|
||||
else {this.data[this.base].HTMLmoveSlice([],end.slice(1),span,state,values,"paddingRight")}
|
||||
}
|
||||
}
|
||||
//
|
||||
// If this is the end, check for super and subscripts, and move those
|
||||
// by moving the stack that contains them, and shifting by the amount of the
|
||||
// base that has been removed. Remove the empty base box from the stack.
|
||||
//
|
||||
if (end.length === 0) {
|
||||
if (this.data[this.base]) {stack.removeChild(stack.firstChild)}
|
||||
for (box = stack.firstChild; box; box = box.nextSibling)
|
||||
{box.style.left = HTMLCSS.Em(HTMLCSS.unEm(box.style.left)-data.px)}
|
||||
stack.bbox.w -= data.px; stack.style.width = HTMLCSS.Em(stack.bbox.w);
|
||||
this.HTMLcombineBBoxes(stack,span.bbox);
|
||||
span.appendChild(stack);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
MML.mo.Augment({
|
||||
//
|
||||
// Override the method for checking line breaks to properly handle <mo>
|
||||
|
@ -628,7 +723,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
// use it to modify the default penalty
|
||||
//
|
||||
var linebreak = PENALTY[linebreakValue];
|
||||
if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit)
|
||||
if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit &&
|
||||
!this.mathbackground && !this.background)
|
||||
{linebreak = [(w+PENALTY.spaceoffset)*PENALTY.spacefactor]}
|
||||
if (!(linebreak instanceof Array)) {
|
||||
// for breaks past the width, don't modify penalty
|
||||
|
|
|
@ -93,6 +93,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
|||
svg.Clean();
|
||||
this.SVGhandleColor(svg);
|
||||
this.SVGsaveData(svg);
|
||||
var data = this.SVGdata;
|
||||
data.dx = dx; data.s = s; data.u = u, data.v = v; data.delta = delta;
|
||||
return svg;
|
||||
},
|
||||
SVGgetScripts: function (s) {
|
||||
|
|
|
@ -469,7 +469,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
|||
}
|
||||
//
|
||||
// If this is the end, check for super and subscripts, and move those
|
||||
// by moving the stack tht contains them, and shifting by the amount of the
|
||||
// by moving the stack that contains them, and shifting by the amount of the
|
||||
// base that has been removed. Remove the empty base box from the stack.
|
||||
//
|
||||
if (end.length === 0) {
|
||||
|
@ -483,6 +483,77 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
MML.mmultiscripts.Augment({
|
||||
SVGbetterBreak: function (info,state) {
|
||||
if (!this.data[this.base]) {return false}
|
||||
//
|
||||
// Get the current breakpoint position and other data
|
||||
//
|
||||
var index = info.index.slice(0), i = info.index.shift(),
|
||||
W, w, scanW, broken = (info.index.length > 0), better = false;
|
||||
if (!broken) {info.W += info.w; info.w = 0}
|
||||
info.scanW = info.W;
|
||||
//
|
||||
// The width of the postscripts
|
||||
//
|
||||
var dw = this.SVGdata.w - this.data[this.base].SVGdata.w - this.SVGdata.dx;
|
||||
//
|
||||
// Add in the prescripts
|
||||
//
|
||||
info.scanW += this.SVGdata.dx; scanW = info.scanW;
|
||||
//
|
||||
// Check if the base can be broken (but don't break between prescripts and base)
|
||||
//
|
||||
if (this.data[this.base].SVGbetterBreak(info,state)) {
|
||||
better = true; index = [this.base].concat(info.index); W = info.W; w = info.w;
|
||||
if (info.penalty === PENALTY.newline) {better = broken = true}
|
||||
}
|
||||
//
|
||||
// Add in the base if it is unbroken, and add the postscripts
|
||||
//
|
||||
if (!broken) {this.SVGaddWidth(this.base,info,scanW)}
|
||||
info.scanW += dw; info.W = info.scanW;
|
||||
info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
|
||||
return better;
|
||||
},
|
||||
|
||||
SVGmoveLine: function (start,end,svg,state,values) {
|
||||
var dx, data = this.SVGdata;
|
||||
//
|
||||
// If this is the start, move the prescripts, if any.
|
||||
//
|
||||
if (start.length < 1) {
|
||||
this.scriptBox = this.SVGgetScripts(this.SVGdata.s);
|
||||
var presub = this.scriptBox[2], presup = this.scriptBox[3]; dx = svg.w + data.dx;
|
||||
if (presup) {svg.Add(presup,dx+data.delta-presup.w,data.u)}
|
||||
if (presub) {svg.Add(presub,dx-presub.w,-data.v)}
|
||||
}
|
||||
//
|
||||
// Move the proper part of the base
|
||||
//
|
||||
if (this.data[this.base]) {
|
||||
if (start.length > 1) {
|
||||
this.data[this.base].SVGmoveSlice(start.slice(1),end.slice(1),svg,state,values,"paddingLeft");
|
||||
} else {
|
||||
if (end.length <= 1) {this.data[this.base].SVGmove(svg,state,values)}
|
||||
else {this.data[this.base].SVGmoveSlice([],end.slice(1),svg,state,values,"paddingRight")}
|
||||
}
|
||||
}
|
||||
//
|
||||
// If this is the end, move the postscripts, if any.
|
||||
//
|
||||
if (end.length === 0) {
|
||||
var sub = this.scriptBox[0], sup = this.scriptBox[1]; dx = svg.w + data.s;
|
||||
if (sup) {svg.Add(sup,dx,data.u)}
|
||||
if (sub) {svg.Add(sub,dx-data.delta,-data.v)}
|
||||
delete this.scriptBox;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
MML.mo.Augment({
|
||||
//
|
||||
// Override the method for checking line breaks to properly handle <mo>
|
||||
|
@ -579,8 +650,9 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
|||
// use it to modify the default penalty
|
||||
//
|
||||
var linebreak = PENALTY[linebreakValue];
|
||||
if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit*1000)
|
||||
{linebreak = [(w+PENALTY.spaceoffset)*PENALTY.spacefactor]}
|
||||
if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit*1000 &&
|
||||
!this.mathbackground && !this.backrgound)
|
||||
{linebreak = [(w/1000+PENALTY.spaceoffset)*PENALTY.spacefactor]}
|
||||
if (!(linebreak instanceof Array)) {
|
||||
// for breaks past the width, don't modify penalty
|
||||
if (offset >= 0) {penalty = linebreak * info.nest}
|
||||
|
|
Loading…
Reference in New Issue
Block a user