We don't want to add whitespace to span-level elements which were
empty to start with, which is normal for e.g. img elements.
Also, if an element contains _only_ whitespace, it was probably put
there on purpose so let's preserve it.
<xsl:call-template name='glue-preceding-span' />
<xsl:copy>
<xsl:apply-templates select='node()|@*' />
- <xsl:text>⁠</xsl:text> <!-- avoid breaking within a span element -->
+ <xsl:if test='*'>
+ <!-- avoid breaking within a span element -->
+ <xsl:text>⁠</xsl:text>
+ </xsl:if>
</xsl:copy>
</xsl:template>
</xsl:when>
<!-- preserve anything under <pre> -->
<xsl:when test='ancestor::xhtml:pre'><xsl:copy /></xsl:when>
+ <!-- preserve whitespace which is the only child node of an element -->
+ <xsl:when test='count(../node()) = 1'><xsl:copy /></xsl:when>
</xsl:choose>
</xsl:template>