</xsl:copy>
</xsl:template>
+<!--
+ Allow abbr to apply to document titles too, since these are generated
+ and kramdown's abbr support won't influence them. We do this by just
+ checking each word of the heading to see if is identical to an existing
+ abbr tag, and just substituting that in its place.
+ -->
+<xsl:key name='abbr' match='xhtml:abbr' use='string(.)' />
+<xsl:template name='insert-abbr' match='xhtml:h1/text()'>
+ <xsl:param name='string' select='normalize-space(.)' />
+
+ <xsl:variable name='head'
+ select='substring-before(concat($string, " "), " ")' />
+ <xsl:variable name='tail' select='substring-after($string, " ")' />
+ <xsl:variable name='match' select='key("abbr", $head)[1]' />
+
+ <xsl:choose>
+ <xsl:when test='$match'><xsl:apply-templates select='$match' /></xsl:when>
+ <xsl:otherwise><xsl:value-of select='$head' /></xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test='$tail'>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name='insert-abbr'>
+ <xsl:with-param name='string' select='$tail' />
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
<!--
Convert caption attribute on tables into proper caption elements, to allow
a simple way to add captions to kramdown tables.
<xsl:text>Posted </xsl:text>
<xsl:value-of select='/document/article/published' />
<xsl:if test='/document/article/updated'>
- <xsl:text>, last updated </xsl:text>
- <xsl:value-of select='/document/article/updated' />
+ <xsl:if test='/document/article/updated != /document/article/published'>
+ <xsl:text>, last updated </xsl:text>
+ <xsl:value-of select='/document/article/updated' />
+ </xsl:if>
</xsl:if>
</p>
</xsl:template>