]> git.draconx.ca Git - homepage.git/blobdiff - layouts/default.xsl
Release cdecl99-1.1.
[homepage.git] / layouts / default.xsl
index 84dcf9df801d3a25c0f68a8d1d3b23964174b6a7..a97f784c2d3e2cb63a4446e4b6eaadf0ed2f7f21 100644 (file)
@@ -2,7 +2,7 @@
 <!--
   Nick's web site: XHTML output stage
 
-  Copyright © 2018-2020 Nick Bowler
+  Copyright © 2018-2021 Nick Bowler
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   exclude-result-prefixes='xhtml'>
 
 <xsl:import href='layouts/functions.xsl' />
-
-<xsl:output method='xml' encoding='UTF-8' indent='yes'
-  doctype-public='-//W3C//DTD XHTML 1.1//EN'
-  doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
-  cdata-section-elements='style script' />
+<xsl:output cdata-section-elements='style script' />
 
 <xsl:param name='source-uri'
   select='"//git.draconx.ca/gitweb/homepage.git/"' />
   <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.
   </code></pre>
 </xsl:template>
 
+<!-- For paragraphs containing only kbd elements, wrap in blockquote. -->
+<xsl:template match='xhtml:p[*[last()=count(../xhtml:kbd)]]'>
+  <blockquote>
+    <xsl:copy>
+      <xsl:apply-templates select='node()|@*' />
+    </xsl:copy>
+  </blockquote>
+</xsl:template>
+
+<!--
+  Wrap each word of text in kbd elements in spans, so they can be styled
+  to avoid linebreaks in the middle of option names and other bad places.
+-->
+<xsl:template name='spanify-text' match='xhtml:kbd/text()'>
+  <xsl:param name='text' select='normalize-space(.)' />
+  <xsl:variable name='firstword' select='substring-before($text, " ")' />
+  <xsl:choose>
+    <xsl:when test='$firstword'>
+      <span><xsl:value-of select='$firstword' /></span>
+      <xsl:text> </xsl:text>
+    </xsl:when>
+    <xsl:when test='$text'>
+      <span><xsl:value-of select='$text' /></span>
+    </xsl:when>
+  </xsl:choose>
+  <xsl:if test='$firstword'>
+    <xsl:call-template name='spanify-text'>
+      <xsl:with-param name='text' select='substring-after($text, " ")' />
+    </xsl:call-template>
+  </xsl:if>
+</xsl:template>
+
 <xsl:template match='copyright'>
   <p>
     <xsl:text>Copyright © </xsl:text>
   </html>
 </xsl:template>
 
+<xsl:include href='layouts/clickytable.xsl' />
+
 </xsl:stylesheet>