I have a confusion about the workings of the Word OpenXml elements Run
, Break
and Text
when it comes to the Text's space="preserve"
directive.
If I have a set of elements such as:
<w:p>
<w:r>
<w:t xml:space="preserve">Medical Admissions are counted where blah</w:t>
</w:r>
<w:r>
<w:br />
<w:t xml:space="preserve">Surgical Admissions are counted where blah</w:t>
</w:r>
</w:p>
Then Word shows this as below - note the leading space before Surgical:
Medical Admissions are counted where the blah blah blah</w:t>
Surgical Admissions are counted where the blah</w:t>
If I remove the space="preserve"
attribute, then all is good unless the Run
ends in a trailing space. Then I need to preserve the trailing space, but then the unwanted leading space reappears.
Both Run
elements have space="preserve"
, so why does Word not show a space on the first Run
in the Paragraph
, but does show a space after the Break
, even though there is no leading whitespace to be preserved?
I've tried putting the Break
element into its own Run
element - same result.