AutoYADM commit: 2025-03-25 14:30:07
This commit is contained in:
parent
2fa5e8b4c4
commit
0ec9bad428
1 changed files with 4 additions and 8 deletions
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
# Simple text-wrapping script for email.
|
# Simple text-wrapping script for email.
|
||||||
# Preserves code blocks, quotes, and signature.
|
# Preserves code blocks, quotes, and signature.
|
||||||
|
# Automatically joins and re-wraps paragraphs to
|
||||||
|
# ensure even spacing & avoid ugly wrapping.
|
||||||
# Author: Daniel Fichtinger
|
# Author: Daniel Fichtinger
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
paragraph = []
|
paragraph = []
|
||||||
skipping = False
|
skipping = False
|
||||||
|
@ -20,22 +23,15 @@ def flush_paragraph():
|
||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
|
|
||||||
if line.startswith("```"):
|
if line.startswith("```"):
|
||||||
flush_paragraph()
|
flush_paragraph()
|
||||||
skipping = not skipping
|
skipping = not skipping
|
||||||
print(line)
|
print(line)
|
||||||
elif line.startswith(">"):
|
|
||||||
flush_paragraph()
|
|
||||||
print(line)
|
|
||||||
elif line.startswith(("- ", "+ ", "* ", "\t", " ")):
|
|
||||||
flush_paragraph()
|
|
||||||
print(line)
|
|
||||||
elif line.startswith("--"):
|
elif line.startswith("--"):
|
||||||
flush_paragraph()
|
flush_paragraph()
|
||||||
skipping = True
|
skipping = True
|
||||||
print(line)
|
print(line)
|
||||||
elif not line:
|
elif not line or re.match(r"^(\s+|-\s+|\+\s+|\*\s+|>\s*)", line):
|
||||||
flush_paragraph()
|
flush_paragraph()
|
||||||
print(line)
|
print(line)
|
||||||
elif skipping:
|
elif skipping:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue