From 8a11eb93b0299eb427f27bcb62e282ceb89ba700 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 07 2014 17:14:27 +0000 Subject: Add a new template filter to put the lines of code displayed within a HTML table --- diff --git a/progit/__init__.py b/progit/__init__.py index d1034ad..7dfe253 100644 --- a/progit/__init__.py +++ b/progit/__init__.py @@ -228,6 +228,33 @@ def rst2html(rst_string): return progit.doc_utils.convert_doc(unicode(rst_string)) +@APP.template_filter('format_loc') +def format_loc(loc): + """ Template filter putting the provided lines of code into a table + """ + output = [ + '
', + '' + ] + cnt = 1 + for line in loc.split('\n'): + output.append( + '' % (cnt, cnt, cnt)) + cnt += 1 + if not line: + output.append(line) + continue + if line == '': + continue + if line.startswith('')[1] + output.append('' % line) + output.append('') + output.append('
%s
%s
') + + return '\n'.join(output) + + @FAS.postlogin def set_user(return_url): ''' After login method. '''