No description
Find a file
2025-06-03 13:24:55 -04:00
mailfmt.py init 2025-06-03 13:24:55 -04:00
README.md init 2025-06-03 13:24:55 -04:00

Mail Format

By default, this script accepts its input on stdin and prints to stdout. This makes it well suited for use with an editor like Helix. It has no dependencies besides the standard Python interpreter, and was written and tested against Python 3.13.2.

Features:

  • Wraps emails at specified columns.
  • Automatically reflows paragraphs.
  • Squashes consecutive paragraph breaks.
  • Preserves:
    • Any long word not broken by spaces (e.g. URLs, email addresses).
    • Quoted lines.
    • Indented lines.
    • Lists.
    • Markdown-style code blocks.
    • Usenet-style signature block at EOF.
    • Sign-offs.

Usage:

usage: format.py [-h] [-w WIDTH] [-b] [--no-replace-whitespace] [--no-reflow]
                 [--no-signoff] [--no-signature] [--no-squash] [-i INPUT] [-o OUTPUT]

Formatter for plain text email.
"--no-*" options are NOT passed by default.

options:
  -h, --help            show this help message and exit
  -w, --width WIDTH     Text width for wrapping. (default: 74)
  -b, --break-long-words
                        Break long words while wrapping. (default: False)
  --no-replace-whitespace
                        Don't normalize whitespace when wrapping.
  --no-reflow           Don't reflow lines.
  --no-signoff          Don't preserve signoff line breaks.
  --no-signature        Don't preserve signature block.
  --no-squash           Don't squash consecutive paragraph breaks.
  -i, --input INPUT     Input file. (default: STDIN)
  -o, --output OUTPUT   Output file. (default: STDOUT)