Accept attributes in inline image syntax
[multimarkdown] / XSLT / xhtml-poetry-support.xslt
1 <?xml version='1.0' encoding='utf-8'?>
2
3 <!-- XHTML-to-XHTML converter by Fletcher Penney
4         specifically designed for use with MultiMarkdown created XHTML
5         
6         Looks for code blocks that start with `[poetry]`.  If matched,
7         strip the poetry tag, apply the poetry class to the <pre> element,
8         and strip out the <code> wrapper.
9         
10         Another example of what can be done with a post-processing XSLT.
11         
12         MultiMarkdown Version 2.0.b5
13         
14         $Id: xhtml-poetry-support.xslt 479 2008-01-12 23:04:13Z fletcher $
15 -->
16
17 <!-- 
18 # Copyright (C) 2007-2008  Fletcher T. Penney <fletcher@fletcherpenney.net>
19 #
20 # This program is free software; you can redistribute it and/or modify
21 # it under the terms of the GNU General Public License as published by
22 # the Free Software Foundation; either version 2 of the License, or
23 # (at your option) any later version.
24 #
25 # This program is distributed in the hope that it will be useful,
26 # but WITHOUT ANY WARRANTY; without even the implied warranty of
27 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28 # GNU General Public License for more details.
29 #
30 # You should have received a copy of the GNU General Public License
31 # along with this program; if not, write to the
32 #    Free Software Foundation, Inc.
33 #    59 Temple Place, Suite 330
34 #    Boston, MA 02111-1307 USA
35 -->
36
37         
38 <xsl:stylesheet
39         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
40         xmlns:xhtml="http://www.w3.org/1999/xhtml"
41         xmlns="http://www.w3.org/1999/xhtml"
42         exclude-result-prefixes="xhtml xsl"
43         version="1.0">
44
45         <xsl:variable name="newline">
46 <xsl:text>
47 </xsl:text>
48         </xsl:variable>
49         
50         <xsl:output method='xml' version="1.0" encoding='utf-8' doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" doctype-system="http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" indent="no"/>
51
52         <!-- the identity template, based on http://www.xmlplease.com/xhtmlxhtml -->
53         <xsl:template match="@*|node()">
54                 <xsl:copy>
55                         <xsl:apply-templates select="@*|node()"/>
56                 </xsl:copy>
57         </xsl:template>
58
59         <xsl:template match="xhtml:pre">
60                 <xsl:choose>
61                         <xsl:when test="starts-with(child::xhtml:code,'[poetry]')">
62                                 <pre class="poetry">
63                                         <xsl:apply-templates select="@*|node()" mode="poetry"/>
64                                 </pre>
65                         </xsl:when>
66                         <xsl:otherwise>
67                                 <xsl:copy>
68                                         <xsl:apply-templates select="@*|node()"/>
69                                 </xsl:copy>
70                         </xsl:otherwise>
71                 </xsl:choose>
72         </xsl:template>
73
74         <xsl:template match="xhtml:code" mode="poetry">
75                 <xsl:value-of select="substring-after(.,'[poetry]')"/>
76         </xsl:template> 
77
78 </xsl:stylesheet>