Skip to content

fix(webvtt): keep cue text in order after a multi-line span - #4105

Merged
cau-git merged 1 commit into
docling-project:mainfrom
businessarshgoyal:devin/1787996794-vtt-multiline-span
Sep 2, 2026
Merged

cau-git merged 1 commit into
docling-project:mainfrom
businessarshgoyal:devin/1787996794-vtt-multiline-span

Conversation

@businessarshgoyal

Copy link
Copy Markdown
Contributor

WebVTTDocumentBackend cached the current cue paragraph in a local variable before walking a cue payload. A nested span (voice, bold, italic, underline) that wraps a line terminator starts a new paragraph inside the recursive call, so after returning the caller was still appending to the paragraph it had cached — text following the span landed on the first line of the cue instead of the line it actually appears on.

For

00:00:01.000 --> 00:00:05.000
<v Bob>Hello
there</v> and afterwards

the cue used to produce ['Hello', ' and afterwards', 'there']; it now produces ['Hello', 'there', ' and afterwards'].

The fix appends to cue_text[-1] instead of a cached reference, which is by construction the paragraph the terminator handling last opened, at any nesting depth. No existing ground truth changes; the four WebVTT reference documents are unaffected.

Issue resolved by this Pull Request:
Resolves #4104

Checklist:

  • Documentation has been updated, if necessary. (not necessary — no user-facing API change)
  • Examples have been added, if necessary. (not necessary)
  • Tests have been added, if necessary.

Verified with uv run pytest tests/test_backend_vtt.py (12 passed) and make check (ruff clean; the ty and max-lines findings it reports are pre-existing and untouched by this change). The new test fails on main and passes with the fix.

AI disclosure: the patch and test were written with an AI coding agent (Devin) and reviewed and run locally by me.

A nested span that wraps a line terminator starts a new paragraph inside
the recursive call, while the caller kept appending to the paragraph it
had cached before recursing. Text following the span was therefore
attached to the first line of the cue instead of the line it appears on.

Signed-off-by: Business.arshgoyal <business.arshgoyal@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @businessarshgoyal, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@cau-git
cau-git merged commit 397bd4e into docling-project:main Sep 2, 2026
26 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.

webvtt: text after a multi-line span is attached to the wrong cue line

3 participants