Skip to content

Preserve spaces around template tags (#104)#117

Open
donaldevine wants to merge 2 commits into
mini-software:mainfrom
donaldevine:fix/preserve-spaces-104
Open

Preserve spaces around template tags (#104)#117
donaldevine wants to merge 2 commits into
mini-software:mainfrom
donaldevine:fix/preserve-spaces-104

Conversation

@donaldevine

Copy link
Copy Markdown

Fixes #104

Problem

Spaces between template tags (or between tags and words) were dropped in the generated document. E.g. From {{a}} to {{b}} rendered as From 11-may-2025to 11-may-2026.

Cause

In OOXML, leading/trailing whitespace in a <w:t> element is stripped unless the element has xml:space="preserve". Text elements created during tag replacement were missing this attribute (which is also why non-breaking spaces were unaffected, as noted in the issue).

Fix

Set Space = SpaceProcessingModeValues.Preserve on Text elements created during replacement.

Testing

Reproduced the issue. After the fix, spaces are preserved correctly.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the text assignment in MiniWord.Implment.cs to use the string representation of a StringBuilder and preserves whitespace formatting. The review feedback suggests caching the StringBuilder's string representation to avoid redundant allocations and improve performance.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/MiniWord/MiniWord.Implment.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spaces are not shown in final result.

1 participant