Commits

Ahmad Khayyat  committed 520366c

Add PAGEDOWN_MARKDOWN_EXTENSIONS setting and a custom filter

PAGEDOWN_MARKDOWN_EXTENSIONS is a tuple that lists enabled
python-markdown extensions.

To enable these extensions, use the new `custom` RICHTEXT_FILTER.

For a list of extensions that are included with python-markdown, see:
http://pythonhosted.org/Markdown/extensions/index.html

Example:
RICHTEXT_FILTER = 'mezzanine_pagedown.filters.custom'
PAGEDOWN_MARKDOWN_EXTENSIONS=('extra', 'toc')

  • Participants
  • Parent commits bf496b4

Comments (0)

Files changed (2)

File mezzanine_pagedown/defaults.py

 from mezzanine.conf import register_setting
 
+
 register_setting(
     name="PAGEDOWN_SERVER_SIDE_PREVIEW",
-    description="Generate previews of the rendered HTML on the server using ajax requests.",
+    description="Render previews on the server using the same "
+                "converter that generates the actual pages.",
     editable=False,
     default=False,
 )
+
+register_setting(
+    name="PAGEDOWN_MARKDOWN_EXTENSIONS",
+    description="A tuple specifying enabled python-markdown extensions.",
+    editable=False,
+    default=(),
+)

File mezzanine_pagedown/filters.py

+from mezzanine.conf import settings
+
 from markdown import markdown
 from bleach import clean
 
     """
     return _clean(markdown(content, ['extra',]))
 
+
+def custom(content):
+    """
+    Renders content using markdown with the extensions listed in
+    ``settings.PAGEDOWN_MARKDOWN_EXTENSIONS``.
+    """
+    return _clean(markdown(content,
+            extensions=settings.PAGEDOWN_MARKDOWN_EXTENSIONS))