Created
July 13, 2014 08:18
-
-
Save phalt/3f5f6425483675fb73f8 to your computer and use it in GitHub Desktop.
Escape html and other common characters
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
def escape_html(text): | |
html_escape_table = { | |
"&": "&", | |
'"': """, | |
"'": "'", | |
">": ">", | |
"<": "<", | |
} | |
return "".join(html_escape_table.get(c,c) for c in text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment