Match on the text
nodes:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()[following-sibling::node()[1][self::sub]]
| text()[preceding-sibling::node()[1][self::sub]]">
<text>
<xsl:value-of select="."/>
</text>
</xsl:template>
</xsl:stylesheet>
Of course if you don't want that behaviour for all text
nodes then edit the match pattern to say e.g. match="p/text()[following-sibling::node()[1][self::sub]] | p/text()[preceding-sibling::node()[1][self::sub]]"
.