AutoYADM commit: 2025-03-25 14:15:08
This commit is contained in:
parent
f5197a2655
commit
2fa5e8b4c4
4 changed files with 34 additions and 89 deletions
|
@ -2,5 +2,6 @@
|
||||||
name = "markdown"
|
name = "markdown"
|
||||||
file-types = [{ glob = "/tmp/aerc-compose-*.eml" }]
|
file-types = [{ glob = "/tmp/aerc-compose-*.eml" }]
|
||||||
language-servers = ["harper-ls", "marksman", "scls"]
|
language-servers = ["harper-ls", "marksman", "scls"]
|
||||||
formatter = { command = "/usr/lib/aerc/filters/wrap", args = ["-w", "74"] }
|
# formatter = { command = "/usr/lib/aerc/filters/wrap", args = ["-w", "74"] }
|
||||||
|
formatter = { command = "/home/fic/.config/mail/format.py" }
|
||||||
auto-format = true
|
auto-format = true
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/env python
|
|
||||||
|
|
||||||
print("test")
|
|
||||||
|
|
|
@ -1,49 +1,46 @@
|
||||||
#!/bin/env python
|
#!/bin/env python
|
||||||
|
|
||||||
|
# Simple text-wrapping script for email.
|
||||||
|
# Preserves code blocks, quotes, and signature.
|
||||||
|
# Author: Daniel Fichtinger
|
||||||
|
# License: MIT
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
import sys
|
import sys
|
||||||
# first pass: reflow paragraphs
|
|
||||||
paragraph = []
|
paragraph = []
|
||||||
lines = []
|
|
||||||
skipping = False
|
skipping = False
|
||||||
|
|
||||||
|
def flush_paragraph():
|
||||||
|
if paragraph:
|
||||||
|
joined = " ".join(paragraph)
|
||||||
|
wrapped = textwrap.wrap(joined, width=74, break_long_words=False, replace_whitespace=True)
|
||||||
|
print("\n".join(wrapped))
|
||||||
|
paragraph.clear()
|
||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
if line:
|
|
||||||
if line.startswith(">") or skipping:
|
if line.startswith("```"):
|
||||||
# ignore quoted line
|
flush_paragraph()
|
||||||
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
|
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()
|
||||||
skipping = True
|
skipping = True
|
||||||
print(line)
|
print(line)
|
||||||
|
elif not line:
|
||||||
|
flush_paragraph()
|
||||||
|
print(line)
|
||||||
|
elif skipping:
|
||||||
|
print(line)
|
||||||
else:
|
else:
|
||||||
# TODO: fix signature being mangled and newlines erased
|
paragraph.append(line)
|
||||||
if not skipping:
|
else:
|
||||||
wrapped = textwrap.wrap(line, width=74, break_long_words=False, replace_whitespace=True)
|
flush_paragraph()
|
||||||
print("\n".join(wrapped))
|
|
||||||
else:
|
|
||||||
print(line)
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
#!/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)
|
|
Loading…
Add table
Add a link
Reference in a new issue