import difflib

def diff(a, b):
	sm = difflib.SequenceMatcher(None, a, b)
	out = []
	for opcode, a0, a1, b0, b1 in sm.get_opcodes():
		if opcode == "equal":
			out.append(sm.a[a0:a1])
		elif opcode == "insert":
			out.append("\x1f" + sm.b[b0:b1] + "\x1f")
		elif opcode == "delete":
			pass
		elif opcode == "replace":
			out.append("\x1f" + sm.b[b0:b1] + "\x1f")
		else:
			raise RuntimeError("unknown opcode")
	return "".join(out)


@@ -214,33 +214,33 @@
 %09out.append(%22%5Cx1
-f
+6
 %22 + sm.b%5Bb0:b1%5D 
@@ -241,25 +241,25 @@
 0:b1%5D + %22%5Cx1
-f
+6
 %22)%0A%09%09elif op
@@ -330,17 +330,17 @@
 end(%22%5Cx1
-f
+6
 %22 + sm.b
@@ -353,17 +353,17 @@
 %5D + %22%5Cx1
-f
+6
 %22)%0A%09%09els

use inverted mode instead of underline for diff output