mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-03-16 21:40:24 +00:00
Add Markdown extension config setting
This commit is contained in:
parent
720a2ae7c6
commit
d07a4f4bfa
4 changed files with 18 additions and 5 deletions
12
README.md
12
README.md
|
|
@ -165,6 +165,7 @@ Place settings in your `settings.py` to override default values:
|
|||
```python
|
||||
#settings.py
|
||||
MARKDOWNX_MARKDOWN_EXTENSIONS = []
|
||||
MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = {}
|
||||
MARKDOWNX_URLS_PATH = '/markdownx/markdownify/' # Urls path that returns compiled markdown text. Change this path to your custom app url. That could i.e. enable do some additional work with compiled markdown text.
|
||||
MARKDOWNX_MEDIA_PATH = 'markdownx/' # subdirectory, where images will be stored in MEDIA_ROOT folder
|
||||
MARKDOWNX_UPLOAD_MAX_SIZE = 52428800 # 50MB
|
||||
|
|
@ -191,12 +192,15 @@ import markdown
|
|||
from django.http import HttpResponse
|
||||
from django.views.generic.edit import View
|
||||
|
||||
from _your_app_.settings import MARKDOWNX_MARKDOWN_EXTENSIONS
|
||||
from _your_app_.settings import MARKDOWNX_MARKDOWN_EXTENSIONS, MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS
|
||||
|
||||
class MarkdownifyView(View):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return HttpResponse(markdown.markdown(request.POST['content'], extensions=MARKDOWNX_MARKDOWN_EXTENSIONS))
|
||||
return HttpResponse(markdown.markdown(
|
||||
request.POST['content'],
|
||||
extensions=MARKDOWNX_MARKDOWN_EXTENSIONS,
|
||||
extension_configs=MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS))
|
||||
```
|
||||
|
||||
## Widget's template
|
||||
|
|
@ -232,6 +236,10 @@ When you want to use Bootstrap 3 and side-by-side panes (as in preview image abo
|
|||
|
||||
# Changelog
|
||||
|
||||
###### v1.3
|
||||
|
||||
* Added Markdown extension configuration setting
|
||||
|
||||
###### v1.2.1
|
||||
|
||||
* Fix by Eduard Sukharev: Fix accessing file length in python3
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
# Markdown extensions
|
||||
MARKDOWNX_MARKDOWN_EXTENSIONS = getattr(settings, 'MARKDOWNX_MARKDOWN_EXTENSIONS', [])
|
||||
MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = getattr(settings, 'MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS', {})
|
||||
|
||||
# Markdown url
|
||||
MARKDOWNX_URLS_PATH = getattr(settings, 'MARKDOWNX_URLS_PATH', '/markdownx/markdownify/')
|
||||
|
|
|
|||
|
|
@ -4,13 +4,17 @@ from django.views.generic.edit import View, FormView
|
|||
from django.http import HttpResponse, JsonResponse
|
||||
|
||||
from .forms import ImageForm
|
||||
from .settings import MARKDOWNX_MARKDOWN_EXTENSIONS
|
||||
from .settings import MARKDOWNX_MARKDOWN_EXTENSIONS, MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS
|
||||
|
||||
|
||||
class MarkdownifyView(View):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return HttpResponse(markdown.markdown(request.POST['content'], extensions=MARKDOWNX_MARKDOWN_EXTENSIONS))
|
||||
return HttpResponse(
|
||||
markdown.markdown(
|
||||
request.POST['content'],
|
||||
extensions=MARKDOWNX_MARKDOWN_EXTENSIONS,
|
||||
extension_configs=MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS))
|
||||
|
||||
|
||||
class ImageUploadView(FormView):
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -11,7 +11,7 @@ def get_requirements():
|
|||
|
||||
setup(
|
||||
name='django-markdownx',
|
||||
version='1.2.1',
|
||||
version='1.3',
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
description='Django Markdown editor with image uploads (stored in MEDIA_ROOT folder) and live preview.',
|
||||
|
|
|
|||
Loading…
Reference in a new issue