Repository navigation
fix(webvtt): escape cue text and voice names when exporting to WebVTT - #972
Conversation
|
✅ DCO Check Passed Thanks @Fahmid-Arman, all your commits are properly signed off. 🎉 |
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
AI triage (advisory)Checked commit The PR changes only CI safety: no concern found. A maintainer must still approve CI. Possible duplicates
1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at efaf5562ea. It read the code and did not run it.
No blocking finding. I traced item.text and the voice name through post_process, WebVTTCueBlock.parse, and WebVTTCueTextSpan / WebVTTCueSpanStartTagAnnotated. Each value is escaped once before parsing and decoded once by the validators. __str__ escapes it once on output, so the four test cases are consistent with the model code.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@Fahmid-Arman Thanks a lot for suggesting this PR! |
Signed-off-by: Fahmid Arman <fahmid.brac@gmail.com>
…t round trip Revert the serializer to the state on main, where the escaping was already added by docling-project#926, and keep the cases from the original change as parameters of test_webvtt_export_keeps_text_literal. Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
efaf556 to
e65a82a
Compare
ceberam
left a comment
There was a problem hiding this comment.
@Fahmid-Arman To accelerate the process, I've just rebased, keeping the tests cases you added. All good to merge 🚀
Resolves #971
export_to_vtt()crashed with aValidationErrorwhen a cue's text or voice name contained&or<, and wrote a literal&unescaped, so it read back as&.WebVTTTextSerializerbuilt the cue text from the rawitem.text, and_add_spanused the raw voice name as the<v>annotation.serialize_docthen parses that text withWebVTTCueBlock.parse, which decodes escapes since #776. Both now go through the existing_escapehelper fromdocling_core.types.doc.webvtt, with the right terminator for each:<for cue text;>for annotations.These are the same rules the parsed data model uses when it writes cues back out.
Review evidence
Tom & JerryValidationErrorTom & Jerrya < bValidationErrora < bAT&TAT&T(reads back asAT&T)AT&amp;TTom & JerryValidationError<v Tom & Jerry>Hello</v>Text without
&or<is written exactly as before (>stays literal in cue text), so the existing WebVTT ground-truth files don't change.test_export_to_vtt_escapes_text_and_voiceintests/test_webvtt.pyexports each case above and parses the result back. It checks the cue line and that the text and voice read back unchanged. All four cases fail onmainand pass with the change.uv run pytest tests: 1366 passed, 12 skipped, 1 xfailed.ruff formatandruff checkare clean.