diff --git a/processor/app.py b/processor/app.py
index 292b110..fae924c 100644
--- a/processor/app.py
+++ b/processor/app.py
@@ -11,6 +11,28 @@ import hashlib
from diff_match_patch import diff_match_patch
+class DiffThing(diff_match_patch):
+ def diff_html(self, diffs):
+ """Like diff_prettyHtml, but without inline style attributes
+ (makes it easier to style it with stylesheets).
+ """
+ html = []
+ for op, data in diffs:
+ text = (
+ data.replace("&", "&")
+ .replace("<", "<")
+ .replace(">", ">")
+ .replace("\n", "¶
")
+ )
+ if op == self.DIFF_INSERT:
+ html.append("%s" % text)
+ elif op == self.DIFF_DELETE:
+ html.append('%s' % text)
+ elif op == self.DIFF_EQUAL:
+ html.append("%s" % text)
+ return "".join(html)
+
+
#
# Idea block:
#
@@ -25,7 +47,7 @@ REDIS_ARTICLE_EXPIRE_SEC = 604800
config = confuse.Configuration("headline", __name__)
config.set_file(CONFIG_FILE)
-dmp = diff_match_patch()
+dmp = DiffThing()
rc = redis.Redis(host="redis", port=6379, db=0)
@@ -88,7 +110,7 @@ def write_article(article, rc):
def process_diff(old, new, rss_id):
diff = dmp.diff_main(old["title"], new["title"])
dmp.diff_cleanupSemantic(diff)
- html_diff = dmp.diff_prettyHtml(diff)
+ html_diff = dmp.diff_html(diff)
# print(old['link'])
# print(diff)