X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/24c1d259ba4af084959d70c6a1f355d0a57f1191..5913c54d19b8f6775633176032161d49f9b2f1aa:/apps/wiki/nice_diff.py?ds=inline diff --git a/apps/wiki/nice_diff.py b/apps/wiki/nice_diff.py deleted file mode 100755 index 6f6e6071..00000000 --- a/apps/wiki/nice_diff.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. -# -import difflib -import re - -from django.template.loader import render_to_string -from django.utils.html import escape as html_escape - -DIFF_RE = re.compile(r"""\x00([+^-])""", re.UNICODE) -NAMES = {'+': 'added', '-': 'removed', '^': 'changed'} - - -def diff_replace(match): - return """""" % NAMES[match.group(1)] - - -def filter_line(line): - return DIFF_RE.sub(diff_replace, html_escape(line)).replace('\x01', '') - - -def html_diff_table(la, lb): - return render_to_string("wiki/diff_table.html", { - "changes": [(a[0], filter_line(a[1]), b[0], filter_line(b[1]), change) - for a, b, change in difflib._mdiff(la, lb)], - }) - - -__all__ = ['html_diff_table']