]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
Tweak whitespace-preserving templates.
[homepage.git] / layouts / default.xsl
index 5a01d79cfcf870176fbc94052b4fa7c1765f3a73..bfe9101a6bb4c55444dd5171d5b39366f566220a 100644 (file)
   <xsl:call-template name='glue-preceding-span' />
   <xsl:copy>
     <xsl:apply-templates select='node()|@*' />
   <xsl:call-template name='glue-preceding-span' />
   <xsl:copy>
     <xsl:apply-templates select='node()|@*' />
-    <xsl:text>&#x2060;</xsl:text> <!-- avoid breaking within a span element -->
+    <xsl:if test='*'>
+      <!-- avoid breaking within a span element -->
+      <xsl:text>&#x2060;</xsl:text>
+    </xsl:if>
   </xsl:copy>
 </xsl:template>
 
   </xsl:copy>
 </xsl:template>
 
     </xsl:when>
     <!-- preserve anything under <pre> -->
     <xsl:when test='ancestor::xhtml:pre'><xsl:copy /></xsl:when>
     </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>
 
   </xsl:choose>
 </xsl:template>