fix(cli): format warm-grain captions and fix TS nullability errors

- Format warm-grain/compositions/captions.html
- Add optional chaining on token.offsets (may be undefined)
- Use intermediate variable for lastWord to satisfy TS strict checks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-03-26 18:03:35 +00:00
committed by Vance Ingalls
co-authored by Claude Opus 4.6
parent b22799ff9a
commit dce10e3e3b
2 changed files with 12 additions and 6 deletions
+6 -5
View File
@@ -244,16 +244,17 @@ function patchTranscript(dir: string, transcriptPath: string): void {
// Merge punctuation with the previous word
const isPunctuation = /^[.,!?;:'")\]}>…–—-]+$/.test(text);
if (isPunctuation && words.length > 0) {
words[words.length - 1].text += text;
words[words.length - 1].end = Math.round((token.offsets.to / 1000) * 1000) / 1000;
const lastWord = words[words.length - 1];
if (isPunctuation && lastWord) {
lastWord.text += text;
lastWord.end = Math.round(((token.offsets?.to ?? 0) / 1000) * 1000) / 1000;
continue;
}
words.push({
text,
start: Math.round((token.offsets.from / 1000) * 1000) / 1000,
end: Math.round((token.offsets.to / 1000) * 1000) / 1000,
start: Math.round(((token.offsets?.from ?? 0) / 1000) * 1000) / 1000,
end: Math.round(((token.offsets?.to ?? 0) / 1000) * 1000) / 1000,
});
}
}
@@ -1,5 +1,10 @@
<template id="captions-template">
<div data-composition-id="captions" data-width="1920" data-height="1080" data-duration="__VIDEO_DURATION__">
<div
data-composition-id="captions"
data-width="1920"
data-height="1080"
data-duration="__VIDEO_DURATION__"
>
<div class="captions-container">
<div id="caption-box" class="caption-box">
<span id="caption-text" class="caption-text"></span>