Skip to main content

Add commonmark processing filter to your Flask app.

Project description

flask-commonmark

Add CommonMark processing filter to your Flask app.

One may notice a similarity to Dan Colish's Flask-Markdown, from which I shamelessly copied a bunch of this. Does not have all the nice provisions for extension baked in, but probably does what you need.

Source code may be found at Gitlab.

Docs at readthedocs.

Installation

pip install Flask-Commonmark

If pip is not available on your system, use:

easy_install Flask-Commonmark

Usage

Script

from flask_commonmark import Commonmark
cm = Commonmark(app)

or, if you are using factory pattern:

cm = Commonmark()
cm.init_app(app)

Create routes in the usual way:

@app.route("/commonmark")
def display_commonmark():
    mycm = u"Hello, *commonmark* block."
    return render_template("commonmark.html", mycm=mycm) 

Template

Inline-style

<html>
{{mycm|commonmark}}
</html>

Block-style

<html>
{% filter commonmark %}
{{mycm}}
{% endfilter %}
</html>

Autoescape

Jinja2's autoescape works as expected. See tests for examples.

Tests

python setup.py test or nosetests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Commonmark-1.0.4.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

Flask_Commonmark-1.0.4-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page