npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

equoter

v0.1.0

Published

Identify quoted text in email messages (TypeScript port of quotequail)

Readme

equoter

Note: This codebase was mostly written by AI (Claude), with human direction and review.

There is an additional private test set based on real emails (not included in this repo for privacy reasons).

A TypeScript library that identifies and separates quoted text in email messages. Detects replies, forwards, and quoted blocks across multiple email clients and languages.

TypeScript port of quotequail, with additional improvements inspired by Mailgun's Talon.

Features

  • Plain text & HTML — works with both text/plain and text/html email bodies
  • Client-specific detection — fast-path selectors for Gmail (div.gmail_quote), Outlook (#divRplyFwdMsg, border styles), Outlook Web App (#OLK_SRC_BODY_SECTION), Zimbra (hr[data-marker]), and more
  • Two-phase HTML detection — tries client-specific CSS selectors first, falls back to line-based pattern matching
  • Multi-language — English, Dutch, German, French, Spanish, Russian, Swedish, Portuguese
  • Email clients — Gmail, Apple Mail, Outlook (2003–2013, Web, iOS), Thunderbird, Mail.ru, Zimbra, Sparrow
  • Lightweight — single runtime dependency (linkedom)

Install

pnpm add equoter
# or
npm install equoter

Usage

quote(text, options?)

Split a plain text email body into quoted and unquoted parts.

import { quote } from "equoter";

const result = quote(`Hello world.

On 2012-10-16 at 17:02, Someone <[email protected]> wrote:

> Some quoted text`);

// [
//   [true, "Hello world.\n\nOn 2012-10-16 at 17:02, Someone <[email protected]> wrote:"],
//   [false, "\n> Some quoted text"]
// ]

Each tuple is [shouldExpand, text]true means original content, false means quoted.

Options:

| Option | Default | Description | |--------|---------|-------------| | limit | 1000 | Auto-quote everything after this many lines if no pattern is found | | quoteIntroLine | false | Include the "On ... wrote:" line in the quoted portion |

quoteHtml(html, options?)

Same as quote() but for HTML email bodies. Uses a two-phase approach:

  1. Phase 1 — Try client-specific CSS selectors (Gmail, Outlook, Zimbra, etc.) for fast, reliable detection
  2. Phase 2 — Fall back to line-based pattern matching
import { quoteHtml } from "equoter";

const result = quoteHtml(`<div>Reply text</div>
<blockquote>On Jan 1, Someone wrote:<br>Original message</blockquote>`);

Accepts the same options as quote(). Returns [shouldExpand, htmlFragment][].

unwrap(text)

Decompose a plain text email into structured parts.

import { unwrap } from "equoter";

const result = unwrap(`Hello

---------- Forwarded message ----------
From: Someone <[email protected]>
Date: Fri, Apr 26, 2013 at 8:13 PM
Subject: Weekend classes
To: [email protected]

Learn something new`);

// {
//   type: "forward",
//   text_top: "Hello",
//   from: "Someone <[email protected]>",
//   date: "Fri, Apr 26, 2013 at 8:13 PM",
//   subject: "Weekend classes",
//   to: "[email protected]",
//   text: "Learn something new"
// }

Returns null if no forwarded/replied/quoted structure is detected.

Return fields:

| Field | Description | |-------|-------------| | type | "reply", "forward", or "quote" | | text_top / text_bottom | Text before/after the quoted content | | text | The unwrapped message body | | from, to, cc, bcc, subject, date, reply-to | Parsed headers (when present) |

unwrapHtml(html)

Same as unwrap() but for HTML email bodies. Returns html_top, html_bottom, and html instead of their text_ equivalents.

import { unwrapHtml } from "equoter";

const result = unwrapHtml(htmlEmailString);

// {
//   type: "forward",
//   html_top: "<div>Some intro text</div>",
//   from: "Someone <[email protected]>",
//   subject: "The subject",
//   html: "<div>The forwarded content</div>"
// }

Supported reply patterns

| Language | Pattern | |----------|---------| | English | On [date], [name] wrote: | | Dutch | Op [date] schreef [name]: / [name] schreef op [date]: / Op [date] heeft [name] het volgende geschreven: | | German | Am [date] schrieb [name]: | | French | Le [date] a écrit : | | Spanish | El [date] escribió: | | Russian | [name] написал(а): | | Swedish | Den [date] skrev [name]: | | Portuguese | Em [date] escreveu: |

Differences from quotequail

  • Function names use camelCase: quote_html -> quoteHtml, unwrap_html -> unwrapHtml
  • Options are passed as an object: quote(text, { limit: 500, quoteIntroLine: true })
  • Uses linkedom for HTML parsing instead of lxml
  • Two-phase HTML detection with client-specific CSS selectors (inspired by Talon)
  • Additional Dutch reply patterns (schreef op, heeft ... het volgende geschreven:)
  • Outlook #divRplyFwdMsg, Outlook Web App, Zimbra, and Windows Mail detection

License

MIT — see LICENSE.

Based on quotequail by Elastic Inc. (Close.io), also MIT licensed.