From f62ca211ebf8badd17fef5d15d61eb8ff00875c1 Mon Sep 17 00:00:00 2001 From: Vanya Sergeev Date: Sun, 13 Oct 2013 06:28:51 -0700 Subject: Add markdown blob support --- utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'utils.py') diff --git a/utils.py b/utils.py index 801580e..9e3ca59 100644 --- a/utils.py +++ b/utils.py @@ -12,6 +12,10 @@ try: except ImportError: pygments = None +try: + import markdown +except ImportError: + markdown = None def shorten(s, width = 60): if len(s) < 60: @@ -41,6 +45,13 @@ def can_colorize(s): return True +def can_markdown(fname): + """True if we can process file through markdown, False otherwise.""" + if markdown is None: + return False + + return fname.endswith(".md") + def colorize_diff(s): lexer = lexers.DiffLexer(encoding = 'utf-8') formatter = HtmlFormatter(encoding = 'utf-8', @@ -68,3 +79,6 @@ def colorize_blob(fname, s): return highlight(s, lexer, formatter) +def markdown_blob(s): + return markdown.markdown(s) + -- cgit v1.2.3