def link(self, link, text=None, title=None): if IMAGE_RE.match(link): return self.image(link, text or "", title or "") if YOUTUBE_RE.match(link): return self.youtube(link, text, title) if VIDEO_RE.match(link): return self.video(link, text, title) if TWITTER_RE.match(link): return self.tweet(link, text, title) return super().link(link, text, title)
def embed(self, src, alt="", title=None): if IMAGE_RE.match(src): return self.simple_image(src, alt, title) if YOUTUBE_RE.match(src): return self.youtube(src, alt, title) if VIDEO_RE.match(src): return self.video(src, alt, title) if TWITTER_RE.match(src): return self.tweet(src, alt, title) return None
def image(self, src, alt="", title=None): if IMAGE_RE.match(src): return self.just_img(src, alt, title) if YOUTUBE_RE.match(src): return self.youtube(src, alt, title) if VIDEO_RE.match(src): return self.video(src, alt, title) if TWITTER_RE.match(src): return self.tweet(src, alt, title) # if its not an image or video, display as a link return f'<a href="{src}">{src}</a>'