22
22
*/
23
23
24
24
MathJax . Hub . Register . StartupHook ( "HTML-CSS Jax Ready" , function ( ) {
25
- var VERSION = "2.0.3 " ;
25
+ var VERSION = "2.0.4 " ;
26
26
var MML = MathJax . ElementJax . mml ,
27
27
HTMLCSS = MathJax . OutputJax [ "HTML-CSS" ] ;
28
28
@@ -36,7 +36,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
36
36
badbreak : [ + 200 ] ,
37
37
auto : [ 0 ] ,
38
38
39
- toobig : 500 ,
39
+ toobig : 800 ,
40
40
nestfactor : 400 ,
41
41
spacefactor : - 100 ,
42
42
spaceoffset : 2 ,
@@ -159,7 +159,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
159
159
better = true ; index = [ i ] . concat ( info . index ) ; W = info . W ; w = info . w ;
160
160
if ( info . penalty === PENALTY . newline ) { info . index = index ; info . nest -- ; return true }
161
161
}
162
- if ( ! broken ) { scanW = this . HTMLaddWidth ( i , info , scanW ) }
162
+ scanW = ( broken ? info . scanW : this . HTMLaddWidth ( i , info , scanW ) ) ;
163
163
}
164
164
info . index = [ ] ; i ++ ; broken = false ;
165
165
}
@@ -193,7 +193,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
193
193
this . HTMLmoveLine ( start , end , line , state , values ) ;
194
194
this . HTMLcleanBBox ( line . bbox ) ;
195
195
//
196
- // Get the alignment and shift values
196
+ // Get the alignment and shift values
197
197
//
198
198
var align = this . HTMLgetAlign ( state , values ) ,
199
199
shift = this . HTMLgetShift ( state , values , align ) ;
@@ -404,7 +404,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
404
404
better = true ; index = [ i ] . concat ( info . index ) ; W = info . W ; w = info . w ;
405
405
if ( info . penalty === PENALTY . newline ) { info . index = index ; info . nest -- ; return true }
406
406
}
407
- if ( ! broken ) { scanW = this . HTMLaddWidth ( k , info , scanW ) }
407
+ scanW = ( broken ? info . scanW : this . HTMLaddWidth ( i , info , scanW ) ) ;
408
408
}
409
409
info . index = [ ] ; i ++ ; broken = false ;
410
410
}
@@ -419,7 +419,6 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
419
419
if ( i === j && start . length > 1 ) {
420
420
//
421
421
// If starting and ending in the same element move the subpiece to the new line
422
- // Add the closing fence, if present
423
422
//
424
423
this . data [ this . dataI [ i ] ] . HTMLmoveSlice ( start . slice ( 1 ) , end . slice ( 1 ) , span , state , values , "paddingLeft" ) ;
425
424
} else {
@@ -436,8 +435,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
436
435
i ++ ; k = this . dataI [ i ] ; state . first = false ; start = [ ] ;
437
436
}
438
437
//
439
- // If the last item is complete, move it and the closing fence,
440
- // otherwise move the first part of it up to the split
438
+ // If the last item is complete, move it
441
439
//
442
440
state . last = last ;
443
441
if ( this . data [ k ] ) {
@@ -451,6 +449,74 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
451
449
452
450
/**************************************************************************/
453
451
452
+ MML . msubsup . Augment ( {
453
+ HTMLbetterBreak : function ( info , state ) {
454
+ if ( ! this . data [ this . base ] ) { return false }
455
+ //
456
+ // Get the current breakpoint position and other data
457
+ //
458
+ var index = info . index . slice ( 0 ) , i = info . index . shift ( ) ,
459
+ W , w , scanW , broken = ( info . index . length > 0 ) , better = false ;
460
+ if ( ! broken ) { info . W += info . w ; info . w = 0 }
461
+ scanW = info . scanW = info . W ;
462
+ //
463
+ // Record the width of the base and the super- and subscripts
464
+ //
465
+ if ( i == null ) {
466
+ this . HTMLbaseW = this . data [ this . base ] . HTMLspanElement ( ) . bbox . w ;
467
+ this . HTMLdw = this . HTMLspanElement ( ) . bbox . w - this . HTMLbaseW ;
468
+ }
469
+ //
470
+ // Check if the base can be broken
471
+ //
472
+ if ( this . data [ this . base ] . HTMLbetterBreak ( info , state ) ) {
473
+ better = true ; index = [ this . base ] . concat ( info . index ) ; W = info . W ; w = info . w ;
474
+ if ( info . penalty === PENALTY . newline ) { better = broken = true }
475
+ }
476
+ //
477
+ // Add in the base if it is unbroken, and add the scripts
478
+ //
479
+ if ( ! broken ) { this . HTMLaddWidth ( this . base , info , scanW ) }
480
+ info . scanW += this . HTMLdw ; info . W = info . scanW ;
481
+ info . index = index ; if ( better ) { info . W = W ; info . w = w }
482
+ return better ;
483
+ } ,
484
+
485
+ HTMLmoveLine : function ( start , end , span , state , values ) {
486
+ //
487
+ // Move the proper part of the base
488
+ //
489
+ if ( this . data [ this . base ] ) {
490
+ if ( start . length > 1 ) {
491
+ this . data [ this . base ] . HTMLmoveSlice ( start . slice ( 1 ) , end . slice ( 1 ) , span , state , values , "paddingLeft" ) ;
492
+ } else {
493
+ if ( end . length <= 1 ) { this . data [ i ] . HTMLmoveSpan ( span , state , values ) }
494
+ else { this . data [ this . base ] . HTMLmoveSlice ( [ ] , end . slice ( 1 ) , span , state , values , "paddingRight" ) }
495
+ }
496
+ }
497
+ //
498
+ // If this is the end, check for super and subscripts, and move those
499
+ // by moving the stack tht contains them, and shifting by the amount of the
500
+ // base that has been removed. Remove the empty base box from the stack.
501
+ //
502
+ if ( end . length === 0 ) {
503
+ var s = this . data [ this . sup ] || this . data [ this . sub ] ;
504
+ if ( s ) {
505
+ var box = s . HTMLspanElement ( ) . parentNode , stack = box . parentNode ;
506
+ if ( this . data [ this . base ] ) { stack . removeChild ( stack . firstChild ) }
507
+ for ( box = stack . firstChild ; box ; box = box . nextSibling )
508
+ { box . style . left = HTMLCSS . Em ( HTMLCSS . unEm ( box . style . left ) - this . HTMLbaseW ) }
509
+ stack . bbox . w -= this . HTMLbaseW ; stack . style . width = HTMLCSS . Em ( stack . bbox . w ) ;
510
+ this . HTMLcombineBBoxes ( stack , span . bbox ) ;
511
+ span . appendChild ( stack ) ;
512
+ }
513
+ }
514
+ }
515
+
516
+ } ) ;
517
+
518
+ /**************************************************************************/
519
+
454
520
MML . mo . Augment ( {
455
521
//
456
522
// Override the method for checking line breaks to properly handle <mo>
0 commit comments