Django Markdown Renderer is a lightweight package that brings secure, high-quality Markdown-to-HTML rendering to your Django projects. Instead of using heavy or complex editors, this package lets you easily add Markdown support for content creation, blogging, and any section where users need to write rich text—directly in your app.
Key benefits:
- Simple integration: Add Markdown editing and preview with minimal setup.
- Secure by default: All HTML output is sanitized to prevent malicious code (using bleach).
- High-quality content: Users can write Markdown and see beautiful, styled HTML instantly.
- Perfect for content sections, blogs, documentation, and anywhere you need safe user-generated HTML.
- No need for complex WYSIWYG editors—just Markdown!
Demo: Below is a graphical demo showing the editor, supported classes, and the final HTML output. You can see exactly how your content will look and which Markdown/HTML features are available.
To use Django Markdown Renderer in your project, simply install the package:
pip install django-markdown-renderer- Add
'markdown_renderer'toINSTALLED_APPSin your Djangosettings.py. - Include the app URLs in your
urls.py:path('', include('markdown_renderer.urls')),
- (Optional) Create a
.envfile for Django settings:SECRET_KEY=your-secret-key DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 - Run migrations:
python manage.py migrate
- Start the server:
python manage.py runserver
If you want to contribute or use the package as open source, clone the repository and install dependencies:
git clone https://github.com/xoxxel/django-markdown-renderer.git
cd django-markdown-renderer
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt ```
SECRET_KEY=your-secret-key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
```
- Run migrations:
python manage.py migrate
- Start the server:
python manage.py runserver
- Live Markdown Preview: Real-time rendering as you type.
- Safe HTML Output: Sanitized with bleach, only safe tags/attributes allowed.
- Emoji Picker: Type
:and select from a rich emoji list. - Task Lists:
[ ]and[x]become real checkboxes. - Tables with Alignment: Markdown tables with left/center/right alignment.
- Footnotes: Standard Markdown footnote support.
- Blockquotes & Nested Blockquotes
- Code Blocks & Syntax Highlighting
- Images & Video Embeds: Supports external images and iframe video (e.g. Aparat, YouTube).
- Advanced HTML:
<details>,<summary>,<mark>,<kbd>, RTL text, etc. - Mentions:
@usernamestyled in output. - Custom CSS: Modern, dark-themed UI, easily customizable.
Block Elements:
h1–h6,p,hr,br,blockquote,pre,ul,ol,li,table,thead,tbody,tr,td,th,details,summary
Inline Elements:
a,b,strong,i,em,code,del,sup,sub,mark,kbd,img,input(checkbox)
Media/Embed:
iframe(video embed)
Attributes:
- Global:
id,class,style - Specific:
src,alt,title,width,height,href,rel,target,dir,type,checked,disabled,allowfullscreen,webkitallowfullscreen,mozallowfullscreen,frameborder
Emoji Shortcodes:
:smile:,:rocket:,:heart:,:thumbsup:,:fire:,:star:,:100:,:clap:,:eyes:,:wave:,:tada:,:thinking:,:sunglasses:,:cry:,:grin:,:wink:,:ok_hand:,:pray:,:confetti_ball:,:poop:,:blush:,:angry:,:sleeping:,:zzz:,:no_mouth:,:neutral_face:,:joy:,:sob:,:facepalm:,:muscle:,:skull:,:alien:,:robot:,:cat:,:dog:,:sun:,:moon:,:rainbow:,:rose:,:crown:,:gift:,:balloon:,:cake:,:coffee:,:pizza:,:soccer:,:basketball:,:car:,:airplane:,:phone:,:computer:,:moneybag:,:gem:,:warning:,:checkered_flag:,:medal:,:trophy
# Features
- ~~strikethrough~~
- [ ] Incomplete task
- [x] Completed task
> Blockquote
> > Nested blockquote
| Right align | Center | Left align |
| ----------: | :----: | :--------- |
| 100 | text | left text |
| 23 | center | more text |

<iframe width="950" height="315" src="https://www.youtube.com/embed/fC9jCZwm1Ck" allowfullscreen></iframe>
Press <kbd>Ctrl</kbd> + <kbd>K</kbd>
<mark>Highlighted text</mark>
@username :rocket:- Fork and clone the repo.
- Create a branch and make your changes.
- Run tests:
python manage.py test - Submit a pull request.
MIT License. See LICENSE.
For issues, feature requests, or contributions, visit GitHub or email [xoxxel.com@gmail.com]. {% load markdown_renderer_tags %} {% markdown_renderer %}
2. Ensure static files are loaded:
```django
{% load static %}
<link rel="stylesheet" href="{% static 'markdown_renderer/css/style.css' %}">
To contribute to the project:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix.
- Run tests using:
python manage.py test - Submit a pull request with a clear description of your changes.
This project is released under the MIT License. See the LICENSE file for details.
For issues, feature requests, or contributions, please visit the GitHub repository or contact xoxxel via email at [xoxxel.com@gmail.com].
