[damned-lies] Fixes #111 - Upgrade and simplify markdown filter



commit e56df3b47ccb045cd07a26a7cc300dd4c4e77b1f
Author: Claude Paroz <claude 2xlibre net>
Date:   Sat Nov 3 18:17:06 2018 +0100

    Fixes #111 - Upgrade and simplify markdown filter

 requirements.txt                   |  2 +-
 stats/templatetags/stats_extras.py | 14 ++------------
 2 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/requirements.txt b/requirements.txt
index 0a819656..7e310f76 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,6 @@ django>=2.0
 pillow
 mysqlclient
 django-debug-toolbar
-markdown
+markdown==3.0.1
 pyicu
 translate-toolkit>=2.2.0
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 2b1ba6d2..169b2cbd 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -263,23 +263,13 @@ def markdown(value, arg=''):
     Syntax::
 
         {{ value|markdown:"extension1_name,extension2_name..." }}
-
-    To enable safe mode, which strips raw HTML and only returns HTML
-    generated by actual Markdown syntax, pass "safe" as the first
-    extension in the list.
     """
     try:
         import markdown
     except ImportError:
         if settings.DEBUG:
             raise template.TemplateSyntaxError("Error in 'markdown' filter: The Python markdown library 
isn't installed.")
-        return force_text(value)
+        return value
     else:
         extensions = [e for e in arg.split(",") if e]
-        if extensions and extensions[0] == "safe":
-            extensions = extensions[1:]
-            return mark_safe(markdown.markdown(
-                force_text(value), extensions, safe_mode=True, enable_attributes=False))
-        else:
-            return mark_safe(markdown.markdown(
-                force_text(value), extensions, safe_mode=False))
+        return mark_safe(markdown.markdown(value, extensions))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]