Repository navigation
Fix UnicodeMapper's trimming of some whitespace that should be preserved - #248
Merged
stesee merged 2 commits intoOct 24, 2026
Merged
Conversation
stesee
approved these changes
Oct 24, 2026
stesee
reviewed
Oct 24, 2026
| ReadOnlySpan<char> span = preserve | ||
| ? text.AsSpan() | ||
| : text.AsSpan().Trim(); | ||
| : text.AsSpan().Trim(" \t\r\n"); |
Collaborator
There was a problem hiding this comment.
Have you thought about other spots that may need the same fix?
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Word retains NBSP and other Unicode whitespace at the boundaries of w:t elements without xml:space="preserve". UnicodeMapper currently uses the general Unicode Trim(), deleting these characters. Split-run text can consequently lose a separator, and mapper round trips or regex replacements can lose text or matches.
Limit boundary trimming to XML whitespace: space, tab, CR, and LF. Existing internal line-ending/tab normalization and preservation behavior stay the same.
Keep the original 107-case Word comparison and add 43 synthetic cases opened and saved by Word for Mac 16.114. The additional fixture covers Unicode whitespace, absent/default/preserve settings, split runs, standalone NBSP, and referenced CR/CRLF. Include reviewable source XML and reproduction/provenance notes. Also test NBSP mapper round trips and repeated split-run replacements with surrounding text.
Validation on Codeuctivity main at 0d55d75 plus only these two commits:
The change introduces no dependency, namespace, or target-framework changes. All added DOCX fixtures are synthetic.