Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mwlib/texmap.py
diff options
context:
space:
mode:
Diffstat (limited to 'mwlib/texmap.py')
-rwxr-xr-xmwlib/texmap.py95
1 files changed, 95 insertions, 0 deletions
diff --git a/mwlib/texmap.py b/mwlib/texmap.py
new file mode 100755
index 0000000..f3071e6
--- /dev/null
+++ b/mwlib/texmap.py
@@ -0,0 +1,95 @@
+#! /usr/bin/env python
+
+# Copyright (c) 2007-2008 PediaPress GmbH
+# See README.txt for additional licensing information.
+
+import re
+
+def convertSymbols(latexsource):
+ def repl(mo):
+ name=mo.group(0)
+ return symbolMap.get(name, name)
+
+ latexsource = texcmd.sub(repl, latexsource)
+ return latexsource
+
+texcmd = re.compile(r"\\[a-zA-Z]+")
+
+symbolMap = {'\\Bbb': '\\mathbb',
+ '\\Complex': '\\mathbb{C}',
+ '\\Dagger': '\\ddagger',
+ '\\Darr': '\\Downarrow',
+ '\\Harr': '\\Leftrightarrow',
+ '\\Larr': '\\Leftarrow',
+ '\\Lrarr': '\\Leftrightarrow',
+ '\\N': '\\mathbb{N}',
+ '\\O': '\\emptyset',
+ '\\R': '\\mathbb{R}',
+ '\\Rarr': '\\Rightarrow',
+ '\\Reals': '\\mathbb{R}',
+ '\\Uarr': '\\Uparrow',
+ '\\Z': '\\mathbb{Z}',
+ '\\alef': '\\aleph',
+ '\\alefsym': '\\aleph',
+ '\\and': '\\land',
+ '\\ang': '\\angle',
+ '\\arccos': '\\mathop{\\mathrm{arccos}}',
+ '\\arccot': '\\mathop{\\mathrm{arccot}}',
+ '\\arccsc': '\\mathop{\\mathrm{arccsc}}',
+ '\\arcsec': '\\mathop{\\mathrm{arcsec}}',
+ '\\bold': '\\mathbf',
+ '\\bull': '\\bullet',
+ '\\clubs': '\\clubsuit',
+ '\\cnums': '\\mathbb{C}',
+ '\\dArr': '\\Downarrow',
+ '\\darr': '\\downarrow',
+ '\\diamonds': '\\diamondsuit',
+ '\\empty': '\\emptyset',
+ '\\exist': '\\exists',
+ '\\ge': '\\geq',
+ '\\hAar': '\\Leftrightarrow',
+ '\\harr': '\\leftrightarrow',
+ '\\hearts': '\\heartsuit',
+ '\\image': '\\Im',
+ '\\infin': '\\infty',
+ '\\isin': '\\in',
+ '\\lArr': '\\Leftarrow',
+ '\\lang': '\\langle',
+ '\\larr': '\\leftarrow',
+ '\\le': '\\leq',
+ '\\lrArr': '\\Leftrightarrow',
+ '\\lrarr': '\\leftrightarrow',
+ '\\natnums': '\\mathbb{N}',
+ '\\ne': '\\neq',
+ '\\or': '\\lor',
+ '\\part': '\\partial',
+ '\\plusmn': '\\pm',
+ '\\rArr': '\\Rightarrow',
+ '\\rang': '\\rangle',
+ '\\rarr': '\\rightarrow',
+ '\\real': '\\Re',
+ '\\reals': '\\mathbb{R}',
+ '\\sdot': '\\cdot',
+ '\\sect': '\\S',
+ '\\sgn': '\\mathop{\\mathrm{sgn}}',
+ '\\spades': '\\spadesuit',
+ '\\sub': '\\subset',
+ '\\sube': '\\subseteq',
+ '\\supe': '\\supseteq',
+ '\\thetasym': '\\vartheta',
+ '\\uArr': '\\Uparrow',
+ '\\uarr': '\\uparrow',
+ '\\weierp': '\\wp',
+ '\\Alpha': 'A{}',
+ '\\Beta': 'B{}',
+ '\\Epsilon': 'E{}',
+ '\\Zeta': 'Z{}',
+ '\\Eta': 'H{}',
+ '\\Iota': 'I{}',
+ '\\Kappa' : 'K{}',
+ '\\Mu': 'M{}',
+ '\\Nu': 'N{}',
+ '\\Rho': 'P{}',
+ '\\Tau': 'T{}',
+ '\\Chi': 'C{}',
+ }