Example #1
0
    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)
Example #2
0
    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
Example #3
0
    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>'
Example #4
0
 def tweet(self, src, alt="", title=None):
     tweet_match = TWITTER_RE.match(src)
     twitter_tag = f'<blockquote class="twitter-tweet" tw-align-center>' \
                   f'<a href="{tweet_match.group(1)}"></a></blockquote>'
     return twitter_tag