dotfiles/.config/mail/format.py

23 lines
513 B
Python
Executable file

#!/bin/env python
import textwrap
import sys
with open(sys.argv[1], 'r') as f:
lines = f.read().splitlines()
skipping = False
for line in lines:
prefix = line.strip()[0]
match prefix:
case ">":
# ignore quoted line
print(line)
case "```":
# ignore code block
skipping = not skipping
case _:
# wrap the line
wrapped = textwrap.wrap(line, width=74, break_long_words=False, replace_whitespace=True)