Changeset - 2927d568f714
[Not reviewed]
stable
0 1 0
Mads Kiilerich - 7 years ago 2018-10-21 17:42:37
mads@kiilerich.com
Grafted from: ddaff496f781
lib: refactor use of markdown library - it is a mandatory dependency
1 file changed with 4 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/markup_renderer.py
Show inline comments
 
@@ -30,6 +30,8 @@ import re
 
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 @@ class MarkupRenderer(object):
 
        """
 
        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:
0 comments (0 inline, 0 general)