mirror of
https://github.com/Hopiu/python-markdown-oembed.git
synced 2026-03-16 22:10:24 +00:00
improve portability
This commit is contained in:
parent
2f56c1c11a
commit
798c9850e6
1 changed files with 9 additions and 2 deletions
|
|
@ -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']
|
||||
|
|
|
|||
Loading…
Reference in a new issue