1 <?xml version='1.0' encoding='utf-8'?>
3 <!-- XHTML2LaTeX replace-substring utility file by Fletcher Penney
4 specifically designed for use with MultiMarkdown created XHTML
6 Extracted this routine so that it can be changed more easily by users.
8 This file is responsible for cleaning up special characters into
9 a LaTeX-friendly format.
11 MultiMarkdown Version 2.0.b5
13 $Id: clean-text.xslt 488 2008-01-14 00:46:15Z fletcher $
17 # Copyright (C) 2005-2008 Fletcher T. Penney <fletcher@fletcherpenney.net>
19 # This program is free software; you can redistribute it and/or modify
20 # it under the terms of the GNU General Public License as published by
21 # the Free Software Foundation; either version 2 of the License, or
22 # (at your option) any later version.
24 # This program is distributed in the hope that it will be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write to the
31 # Free Software Foundation, Inc.
32 # 59 Temple Place, Suite 330
33 # Boston, MA 02111-1307 USA
38 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
39 xmlns:html="http://www.w3.org/1999/xhtml"
42 <!-- Pass XHTML Comments through unaltered (useful for including
43 raw LaTeX in your MultiMarkdown document) -->
44 <xsl:template match="comment()">
45 <xsl:value-of select="."/>
48 <!-- This is a "pointer" function that can be over-ridden easily
49 in order to add quick additional changes -->
50 <xsl:template name="clean-text">
51 <xsl:param name="source"/>
52 <xsl:call-template name="clean-text-utility">
53 <xsl:with-param name="source">
54 <xsl:value-of select="$source"/>
59 <!-- This is the "real" function that does the work. You can also
60 override this if you need to make some real changes -->
61 <xsl:template name="clean-text-utility">
62 <xsl:param name="source" />
63 <xsl:call-template name="replace-substring">
64 <xsl:with-param name="original">
65 <xsl:call-template name="replace-substring">
66 <xsl:with-param name="original">
67 <xsl:call-template name="replace-substring">
68 <xsl:with-param name="original">
69 <xsl:call-template name="replace-substring">
70 <xsl:with-param name="original">
71 <xsl:call-template name="replace-substring">
72 <xsl:with-param name="original">
73 <xsl:call-template name="replace-substring">
74 <xsl:with-param name="original">
75 <xsl:call-template name="replace-substring">
76 <xsl:with-param name="original">
77 <xsl:call-template name="replace-substring">
78 <xsl:with-param name="original">
79 <xsl:call-template name="replace-substring">
80 <xsl:with-param name="original">
81 <xsl:call-template name="replace-substring">
82 <xsl:with-param name="original">
83 <xsl:call-template name="replace-substring">
84 <xsl:with-param name="original">
85 <xsl:call-template name="replace-substring">
86 <xsl:with-param name="original">
87 <xsl:call-template name="replace-substring">
88 <xsl:with-param name="original">
89 <xsl:call-template name="replace-substring">
90 <xsl:with-param name="original">
91 <xsl:call-template name="replace-substring">
92 <xsl:with-param name="original">
93 <xsl:call-template name="replace-substring">
94 <xsl:with-param name="original">
95 <xsl:call-template name="replace-substring">
96 <xsl:with-param name="original">
97 <xsl:call-template name="replace-substring">
98 <xsl:with-param name="original">
99 <xsl:call-template name="replace-substring">
100 <xsl:with-param name="original">
101 <xsl:call-template name="replace-substring">
102 <xsl:with-param name="original">
103 <xsl:call-template name="replace-substring">
104 <xsl:with-param name="original">
105 <xsl:call-template name="replace-substring">
106 <xsl:with-param name="original">
107 <xsl:call-template name="replace-substring">
108 <xsl:with-param name="original">
109 <xsl:call-template name="replace-substring">
110 <xsl:with-param name="original">
111 <xsl:call-template name="replace-substring">
112 <xsl:with-param name="original">
113 <xsl:call-template name="replace-substring">
114 <xsl:with-param name="original">
115 <xsl:call-template name="replace-substring">
116 <xsl:with-param name="original">
117 <xsl:value-of select="$source"/>
119 <xsl:with-param name="substring">
120 <xsl:text>%20</xsl:text>
122 <xsl:with-param name="replacement">
123 <xsl:text> </xsl:text>
127 <xsl:with-param name="substring">
128 <xsl:text>\</xsl:text>
130 <xsl:with-param name="replacement">
131 <xsl:text>$\backslash$</xsl:text>
135 <xsl:with-param name="substring">
136 <xsl:text>e.g. </xsl:text>
138 <xsl:with-param name="replacement">
139 <xsl:text>e.g.\ </xsl:text>
143 <xsl:with-param name="substring">
144 <xsl:text>i.e. </xsl:text>
146 <xsl:with-param name="replacement">
147 <xsl:text>i.e.\ </xsl:text>
151 <xsl:with-param name="substring">
152 <xsl:text>—</xsl:text>
154 <xsl:with-param name="replacement">
155 <xsl:text>---</xsl:text>
159 <xsl:with-param name="substring">
160 <xsl:text>–</xsl:text>
162 <xsl:with-param name="replacement">
163 <xsl:text>--</xsl:text>
167 <xsl:with-param name="substring">
168 <xsl:text>‘</xsl:text>
170 <xsl:with-param name="replacement">
171 <xsl:text>`</xsl:text>
175 <xsl:with-param name="substring">
176 <xsl:text>”</xsl:text>
178 <xsl:with-param name="replacement">
179 <xsl:text>''</xsl:text>
183 <xsl:with-param name="substring">
184 <xsl:text>“</xsl:text>
186 <xsl:with-param name="replacement">
187 <xsl:text>``</xsl:text>
191 <xsl:with-param name="substring">
192 <xsl:text>’</xsl:text>
194 <xsl:with-param name="replacement">
195 <xsl:text>'</xsl:text>
199 <xsl:with-param name="substring">
200 <xsl:text>%</xsl:text>
202 <xsl:with-param name="replacement">
203 <xsl:text>\%</xsl:text>
207 <xsl:with-param name="substring">
208 <xsl:text>&</xsl:text>
210 <xsl:with-param name="replacement">
211 <xsl:text>\&</xsl:text>
215 <xsl:with-param name="substring">
216 <xsl:text>}</xsl:text>
218 <xsl:with-param name="replacement">
219 <xsl:text>\}</xsl:text>
223 <xsl:with-param name="substring">
224 <xsl:text>{</xsl:text>
226 <xsl:with-param name="replacement">
227 <xsl:text>\{</xsl:text>
231 <xsl:with-param name="substring">
232 <xsl:text>_</xsl:text>
234 <xsl:with-param name="replacement">
235 <xsl:text>\_</xsl:text>
239 <xsl:with-param name="substring">
240 <xsl:text>$</xsl:text>
242 <xsl:with-param name="replacement">
243 <xsl:text>\$</xsl:text>
247 <xsl:with-param name="substring">
248 <xsl:text>©</xsl:text>
250 <xsl:with-param name="replacement">
251 <xsl:text>\textcopyright{}</xsl:text>
255 <xsl:with-param name="substring">
256 <xsl:text>#</xsl:text>
258 <xsl:with-param name="replacement">
259 <xsl:text>\#</xsl:text>
263 <xsl:with-param name="substring">
264 <xsl:text>\$\backslash\$</xsl:text>
266 <xsl:with-param name="replacement">
267 <xsl:text>$\backslash$</xsl:text>
271 <xsl:with-param name="substring">
272 <xsl:text>^</xsl:text>
274 <xsl:with-param name="replacement">
275 <xsl:text>\^{}</xsl:text>
279 <xsl:with-param name="substring">
280 <xsl:text>~</xsl:text>
282 <xsl:with-param name="replacement">
283 <xsl:text>\ensuremath{\sim}</xsl:text>
287 <xsl:with-param name="substring">
288 <xsl:text> </xsl:text>
290 <xsl:with-param name="replacement">
291 <xsl:text>~</xsl:text>
295 <xsl:with-param name="substring">
296 <xsl:text><</xsl:text>
298 <xsl:with-param name="replacement">
299 <xsl:text>$<$</xsl:text>
303 <xsl:with-param name="substring">
304 <xsl:text>></xsl:text>
306 <xsl:with-param name="replacement">
307 <xsl:text>$>$</xsl:text>
311 <xsl:with-param name="substring">
312 <xsl:text>↓</xsl:text>
314 <xsl:with-param name="replacement">
315 <xsl:text>${\displaystyle \downarrow}$</xsl:text>
319 <xsl:with-param name="substring">
320 <xsl:text>↑</xsl:text>
322 <xsl:with-param name="replacement">
323 <xsl:text>${\displaystyle \uparrow}$</xsl:text>
327 <xsl:with-param name="substring">
328 <xsl:text>…</xsl:text>
330 <xsl:with-param name="replacement">
331 <xsl:text>{\ldots}</xsl:text>