Accept attributes in inline image syntax
[multimarkdown] / XSLT / manuscript-novel.xslt
1 <?xml version='1.0' encoding='utf-8'?>
2
3 <!-- XHTML-to-Manuscript converter by Fletcher Penney
4         specifically designed for use with MultiMarkdown created XHTML
5
6         Uses my manuscript class for output     
7         
8         MultiMarkdown Version 2.0.b5
9         
10         $Id: manuscript-novel.xslt 479 2008-01-12 23:04:13Z fletcher $
11 -->
12
13 <!-- 
14 # Copyright (C) 2005-2008  Fletcher T. Penney <fletcher@fletcherpenney.net>
15 #
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
20 #
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the
28 #    Free Software Foundation, Inc.
29 #    59 Temple Place, Suite 330
30 #    Boston, MA 02111-1307 USA
31 -->
32
33         
34 <xsl:stylesheet
35         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
36         xmlns:html="http://www.w3.org/1999/xhtml"
37         version="1.0">
38
39         <xsl:import href="xhtml2latex.xslt"/>
40         
41         <xsl:template match="/">
42                 <xsl:apply-templates select="html:html/html:head"/>
43                 <xsl:apply-templates select="html:html/html:body"/>
44                 <xsl:call-template name="latex-footer"/>
45         </xsl:template>
46
47         <xsl:template name="latex-footer">
48                 <xsl:text>%
49 % Back Matter
50 %
51
52 \backmatter
53 %\appendixpage
54
55 %       Bibliography
56 \bibliographystyle{\mybibliostyle}
57 \bibliocommand
58
59 %       Glossary
60 % \printglossary
61
62
63 %       Index
64 % \printindex
65
66 \end{document}
67 </xsl:text>
68         </xsl:template>
69
70         <xsl:template name="latex-document-class">
71                 <xsl:text>\documentclass[10pt,oneside]{memoir}
72 \usepackage{layouts}[2001/04/29]
73 \usepackage{manuscript}
74 \makeglossary
75 \makeindex
76
77 \def\revision{}
78
79
80 </xsl:text>
81         </xsl:template>
82
83         <xsl:template name="latex-paper-size">
84                 <xsl:text>
85 </xsl:text>
86         </xsl:template>
87
88         <xsl:template name="latex-intro">
89                 <xsl:text>
90
91         %
92         %       PDF Stuff
93         %
94
95 %       \ifpdf                                                  % Removed for XeLaTeX compatibility
96 %         \pdfoutput=1                                  % Removed for XeLaTeX compatibility
97           \usepackage[
98                 plainpages=false,
99                 pdfpagelabels,
100                 pdftitle={\mytitle},
101                 pagebackref,
102                 pdfauthor={\myauthor},
103                 pdfkeywords={\mykeywords}
104                 ]{hyperref}
105           \usepackage{memhfixc}
106 %       \fi                                                             % Removed for XeLaTeX compatibility
107
108
109         \title{\mytitle}
110         \author{\myauthor}
111
112         \begin{document}
113         </xsl:text>
114                 </xsl:template> <xsl:template name="latex-title">
115                         <xsl:text>
116
117 % Title Page
118 \begin{titlingpage} 
119 \aliaspagestyle{titlingpage}{title} 
120 \setlength{\droptitle}{30pt} 
121
122 \manuscript\noindent\myauthor \\
123 \address
124 \vskip 12pt
125 \noindent\agent
126
127 \vfill
128 \renewcommand{\baselinestretch}{2}
129 \normalsize\manuscript\centering\MakeUppercase\mytitle
130
131 by \myauthor
132 \vskip 4in
133
134 \end{titlingpage} 
135
136
137 </xsl:text>
138         </xsl:template>
139
140         <xsl:template name="latex-copyright">
141                         <xsl:text></xsl:text>
142         </xsl:template>
143
144         <xsl:template name="latex-begin-body">
145                 <xsl:text>%
146 % Main Content
147 %
148
149 % Manuscript settings
150 \renewcommand{\baselinestretch}{2}
151 \raggedright\normalsize
152 \font\body="Courier New" at 12pt\body
153
154 % Layout settings
155 \setlength{\parindent}{0.5in}
156
157 \mainmatter
158 </xsl:text>
159         </xsl:template>
160
161         <!-- Rename Bibliography -->
162         <xsl:template name="rename-bibliography">
163                 <xsl:param name="source" />
164                 <xsl:text>\renewcommand\bibname{</xsl:text>
165                 <xsl:value-of select="$source" />
166                 <xsl:text>}
167 </xsl:text>
168         </xsl:template>
169
170         <!-- Convert headers into chapters, etc -->
171         
172         <xsl:template match="html:h1">
173                 <xsl:text>\part{</xsl:text>
174                 <xsl:apply-templates select="node()"/>
175                 <xsl:text>}</xsl:text>
176                 <xsl:value-of select="$newline"/>
177                 <xsl:text>\label{</xsl:text>
178                 <xsl:value-of select="@id"/>
179                 <xsl:text>}</xsl:text>
180                 <xsl:value-of select="$newline"/>
181                 <xsl:value-of select="$newline"/>
182         </xsl:template>
183
184         <xsl:template match="html:h2">
185                 <xsl:text>\chapter{</xsl:text>
186                 <xsl:apply-templates select="node()"/>
187                 <xsl:text>}</xsl:text>
188                 <xsl:value-of select="$newline"/>
189                 <xsl:text>\label{</xsl:text>
190                 <xsl:value-of select="@id"/>
191                 <xsl:text>}</xsl:text>
192                 <xsl:value-of select="$newline"/>
193                 <xsl:value-of select="$newline"/>
194         </xsl:template>
195
196         <xsl:template match="html:h3">
197                 <xsl:text>\begin{center}
198 \#
199 \end{center}
200
201 </xsl:text>
202                 
203         </xsl:template>
204
205         <xsl:template match="html:h4">
206                 <xsl:text>\subsection{</xsl:text>
207                 <xsl:apply-templates select="node()"/>
208                 <xsl:text>}</xsl:text>
209                 <xsl:value-of select="$newline"/>
210                 <xsl:text>\label{</xsl:text>
211                 <xsl:value-of select="@id"/>
212                 <xsl:text>}</xsl:text>
213                 <xsl:value-of select="$newline"/>
214                 <xsl:value-of select="$newline"/>
215         </xsl:template>
216
217         <xsl:template match="html:h5">
218                 <xsl:text>\subsubsection{</xsl:text>
219                 <xsl:apply-templates select="node()"/>
220                 <xsl:text>}</xsl:text>
221                 <xsl:value-of select="$newline"/>
222                 <xsl:text>\label{</xsl:text>
223                 <xsl:value-of select="@id"/>
224                 <xsl:text>}</xsl:text>
225                 <xsl:value-of select="$newline"/>
226                 <xsl:value-of select="$newline"/>
227         </xsl:template>
228
229         <xsl:template match="html:h6">
230                 <xsl:text>{\itshape </xsl:text>
231                 <xsl:apply-templates select="node()"/>
232                 <xsl:text>}</xsl:text>
233                 <xsl:value-of select="$newline"/>
234                 <xsl:text>\label{</xsl:text>
235                 <xsl:value-of select="@id"/>
236                 <xsl:text>}</xsl:text>
237                 <xsl:value-of select="$newline"/>
238                 <xsl:value-of select="$newline"/>
239         </xsl:template>
240
241
242         <!-- code block -->
243         <xsl:template match="html:pre/html:code">
244                 <xsl:text>\begin{adjustwidth}{2.5em}{2.5em}
245 \begin{verbatim}
246
247 </xsl:text>
248                 <xsl:value-of select="."/>
249                 <xsl:text>
250 \end{verbatim}
251 \end{adjustwidth}
252
253 </xsl:text>
254         </xsl:template>
255         
256         <!-- Changes due to limitations of manuscript format -->
257         <xsl:template match="html:a[@href]">
258                 <xsl:value-of select="."/>
259                 <xsl:text>(</xsl:text>
260                 <xsl:value-of select="@href"/>
261                 <xsl:text>)</xsl:text>
262         </xsl:template>
263
264         <!-- emphasis -->
265         <xsl:template match="html:em">
266                 <xsl:text>\underline{</xsl:text>
267                         <xsl:apply-templates select="node()"/>
268                 <xsl:text>}</xsl:text>
269         </xsl:template>
270
271         <!-- strong -->
272         <xsl:template match="html:strong">
273                 <xsl:text>\textbf{</xsl:text>
274                         <xsl:apply-templates select="node()"/>
275                 <xsl:text>}</xsl:text>
276         </xsl:template>
277
278 </xsl:stylesheet>