Skip to content

Instantly share code, notes, and snippets.

@pypetey
Created May 12, 2014 19:51
Show Gist options
  • Save pypetey/089332e8bed73890e20f to your computer and use it in GitHub Desktop.
Save pypetey/089332e8bed73890e20f to your computer and use it in GitHub Desktop.
1. My input is:
https://www.youtube.com/watch?v=6qNW7yRsqAM
Result is:
<iframe width="480" height="270" frameborder="0" allowfullscreen="" src="http://www.youtube.com/embed/6qNW7yRsqAM?feature=oembed"></iframe>
# Code
def get_description(self):
providers = micawber.bootstrap_basic()
description = bleach.clean(self.description)
description = micawber.parse_text(description, providers)
Result is valid but I did not linkify the content so non embeddable links will not have nofollow/target _blank
2. My input is:
https://www.youtube.com/watch?v=6qNW7yRsqAM
My result is
&lt;iframe width="480" height="270" src="&amp;lt;a href=" http:="" &lt;a="" href="http://www.youtube.com" rel="nofollow"&gt;www.youtube.com="" embed="" 6qNW7yRsqAM?feature="oembed"" rel="nofollow"&gt;<a rel="nofollow" href="http://www.youtube.com/embed/6qNW7yRsqAM?feature=oembed">http://www.youtube.com/embed/6qNW7yRsqAM?feature=oembed</a>" frameborder="0" allowfullscreen=""&gt;&lt;/iframe&gt;
# Code
def get_description(self):
providers = micawber.bootstrap_basic()
description = bleach.clean(self.description)
description = micawber.parse_text(description, providers)
description = bleach.linkify(description)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment