summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Server/Reports/reports/templatetags/syntax_coloring.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py
index 14827b3c6..083b83a73 100644
--- a/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py
+++ b/src/lib/Server/Reports/reports/templatetags/syntax_coloring.py
@@ -1,25 +1,25 @@
from django import template
+register = template.Library()
+
try:
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
colorize = True
+
except:
colorize = False
-
-register = template.Library()
def syntaxhilight(value, arg="diff"):
- '''Returns a syntax-hilighted version of Code; requires code and language arguments'''
- lexer = get_lexer_by_name(arg)
+ '''Returns a syntax-hilighted version of Code; requires code/language arguments'''
if colorize:
try:
+ lexer = get_lexer_by_name(arg)
return highlight(value, lexer, HtmlFormatter())
except:
return value
else:
return value
-
register.filter('syntaxhilight', syntaxhilight)