I’ve observed that when using multiple runs in an internally linking hyperlink, that the style of the final run is used for all runs. This can be seen as the following XML:
<w:p>
<w:hyperlink w:anchor="bookmark_id">
<w:r>
<w:t xml:space="preserve">Regular display text </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>but this is bold</w:t>
</w:r>
</w:hyperlink>
</w:p>
In this, I’d expected that the content “but this is bold” has bold applied, while the rest has default styling.
In reality all of the text has bold applied as seen in the attached image.
If I include another run with no styling, then all items render as expected.
<w:p>
<w:hyperlink w:anchor="bookmark_id">
<w:r>
<w:t xml:space="preserve">Regular display text </w:t>
</w:r>
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>but this is bold</w:t>
</w:r>
<w:r>
<w:t xml:space="preserve"> and this is not</w:t>
</w:r>
</w:hyperlink>
</w:p>
The following image shows the two hyperlinks in writer:
These documents are created programmatically, and therefore solutions requiring the user interface are not feasible resolutions.
Currently I’ve found the following workarounds:
- Ensure there is a run with no styling and content present as the last run
- Explicitly set formatting to off ( <w:b w:val=“0”/> )
Is this something I am overlooking or should I report a bug? I’d expect that only runs with formatting explicitly applied would receive the formatting and this is the case in other editors such as OnlyOffice.
This is on version 25.2.5.2.
Cheers!