File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 617617 }
618618 }
619619 if ( comp . type === "b" || comp . type == "i" ) {
620- result . push ( $tag , " " ) ;
620+ result . push ( $tag ) ;
621621 }
622622 } else {
623623 for ( var i = 0 ; i < comp . children . length ; i ++ ) {
630630 } ;
631631
632632 for ( var i = 0 ; i < cap . components . children . length ; i ++ ) {
633+ var next_child_tagname ;
634+ if ( i < cap . components . children . length - 1 ) {
635+ next_child_tagname = cap . components . children [ i + 1 ] . tagName ;
636+ }
633637 var results = flattenComponentForCaption ( cap . components . children [ i ] ) ;
634638 for ( var jj = 0 ; jj < results . length ; jj ++ ) {
635639 var result = results [ jj ] ;
636640 if ( typeof result === "string" ) {
637- if ( thisObj . lyricsMode ) {
638- // add <br> BETWEEN each caption and WITHIN each caption (if payload includes "\n")
639- result = result . replace ( / \n / g, "<br>" ) + "<br>" ;
641+ if ( thisObj . lyricsMode ) {
642+ // add <br> WITHIN each caption (if payload includes "\n")
643+ result = result . replace ( '\n' , '<br>' ) ;
644+
645+ // add <br> BETWEEN each caption, but do not consider sibling style tags within this caption as the next caption!
646+ if ( ! next_child_tagname || ( next_child_tagname !== 'i' && next_child_tagname !== 'b' ) ) {
647+ result += '<br>' ;
648+ }
640649 } else {
641650 // just add a space between captions
642651 result += " " ;
You can’t perform that action at this time.
0 commit comments