API

class flask_mde.models.MdeField(id='wmd-input', **kwargs)

MdeField extends wtforms.fields.TextAreaField

id defaults to wmd-input. Do NOT change this. You can change the other parameters in the WTForms Field base class.

class flask_mde.models.Mde(app=None)

Pagedown Editor Class.

Usage Model

app = Flask(__name__)
mde = Mde(app)

or

mde = Mde()

def create_app():
    app = Flask(__name__)
    mde.init_app(app)
    return app
editor(name='', default='')

Loads the Pagedown editor (without preview).

Parameters:
  • name (str, optional) – Name of the textaread field.
  • default (str, optional) – Default value in the the textaread field.
Returns:

Editor markup.

Return type:

markupsafe.Markup

Example of usage in Jinja2

{{mde.editor(name='e1', default='# Heading')}}
preview

Loads the preview panel.

Accessible as {{mde.preview}} in Jinja2.

editor_with_preview(**kwargs)

Loads the Pagedown editor and preview.

Parameters:
  • name (str, optional) – Name of the textaread field.
  • default (str, optional) – Default value in the the textaread field.
Returns:

Editor markup.

Return type:

markupsafe.Markup

Example of usage in Jinja2

{{mde.editor_with_preview(name='e1', default='# Heading')}}

This will give (almost) the same effect as using

{{mde.editor(name='e1', default='# Heading')}}
{{mde.preview}}
js

Loads the Javascript files.

Accessible as {{mde.js}} in Jinja2.

css

Loads the css files.

Accessible as {{mde.css}} in Jinja2.