diff options
author | Vanya Sergeev <vsergeev@gmail.com> | 2013-10-13 15:28:51 +0200 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2013-11-02 20:03:59 +0100 |
commit | f62ca211ebf8badd17fef5d15d61eb8ff00875c1 (patch) | |
tree | 93725537a05fab918bcdf50ee74120c627da79b1 /utils.py | |
parent | d3bf98ea006f9949b16ad10f7d2c88d6809b8619 (diff) | |
download | git-arr-fork-f62ca211ebf8badd17fef5d15d61eb8ff00875c1.zip |
Add markdown blob support
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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) + |