You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inline-styled captions gain an extra space around every styled span on each conversion (grows every round-trip) #467
Captions that contain inline styling pick up extra spaces around the styled spans when converted between formats, and the corruption grows with every round-trip: converting a file, reading it back and converting it again adds one more space around each <b>/<span> each time.
DFXP output shows the same inflation, e.g. a WebVTT caption Hello <b>world</b> end written with DFXPWriter comes out as <span tts:fontWeight="bold">world</span> end, and SAMIWriter applied to a spec-conformant TTML file with <span tts:fontWeight="bold"> produces Hello <b>world</b> end.
Cause
pycaption/sami/writer.py:272 — _recreate_text appends a separator space after every text node:
line+=escape(node.content) +" "
Text nodes already carry the original surrounding whitespace (e.g. 'Hello ' before the tag and ' end' after it), so a styled caption always ends up with a doubled space.
pycaption/dfxp/writer.py:267 (and 272/521) — closing spans are emitted as line.rstrip() + "</span> ", which also injects a space that the next text node usually duplicates.
The readers keep whatever spacing the writers produce, so each conversion adds another one.
Expected behavior
The styled word should keep its single spaces: Hello <b>world</b> end. A pattern that only adds the separator when both neighbors need it (or rstrip/rstrip-join on the accumulated line, like the BREAK branch already does) would fix both writers and make round-trips stable.
Activity