1 <?xml version='1.0' encoding='utf-8'?>
3 <!-- XHTML-to-SFFMS converter by Fletcher Penney
4 specifically designed for use with MultiMarkdown created XHTML
6 Uses the SFFMS class for output:
8 http://www.mcdemarco.net/sffms/
10 MultiMarkdown Version 2.0.b5
12 $Id: sffms.xslt 479 2008-01-12 23:04:13Z fletcher $
16 # Copyright (C) 2005-2008 Fletcher T. Penney <fletcher@fletcherpenney.net>
18 # This program is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20 # the Free Software Foundation; either version 2 of the License, or
21 # (at your option) any later version.
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to the
30 # Free Software Foundation, Inc.
31 # 59 Temple Place, Suite 330
32 # Boston, MA 02111-1307 USA
37 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
38 xmlns:html="http://www.w3.org/1999/xhtml"
41 <xsl:import href="xhtml2latex.xslt"/>
43 <xsl:template match="/">
44 <xsl:apply-templates select="html:html/html:head"/>
45 <xsl:apply-templates select="html:html/html:body"/>
46 <xsl:call-template name="latex-footer"/>
49 <xsl:template name="latex-footer">
50 <xsl:text>\end{document}
54 <xsl:template name="latex-document-class">
55 <xsl:text>\documentclass[courier,novel]{sffms}
59 <xsl:template name="latex-paper-size">
63 <xsl:template name="latex-intro">
70 <xsl:template name="latex-title">
74 <xsl:template name="latex-copyright">
78 <xsl:template name="latex-begin-body">
82 <xsl:template name="latex-header">
85 <!-- Rename Bibliography -->
86 <xsl:template name="rename-bibliography">
89 <!-- Convert headers into chapters, etc -->
91 <xsl:template match="html:h1">
92 <xsl:text>\chapter*{</xsl:text>
93 <xsl:apply-templates select="node()"/>
94 <xsl:text>}</xsl:text>
95 <xsl:value-of select="$newline"/>
96 <xsl:text>\label{</xsl:text>
97 <xsl:value-of select="@id"/>
98 <xsl:text>}</xsl:text>
99 <xsl:value-of select="$newline"/>
100 <xsl:value-of select="$newline"/>
103 <xsl:template match="html:h2">
104 <xsl:text>\chapter{</xsl:text>
105 <xsl:apply-templates select="node()"/>
106 <xsl:text>}</xsl:text>
107 <xsl:value-of select="$newline"/>
108 <xsl:text>\label{</xsl:text>
109 <xsl:value-of select="@id"/>
110 <xsl:text>}</xsl:text>
111 <xsl:value-of select="$newline"/>
112 <xsl:value-of select="$newline"/>
115 <xsl:template match="html:h3">
122 <xsl:template match="html:h4">
125 <xsl:template match="html:h5">
128 <xsl:template match="html:h6">
133 <xsl:template match="html:pre/html:code">
134 <xsl:text>\begin{verbatim}
137 <xsl:value-of select="."/>
144 <xsl:template match="*[local-name() = 'title']">
145 <xsl:text>\title{</xsl:text>
146 <xsl:call-template name="clean-text">
147 <xsl:with-param name="source">
148 <xsl:value-of select="."/>
155 <xsl:template match="html:meta">
157 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
158 'abcdefghijklmnopqrstuvwxyz') = 'author'">
159 <xsl:text>\author{</xsl:text>
160 <xsl:call-template name="clean-text">
161 <xsl:with-param name="source">
162 <xsl:value-of select="@content"/>
168 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
169 'abcdefghijklmnopqrstuvwxyz') = 'authorname'">
170 <xsl:text>\authorname{</xsl:text>
171 <xsl:call-template name="clean-text">
172 <xsl:with-param name="source">
173 <xsl:value-of select="@content"/>
179 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
180 'abcdefghijklmnopqrstuvwxyz') = 'title'">
181 <xsl:text>\title{</xsl:text>
182 <xsl:call-template name="replace-substring">
183 <!-- put line breaks in -->
184 <xsl:with-param name="original">
185 <xsl:call-template name="clean-text">
186 <xsl:with-param name="source">
187 <xsl:value-of select="@content"/>
191 <xsl:with-param name="substring">
192 <xsl:text> </xsl:text>
194 <xsl:with-param name="replacement">
195 <xsl:text> \\ </xsl:text>
201 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
202 'abcdefghijklmnopqrstuvwxyz') = 'runningtitle'">
203 <xsl:text>\runningtitle{</xsl:text>
204 <xsl:call-template name="clean-text">
205 <xsl:with-param name="source">
206 <xsl:value-of select="@content"/>
212 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
213 'abcdefghijklmnopqrstuvwxyz') = 'surname'">
214 <xsl:text>\surname{</xsl:text>
215 <xsl:call-template name="clean-text">
216 <xsl:with-param name="source">
217 <xsl:value-of select="@content"/>
223 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
224 'abcdefghijklmnopqrstuvwxyz') = 'address'">
225 <xsl:text>\address{</xsl:text>
226 <xsl:call-template name="replace-substring">
227 <!-- put line breaks in -->
228 <xsl:with-param name="original">
229 <xsl:call-template name="clean-text">
230 <xsl:with-param name="source">
231 <xsl:value-of select="@content"/>
235 <xsl:with-param name="substring">
236 <xsl:text> </xsl:text>
238 <xsl:with-param name="replacement">
239 <xsl:text> \\ </xsl:text>
245 <xsl:when test="translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
246 'abcdefghijklmnopqrstuvwxyz') = 'wordcount'">
247 <xsl:text>\wordcount{</xsl:text>
248 <xsl:call-template name="clean-text">
249 <xsl:with-param name="source">
250 <xsl:value-of select="@content"/>
260 <!-- Changes due to limitations of manuscript format -->
261 <xsl:template match="html:a[@href]">
262 <xsl:value-of select="."/>
263 <xsl:text>(</xsl:text>
264 <xsl:call-template name="clean-text">
265 <xsl:with-param name="source">
266 <xsl:value-of select="@href"/>
269 <xsl:text>)</xsl:text>
273 <xsl:template match="html:em">
274 <xsl:text>\underline{</xsl:text>
275 <xsl:apply-templates select="node()"/>
276 <xsl:text>}</xsl:text>
280 <xsl:template match="html:strong">
281 <xsl:text>\textbf{</xsl:text>
282 <xsl:apply-templates select="node()"/>
283 <xsl:text>}</xsl:text>