Skip to content

Commit eb3ae78

Browse files
committed
Fix unwanted lines in lyrics mode
Props @conorom. Fixes #591.
1 parent 82b218c commit eb3ae78

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

scripts/transcript.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@
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++) {
@@ -630,13 +630,22 @@
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 += " ";

0 commit comments

Comments
 (0)