Created
September 22, 2016 12:56
-
-
Save muhammad-ammar/c712500596df62d917973f6e40d53608 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import bleach | |
import markupsafe | |
from mako.template import Template | |
def HTML(html): | |
return markupsafe.Markup(html) | |
def remove_markup(html): | |
return bleach.clean(html, tags=[], strip=True) | |
template = """ | |
<%page expression_filter="h"/> | |
${html} | |
""" | |
data = "<b>Rock & Roll</b>" | |
bleached_html = remove_markup(data) | |
HTML_bleached_html = HTML(remove_markup(data)) | |
mytemplate = Template(template) | |
print mytemplate.render_unicode(html=bleached_html) | |
print mytemplate.render_unicode(html=HTML_bleached_html) | |
####### OUTPUT | |
# Rock &amp; Roll | |
# Rock &amp; Roll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment