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 The `allow-latex` variant does not protect characters needed to express
12 LaTeX commands. Use with caution.
14 MultiMarkdown Version 2.0.b5
16 $Id: clean-text-allow-latex.xslt 488 2008-01-14 00:46:15Z fletcher $
20 # Copyright (C) 2005-2008 Fletcher T. Penney <fletcher@fletcherpenney.net>
22 # This program is free software; you can redistribute it and/or modify
23 # it under the terms of the GNU General Public License as published by
24 # the Free Software Foundation; either version 2 of the License, or
25 # (at your option) any later version.
27 # This program is distributed in the hope that it will be useful,
28 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 # GNU General Public License for more details.
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write to the
34 # Free Software Foundation, Inc.
35 # 59 Temple Place, Suite 330
36 # Boston, MA 02111-1307 USA
41 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
42 xmlns:html="http://www.w3.org/1999/xhtml"
45 <!-- Pass XHTML Comments through unaltered (useful for including
46 raw LaTeX in your MultiMarkdown document) -->
47 <xsl:template match="comment()">
48 <xsl:value-of select="."/>
51 <!-- It's easier (for now) to rewrite the entire function, since
52 certain substitutions need to be deleted... -->
53 <xsl:template name="clean-text">
54 <xsl:param name="source" />
55 <xsl:call-template name="replace-substring">
56 <xsl:with-param name="original">
57 <xsl:call-template name="replace-substring">
58 <xsl:with-param name="original">
59 <xsl:call-template name="replace-substring">
60 <xsl:with-param name="original">
61 <xsl:call-template name="replace-substring">
62 <xsl:with-param name="original">
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:value-of select="$source"/>
101 <xsl:with-param name="substring">
102 <xsl:text>%20</xsl:text>
104 <xsl:with-param name="replacement">
105 <xsl:text> </xsl:text>
109 <xsl:with-param name="substring">
110 <xsl:text>e.g. </xsl:text>
112 <xsl:with-param name="replacement">
113 <xsl:text>e.g.\ </xsl:text>
117 <xsl:with-param name="substring">
118 <xsl:text>i.e. </xsl:text>
120 <xsl:with-param name="replacement">
121 <xsl:text>i.e.\ </xsl:text>
125 <xsl:with-param name="substring">
126 <xsl:text>—</xsl:text>
128 <xsl:with-param name="replacement">
129 <xsl:text>---</xsl:text>
133 <xsl:with-param name="substring">
134 <xsl:text>–</xsl:text>
136 <xsl:with-param name="replacement">
137 <xsl:text>--</xsl:text>
141 <xsl:with-param name="substring">
142 <xsl:text>‘</xsl:text>
144 <xsl:with-param name="replacement">
145 <xsl:text>`</xsl:text>
149 <xsl:with-param name="substring">
150 <xsl:text>”</xsl:text>
152 <xsl:with-param name="replacement">
153 <xsl:text>''</xsl:text>
157 <xsl:with-param name="substring">
158 <xsl:text>“</xsl:text>
160 <xsl:with-param name="replacement">
161 <xsl:text>``</xsl:text>
165 <xsl:with-param name="substring">
166 <xsl:text>’</xsl:text>
168 <xsl:with-param name="replacement">
169 <xsl:text>'</xsl:text>
173 <xsl:with-param name="substring">
174 <xsl:text>%</xsl:text>
176 <xsl:with-param name="replacement">
177 <xsl:text>\%</xsl:text>
181 <xsl:with-param name="substring">
182 <xsl:text>&</xsl:text>
184 <xsl:with-param name="replacement">
185 <xsl:text>\&</xsl:text>
189 <xsl:with-param name="substring">
190 <xsl:text>_</xsl:text>
192 <xsl:with-param name="replacement">
193 <xsl:text>\_</xsl:text>
197 <xsl:with-param name="substring">
198 <xsl:text>©</xsl:text>
200 <xsl:with-param name="replacement">
201 <xsl:text>\textcopyright{}</xsl:text>
205 <xsl:with-param name="substring">
206 <xsl:text>#</xsl:text>
208 <xsl:with-param name="replacement">
209 <xsl:text>\#</xsl:text>
213 <xsl:with-param name="substring">
214 <xsl:text>\$\backslash\$</xsl:text>
216 <xsl:with-param name="replacement">
217 <xsl:text>$\backslash$</xsl:text>
221 <xsl:with-param name="substring">
222 <xsl:text>~</xsl:text>
224 <xsl:with-param name="replacement">
225 <xsl:text>\ensuremath{\sim}</xsl:text>
229 <xsl:with-param name="substring">
230 <xsl:text> </xsl:text>
232 <xsl:with-param name="replacement">
233 <xsl:text>~</xsl:text>
237 <xsl:with-param name="substring">
238 <xsl:text><</xsl:text>
240 <xsl:with-param name="replacement">
241 <xsl:text>$<$</xsl:text>
245 <xsl:with-param name="substring">
246 <xsl:text>></xsl:text>
248 <xsl:with-param name="replacement">
249 <xsl:text>$>$</xsl:text>
253 <xsl:with-param name="substring">
254 <xsl:text>↓</xsl:text>
256 <xsl:with-param name="replacement">
257 <xsl:text>${\displaystyle \downarrow}$</xsl:text>
261 <xsl:with-param name="substring">
262 <xsl:text>↑</xsl:text>
264 <xsl:with-param name="replacement">
265 <xsl:text>${\displaystyle \uparrow}$</xsl:text>
269 <xsl:with-param name="substring">
270 <xsl:text>…</xsl:text>
272 <xsl:with-param name="replacement">
273 <xsl:text>{\ldots}</xsl:text>