Accept attributes in inline image syntax
[multimarkdown] / XSLT / science.xslt
1 <?xml version='1.0' encoding='utf-8'?>
2
3 <!-- XHTML-to-Science converter by Fletcher Penney
4         specifically designed for use with MultiMarkdown created XHTML
5         
6         Uses the LaTeX article class for output
7         
8         MultiMarkdown Version 2.0.b5
9         
10         $Id: science.xslt 479 2008-01-12 23:04:13Z fletcher $
11         
12         TODO: The multicolumn layout broke
13         TODO: Top margin is short, bottom margin is long
14         TODO: Still needs work
15 -->
16
17 <!-- 
18 # Copyright (C) 2005-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:html="http://www.w3.org/1999/xhtml"
41         version="1.0">
42
43         <xsl:import href="article.xslt"/>
44
45         <xsl:output method='text' encoding='utf-8'/>
46
47         <xsl:strip-space elements="*" />
48
49         <xsl:template match="/">
50                 <xsl:apply-templates select="html:html/html:head"/>
51                 <xsl:apply-templates select="html:html/html:body"/>
52                 <xsl:call-template name="latex-footer"/>
53         </xsl:template>
54
55         <xsl:template name="latex-document-class">
56                 <xsl:text>\documentclass[oneside,article,9pt]{memoir}
57 \usepackage{layouts}[2001/04/29]
58 \usepackage{science}
59 \usepackage{xmpincl}    % Seems to be required to get the pdf to generate??
60
61 \def\revision{}
62 </xsl:text>
63         </xsl:template>
64
65         <!-- Science allows for an abstract -->
66
67         <!-- support for abstracts -->
68         <xsl:template match="html:h1[1]">
69                 <xsl:choose>
70                         <!-- abstract -->
71                         <xsl:when test="translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
72                                 'abcdefghijklmnopqrstuvwxyz') = 'abstract'">
73                                 <xsl:text>\begin{abstract}</xsl:text>
74                                 <xsl:value-of select="$newline"/>
75                                 <xsl:text>\addcontentsline{toc}{section}{</xsl:text>
76                                 <xsl:apply-templates select="node()"/>
77                                 <xsl:text>}</xsl:text>
78                         </xsl:when>
79                         <xsl:otherwise>
80 <xsl:text>\begin{body}
81
82 % Layout settings
83 \setlength{\parindent}{1em}
84
85 \section{</xsl:text>
86                                 <xsl:apply-templates select="node()"/>
87                                 <xsl:text>}</xsl:text>
88                         </xsl:otherwise>
89                 </xsl:choose>
90                 <xsl:text>\label{</xsl:text>
91                 <xsl:value-of select="@id"/>
92                 <xsl:text>}</xsl:text>
93                 <xsl:value-of select="$newline"/>
94                 <xsl:value-of select="$newline"/>
95                 <xsl:value-of select="$newline"/>
96         </xsl:template>
97
98         <xsl:template match="html:h1[position() = '2'][preceding-sibling::html:h1[position()='1'][translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
99                 'abcdefghijklmnopqrstuvwxyz') = 'abstract']]">
100                 <xsl:text>\end{abstract}
101
102 \begin{body}
103
104 % Layout settings
105 \setlength{\parindent}{1em}</xsl:text>
106                 <xsl:value-of select="$newline"/>
107                 <xsl:value-of select="$newline"/>
108                 <xsl:text>\section{</xsl:text>
109                 <xsl:apply-templates select="node()"/>
110                 <xsl:text>}</xsl:text>
111                 <xsl:value-of select="$newline"/>
112                 <xsl:text>\label{</xsl:text>
113                 <xsl:value-of select="@id"/>
114                 <xsl:text>}</xsl:text>
115                 <xsl:value-of select="$newline"/>
116                 <xsl:value-of select="$newline"/>
117         </xsl:template>
118
119         <xsl:template match="html:h2[count(preceding-sibling::html:h1) = '1'][preceding-sibling::html:h1[position()='1'][translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
120                 'abcdefghijklmnopqrstuvwxyz') = 'abstract']]">
121                 <xsl:text>\subsection*{</xsl:text>
122                 <xsl:apply-templates select="node()"/>
123                 <xsl:text>}</xsl:text>
124                 <xsl:value-of select="$newline"/>
125                 <xsl:text>\label{</xsl:text>
126                 <xsl:value-of select="@id"/>
127                 <xsl:text>}</xsl:text>
128                 <xsl:value-of select="$newline"/>
129                 <xsl:value-of select="$newline"/>
130         </xsl:template>
131
132         <!-- code block -->
133         <xsl:template match="html:pre/html:code">
134                 <xsl:text>\begin{verbatim}
135
136 </xsl:text>
137                 <xsl:value-of select="."/>
138                 <xsl:text>
139 \end{verbatim}
140
141 </xsl:text>
142         </xsl:template>
143
144 </xsl:stylesheet>