AutoYADM commit: 2025-03-25 14:00:07

This commit is contained in:
Daniel Fichtinger 2025-03-25 14:00:07 -04:00
parent fadf9c9d31
commit f5197a2655
2 changed files with 80 additions and 55 deletions

49
.config/mail/format2.py Executable file
View file

@ -0,0 +1,49 @@
#!/bin/env python
import textwrap
import sys
# first pass: reflow paragraphs
paragraph = []
lines = []
skipping = False
for line in sys.stdin:
line = line.rstrip()
if line:
if line.startswith(">") or skipping:
# ignore quoted line
lines.append(line)
elif line.startswith("```"):
# ignore code block
skipping = not skipping
lines.append(line)
elif line.startswith("--"):
skipping = True
lines.append(line)
else:
paragraph.append(line)
else:
if paragraph:
lines.append(' '.join(paragraph))
paragraph = []
lines.append("\n")
if paragraph:
lines.append(' '.join(paragraph))
skipping = False
for line in lines:
if line.startswith(">"):
# ignore quoted line
print(line)
elif line.startswith("```"):
# ignore code block
skipping = not skipping
print(line)
elif line.startswith("--"):
skipping = True
print(line)
else:
# TODO: fix signature being mangled and newlines erased
if not skipping:
wrapped = textwrap.wrap(line, width=74, break_long_words=False, replace_whitespace=True)
print("\n".join(wrapped))
else:
print(line)