Skip to content

fix(cli): preserve literal WebVTT cue text - #5236

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/cli-vtt-literal-cue-text
Oct 8, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/cli-vtt-literal-cue-text

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

WebVTT sidecars write normalized transcript text directly as cue markup. A literal <config> disappears when Chrome displays the cue, and literal &lt; becomes <. Importing encoded cues also keeps entity spellings instead of their displayed characters, so export/import does not preserve the text.

Escape ampersands and angle brackets in exported WebVTT payloads, and decode imported character references once after the existing tag removal. Reuse the existing linkedom dependency, protect literal less-than signs before entity decoding, and skip decoding for plain cues without ampersands. Add literal-text round trips and encoded payload cases, including numeric entities, actual cue formatting, unknown entities, and bidirectional marks.

Validation:

  • Ten new cases fail before the fix; 225 caption/transcription tests pass afterward, with one existing platform skip. The final normalizer suite passes all 51 tests.
  • Actual CLI: five exports/reimports and seven encoded imports preserve text and timing; repeated exports are byte-stable and leave inputs unchanged.
  • Chrome native TextTrack display matches expected text and timestamps in all twelve CLI-generated or imported cases.
  • CLI build/typecheck, repository lint, formatting, comment checks, and all commit hooks passed.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escaping &, < and > on export is what the WebVTT spec requires, and decoding character references once on import makes an export followed by a re-import round-trip correctly. The tests cover the important edge cases. One ordering note: with decoding in place, an imported &lt;/script&gt; becomes a literal </script> that reaches patchCaptionHtml, so this should land after #5226, which escapes it there. Minor and optional: the linkedom document could be created once per parse instead of once per cue.

— Rames

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 8, 2026
Merged via the queue into heygen-com:main with commit 1fac5fb Oct 8, 2026
80 checks passed
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.

2 participants