Docutils (a.k.a. reStructuredText, reST, RST) support for django.
Project description
django-docutils ·
docutils (a.k.a. reStructuredText / rst / reST) support for Django.
Quickstart
Install django-docutils:
$ pip install django-docutils
Next, add django_docutils
to your INSTALLED_APPS
in your settings file:
INSTALLED_APPS = [
# ... your default apps,
'django_docutils'
]
Template tag
In your template:
{% load django_docutils %}
{% rst %}
# hey
# how's it going
A. hows
B. it
C. going
D. today
**hi**
*hi*
{% endrst %}
Template filter
In your template:
{% load django_docutils %}
{% filter rst %}
# hey
# how's it going
A. hows
B. it
C. going
D. today
**hi**
*hi*
{% endfilter %}
Template engine (class-based view)
You can also use a class-based view to render reStructuredText (reST).
If you want to use reStructuredText as a django template engine, INSTALLED_APPS
isn't required,
instead you add this to your TEMPLATES
variable in your settings:
TEMPLATES = [
# ... Other engines
{
"NAME": "docutils",
"BACKEND": "django_docutils.template.DocutilsTemplates",
"DIRS": [],
"APP_DIRS": True,
}
]
Now django will be able to scan for .rst files and process them. In your view:
from django_docutils.views import DocutilsView
class HomeView(DocutilsView):
template_name = 'base.html'
rst_name = 'home.rst'
Settings
# Optional, automatically maps roles, directives and transformers
DJANGO_DOCUTILS_LIB_RST = {
"docutils": {
"raw_enabled": True,
"strip_comments": True,
"initial_header_level": 2,
},
"roles": {
"local": {
"gh": "django_docutils.lib.roles.github.github_role",
"twitter": "django_docutils.lib.roles.twitter.twitter_role",
"email": "django_docutils.lib.roles.email.email_role",
}
},
}
# Optional
DJANGO_DOCUTILS_LIB_TEXT = {
"uncapitalized_word_filters": ["project.my_module.my_capitalization_fn"]
}
More information
- Python 3.8+
- Django 3.2+
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
django_docutils-0.21.0.tar.gz
(33.0 kB
view hashes)
Built Distribution
Close
Hashes for django_docutils-0.21.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8c5e85450db72b10783055ae96f44e44e38ebf6b631c4204893af0942192c55 |
|
MD5 | e67254a129c726d74c7896e1a6b1a53e |
|
BLAKE2b-256 | 15e46c3adb1a20b46051a0ccc05a47644dfdc35cdf05664ade1cd54d8e0e32eb |