Comprehensive Markdown plugin built for Django

Overview

Django MarkdownX

PyPi_Version PyPi_Status Build_Status Format Supported_versions_of_Python Supported_versions_of_Django License

Django MarkdownX is a comprehensive Markdown plugin built for Django, the renowned high-level Python web framework, with flexibility, extensibility, and ease-of-use at its core.

Documentation

https://neutronx.github.io/django-markdownx/

Key features

  • Raw editing.
  • Live preview.
  • Drag & drop image uploads (automatically stored in the designated location in the Media directory).
  • Customizable image insertion tag.
  • Definition of maximum size for an image.
  • Definition of acceptable image formats (PNG, JPEG, SVG).
  • Image manipulations (compression, size reduction, cropping, upscaling).
  • Pre- and post- text modification.
  • Easy template customization, layout modification, and personalization.
  • Multiple editors per page.
  • Django Admin support.

Preview

django-markdownx preview

(using Bootstrap for layout and styling – not included in package)

Comments
  • Disable TAB key if CTRL was down

    Disable TAB key if CTRL was down

    This stops the editor receiving a TAB event if using CTRL-TAB to cycle browser tabs. Otherwise the tab works as it should.

    Related to #66.

    ~~One problem though, not entirely sure how to deal with it. While the tab does get ignored when doing CTRL+TAB, for some reason the cursor jumps to the end of the text area. I'm not sure what to do about that.~~

    enhancement 
    opened by jaywink 16
  • [SOLVED] Render markdown to HTML in template

    [SOLVED] Render markdown to HTML in template

    Hi there

    I'm new here, and I'm having an issue rendering markdownx to HTML. I use this tag :

    {{ post.content|safe }}
    

    But it's not working. And I cannot find in the docs (Maybe I missed it?)

    Thank you!

    duplicate 
    opened by alzearafat 11
  • Make it possible to customize image insertion code.

    Make it possible to customize image insertion code.

    It can be useful to insert more that just a markdown image tag, for example to provide additional control on the layout of images. Since there's no convenient way to handle this on the JavaScript side, we generate the code to insert in Python. Then it can be overridden with the existing extensibility mechanism, that is, with a custom view.

    opened by aaugustin 11
  • Handle csrf stored in sessions

    Handle csrf stored in sessions

    This allow to use CSRF_USE_SESSIONS = True which store crsf token in session instead of cookies. It checks if csrf token found in cookies otherwise try to get csrf token in session.

    opened by Intestinall 10
  • self.attrs problem

    self.attrs problem

    I have a problem to develop using this package.

    class MyModelForm(forms.ModelForm):
      class Meta:
        model = MyModel
        field_classes = {'content': MarkdownxFormField,}
        widgets = {'content': MarkdowxWidget(attrs={'class':'form-control'})}
    

    So I override your function 'render' and merge attrs and self.attrs and it works. Also, I think it will handle this problem.

    class MarkdownxWidgetImproved(MarkdownxWidget):
      def render(self, name, value, attrs=None):
        allAttrs = {**attrs, **self.attrs}
        return super(MarkdownxWidgetImproved, self).render(name, value, allAttrs)
    

    I request pull, but canceled because I expect that that code doesn't work when attrs is None.

    opened by sh0416 10
  • Preview not working on outside admin (on frontend)

    Preview not working on outside admin (on frontend)

    Hi.

    I have successfully configured markdown field and it works fine in the admin:

    image

    I also use it in my custom form on frontend, but unfortunately, the preview does not work. I can see the requests in the "Network" tab in the Google Chrome Developer Tools and I see the response is correctly returned:

    image

    I debugged markdown.js file at line 477:

    xhr.success = function (response) {
        console.log('success');
        console.log(response);
        properties.preview.innerHTML = response;
        properties.editor = updateHeight(properties.editor);
        utils_1.triggerCustomEvent('markdownx.update', properties.parent, [response]);
    };
    

    and the result is, that "response" variable is always null:

    image

    Any idea what can cause the issue?

    pip:

    Django==2.0.2
    django-markdownx==2.0.22
    
    opened by eriktelepovsky 9
  • Security issue - Vulnerable to XSS attack

    Security issue - Vulnerable to XSS attack

    Description

    A security problem exists when markdownx.js dynamically interprets the content of the form without first checking the content. The application is vulnerable to XSS attack.

    Versions

    • django 1.11.13 and 2.2.5,
    • python 2.7.16 and 3.7.4.
    • django-markdownx 2.0.28.

    Preview

    POC_XSS_Markdownx_v2 0 28

    opened by LzOggar 8
  • Line breaks in code blocks

    Line breaks in code blocks

    Hello,

    I would expect line breaks to be parsed in code blocks.

    For example, the markdown

    ```javascript var x = 1; var y = 2; ``` should render, much like it does on Github, as

    var x = 1;
    var y = 2;
    

    Instead, markdownx renders it as

    var x = 1; var y = 2;
    

    Is that intentional or am I missing something?

    Thank you for building markdownx! -- Niko

    question 
    opened by nstahl 8
  • Size settings for non-svg images and inclusion of xml+svg in Settings

    Size settings for non-svg images and inclusion of xml+svg in Settings

    • Rectified the error causing image size alteration for non-svg images being ignored.
    • Additionally, broke down pieces of code into task-specific functions inline with functional/OOP programming best practices, but also to make them easier to read and debug.
    • image/xml+svg is now included in the default settings.
    • Also tested on Python 3.6 - works perfectly fine.

    Reminder: This would require a minor version change + pipy update as the error I found was preventing the application from performing one of the preceding features.

    opened by xenatisch 8
  • Template

    Template

    Hello, can you help me ? :smile: I don`t know how to show my markdown data on template. I have something like

    <h1>{{ post.title }}</h1>
    <p>{{ post.text }}</p>
    <p>{{ post.markdown }}</p>
    

    and i see only

    title
    text
    #text1 ![](/media/markdownx/ab3bfac7-7509-411a-96c8-11aebc20b873.jpg)
    

    but i want compiled version (with image) Could you explain how templates with markdownx work ? Or create some exaple with that ? :smile:

    opened by StudentDawid 8
  • View opacity reset after invalid image upload

    View opacity reset after invalid image upload

    When working on https://github.com/neutronX/django-markdownx/issues/143 i noticed the view opacity is not reset after uploading an invalid image. Proposal: remove return null on this line, so the properties.editor.style.opacity = NORMAL_OPACITY; is called correctly. https://github.com/neutronX/django-markdownx/blob/master/markdownx/static/markdownx/js/markdownx.js#L457

    What is the reason to return null here?

    opened by JeroenvO 7
  • Bump actions/checkout from 2.3.2 to 3.2.0

    Bump actions/checkout from 2.3.2 to 3.2.0

    Bumps actions/checkout from 2.3.2 to 3.2.0.

    Release notes

    Sourced from actions/checkout's releases.

    v3.2.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.2.0

    v3.1.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3.0.2...v3.1.0

    v3.0.2

    What's Changed

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.0.2

    v3.0.1

    v3.0.0

    • Updated to the node16 runtime by default
      • This requires a minimum Actions Runner version of v2.285.0 to run, which is by default available in GHES 3.4 or later.

    v2.5.0

    What's Changed

    Full Changelog: https://github.com/actions/checkout/compare/v2...v2.5.0

    ... (truncated)

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    v3.1.0

    v3.0.2

    v3.0.1

    v3.0.0

    v2.3.1

    v2.3.0

    v2.2.0

    v2.1.1

    • Changes to support GHES (here and here)

    v2.1.0

    v2.0.0

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • Simple optimization inside views.py

    Simple optimization inside views.py

    Instead of importing the markdownify function every time the view's POST method is called, instead import it at global scope.

    Example:

    markdownify_func = import_string(MARKDOWNX_MARKDOWNIFY_FUNCTION)
    
    class MarkdownifyView(View):
        """
        Conversion of Markdown to HTML.
        """
    
        def post(self, request, *args, **kwargs):
            """
            Handling of the conversion from Markdown to HTML using the conversion
            function in settings under ``MARKDOWNX_MARKDOWNIFY_FUNCTION``.
    
            :param request: HTTP request.
            :param args: Default Django POST arguments.
            :param kwargs: Default Django POST keyword arguments.
            :return: HTTP response
            :rtype: django.http.HttpResponse
            """
            # Function used to be imported every POST request. 
            return HttpResponse(markdownify_func(request.POST['content']))
    
    
    opened by Nigel2392 0
  • Bump actions/setup-python from 2 to 4

    Bump actions/setup-python from 2 to 4

    Bumps actions/setup-python from 2 to 4.

    Release notes

    Sourced from actions/setup-python's releases.

    v4.0.0

    What's Changed

    • Support for python-version-file input: #336

    Example of usage:

    - uses: actions/setup-python@v4
      with:
        python-version-file: '.python-version' # Read python version from a file
    - run: python my_script.py
    

    There is no default python version for this setup-python major version, the action requires to specify either python-version input or python-version-file input. If the python-version input is not specified the action will try to read required version from file from python-version-file input.

    • Use pypyX.Y for PyPy python-version input: #349

    Example of usage:

    - uses: actions/setup-python@v4
      with:
        python-version: 'pypy3.9' # pypy-X.Y kept for backward compatibility
    - run: python my_script.py
    
    • RUNNER_TOOL_CACHE environment variable is equal AGENT_TOOLSDIRECTORY: #338

    • Bugfix: create missing pypyX.Y symlinks: #347

    • PKG_CONFIG_PATH environment variable: #400

    • Added python-path output: #405 python-path output contains Python executable path.

    • Updated zeit/ncc to vercel/ncc package: #393

    • Bugfix: fixed output for prerelease version of poetry: #409

    • Made pythonLocation environment variable consistent for Python and PyPy: #418

    • Bugfix for 3.x-dev syntax: #417

    • Other improvements: #318 #396 #384 #387 #388

    Update actions/cache version to 2.0.2

    In scope of this release we updated actions/cache package as the new version contains fixes related to GHES 3.5 (actions/setup-python#382)

    Add "cache-hit" output and fix "python-version" output for PyPy

    This release introduces new output cache-hit (actions/setup-python#373) and fix python-version output for PyPy (actions/setup-python#365)

    The cache-hit output contains boolean value indicating that an exact match was found for the key. It shows that the action uses already existing cache or not. The output is available only if cache is enabled.

    ... (truncated)

    Commits
    • d09bd5e fix: 3.x-dev can install a 3.y version (#417)
    • f72db17 Made env.var pythonLocation consistent for Python and PyPy (#418)
    • 53e1529 add support for python-version-file (#336)
    • 3f82819 Fix output for prerelease version of poetry (#409)
    • 397252c Update zeit/ncc to vercel/ncc (#393)
    • de977ad Merge pull request #412 from vsafonkin/v-vsafonkin/fix-poetry-cache-test
    • 22c6af9 Change PyPy version to rebuild cache
    • 081a3cf Merge pull request #405 from mayeut/interpreter-path
    • ff70656 feature: add a python-path output
    • fff15a2 Use pypyX.Y for PyPy python-version input (#349)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • getCookie() bug?

    getCookie() bug?

            var cookies = document.cookie
                .split(';')
                .filter(function (cookie) { return cookie.indexOf(name + "=") === 0; })[0];
    

    code works when cookie is csrftoken=xyz; abc=def but fails on abc=def; csrftoken=xyz

    opened by alphatownsman 0
  • Release for Django 4.0

    Release for Django 4.0

    The last release on PyPI can't work with Django 4.0 because of the API shift in Django.

    The current code does work, and we're putting it in production.

    It's mildly inconvenient to have to pin our requirements to a Git commit ID, though. Would it be possible to get a PyPI-uploaded version for Django 4.0?

    opened by joelburton 0
Releases(v4.0.0-beta.1)
Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

Django-MySQL The dolphin-pony - proof that cute + cute = double cute. Django-MySQL extends Django's built-in MySQL and MariaDB support their specific

Adam Johnson 504 Jan 4, 2023
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
A simple plugin to attach a debugger in Django on runserver command.

django-debugger A simple plugin to attach a debugger in Django during runserver Installation pip install django-debugger Usage Prepend django_debugger

Sajal Shrestha 11 Nov 15, 2021
This is a simple Todo web application built Django (back-end) and React JS (front-end)

Django REST Todo app This is a simple Todo web application built with Django (back-end) and React JS (front-end). The project enables you to systemati

Maxim Mukhin 5 May 6, 2022
Fully reponsive Chat Application built with django, javascript, materialUi, bootstrap4, html and css.

Chat app (Full Stack Frameworks with Django Project) Fully reponsive Chat Application built with django, javascript, materialUi, bootstrap4, html and

null 1 Jan 19, 2022
A Blog Management System Built with django

Blog Management System Backend use: Django Features Enhanced Ui

Vishal Goswami 1 Dec 6, 2021
Flashback is an awesome, retro IRC based app built using Django

Flashback Flashback is an awesome, retro IRC based app built using Django (and the Django Rest Framework) for the backend as well as React for the fro

Unloading Gnat 1 Dec 22, 2021
A CTF leaderboard for the submission of flags during a CTF challenge. Built using Django.

?? CTF Leaderboard The goal of this project is to provide a simple web page to allow the participants of an CTF to enter their found flags. Also the l

Maurice Bauer 2 Jan 17, 2022
This is a repository for a web application developed with Django, built with Crowdbotics

assignment_32558 This is a repository for a web application developed with Django, built with Crowdbotics Table of Contents Project Structure Features

Crowdbotics 1 Dec 29, 2021
Djangoblog - A blogging platform built on Django and Python.

djangoblog ??‍?? A blogging platform built on Django and Python

Lewis Gentle 1 Jan 10, 2022
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 1, 2022
A Student/ School management application built using Django and Python.

Student Management An awesome student management app built using Django.! Explore the docs » View Demo · Report Bug · Request Feature Table of Content

Nishant Sethi 1 Feb 10, 2022
ProjectManagementWebsite - Project management website for CMSC495 built using the Django stack

ProjectManagementWebsite A minimal project management website for CMSC495 built

Justin 1 May 23, 2022
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django ?? Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 9, 2022
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.8k Jan 2, 2023
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 7, 2023
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022