-
-
Save Perlmint/8c33b068cee6c0326b08 to your computer and use it in GitHub Desktop.
test
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
from bleach import clean, linkify, callbacks | |
content = '<aaaa https://google.com' | |
def sep(): | |
print '=====================' | |
def custom_linkify(text): | |
return linkify(text, parse_email=True, | |
callbacks=[callbacks.nofollow, callbacks.target_blank]) | |
sep() | |
print custom_linkify(clean(content, tags=list())) | |
# blank | |
sep() | |
print custom_linkify(content.replace('<', '<').replace('>', '>')) | |
# <aaaa <a="" href="&lt;a href=" https:="" google.com"="" target="_blank" rel="nofollow">https://google.com" target="_blank" rel="nofollow"><a href="https://google.com" rel="nofollow" target="_blank">https://google.com</a> | |
sep() | |
print custom_linkify('<aaaa https://google.com') | |
# <aaaa <a="" href="&lt;a href=" https:="" google.com"="" target="_blank" rel="nofollow">https://google.com" target="_blank" rel="nofollow"><a href="https://google.com" rel="nofollow" target="_blank">https://google.com</a> | |
sep() | |
print custom_linkify(content).replace('<', '<').replace('>', '>') | |
# blank |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment