mirror of
https://github.com/Hopiu/python-markdown-oembed.git
synced 2026-03-16 22:10:24 +00:00
Update inlinepatterns.py
This commit is contained in:
parent
477d04541c
commit
0e3bf49c86
1 changed files with 2 additions and 4 deletions
|
|
@ -8,7 +8,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
OEMBED_LINK_RE = r'\!\[([^\]]*)\]\(((?:https?:)?//[^\)]*)' \
|
OEMBED_LINK_RE = r'\!\[([^\]]*)\]\(((?:https?:)?//[^\)]*)' \
|
||||||
r'(?<!png)(?<!jpg)(?<!jpeg)(?<!gif)\)'
|
r'(?<!png)(?<!jpg)(?<!jpeg)(?<!gif)(?<!avif)(?<!webp)\)'
|
||||||
|
|
||||||
|
|
||||||
class OEmbedLinkPattern(Pattern):
|
class OEmbedLinkPattern(Pattern):
|
||||||
|
|
@ -19,17 +19,15 @@ class OEmbedLinkPattern(Pattern):
|
||||||
|
|
||||||
def handleMatch(self, match):
|
def handleMatch(self, match):
|
||||||
html = self.get_oembed_html_for_match(match)
|
html = self.get_oembed_html_for_match(match)
|
||||||
LOG.warn(html)
|
|
||||||
if html is None:
|
if html is None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
html = "<figure class=\"oembed\">%s</figure>" % html
|
html = "<figure class=\"oembed\">%s</figure>" % html
|
||||||
placeholder = self.markdown.htmlStash.store(html)
|
placeholder = self.md.htmlStash.store(html)
|
||||||
return placeholder
|
return placeholder
|
||||||
|
|
||||||
def get_oembed_html_for_match(self, match):
|
def get_oembed_html_for_match(self, match):
|
||||||
url = match.group(3).strip()
|
url = match.group(3).strip()
|
||||||
LOG.warn(url)
|
|
||||||
try:
|
try:
|
||||||
response = self.consumer.embed(url)
|
response = self.consumer.embed(url)
|
||||||
except oembed.OEmbedNoEndpoint:
|
except oembed.OEmbedNoEndpoint:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue