changeset 7400:2927d568f714 stable

lib: refactor use of markdown library - it is a mandatory dependency
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 21 Oct 2018 17:42:37 +0200
parents ea46ff2a9404
children 5746cc3b3fa5
files kallithea/lib/markup_renderer.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/markup_renderer.py	Sun Oct 21 17:42:00 2018 +0200
+++ b/kallithea/lib/markup_renderer.py	Sun Oct 21 17:42:37 2018 +0200
@@ -30,6 +30,8 @@
 import logging
 import traceback
 
+import markdown as markdown_mod
+
 from kallithea.lib.utils2 import safe_unicode, MENTIONS_REGEX
 
 log = logging.getLogger(__name__)
@@ -158,13 +160,10 @@
         """
         source = safe_unicode(source)
         try:
-            import markdown as __markdown
             if flavored:
                 source = cls._flavored_markdown(source)
-            return __markdown.markdown(source, ['codehilite', 'extra'])
-        except ImportError:
-            log.warning('Install markdown to use this function')
-            return cls.plain(source)
+            markdown_html = markdown_mod.markdown(source, ['codehilite', 'extra'])
+            return markdown_html
         except Exception:
             log.error(traceback.format_exc())
             if safe: