From 798c9850e6f833f752a942aae26e7c77979c413d Mon Sep 17 00:00:00 2001 From: "J. Tanner Netterville" Date: Wed, 14 Nov 2012 12:15:41 -0600 Subject: [PATCH] improve portability --- mdx_oembed/inlinepatterns.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mdx_oembed/inlinepatterns.py b/mdx_oembed/inlinepatterns.py index 2a9b4fd..1f585d7 100644 --- a/mdx_oembed/inlinepatterns.py +++ b/mdx_oembed/inlinepatterns.py @@ -18,10 +18,17 @@ class OEmbedLinkPattern(Pattern): self.consumer = oembed_consumer def handleMatch(self, match): + html = self.get_oembed_html_for_match(match) + if html is None: + return None + placeholder = self.markdown.htmlStash.store(html) + return placeholder + + def get_oembed_html_for_match(self, match): url = match.group(3).strip() try: response = self.consumer.embed(url) except oembed.OEmbedNoEndpoint: return None - placeholder = self.markdown.htmlStash.store(response['html']) - return placeholder + else: + return response['html']