samemark
The same mdast as remark-parse, up to 10x faster, with streaming for chat UIs
- Area
- Libraries
- Language
- JavaScript
- License
- MIT
- Latest
- v0.1.0
- Plate
- No. 14 of 14
samemark returns the same mdast tree as remark-parse with GFM, positions included, and replaces it in a unified pipeline with one import. Your remark plugins keep working, and the whole markdown to HTML run gets several times faster. A second entry, samemark/stream, parses chat answers incrementally so streaming UIs stop re-parsing the whole message on every token.
How it works
- 01
A hand-written fast path parses markdown straight into the mdast node shapes micromark produces, with no micromark at parse time.
- 02
Any setup it does not reproduce exactly (other micromark extensions, custom frontmatter fences) is detected and handed to mdast-util-from-markdown, so you always get micromark's answer.
- 03
The stream parser re-parses only the unfinished tail of the message and reuses every finished block, so a push costs the new text, not the whole answer.
What it does
- Same mdast as mdast-util-from-markdown with GFM, positions included, checked node by node against micromark
- remarkParseFast is a drop-in for remark-parse in unified, Astro and react-markdown
- remark-gfm, remark-frontmatter and remark-math are handled natively; other extensions are passed to the real parser, so the output stays correct
- samemark/stream parses chat output incrementally and matches a full parse after every chunk, so finished blocks keep their object identity for React.memo
- Plain JavaScript, no native binary, runs in Node 18+, browsers, Deno, Bun and edge runtimes
More from the bench
All projectssheetstream
Read and write million-row XLSX and CSV files in Node.js in about 80 MB of memory
purify-edge
DOMPurify without jsdom: identical output, 4x faster, runs on Cloudflare Workers
Quicky Wiki
Turn a pile of documents into a knowledge base that scores how sure it is