Repository navigation
fix(md): preserve whitespace around inline emphasis in table cells - #4318
Conversation
|
✅ DCO Check Passed Thanks @Anurag-M1, all your commits are properly signed off. 🎉 |
8a9bea0 to
9b29683
Compare
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
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
When parsing Markdown tables, table row text is accumulated in md_table_buffer across Markdown AST tokens. Previously, each snippet was stripped with .strip(), which caused spaces following or preceding inline emphasis tokens (like '**C** Cadre') to be dropped, resulting in 'CCadre' and similar squashed text. Avoid stripping snippet text while accumulating table buffer lines, relying on cell trimming during _split_table_row instead. Resolves docling-project#4314 Signed-off-by: Anurag Singh <[email protected]>
9b29683 to
77f04c4
Compare
ceberam
left a comment
There was a problem hiding this comment.
Thanks @Anurag-M1 , the fix is minimal and it targets the right issue.
I added some minor comments. In addition, could you please add the example in a real .md file? We collect these cases in source data files that we used for testing the conversion and serialization in some formats.
The test file tests/data/md/sources/inline_and_formatting.md already has a table at the end with some formatted cells, but not the use case you fixed. Appending your example at the end of that file would be the right choice. Keep in mind that you will need to regenerate the ground-truth files.
- Check original_text directly in MarkdownDocumentBackend table element handling. - Use Google-style docstring in test_convert_table_cell_whitespace_around_inline_emphasis and remove issue reference. - Add inline emphasis table cell test cases to tests/data/md/sources/inline_and_formatting.md. - Regenerate ground-truth test files (inline_and_formatting.md.md and inline_and_formatting.md.yaml). Signed-off-by: Anurag Singh <[email protected]>
|
Thanks for the review @ceberam! I've addressed all the feedback in the latest commit:
All validation checks ( |
Summary
Resolves #4314.
When parsing Markdown tables in
MarkdownDocumentBackend, table row text is accumulated across Markdown tokens inself.md_table_buffer. Previously, each token snippet was stripped withoriginal_text.strip(), which inadvertently stripped leading and trailing whitespace from fragments adjacent to inline emphasis tokens (e.g.**C** Cadre-> cell text becameCCadre).This PR:
_unescape_except_pipe(original_text)instead of stripping each token snippet.**A** **B**)._split_table_row()so cell padding whitespace around|boundaries continues to be cleanly trimmed.Verification
test_convert_table_cell_whitespace_around_inline_emphasisintests/test_backend_markdown.py.tests/test_backend_markdown.pypass: