]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
Try to allow word wrapping to occur in email addresses.
[homepage.git] / layouts / default.xsl
index f0fddc97bb27cf9063ad403f27612f4c35b48953..a97f784c2d3e2cb63a4446e4b6eaadf0ed2f7f21 100644 (file)
   <pre>&#x2060;<code><xsl:value-of select='f:strip-leading(.)' /></code></pre>
 </xsl:template>
 
+<!--
+  Attempt to wrap the first bit of linked email addresses to allow
+  linewrapping to occur after the '@'.
+-->
+<xsl:template match='xhtml:a[starts-with(@href,"mailto:")]/text()'>
+  <xsl:variable name='addr' select='substring-after(../@href, "mailto:")' />
+
+  <xsl:variable name='wrap'
+    select='concat(substring-before($addr, "@"), "@")' />
+
+  <xsl:choose>
+    <xsl:when test='contains(., $wrap)'>
+      <xsl:value-of select='substring-before(., $wrap)' />
+      <span class='wbr'>
+        <xsl:value-of select='$wrap' />
+      </span>
+      <xsl:value-of select='substring-after(., $wrap)' />
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy />
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <!--
   Add a simple way to reference a document node by ID and include the XHTML
   code listing directly in the document.