Skip to main content

Markdown template filter for Django.

Project description

# Django Markdown filter

Template filter to convert Markdown to HTML in Django.
Markdown is converted to HTML and sanitized.

Replacement for the deprecated: [django-markup-deprecated](https://pypi.python.org/pypi/django-markup-deprecated).

## Usage

Load the tag inside your template:

```
{% load markdownify %}
```

Then you can change markdown to html as follows:

```
{{ model|markdownify|safe }}
```

## Example

```
{% load markdownify %}
{{'Some *test* [link](#)'|markdownify|safe }}
```

Is transformed to:

```html
<p>
Some <em>test</em> <a href="" rel="nofollow">link</a>
</p>
```


## Installation

```
pip install django-markdownify
```

or add the following to your requirements.txt

```
django-markdownify
```

And add whitelisted tags to your `settings.py` file:

```
MARKDOWNIFY_WHITELIST_TAGS = [
'a',
'abbr',
'acronym',
'b',
'blockquote',
'em',
'i',
'li',
'ol',
'p',
'strong',
'ul'
]
```

## Credits

This filter is a slightly richer and packaged version of the snippet: [using-markdown-django-17 blog](http://www.jw.pe/blog/post/using-markdown-django-17/).

## Remarks

Please open a PR or create a ticket if you have something to add.
Especially if you are able to set dependency version limits.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-markdownify-0.1.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page