From 56ea7f0e430bc44f8b652ef88bedb186b6b3e0df Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 31 Mar 2019 12:57:44 -0400 Subject: Add plaintext highlighter, escape ANSI in source --- contrib/hldiff.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'contrib/hldiff.py') diff --git a/contrib/hldiff.py b/contrib/hldiff.py index 8171625..716dbce 100755 --- a/contrib/hldiff.py +++ b/contrib/hldiff.py @@ -3,10 +3,13 @@ from colorama import Fore, Style import sys import re -patch = sys.stdin.read().replace("\r\n", "\n") +ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') stat_re = re.compile(r'(\+*)(\-*)') lines_re = re.compile(r'@@ (-\d+,\d+ \+\d+,\d+) @@') +patch = sys.stdin.read().replace("\r\n", "\n") +patch = ansi_escape.sub('', patch) + hit_diff = False for line in patch.split("\n"): if line.startswith("diff "): -- cgit v1.2.3