Skip to content

Remove single trailing newlines from strict subtitle content - #105

Open
civilwarinfrance wants to merge 1 commit into
cdown:developfrom
civilwarinfrance:fix/strict-trailing-newline
Open

civilwarinfrance wants to merge 1 commit into
cdown:developfrom
civilwarinfrance:fix/strict-trailing-newline

Conversation

@civilwarinfrance

Copy link
Copy Markdown

make_legal_content("caption\n") currently returns the trailing newline unchanged because its fast path only checks the first character and internal blank lines. Consequently, strict Subtitle.to_srt() and compose() emit three newlines after that cue instead of the usual two.

Check the last character before taking the fast path, so this input uses the existing boundary-newline normalization. Legal multiline content and horizontal whitespace are preserved; non-strict output is unchanged.

Validation on macOS with Python 3.9.6:

  • The new regression file has 11 failures and 11 passing controls on the unchanged baseline; all 22 cases pass after the fix. It checks exact LF/CRLF output from to_srt() and compose(), non-strict controls, Unicode, and whitespace preservation.
  • Full tests and doctests: 73 passed, with 100% statement and branch coverage for srt.py.
  • Both configured Black checks, Pytype and Bandit pass.
  • The configured Pylint command reports the same three diagnostics before and after this change: a removed C0330 option and two existing positional-argument warnings. The full OS/Python CI matrix was not run locally.

AI assistance: This patch, tests and description were prepared with Codex (GPT-6).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant