@views.app_template_filter()
def add_preview(content):
    if any('<' + tag in content for tag in (
            'img', 'iframe', 'embed', 'audio', 'video')):
        # don't add  a preview to a post that already has one
        return content

    instagram_regex = 'https?://instagram\.com/p/[\w\-]+/?'
    vimeo_regex = 'https?://vimeo\.com/(\d+)/?'
    youtube_regex = 'https?://(?:(?:www\.)youtube\.com/watch\?v=|youtu\.be/)([\w\-]+)'
    img_regex = 'https?://[^\s">]*\.(?:gif|png|jpg)'

    m = re.search(instagram_regex, content)
    if m:
        ig_url = m.group(0)
        media_url = urllib.parse.urljoin(ig_url, 'media/?size=l')
        return '{}<a href="{}"><img src="{}" /></a>'.format(
            content, ig_url, media_url)

    m = re.search(vimeo_regex, content)
    if m:
        # vimeo_url = m.group(0)
        vimeo_id = m.group(1)
        return (
            '{}<iframe src="//player.vimeo.com/video/{}" width="560" '
            'height="315" frameborder="0" webkitallowfullscreen '
            'mozallowfullscreen allowfullscreen></iframe>'
        ).format(content, vimeo_id)

    m = re.search(youtube_regex, content)
    if m:
        youtube_id = m.group(1)
        return (
            '{}<iframe width="560" height="315" '
            'src="https://www.youtube.com/embed/{}" frameborder="0" '
            'allowfullscreen></iframe>'
        ).format(content, youtube_id)

    m = re.search(img_regex, content)
    if m:
        return '{}<img src="{}"/>'.format(content, m.group(0))

    return content
Rendering table element. Wrap header and body in it.
dataset/ETHPy150Open kylewm/redwind/redwind/views.py/add_preview--crossover with--dataset/ETHPy150Open neuroo/equip/examples/sample-test-program/test_module/mistune.py/Renderer.table