mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-24 10:10:05 -06:00
Keep WebVTT cues whose identifier starts with NOTE
Found while testing crates/captions/src/vtt.rs:75 (parse, NOTE block check) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
70f0fc7a75
commit
2736a1831e
@@ -79,7 +79,7 @@ pub fn parse(text: &str) -> Result<Document> {
|
||||
let mut seen_cue = false;
|
||||
for b in blocks {
|
||||
let first = b[0].trim();
|
||||
if !first.contains("-->") && (first == "NOTE" || first.starts_with("NOTE ") || first.starts_with("NOTE\t")) {
|
||||
if !b.iter().any(|l| l.contains("-->")) && (first == "NOTE" || first.starts_with("NOTE ") || first.starts_with("NOTE\t")) {
|
||||
doc.blocks.push(b.join("\n"));
|
||||
continue;
|
||||
}
|
||||
@@ -190,6 +190,14 @@ mod tests {
|
||||
assert_eq!(split_voice(closed), (None, closed.to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_prefixed_cue_id_is_a_cue() {
|
||||
let d = parse("WEBVTT\n\nNOTE 1\n00:00:01.000 --> 00:00:02.000\nhello\n").unwrap();
|
||||
assert_eq!(d.cues.len(), 1);
|
||||
assert_eq!(d.cues[0].id.as_deref(), Some("NOTE 1"));
|
||||
assert!(d.blocks.is_empty());
|
||||
}
|
||||
|
||||
#[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