Skip to content

Commit bcfabb5

Browse files
authored
Merge pull request #1917 from dpvc/issue1883
Improve line breaks past the container width. #1883.
2 parents 7d6213e + 36484b5 commit bcfabb5

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

unpacked/jax/output/CommonHTML/autoload/multiline.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
4040
badbreak: [+200],
4141
auto: [0],
4242

43+
maxwidth: 1.33, // stop looking for breaks after this time the line-break width
4344
toobig: 800,
4445
nestfactor: 400,
4546
spacefactor: -100,
@@ -150,7 +151,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
150151
// Look through the line for breakpoints,
151152
// (as long as we are not too far past the breaking width)
152153
//
153-
while (i < m && info.scanW < 1.33*CHTML.linebreakWidth) {
154+
while (i < m && (info.scanW < PENALTY.maxwidth*CHTML.linebreakWidth || info.w === 0)) {
154155
if (this.data[i]) {
155156
if (this.data[i].CHTMLbetterBreak(info,state)) {
156157
better = true; index = [i].concat(info.index); W = info.W; w = info.w;
@@ -400,7 +401,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
400401
// Look through the line for breakpoints, including the open, close, and separators
401402
// (as long as we are not too far past the breaking width)
402403
//
403-
while (i < m && info.scanW < 1.33*CHTML.linebreakWidth) {
404+
while (i < m && (info.scanW < PENALTY.maxwidth*CHTML.linebreakWidth || info.w === 0)) {
404405
var k = this.dataI[i];
405406
if (this.data[k]) {
406407
if (this.data[k].CHTMLbetterBreak(info,state)) {

unpacked/jax/output/HTML-CSS/autoload/multiline.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
3939
badbreak: [+200],
4040
auto: [0],
4141

42+
maxwidth: 1.33, // stop looking for breaks after this time the line-break width
4243
toobig: 800,
4344
nestfactor: 400,
4445
spacefactor: -100,
@@ -157,7 +158,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
157158
// Look through the line for breakpoints,
158159
// (as long as we are not too far past the breaking width)
159160
//
160-
while (i < m && info.scanW < 1.33*HTMLCSS.linebreakWidth) {
161+
while (i < m && (info.scanW < PENALTY.maxwidth*HTMLCSS.linebreakWidth || info.w === 0)) {
161162
if (this.data[i]) {
162163
if (this.data[i].HTMLbetterBreak(info,state)) {
163164
better = true; index = [i].concat(info.index); W = info.W; w = info.w;
@@ -411,7 +412,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
411412
// Look through the line for breakpoints, including the open, close, and separators
412413
// (as long as we are not too far past the breaking width)
413414
//
414-
while (i < m && info.scanW < 1.33*HTMLCSS.linebreakWidth) {
415+
while (i < m && (info.scanW < PENALTY.maxwidth*HTMLCSS.linebreakWidth || info.w === 0)) {
415416
var k = this.dataI[i];
416417
if (this.data[k]) {
417418
if (this.data[k].HTMLbetterBreak(info,state)) {

unpacked/jax/output/SVG/autoload/multiline.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
4040
badbreak: [+200],
4141
auto: [0],
4242

43+
maxwidth: 1.33, // stop looking for breaks after this time the line-break width
4344
toobig: 800,
4445
nestfactor: 400,
4546
spacefactor: -100,
@@ -162,7 +163,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
162163
// Look through the line for breakpoints,
163164
// (as long as we are not too far past the breaking width)
164165
//
165-
while (i < m && info.scanW < 1.33*SVG.linebreakWidth) {
166+
while (i < m && (info.scanW < PENALTY.maxwidth*SVG.linebreakWidth || info.w === 0)) {
166167
if (this.data[i]) {
167168
if (this.data[i].SVGbetterBreak(info,state)) {
168169
better = true; index = [i].concat(info.index); W = info.W; w = info.w;
@@ -370,7 +371,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
370371
// Look through the line for breakpoints, including the open, close, and separators
371372
// (as long as we are not too far past the breaking width)
372373
//
373-
while (i < m && info.scanW < 1.33*SVG.linebreakWidth) {
374+
while (i < m && (info.scanW < PENALTY.maxwidth*SVG.linebreakWidth || info.w === 0)) {
374375
var k = this.dataI[i];
375376
if (this.data[k]) {
376377
if (this.data[k].SVGbetterBreak(info,state)) {

0 commit comments

Comments
 (0)