+<!--
+ Convert caption attribute on tables into proper caption elements, to allow
+ a simple way to add captions to kramdown tables.
+-->
+<xsl:template match='@caption[parent::xhtml:table]' />
+<xsl:template match='xhtml:table[@caption]'>
+ <xsl:copy>
+ <xsl:apply-templates select='@*' />
+ <caption><xsl:value-of select='normalize-space(@caption)' /></caption>
+ <xsl:apply-templates select='node()' />
+ </xsl:copy>
+</xsl:template>
+
+<!--
+ Delete style elements, as they will get hoisted occur under <head> below.
+ If the generate-listing attribute was specified, produce a code listing
+ where the style attribute was found.
+-->
+<xsl:template match='xhtml:style|@generate-listing[parent::xhtml:style]' />
+<xsl:template match='xhtml:style[@generate-listing]'>
+ <pre>⁠<code><xsl:value-of select='f:strip-leading(.)' /></code></pre>
+</xsl:template>
+
+<!--
+ Add a simple way to reference a document node by ID and include the XHTML
+ code listing directly in the document.
+-->
+<xsl:template match='xhtml:generate-xhtml-listing'>
+ <xsl:variable name='target' select='@target' />
+ <pre>⁠<code>
+ <xsl:value-of select='f:xhtml-listing(//xhtml:*[@id=$target])' />
+ </code></pre>
+</xsl:template>
+