Textile parsing from within Flask
Project description
The Python port of Dean Allen's humane web text generator packaged for use with Flask.
pip install flask-textile
Import into our project:
from flask_textile import Textile
And then...
app = Flask(__name__)
textile = Textile(app)
Or, if one prefers, with an application factory:
textile = Textile()
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
textile.init_app(app)
#...
Simple usage within a Jinja2 template:
{{ text|textile }}
Or use as a filter:
{% filter textile %}
h2. Textile
* is a _shorthand syntax_ used to generate valid HTML
* is *easy* to read and *easy* to write
* can generate complex pages, including: headings, quotes, lists, tables and figures
Textile integrations are available for "a wide range of platforms":/article/.
{% endfilter %}
Additionally, Flask-Textile offers a static method, parse()
, which returns a raw HTML sting from Textile input—i.e. the direct output of python-textile. (Useful for working with Textile outside of a template):
from flask_textile import Textile
Textile.parse('_Emphasized_ or *Strong* text')
# Or if you already have an instance laying around...
app = Flask(__name__)
textile = Textile(app)
#...
textile.parse('"We *adore* _Textile_":https://en.wikipedia.org/wiki/Textile_(markup_language)')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-Textile-0.4.0.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for Flask_Textile-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbe79e5cdc86337280d7c4216f9cc92f3b14b1d36dee649116e20212d2cbb71c |
|
MD5 | c8afbff13776f8efc2d2d25a74097708 |
|
BLAKE2b-256 | 91f67d1f2a65ccd56dca50e8559d55d4292396282faa9977a76db92d705aa6c2 |