Skip to content

Instantly share code, notes, and snippets.

@tesu
Last active March 21, 2018 19:30
Show Gist options
  • Save tesu/2af2e4cfa7987e5b0b41b27206840436 to your computer and use it in GitHub Desktop.
Save tesu/2af2e4cfa7987e5b0b41b27206840436 to your computer and use it in GitHub Desktop.
katex for facebook messenger
#!/bin/python3
import sys
if len(sys.argv) < 2:
l = 'sample text'
else:
l = " ".join(sys.argv[1:])
colors = ['#ff0000',
'#ff7f00',
'#ffff00',
'#00ff00',
'#0000ff',
'#4b0082',
'#9400d3']
print('$$', end='', sep='')
for i in range(len(l)):
if l[i].isspace():
print('\\text{',l[i],'}', end='', sep='')
else:
print('\color{',colors[i%len(colors)],'}\\text{',l[i],'}', end='', sep='')
print('$$')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment