# html-email-to-markdown benchmark

Reproduces every number quoted in `content/blog/{ja,en,es,pt}/html-email-to-markdown.md`.

## What it measures

Two samples are converted with the exact Turndown configuration FormatArc's
html-to-markdown tool uses (`lib/tooling.ts` `getTurndown()`: `headingStyle: "atx"`,
`codeBlockStyle: "fenced"`, `bulletListMarker: "-"`, `emDelimiter: "_"` plus the
custom table rule that flattens `<table>` via `querySelectorAll("tr")` +
`renderMarkdownTable`):

1. `sample-newsletter.html` — a hand-built but representative full newsletter
   source: XHTML doctype, 3 MSO conditional comments, 8 `<table>` elements
   (nested layout tables), 33 inline `style` attributes, a `<style>` block,
   a 1x1 tracking pixel, 4 ESP-wrapped (`click.example-esp.com`) links and
   `&nbsp;` spacers. 6,491 bytes UTF-8.
2. `sample-content-block.html` — only the main content block of the same email,
   the way you would copy it from browser devtools ("Copy outerHTML" on the
   content cell). 1,086 bytes UTF-8.

Recorded per sample (see `results.json`): input bytes / table count / style-attr
count / tracking artifacts, and output chars / lines / pipe-table rows /
surviving tracking URLs, plus the full converted Markdown.

## Key results (2026-07-17 run)

- Full newsletter source: 6,491 bytes in, converts to a flattened 12-column
  pipe table (10 pipe rows) with heavily duplicated cell text, and the
  `<title>` text plus the 380-byte `<style>` block CSS leak into the output as
  plain text. The MSO conditional comments and inline `style` attributes are
  stripped.
- Content block only: 1,086 bytes in, 477 chars of clean Markdown out
  (heading, paragraphs, link preserved). The ESP-wrapped link URL survives
  verbatim and still needs manual post-processing.

## Environment

- Node v26.3.1, darwin/arm64 (Apple M5 Pro), turndown 7.2.4 (same version as
  the site: `package.json` pins `^7.2.4`)
- The production tool runs the identical Turndown config in the browser
  (DOMParser instead of domino); the flatten-table rule and options are copied
  verbatim from `lib/tooling.ts`.

## Run

```bash
npm install
node measure.mjs   # rewrites results.json and prints both conversions
```
