Skip to main content

max / pter

git clone https://makenot.work/git/max/pter.git git clone git@ssh.makenot.work:max/pter.git
Name Size
/ benches/
/ docs/
/ src/
/ tests/
· .gitignore 132 B
· Cargo.lock 34.6 KB
· Cargo.toml 535 B
· LICENSE 1.0 KB
· README.md 1.2 KB

README

pter

Plain Text Email Renderer — convert HTML email bodies into readable markdown.

Email HTML is a hostile environment: table-based layouts from 2004, tracking pixels, Outlook conditional comments, deeply nested reply chains with inconsistent quoting. pter converts all of it into clean, readable markdown.

Usage

let html = r#"<h1>Hello</h1><p>This is an <strong>email</strong>.</p>"#;
let markdown = pter::convert(html);
assert_eq!(markdown, "# Hello\n\nThis is an **email**.");

What it does

  • Converts HTML elements to markdown equivalents (headings, links, lists, emphasis, code, images)
  • Unwraps table-based email layouts (single-cell tables become content, multi-column linearizes)
  • Detects and normalizes reply chains into > quoted markdown
  • Strips tracking pixels, invisible elements, and Outlook conditional comments
  • Produces output that is readable as plain text and renderable by any markdown toolchain

What it does not do

  • Parse MIME email structure (use mailparse or mail-parser for that)
  • Extract article content from marketing templates (compose with a separate extractor)
  • Render markdown to a display format (use pulldown-cmark, comrak, etc.)

License

MIT