Skip to content

fix(webvtt): keep cues with misnested end tags - #1079

Open
aad1tyaaaaa wants to merge 2 commits into
docling-project:mainfrom
aad1tyaaaaa:fix-webvtt-stray-lt-misnested
Open

aad1tyaaaaa wants to merge 2 commits into
docling-project:mainfrom
aad1tyaaaaa:fix-webvtt-stray-lt-misnested

Conversation

@aad1tyaaaaa

@aad1tyaaaaa aad1tyaaaaa commented Nov 26, 2026 •

Copy link
Copy Markdown

Fixes #1078

A cue with misnested end tags (<b><i>x</b></i>) made WebVTTCueBlock.parse raise Incorrect end tag, so the whole cue was dropped from the converted document.

Change (webvtt.py): an end tag that does not close the innermost open span is ignored, as WebVTT §6.4 requires ("Otherwise, ignore the token"), instead of raising. <b><i>x</b></i> now parses to <b><i>x</i></b>.

Tests (tests/test_webvtt.py): the "Misnested end tags are still rejected" assertion now checks that such cues are kept and repaired. It fails on main and passes with this change; ruff is clean.

Following the discussion in #1078, this PR no longer changes how a bare < is handled.


I used an AI assistant (Claude Code) to help find this bug and write the fix and tests. I reviewed and ran everything myself.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit —

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

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)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added bug Something isn't working media Images, audio, video, WebVTT, PDF shapes/widgets, MIME types, ImageRef labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit b5f70e7a89. The analysis read the diff only. It did not run code from this pull request.

Warning

The AI analysis did not finish. Only the deterministic checks are shown.

CI safety: not assessed.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ceberam

ceberam commented Nov 26, 2026

Copy link
Copy Markdown
Member

@aad1tyaaaaa Thanks for suggesting this PR. Before entering into the development details, I added a comment to the issue conversation on how I see the scope of this PR.
#1078 (comment)

@aad1tyaaaaa aad1tyaaaaa changed the title fix(webvtt): keep cues with a stray '<' or misnested end tags fix(webvtt): keep cues with misnested end tags Nov 27, 2026
@ceberam

ceberam commented Nov 27, 2026

Copy link
Copy Markdown
Member

@aad1tyaaaaa There is a conflict with docling_core/types/doc/webvtt.py. The best would be to rebase to the latest main.

A bare '<' that starts no tag, as in "x < 5", is now kept as text
instead of failing validation. An end tag that does not close the
innermost open span is ignored, as the WebVTT cue text parsing rules
require, instead of raising "Incorrect end tag". In both cases the
whole cue used to be dropped.

Signed-off-by: aad1tyaaaaa <aadityaaaaa.jaiswar@gmail.com>
Signed-off-by: aad1tyaaaaa <aadityaaaaa.jaiswar@gmail.com>
@aad1tyaaaaa
aad1tyaaaaa force-pushed the fix-webvtt-stray-lt-misnested branch from 63709f3 to b5f70e7 Compare November 29, 2026 07:19

This branch has not been deployed

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

Labels

bug Something isn't working media Images, audio, video, WebVTT, PDF shapes/widgets, MIME types, ImageRef

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebVTT: a cue with a bare '<' or misnested end tags is dropped

2 participants