1 2 3 4 5 6 7 8 | from django.template import Library
from docutils.core import publish_parts
@register.filter
def rest(value, arg):
arg = arg or 'html'
parts = publish_parts(value, writer_name=arg)
return parts['html_body']
|
More like this
- Date/time util template filters by marinho 5 years, 6 months ago
- Template filters utils by marinho 5 years, 6 months ago
- Using Pygments with reST by joshua 6 years, 2 months ago
- Name Capitalize Filter by hotani 6 years ago
- Add delete buttons to admin changelist by kylefox 6 years ago
Comments
Why would one need to reinvent the wheel? There is already ReST filter in
markupcontrib library.#
hummm... it's truth, I not knew this :/ thanks :)
#
NOTE: there are reasons to reinvent the wheel. For instance the default stuff in django contrib has some security risks that with it's base install can only be turned off if you have access to modify the machine level rest settings (cant be done on commodity hosting).
Also there are other things you might want to do, like find out if some RST has errors... render a file that is included in your template, etc. You may want to have a RSTField() for your forms (with validation!). Heck, you might even want a RST based wiki.
For that, may I recommend the system that the creator of RST uses:
PyCon-Tech!
http://pycon.coderanger.net/browser/django/trunk/pycon/restructuredtext/
Markdown does not support https links! what crap.
#