Created
June 10, 2014 20:48
-
-
Save jvanasco/2cda35740de8afc0a003 to your computer and use it in GitHub Desktop.
issue with html5lib
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
import bleach | |
sample_text = """<button class="navbar-toggle collapsed" data-target=".navbar-collapse" data-toggle="collapse" type="button"> | |
<span class="sr-only">Toggle navigation</span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button>""" | |
tags_ok = [ 'button', 'span', ] | |
attributes_ok = [ 'button', 'span', ] | |
attributes_ok = { | |
'*': ['class', 'data-toggle', 'data-target', 'type'], | |
} | |
def clean_text( text ): | |
text = bleach.clean( text, tags=tags_ok, attributes=attributes_ok, strip=True, strip_comments=False ) | |
return text | |
for i in range( 1, 10 ): | |
sample_text = clean_text( sample_text ) | |
print "*" * 10 | |
print sample_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment