Welcome to Flask Markdown’s documentation!

Flask-Markdown adds support for Markdown to your Flask application. There is little to no documentation for it, but it works just the same as markdown would normally.

All source code can be found at Github


Install the extension with one of the following commands:

$ easy_install Flask-Markdown

or alternatively if you have pip installed:

$ pip install Flask-Markdown

How to Use

To use you must construct a Markdown with your Flask instance.

from flaskext.markdown import Markdown

Then in your template

{% filter markdown %}
Your Markdown
{% endfilter %}

You can also do

{{ mkd|markdown }}

Optionally, you can keep a reference to the Markdown instance and use that to register custom extensions by calling Markdown.register_extension() or decorating the extension class with Markdown.extend()

API Reference

class flaskext.markdown.Markdown(app, **markdown_options)

Simple wrapper class for Markdown objects, any options that are available for markdown may be passed as keyword arguments like so:

md = Markdown(app,
              extension_configs={'footnotes': ('PLACE_MARKER','~~~~~~~~')},

You can then call register_extension() to load custom extensions into the Markdown instance or use the extend() decorator

  • app – Your Flask app instance
  • markdown_options – Keyword args for the Markdown instance

Decorator for registering macros

You must either force the decorated class to be imported or define it in the same file you instantiate Markdown. To register a simple extension you could do:

from flaskext.markdown import Extension, Markdown
from preprocessors import SimplePreprocessor
markdown_instance = Markdown(app)

class SimpleExtension(Extension):
     def extendMarkdown(self, md, md_globals):
  • configs – A dictionary of options for the extension being registered
register_extension(ext_cls, configs=None)

This will register an extension class with self._instance. You may pass any additional configs required for your extension

It is best to call this when starting your Flask app, ie.:

from .mdx_simpl import SimpleExtension

md = Markdown(app)

Any additional configuration arguments can be added to configs and will be passed through to the extension you are registering

  • configs – A dictionary of options for the extension being regsitered
  • ext_cls – The class name of your extension
Fork me on GitHub