Source

flask-creole-main / flaskext / creole.py

# -*- coding: utf-8 -*-
"""
    flaskext.creole
    ~~~~~~~~~~~~~~~

    Template filters for the creole parser python-creole.

    Usage example::

        from flaskext.creole import Creole
        Creole(app)

    Now in your templates you can use the filters::

        {{ article.body|creole2html }}

    Or if you want to try it backwards, yes, markup from html::

        {{ article.html_body|html2creole }}

    Why use python-creole, not creoleparser?

        * creoleparser depends on genshi
        * creoleparser is only one-way markup -> html

    :copyright: (c) 2010 by Ali Afshar.
    :license: MIT, see LICENSE for more details.
"""

from __future__ import absolute_import

from creole import creole2html, html2creole


class Creole(object):
    """Flask extension to add template filters for using creole
    """

    def __init__(self, app):
        app.jinja_env.filters['creole2html'] = creole2html
        app.jinja_env.filters['html2creole'] = html2creole