mirror of
https://github.com/Hopiu/python-markdown-oembed.git
synced 2026-05-26 15:24:00 +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
|
self.consumer = oembed_consumer
|
||||||
|
|
||||||
def handleMatch(self, match):
|
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()
|
url = match.group(3).strip()
|
||||||
try:
|
try:
|
||||||
response = self.consumer.embed(url)
|
response = self.consumer.embed(url)
|
||||||
except oembed.OEmbedNoEndpoint:
|
except oembed.OEmbedNoEndpoint:
|
||||||
return None
|
return None
|
||||||
placeholder = self.markdown.htmlStash.store(response['html'])
|
else:
|
||||||
return placeholder
|
return response['html']
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue