2019-03-31 18:57:44 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from colorama import Fore, Style
|
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
|
|
|
# TODO: Wrap text to terminal width?
|
|
|
|
|
|
|
|
# TODO: I guess this might vary from MUA to MUA. I've definitely seen localized
|
|
|
|
# versions in the wild
|
2019-03-31 20:43:46 +02:00
|
|
|
quote_prefix_re = re.compile(r"On .*, .* wrote:")
|
|
|
|
quote_re = re.compile(r">+")
|
2019-03-31 18:57:44 +02:00
|
|
|
|
2019-06-07 16:18:46 +02:00
|
|
|
sys.stdin.reconfigure(encoding='utf-8', errors='ignore')
|
2019-03-31 18:57:44 +02:00
|
|
|
mail = sys.stdin.read().replace("\r\n", "\n")
|
|
|
|
|
|
|
|
for line in mail.split("\n"):
|
|
|
|
if quote_re.match(line) or quote_prefix_re.match(line):
|
|
|
|
print(f"{Style.DIM}{Fore.CYAN}{line}{Style.RESET_ALL}")
|
|
|
|
else:
|
|
|
|
print(line)
|