def markup(text, small_headings=False, no_follow=True, escape=False,
           scale_headings=True):
    """Markup text using the markup language specified in the settings.
    """
    if MARKUP_LANGUAGE == 'markdown':
        import markdown
        safe_mode = 'escape' if escape else None
        try:
            import pygments
            options = ['codehilite', 'extra', 'toc']
            if scale_headings:
                options.append('headerid(level=3, forceid=False)')
            text = markdown.markdown(text, options, safe_mode=safe_mode)

        except __HOLE__:
            options = ['extra', 'toc']
            if scale_headings:
                options.append('headerid(level=3, forceid=False)')
            text = markdown.markdown(text, options, safe_mode=safe_mode)
    
    if small_headings:
        text = re.sub('<(/?h)[1-6]', '<\g<1>5', text)

    if no_follow:
        text = re.sub('<a (?![^>]*nofollow)', '<a rel="nofollow" ', text)

    return text
dataset/ETHPy150Open hmarr/django-mumblr/mumblr/entrytypes/__init__.py/markup