fix: preserve unknown empty elements inside runs (w:commentReference)#5
Open
dryheatwindbag wants to merge 1 commit into
Open
fix: preserve unknown empty elements inside runs (w:commentReference)#5dryheatwindbag wants to merge 1 commit into
dryheatwindbag wants to merge 1 commit into
Conversation
CT_R::from_xml's Event::Empty branch handled tab/br/footnoteReference/ endnoteReference and silently dropped every other empty element inside <w:r>. This destroys w:commentReference anchors on round-trip (the comments part survives but every comment is orphaned), and loses any other empty run-level markup. Add the same unknown-element fallback the function already has for Event::Start (and CT_P has for both): capture the element into extra_xml via capture_empty_element. Includes a regression test: a run containing <w:commentReference/> round-trips verbatim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
CT_R::from_xml'sEvent::Emptybranch handlestab,br,footnoteReference, andendnoteReference— and silently drops every other empty element inside<w:r>.The most visible casualty is
w:commentReference: on any read→write round-trip of a document containing Word comments, theword/comments.xmlpart and its relationship survive, but the body anchors are destroyed — every comment is orphaned. Any other empty run-level markup (current or future OOXML, vendor extensions) is likewise lost.Fix
One
elsearm, mirroring the unknown-element fallback the function already has forEvent::Start(and thatCT_P::from_xmlhas for both event kinds):Test
Adds
unknown_empty_run_children_roundtrip: a paragraph whose run contains<w:commentReference w:id="1"/>round-trips verbatim. Fails on main, passes with the fix.cargo test -p rdocx-oxml: 106 passed, 0 failed.cargo fmt --checkclean.Found while round-trip testing documents that carry reviewer comments — happy to adjust anything about the approach.