diff --git a/kallithea/lib/diffs.py b/kallithea/lib/diffs.py --- a/kallithea/lib/diffs.py +++ b/kallithea/lib/diffs.py @@ -449,8 +449,45 @@ _escape_re = re.compile(r'(&)|(<)|(>)|(\ def _escaper(diff_line): - """ + r""" Do HTML escaping/markup of a single diff line (including first +/- column) + + >>> _escaper('foobar') + 'foobar' + >>> _escaper('@foo & bar') + '@foo & bar' + >>> _escaper('+foo < bar') + '+foo < bar' + >>> _escaper('-foo > bar') + '-foo > bar' + >>> _escaper(' ') + ' <foo>' + >>> _escaper(' foo\tbar') + ' foo\tbar' + >>> _escaper(' foo\rbar\r') + ' foobar' + >>> _escaper(' foo\t') + ' foo\t' + >>> _escaper(' foo ') + ' foo ' + >>> _escaper(' foo ') + ' foo ' + >>> _escaper(' ') + ' ' + >>> _escaper(' ') + ' ' + >>> _escaper(' \t') + ' \t' + >>> _escaper(' \t ') + ' \t ' + >>> _escaper(' \t') + ' \t' + >>> _escaper(' \t\t ') + ' \t\t ' + >>> _escaper(' \t\t') + ' \t\t' + >>> _escaper(' foo&bar ') + ' foo&bar<baz> ' """ def substitute(m):