summary refs log tree commit diff stats
path: root/contrib/hldiff.py
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 12:57:44 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 12:57:44 -0400
commit56ea7f0e430bc44f8b652ef88bedb186b6b3e0df (patch)
treecddb410b70aafa6904fee4662beca27f4d1afebb /contrib/hldiff.py
parent0abafa60e159f87595148c0d0fc4f5f46be2d400 (diff)
downloadaerc-56ea7f0e430bc44f8b652ef88bedb186b6b3e0df.tar.gz
Add plaintext highlighter, escape ANSI in source
Diffstat (limited to 'contrib/hldiff.py')
-rwxr-xr-xcontrib/hldiff.py5
1 files changed, 4 insertions, 1 deletions
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 "):