Skip to content

Instantly share code, notes, and snippets.

@abinashmeher999
Last active February 8, 2017 11:33
Show Gist options
  • Save abinashmeher999/511e7ad389f6a3aaba4032cf106fb031 to your computer and use it in GitHub Desktop.
Save abinashmeher999/511e7ad389f6a3aaba4032cf106fb031 to your computer and use it in GitHub Desktop.
Converts mathematical equations in unicode to MathJax.
#!/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