Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ impl fmt::Display for WebVtt {
// Write cues
for (i, cue) in self.cues.iter().enumerate() {
if i > 0 {
writeln!(f)?; // Empty line between cues
// Empty line between cues
writeln!(f)?;
writeln!(f)?;
}
write!(f, "{}", cue)?;
}
Expand Down Expand Up @@ -886,19 +888,31 @@ First subtitle"#;
vtt.header.description = Some("Test".to_string());
vtt.add_metadata("Language", "en");

let cue = VttCue {
let cue1 = VttCue {
identifier: None,
start: VttTimestamp::new(Duration::from_secs(1)),
end: VttTimestamp::new(Duration::from_secs(5)),
settings: None,
payload: "Test".to_string(),
};
vtt.add_cue(cue);
vtt.add_cue(cue1);

let cue2 = VttCue {
identifier: None,
start: VttTimestamp::new(Duration::from_secs(5)),
end: VttTimestamp::new(Duration::from_secs(9)),
settings: None,
payload: "Test".to_string(),
};
vtt.add_cue(cue2);

let expected = r#"WEBVTT Test
Language: en

00:00:01.000 --> 00:00:05.000
Test

00:00:05.000 --> 00:00:09.000
Test"#;

assert_eq!(vtt.to_string(), expected);
Expand Down