<!--
Nick's web site: XHTML output stage
- Copyright © 2018-2019 Nick Bowler
+ Copyright © 2018-2020 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
<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' />
+ doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
+ cdata-section-elements='style' />
<xsl:param name='source-uri'
select='"//git.draconx.ca/gitweb/homepage.git/blob/"' />
</xsl:copy>
</xsl:template>
+<!--
+ 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>
+
<xsl:template match='copyright'>
<p>
<xsl:text>Copyright © </xsl:text>
</p>
</xsl:template>
+<xsl:template match='xhtml:h1[not(preceding::xhtml:h1)]'>
+ <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
+ <xsl:if test='/document/article/published'>
+ <div id='article-info'>
+ <p>
+ <xsl:text>Posted </xsl:text>
+ <xsl:value-of select='/document/article/published' />
+ </p>
+ </div>
+ </xsl:if>
+</xsl:template>
+
<xsl:template match='/'>
<html>
<head>
</xsl:if>
<xsl:value-of select='$site-title' />
</title>
+ <!-- Hoist all style elements to <head> as required by the doctype. -->
+ <xsl:for-each select='//xhtml:style'>
+ <xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
+ </xsl:for-each>
</head>
<body>
<xsl:apply-templates select='/document/xhtml:html/@*' />