--- author: '' category: '' date: 2013/08/23 17:10:11 description: A very simple reStructuredText directive which makes it 10x more awesome. link: '' priority: '' slug: the-best-restructuredtext-directive-ever-really tags: python, nikola title: The best reStructuredText directive ever. Really. type: text updated: 2013/08/23 17:10:11 url_type: '' --- It all started quietly with an Issue in the `Nikola `_ bug tracker: | gustavodiazjaimes opened this issue 3 hours ago | **oembed by micawber - feature sugestion** | | instead of using specific code for embed object (Youtube, Vimeo, Soundcloud) use a generic solution like https://github.com/coleifer/micawber So, I looked at `micawber `_. And it's **awesome** and I had never heard of it before. What it does is, it looks at a URL, and if it knows the site where it's pointed at, it will then gather information from it. And using that information it will create for you a HTML fragment so you can embed it in your own HTML page. And how hard is it to turn that into a reStructuredText directive? **NOT HARD AT ALL**. .. code:: python import micawber class Media(Directive): """ Restructured text extension for inserting any sort of media using micawber.""" has_content = False required_arguments = 1 def run(self): providers = micawber.bootstrap_basic() return [nodes.raw('', micawber.parse_text(self.arguments[0], providers), format='html')] So now, in Nikola's github master you can do this: .. TEASER_END :: .. media:: http://www.flickr.com/photos/ralsina/7827374994/ ----- .. media:: http://www.youtube.com/watch?v=cEh5cLqxgpA And get this: .. media:: http://www.flickr.com/photos/ralsina/7827374994/ ----- .. media:: http://www.youtube.com/watch?v=cEh5cLqxgpA Micawber supports *many* sites, and more can be added. So, thanks `coleifer `_ and `gustavodiazjaimes `_ for bringing this up :-)