worldcompany / djangoembed

rich media consuming and providing with django
http://djangoembed.readthedocs.org
MIT License
138 stars 38 forks source link

Allow stripping "a" tags #28

Open shagi opened 12 years ago

shagi commented 12 years ago

Currently it's very difficult (if not impossible) to use djangoembed with any markup format. I'm using restructured text, with the same goes for textile, markdown, etc.

The big problem is that in markup rich text all links are enclosed in a "a" element, so djangoembed never changes those links.

It would be great if I could set OEMBED_STRIP_LINKS=True or something like that in django settings.

I have played a bit with the code and could send a patch or pull request for this, but I'm not very confident with my proposal. Maybe there's a better way to get this working?

coleifer commented 12 years ago

Yeah, this is a tricky one... I use markdown on my blog (ew, which i would've used ReST to begin with), so I do blog.entry|markdown|oembed ... but i can see how using something that automatically links things would make this hard. It might be possible to modify the beautifulsoup parser to, if inside an A tag, go up the DOM and replace out the whole thing.

shagi commented 12 years ago

Yes, in my experiment I do just that, but don't understand the template_dir = 'inline' part of HTMLParser.parse_data, so I'm not very confident with my code.

coleifer commented 12 years ago

It allows you to render oembed-able things differently depending on whether the link is on a line by itself or whehter it is interspersed with text. In the former you prob drop in a div / player / etc. In the latter maybe just a link with descriptive text so as not to break up the apragraph.