Last active
February 8, 2017 11:33
-
-
Save abinashmeher999/511e7ad389f6a3aaba4032cf106fb031 to your computer and use it in GitHub Desktop.
Converts mathematical equations in unicode to MathJax.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import sys | |
texmap ={ | |
u'α': r'\alpha ', | |
u'β': r'\beta ', | |
u'λ': r'\lambda ', | |
u'{': r'\{', | |
u'}': r'\}', | |
u'×': r'\times', | |
u'÷': r'\div', | |
u' ': r'\ ', | |
u'!': r'\rightarrow', | |
'\n': r'\\' | |
} | |
def texify(text): | |
ans = u'' | |
for c in text: | |
ans += texmap.get(c, c) | |
return ans | |
print(u'$$') | |
for line in sys.stdin: | |
print(texify(line)) | |
print(u'$$') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment