Raw documents (Markdown, HTML, plain text) → structured bridge format <D>?<H><B> — with adaptive compression that keeps you under token budget.
Table of Contents
Why
LLMs perform better when context is clean and dense. This library handles the mechanical work:
| Feature | Why it matters |
|---|
| 🏗️ | Structural parsing | Markdown/HTML/plain text → typed IR nodes (headings, paragraphs, tables, lists, code blocks) |
| 📉 | Adaptive compression | Automatically escalates through 4 stages as token budget fills up |
| 🔣 | Symbol substitution | Repeated domain terms → Unicode PUA characters, decoded by <D> dictionary header |
| 📊 | Table linearization | Markdown tables → compact Key:Val (≤5 rows) or pipe-separated rows for larger tables |
| 🌊 | Streaming output | Tokio stream delivers the first chunk immediately, minimizing TTFT |
Benchmarks
48 documents, 3 formats, 15 languages — Apple M-series, --release build. Numbers below are measured with the real cl100k BPE tokenizer (not the self-referential heuristic — see the analysis). Full methodology and token-honesty breakdown: docs/EVALUATION.md
| Format | Semantic reduction | Compressed reduction | Lossless word coverage | Throughput |
|---|
| Markdown | 27.4% | 69.4% | 99.0% | — |
| HTML | 98.7% | 99.3% | 99.0% | — |
| PlainText | −3.5% | 30.4% | 99.0% | — |
| Overall (BPE) | 81.5% | 91.8% | 99.0% | ~1,070 tok/ms |
⚠️ The overall figure is dominated by HTML markup stripping. Markdown 27.4% is the genuine compression rate. PlainText is net-negative in Semantic mode due to structural overhead. See docs/EVALUATION.md for the per-format reality.
HTML reduction reflects markup overhead removal (nav, scripts, styles), not prose compression alone.
Installation
Claude Code