fix(docx): preserve field display text (fldSimple, MACROBUTTON) - #2553
Open
Rohan Patnaik (rohan-patnaik) wants to merge 1 commit into
Open
Rohan Patnaik (rohan-patnaik) wants to merge 1 commit into
Rohan Patnaik (rohan-patnaik) wants to merge 1 commit into
Conversation
Mammoth has no handler for w:fldSimple, so simple fields are dropped along with the child runs holding their cached result, and it never emits field instructions, so MACROBUTTON fields (whose display text is the trailing argument of the instruction, with no result runs) vanish entirely. Text carried in Word fields was silently missing from the Markdown output. Add a _pre_process_fields step for document/footnotes/endnotes XML that unwraps w:fldSimple elements so their cached result runs convert like ordinary content, and rewrites the MACROBUTTON instruction of fields without a separator (simple or complex) into text runs holding only the display-text argument. Other instructions are still never emitted, and complex fields with a separator are untouched since Mammoth already converts their result runs. Fixes microsoft#1247
Rohan Patnaik (rohan-patnaik)
force-pushed
the
fix/docx-field-text
branch
from
September 24, 2026 20:02
8b9f76e to
bf7054a
Compare
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.
Fixes #1247.
Summary
DOCX conversion dropped visible text from simple fields and separator-less
MACROBUTTONfields. This adds a preprocessing step that:w:fldSimplecached result runs, using theMACROBUTTONdisplay argument only when needed;MACROBUTTONfields without exposing other field instructions; andTests
b8f79c5and pass here.The reporter's currently hosted 3GPP sample no longer contains fields, so this fixes the field-loss mechanism without changing that reprocessed file.