diff options
Diffstat (limited to 'bn_django/git_browse/views.py')
-rw-r--r-- | bn_django/git_browse/views.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py index 79b3573..23b0191 100644 --- a/bn_django/git_browse/views.py +++ b/bn_django/git_browse/views.py @@ -104,6 +104,13 @@ def view_blob(request, repo, hash): (GITPREFIX, heads, tags) = therepo.scan() b = Blob(id=hash,repo=therepo) b.update() + try: + from pygments import highlight + from pygments.lexers import guess_lexer + from pygments.formatters import HtmlFormatter + b.pretty_contents = highlight(b.contents, guess_lexer(b.contents), HtmlFormatter()) + except: + b.pretty_contents = None return render_to_response('git_browse/blob.html', dict(object=therepo, @@ -111,7 +118,8 @@ def view_blob(request, repo, hash): tags=tags, hash=b.id, size=b.size, - contents=b.contents)) + contents=b.contents, + pretty_contents=b.pretty_contents)) def view_commit(request, repo, hash): therepo = get_object_or_404(Repository, slug=repo) |