# django-docutils · [![Python Package](https://img.shields.io/pypi/v/django-docutils.svg)](https://pypi.org/project/django-docutils/) [![License](https://img.shields.io/github/license/tony/django-docutils.svg)](https://github.com/tony/django-docutils/blob/master/LICENSE)
docutils (a.k.a. reStructuredText / rst / reST) support for Django.
## Quickstart
Install django-docutils:
```console
$ pip install django-docutils
```
Next, add `django_docutils` to your `INSTALLED_APPS` in your settings file:
```python
INSTALLED_APPS = [
# ... your default apps,
'django_docutils'
]
```
## Template tag
In your template:
```django
{% 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:
```django
{% 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:
```python
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:
```python
from django_docutils.views import DocutilsView
class HomeView(DocutilsView):
template_name = 'base.html'
rst_name = 'home.rst'
```
# Settings
```python
# 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",
}
},
"directives": {
"code-block": "django_docutils.lib.directives.code.CodeBlock",
}
}
# Optional
DJANGO_DOCUTILS_LIB_TEXT = {
"uncapitalized_word_filters": ["project.my_module.my_capitalization_fn"]
}
```
## More information
- Python 3.8+
- Django 3.2+
[![Docs](https://github.com/tony/django-docutils/workflows/docs/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22Docs%22)
[![Build Status](https://github.com/tony/django-docutils/workflows/tests/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22tests%22)
[![Code Coverage](https://codecov.io/gh/tony/django-docutils/branch/master/graph/badge.svg)](https://codecov.io/gh/tony/django-docutils)
Raw data
{
"_id": null,
"home_page": "https://django-docutils.git-pull.com",
"name": "django-docutils",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "django, docutils, reStructuredText, rst, reST",
"author": "Tony Narlock",
"author_email": "tony@git-pull.com",
"download_url": "https://files.pythonhosted.org/packages/e7/93/84c4ed1d6ad076b4b6813b46c670a2823924fe4d824ae91f05bba7141eb4/django_docutils-0.26.0.tar.gz",
"platform": null,
"description": "# django-docutils · [![Python Package](https://img.shields.io/pypi/v/django-docutils.svg)](https://pypi.org/project/django-docutils/) [![License](https://img.shields.io/github/license/tony/django-docutils.svg)](https://github.com/tony/django-docutils/blob/master/LICENSE)\n\ndocutils (a.k.a. reStructuredText / rst / reST) support for Django.\n\n## Quickstart\n\nInstall django-docutils:\n\n```console\n$ pip install django-docutils\n```\n\nNext, add `django_docutils` to your `INSTALLED_APPS` in your settings file:\n\n```python\nINSTALLED_APPS = [\n # ... your default apps,\n 'django_docutils'\n]\n```\n\n## Template tag\n\nIn your template:\n\n```django\n{% load django_docutils %}\n{% rst %}\n# hey\n# how's it going\nA. hows\nB. it\n\nC. going\nD. today\n\n**hi**\n*hi*\n{% endrst %}\n```\n\n## Template filter\n\nIn your template:\n\n```django\n{% load django_docutils %}\n{% filter rst %}\n# hey\n# how's it going\nA. hows\nB. it\n\nC. going\nD. today\n\n**hi**\n*hi*\n{% endfilter %}\n```\n\n## Template engine (class-based view)\n\nYou can also use a class-based view to render reStructuredText (reST).\n\nIf you want to use reStructuredText as a django template engine, `INSTALLED_APPS` _isn't_ required,\ninstead you add this to your `TEMPLATES` variable in your settings:\n\n```python\nTEMPLATES = [\n # ... Other engines\n {\n \"NAME\": \"docutils\",\n \"BACKEND\": \"django_docutils.template.DocutilsTemplates\",\n \"DIRS\": [],\n \"APP_DIRS\": True,\n }\n]\n```\n\nNow django will be able to scan for .rst files and process them. In your view:\n\n```python\nfrom django_docutils.views import DocutilsView\n\nclass HomeView(DocutilsView):\n template_name = 'base.html'\n rst_name = 'home.rst'\n```\n\n# Settings\n\n```python\n# Optional, automatically maps roles, directives and transformers\nDJANGO_DOCUTILS_LIB_RST = {\n \"docutils\": {\n \"raw_enabled\": True,\n \"strip_comments\": True,\n \"initial_header_level\": 2,\n },\n \"roles\": {\n \"local\": {\n \"gh\": \"django_docutils.lib.roles.github.github_role\",\n \"twitter\": \"django_docutils.lib.roles.twitter.twitter_role\",\n \"email\": \"django_docutils.lib.roles.email.email_role\",\n }\n },\n \"directives\": {\n \"code-block\": \"django_docutils.lib.directives.code.CodeBlock\",\n }\n}\n\n# Optional\nDJANGO_DOCUTILS_LIB_TEXT = {\n \"uncapitalized_word_filters\": [\"project.my_module.my_capitalization_fn\"]\n}\n```\n\n## More information\n\n- Python 3.8+\n- Django 3.2+\n\n[![Docs](https://github.com/tony/django-docutils/workflows/docs/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22Docs%22)\n[![Build Status](https://github.com/tony/django-docutils/workflows/tests/badge.svg)](https://github.com/tony/django-docutils/actions?query=workflow%3A%22tests%22)\n[![Code Coverage](https://codecov.io/gh/tony/django-docutils/branch/master/graph/badge.svg)](https://codecov.io/gh/tony/django-docutils)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Docutils (a.k.a. reStructuredText, reST, RST) support for django.",
"version": "0.26.0",
"project_urls": {
"Bug Tracker": "https://github.com/tony/django-docutils/issues",
"Changes": "https://github.com/tony/django-docutils/blob/master/CHANGES",
"Documentation": "https://django-docutils.git-pull.com",
"Homepage": "https://django-docutils.git-pull.com",
"Q & A": "https://github.com/tony/django-docutils/discussions",
"Repository": "https://github.com/tony/django-docutils"
},
"split_keywords": [
"django",
" docutils",
" restructuredtext",
" rst",
" rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "99dc007dd2fcd9d654f595519638e360749221c0c7d973c53b3aaa319dbd2bad",
"md5": "19ec3bd2da277a6f521639b1d2e3c51b",
"sha256": "ad1eb148a29b677728c72a424dff7ec8904ddc89e554907c8b388ddb117bff49"
},
"downloads": -1,
"filename": "django_docutils-0.26.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "19ec3bd2da277a6f521639b1d2e3c51b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 44767,
"upload_time": "2024-07-20T14:11:54",
"upload_time_iso_8601": "2024-07-20T14:11:54.563035Z",
"url": "https://files.pythonhosted.org/packages/99/dc/007dd2fcd9d654f595519638e360749221c0c7d973c53b3aaa319dbd2bad/django_docutils-0.26.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e79384c4ed1d6ad076b4b6813b46c670a2823924fe4d824ae91f05bba7141eb4",
"md5": "0fcd003f82b538436e53cc572c29497a",
"sha256": "d961eadb6af04ff67bc72768d49d19338a791484cd81023b7de3633071bbfc10"
},
"downloads": -1,
"filename": "django_docutils-0.26.0.tar.gz",
"has_sig": false,
"md5_digest": "0fcd003f82b538436e53cc572c29497a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 33588,
"upload_time": "2024-07-20T14:11:56",
"upload_time_iso_8601": "2024-07-20T14:11:56.338647Z",
"url": "https://files.pythonhosted.org/packages/e7/93/84c4ed1d6ad076b4b6813b46c670a2823924fe4d824ae91f05bba7141eb4/django_docutils-0.26.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 14:11:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tony",
"github_project": "django-docutils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-docutils"
}