M wiki/conf/settings.py => wiki/conf/settings.py +2 -2
@@ 13,8 13,8 @@ WIKI_LANGUAGE = 'markdown'
# extend the built-in editor and customize it....
EDITOR = getattr( django_settings, 'WIKI_EDITOR', 'wiki.editors.markitup.MarkItUp' )
-MARKDOWN_EXTENSIONS = getattr( django_settings, 'WIKI_MARKDOWN_EXTENSIONS', ['extra', 'toc'] )
-MARKDOWN_SAFE_MODE = getattr( django_settings, 'WIKI_MARKDOWN_SAFE_MODE', 'remove' )
+MARKDOWN_KWARGS = {'extensions': ['extra', 'toc'], 'safe_mode': 'replace'}
+MARKDOWN_KWARGS.update(getattr( django_settings, 'WIKI_MARKDOWN_KWARGS', {} ))
# This slug is used in URLPath if an article has been deleted. The children of the
# URLPath of that article are moved to lost and found. They keep their permissions
M wiki/core/__init__.py => wiki/core/__init__.py +4 -1
@@ 1,12 1,15 @@
import markdown
+from wiki.core.plugins import registry as plugin_registry
from wiki.conf import settings
class ArticleMarkdown(markdown.Markdown):
def __init__(self, article, *args, **kwargs):
- kwargs['safe_mode'] = settings.MARKDOWN_SAFE_MODE
+ kwargs = settings.MARKDOWN_KWARGS
+ kwargs['extensions'] = kwargs.get('extensions', [])
+ kwargs['extensions'] += plugin_registry.get_markdown_extensions()
markdown.Markdown.__init__(self, *args, **kwargs)
self.article = article
M wiki/models/article.py => wiki/models/article.py +1 -4
@@ 8,7 8,6 @@ from django.utils.translation import ugettext_lazy as _
from wiki.conf import settings
from wiki.core import article_markdown, permissions
-from wiki.core.plugins import registry as plugin_registry
from wiki import managers
from mptt.models import MPTTModel
@@ 185,9 184,7 @@ class Article(models.Model):
content = preview_content
else:
content = self.current_revision.content
- extensions = plugin_registry.get_markdown_extensions()
- extensions += settings.MARKDOWN_EXTENSIONS
- return mark_safe(article_markdown(content, self, extensions=extensions))
+ return mark_safe(article_markdown(content, self))
class ArticleForObject(models.Model):