Skip to content

fix(webvtt): keep the line break after a span end tag - #1029

Merged
ceberam merged 2 commits into
docling-project:mainfrom
Arsh624:fix/webvtt-line-break-after-end-tag
Nov 27, 2026
Merged

ceberam merged 2 commits into
docling-project:mainfrom
Arsh624:fix/webvtt-line-break-after-end-tag

Conversation

@Arsh624

@Arsh624 Arsh624 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

When a cue line ended with an end tag, WebVTTCueBlock.parse dropped the line break after it and joined the next line to the span:

<i>Previously on the show</i>
we met the team.

parsed as <i>Previously on the show</i>we met the team., and docling turned it into *Previously on the show*we met the team. in Markdown.

The text after the end tag starts with the line break, so its first line is empty, and _create_text_components skips empty lines together with their terminator.

Changes

  • Text after a tag now goes through a small helper, _add_text. If that text starts with a line break, the helper puts the terminator on the component right before it, which is either the span that just closed or the text before a stray end tag. That's where the model already keeps a line break that follows a component.

Tests

test_webvtt_parse_line_break_after_end_tag checks that a cue with a line break right after an end tag serializes back unchanged. It covers an italic span, two voice spans, a bold span and a ruby span with <rt>. test_webvtt_parse_line_break_after_stray_end_tag checks that the line break after an ignored stray end tag is kept. Both fail on main and pass with this change.

Closes #1027

@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

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

@mergify

mergify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

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

🟢 Require two reviewer for test updates

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working media Images, audio, video, WebVTT, PDF shapes/widgets, MIME types, ImageRef labels Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit a2824d2d57. 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.

Possibly related pull requests

PR State Signal Assessment
#1079 open changes the same code not assessed
#1031 open changes the same code 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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI first review (advisory): no blocker found

This review covers the full diff at 1bda04a378. It read the code and did not run it.

I found no defect in the change. _add_text in docling_core/types/doc/webvtt.py sets a line feed on the span that just closed. Before the change, _create_text_components dropped that line break. I checked the edge cases: an ignored end tag, text after a start tag, and a close inside <ruby>. The change is correct in each one.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 13, 2026
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

When a cue line ended with an end tag, the text after the tag started
with the line break and an empty first line. `_create_text_components`
skips empty lines, so the line terminator was lost and the next line was
joined to the span: `<i>a</i>` and `b` on two lines became `<i>a</i>b`.

Put that terminator on the span that just closed, which is where the
model keeps a line break that follows a component.

Signed-off-by: Arsh624 <architshukla546@gmail.com>
@Arsh624
Arsh624 force-pushed the fix/webvtt-line-break-after-end-tag branch from 1bda04a to b3eb29b Compare November 26, 2026 19:47
@github-actions github-actions Bot removed ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 26, 2026

@ceberam ceberam 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.

Thanks for the PR, @Arsh624, and for the clear issue write-up. I have only a couple of minor, non-blocking suggestions.

  1. Consider adding one case with a nested or ruby span (e.g. <ruby>a<rt>b</rt></ruby>\nc) to the parametrization, and one where the break follows a stray end tag. It would document that the helper works for every end-tag path, not only the three simple ones.
  2. The PR description says the rest of the suite gives the same results with and without the change. That matches what I saw, so no change is needed, but you could trim the "Tests" section to the behavior covered and leave out the tool outputs.

Signed-off-by: Arsh624 <architshukla546@gmail.com>
@Arsh624

Arsh624 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @ceberam! I added both cases. <ruby>a<rt>b</rt></ruby>\nc is now in the parametrized test, and there's a new test for a</i>\nb: the stray </i> is ignored and the line break after it stays. Both fail on main and pass with the fix. I also cut the Tests section of the description down to what the tests cover. Could you take another look when you get a chance?

@ceberam ceberam 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.

Thanks @Arsh624 for the addressing my comments so quickly!

All looks good now 🚀

@ceberam
ceberam merged commit 5dabd82 into docling-project:main Nov 27, 2026
21 checks passed
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 line break right after a span end tag is dropped

3 participants