</xsl:template>
<!-- For paragraphs containing only kbd elements, wrap in blockquote. -->
-<xsl:template match='xhtml:p[*[last()=count(../xhtml:kbd)]]'>
+<xsl:template match='xhtml:p[*[last()=count(../xhtml:kbd|../xhtml:br)]]'>
<blockquote>
<xsl:copy>
<xsl:apply-templates select='node()|@*' />
</p>
</xsl:template>
+<!-- Article info block inserted between heading and main contents -->
<xsl:template match='xhtml:h1[not(preceding::xhtml:h1)]'>
+ <xsl:variable name='nodes'
+ select='/document/article/published|//xhtml:*[@article-info]' />
+
<xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
- <xsl:if test='/document/article/published'>
+
+ <xsl:if test='$nodes'>
<div id='article-info'>
- <p>
- <xsl:text>Posted </xsl:text>
- <xsl:value-of select='/document/article/published' />
- </p>
+ <xsl:apply-templates mode='article-info' select='$nodes'>
+ <xsl:sort data-type='number'
+ select='number(generate-id(..)=generate-id(/document/article))' />
+ </xsl:apply-templates>
</div>
</xsl:if>
</xsl:template>
+<xsl:template mode='article-info' match='/document/article/published'>
+ <p>
+ <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>
+ </p>
+</xsl:template>
+
+<xsl:template match='*[@article-info]' />
+<xsl:template mode='article-info' match='*[@article-info]'>
+ <xsl:copy>
+ <xsl:apply-templates select='@*[local-name() != "article-info"]' />
+ <xsl:apply-templates select='node()' />
+ </xsl:copy>
+</xsl:template>
+
<xsl:template name='imgpara' match='xhtml:p[count(*)=1]
[normalize-space(text())=""]
[descendant::xhtml:img]'>
<xsl:variable name='images' select='key("gallery", generate-id(.))' />
<xsl:choose>
<xsl:when test='count($images) > 1'>
- <div class='gallery'>
+ <div>
+ <xsl:attribute name='class'>
+ <xsl:text>gallery</xsl:text>
+ <xsl:if test='//xhtml:a[f:contains-token(@class, "left")
+ or f:contains-token(@class, "right")]'>
+ <xsl:text> inline</xsl:text>
+ </xsl:if>
+ </xsl:attribute>
<xsl:for-each select='$images'>
<xsl:call-template name='imgpara' />
</xsl:for-each>