diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-31 12:57:44 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-31 12:57:44 -0400 |
commit | 56ea7f0e430bc44f8b652ef88bedb186b6b3e0df (patch) | |
tree | cddb410b70aafa6904fee4662beca27f4d1afebb /contrib/hldiff.py | |
parent | 0abafa60e159f87595148c0d0fc4f5f46be2d400 (diff) | |
download | aerc-56ea7f0e430bc44f8b652ef88bedb186b6b3e0df.tar.gz |
Add plaintext highlighter, escape ANSI in source
Diffstat (limited to 'contrib/hldiff.py')
-rwxr-xr-x | contrib/hldiff.py | 5 |
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 "): |