Repository navigation
fix(cli): preserve subtitle cues across line endings - #5223
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
SRT and WebVTT files with Windows line endings do merge every cue into the first one today, because cue blocks are split on a bare blank line. Normalizing CRLF and CR before parsing fixes that without changing the result for LF files, and the new tests fail on main and pass here. Heads up: this conflicts textually with #5233 on the parseVtt header line and with #5224 in the test file, so whichever lands second needs a small rebase.
— Rames
|
Thanks for this fix, it is approved. main has moved since: #5224, #5226, #5233 and #5236 all touched |
jrusso1020
left a comment
There was a problem hiding this comment.
Approve at 693b197f. CRLF and CR line endings in SRT and VTT still split into separate cues after the merge from main, and CI is green.
What changed since my approval at bddc429a
- Main changed
parseVttunderneath this PR. It no longer stripsHEADER: valuelines (#5233 keeps speaker labels), and it adds timestamp handling before cue settings (#5224). - The merge kept main's behaviour and adds only the normalization:
content.replace(/\r\n?/g, "\n"), applied before theWEBVTTheader strip and before the SRT block split (normalize.ts:193,:230). Doing it at the parser entry means the blank-line split, the header regex and the per-line split all see\nonly. - The tests are wrapped in a
subtitle line endingsdescribe block next to main's new suites. None of main's tests were removed. - The diff against main is just
normalize.ts(2 lines) andnormalize.test.ts.
Tests: I couldn't run normalize.test.ts locally: the borrowed dependencies here are too old for current parsers, which is an environment problem. CI ran it at this head, and the required Test and Windows lanes pass. oxfmt --check is clean on both files.
— Rames
Importing an SRT or WebVTT file with Windows CRLF line endings merges every cue into the first entry: the next cue's index and timing line become caption text, and its timing is lost. CR-only files import no cues.
Normalize CRLF and CR to LF before scanning SRT cue boundaries or stripping WebVTT headers. This preserves the existing cue text, stable IDs and timestamps across newline forms.
Validation:
/varversus/private/varpath assertions.