]> git.draconx.ca Git - homepage.git/commitdiff
Adjust whitespace preservation rules.
authorNick Bowler <nbowler@draconx.ca>
Wed, 24 Jun 2020 05:02:25 +0000 (01:02 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 24 Jun 2020 05:10:29 +0000 (01:10 -0400)
We don't generally want to delete whitespace between span elements.

An exception is made if all sibling text nodes are whitespace, in
which case they should all be removed to allow indentation.

layouts/default.xsl

index f95a2c77805811d0a477025474f996ac50fd59b2..eaeef724f3411cb14ea63a5b6e7593d8fefc0423 100644 (file)
     <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>
+    <!-- preserve whitespace between consecutive span-level elements
+         which have at least one non-whitespace sibling text element -->
+    <xsl:when test='f:element-is-span(preceding-sibling::node()[1])
+                    and f:element-is-span(following-sibling::node()[1])
+                    and ../text()[normalize-space(.) != ""]'>
+      <xsl:copy />
+    </xsl:when>
   </xsl:choose>
 </xsl:template>