Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from kgleeson/gist:3702104
Created September 11, 2012 21:20
Show Gist options
  • Save zeffii/3702158 to your computer and use it in GitHub Desktop.
Save zeffii/3702158 to your computer and use it in GitHub Desktop.
from xml.sax.saxutils import escape
def escape_html(s):
for i in '&','<','"','>':
if i in s:
s = s.replace(i, escape(i))
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment