mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-14 19:26:59 -04:00
Captions: preserve tab-separated WebVTT voices
This commit is contained in:
1 parent
71438c627b
commit
20d196401a
1 file changed
+14
-1
@@ -38,7 +38,7 @@ pub fn split_voice(text: &str) -> (Option<String>, String) {
|
||||
Some(_) => return (None, text.to_string()),
|
||||
None => body.to_string(),
|
||||
};
|
||||
if body.contains("<v ") || body.contains("<v.") {
|
||||
if body.contains("<v ") || body.contains("<v.") || body.contains("<v\t") {
|
||||
return (None, text.to_string());
|
||||
}
|
||||
return ((!name.is_empty()).then(|| name.to_string()), body);
|
||||
@@ -177,6 +177,19 @@ mod tests {
|
||||
assert_eq!(split_voice("<vx>hi"), (None, "<vx>hi".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiple_voices_with_tab_separator() {
|
||||
let text = "<v Ann>Hello <v\tBob>there";
|
||||
assert_eq!(split_voice(text), (None, text.to_string()));
|
||||
let source = format!("WEBVTT\n\n00:00:01.000 --> 00:00:02.000\n{text}\n");
|
||||
let doc = parse(&source).unwrap();
|
||||
assert_eq!(doc.cues[0].speaker, None);
|
||||
assert_eq!(doc.cues[0].text, text);
|
||||
assert_eq!(parse(&write(&doc)).unwrap().cues, doc.cues);
|
||||
let closed = "<v Ann>Hi <v\tBob>x</v>";
|
||||
assert_eq!(split_voice(closed), (None, closed.to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_signature() {
|
||||
let d = parse("00:00:01.000 --> 00:00:02.000\nx\n").unwrap();
|
||||
|
||||
Reference in new issue
Block a user