Parses the provided Markdown-formatted text into valid HTML, and returns
    it as a :class:`flask.Markup` instance.

    :param text: Markdown-formatted text to be rendered into HTML
    :param renderer: A custom misaka renderer to be used instead of the default one
    :param options: Additional options for customizing the default renderer
    :return: A :class:`flask.Markup` instance representing the rendered text

def markdown(text, renderer=None, **options):
    """
    Parses the provided Markdown-formatted text into valid HTML, and returns
    it as a :class:`flask.Markup` instance.

    :param text: Markdown-formatted text to be rendered into HTML
    :param renderer: A custom misaka renderer to be used instead of the default one
    :param options: Additional options for customizing the default renderer
    :return: A :class:`flask.Markup` instance representing the rendered text
    """
    ext, rndr = make_flags(**options)
    if renderer:
        md = misaka.Markdown(renderer,ext)
        result = md(text)
    else:
        result = misaka.html(text, extensions=ext, render_flags=rndr)
    if options.get("smartypants"):
        result = misaka.smartypants(result)
    return Markup(result)