From f14ecefa375d207da504f8450c2610def298fcc4 Mon Sep 17 00:00:00 2001 From: tschmidt-dev Date: Mon, 28 Jan 2013 11:55:17 -0800 Subject: [PATCH] collapsed MARKDOWN_EXTENSIONS and MARKDOWN_SAFE_MODE settings into MARKDOWN_KWARGS --- wiki/conf/settings.py | 4 ++-- wiki/core/__init__.py | 5 ++++- wiki/models/article.py | 5 +---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wiki/conf/settings.py b/wiki/conf/settings.py index 74302116..2dad07d3 100644 --- a/wiki/conf/settings.py +++ b/wiki/conf/settings.py @@ -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 diff --git a/wiki/core/__init__.py b/wiki/core/__init__.py index bc0e532e..348a54d2 100644 --- a/wiki/core/__init__.py +++ b/wiki/core/__init__.py @@ -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 diff --git a/wiki/models/article.py b/wiki/models/article.py index 44d74dba..04ac915f 100644 --- a/wiki/models/article.py +++ b/wiki/models/article.py @@ -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 @@ -183,9 +182,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): -- 2.45.2