Repository navigation
fix(backend): identify and preserve subscripts and superscripts in table cells - #4809
abhinavchinna wants to merge 1 commit into
Conversation
…ble cells Ensure table cells identify, preserve, and serialize subscript and superscript formatting identically to body text across all document backends: - DOCX: Preserve InlineGroup elements inside rich table cell groups instead of stripping runs to unformatted groups. Wrap standalone formatted runs in an InlineGroup and pass the parent paragraph context to Run instances. - ODF: Check paragraph children for styled text:span and text:a tags in _odf_cell_has_rich_content so single-paragraph cells with script formatting are classified as rich. - JATS XML: Walk soup table cells with _walk_soup_cell to preserve inline script tags (sub, sup), map HTML format tags (b, i, u, s), and construct RichTableCell pointing to the emitted InlineGroup. Guard internalDTD against NoneType error. - Chandra / Dots: Ensure single runs with Script.SUB or Script.SUPER are wrapped in an InlineGroup. - Tests: Add targeted unit tests for DOCX, ODF, and JATS table cell script preservation and update groundtruth data where table scripts were previously dropped. Signed-off-by: abhinav chinna lachannagari <abhi02111999@gmail.com>
|
✅ DCO Check Passed Thanks @abhinavchinna, all your commits are properly signed off. 🎉 |
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR keeps subscript and superscript formatting inside table cells for DOCX, ODF, JATS XML and Chandra/Dots output. Table cells with scripts now become Topic labels added: CI safety: needs maintainer care before you approve CI.
1 related pull request(s) in the same code
Reference data changes
Assessment: expected. The changes match the code change. The JATS and ODF files gain text items and changed table rows because cells with scripts now get inline groups. The DOCX file changes reading order because cell content is now grouped differently. The diff content of these files was not available, so the exact text was not checked. The |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
This PR fixes an issue where subscript and superscript formatting inside table cells was either dropped or broken into disconnected block paragraphs across document backends (DOCX, ODF, JATS XML, and Chandra/Dots).
Changes
msword_backend.py):InlineGroupitems when grouping elements in rich table cells instead of stripping runs into flatUNSPECIFIEDgroups.InlineGroup.Runinstances in_is_rich_table_cellto ensure run formatting is read accurately.opendocument_backend.py):text:spanandtext:atags in_odf_cell_has_rich_contentto prevent single-paragraph cells with script formatting from degrading to plain text cells.jats_backend.py):b,i,u,s) to_JATS_FORMAT_TAG_MAP._walk_soup_cellto preserve inline formatting (<sub>,<sup>, links) inside table cells and constructsRichTableCellpointing to anInlineGroup.doc_info.internalDTDfromAttributeErrorwheninternalDTDisNone.chandra_utils.py):Script.SUBorScript.SUPERinto anInlineGroup.tests/test_backend_msword.py,tests/test_backend_opendocument.py, andtests/test_backend_jats.py.Validation
prek/ruff,ty,tach, line checks) pass cleanly.