Skip to content

Instantly share code, notes, and snippets.

@z-a-f
Created December 21, 2016 19:40
Show Gist options
  • Save z-a-f/66cadd5140b13da26147922d3bd77de5 to your computer and use it in GitHub Desktop.
Save z-a-f/66cadd5140b13da26147922d3bd77de5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
"""
Convert any text to a set of HTML codes.
You can use it against email and phone number HTML parsers
"""
def htmlize(text):
assert(isinstance(text, str))
res = ''
for char in text:
res += '&#'+str(ord(char))+';'
return res
if __name__ == '__main__':
print htmlize(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment