Most terminal Markdown renderers, such as glow and mdcat, buffer the entire document before rendering. This makes them poorly suited to live LLM output and can result in unnecessary CPU and memory usage.
I built mdflow, a true real-time streaming Markdown cli renderer that is super fast and lightweight.
I started with MD4C, written in C, like others it also buffers the whole document, but its flat-buffer design made it possible for me to reconstruct feature by feature, that render and emit output immediately.
Streaming: Renders and outputs in real-time, line by line
Markdown support: Tested against the CommonMark and GFM test suites
Performance:
~ 10 to 100x faster than existing renderers in my benchmarks
~ 2MB RAM regardless of input size
~ 300KB binary, no deps
Limitaions:
Markdown was not designed with streaming in mind. However much of the Markdown today is generated incrementally, by LLMs. In practice, when Markdown is generated properly, it rarely uses features that depend on future output, so the limitations are almost nonexistent.
For more details, please see the GitHub repository. I’d love to hear your feedback.
(In my benchmarks, glow - the most popular cli renderer, was about 100x slower and used about 100x more RAM, which is quite unexpeected that I'd appreciate it if anyone could review or run a benchmarks to verify)
Hi HN,
Most terminal Markdown renderers, such as glow and mdcat, buffer the entire document before rendering. This makes them poorly suited to live LLM output and can result in unnecessary CPU and memory usage.
I built mdflow, a true real-time streaming Markdown cli renderer that is super fast and lightweight.
I started with MD4C, written in C, like others it also buffers the whole document, but its flat-buffer design made it possible for me to reconstruct feature by feature, that render and emit output immediately.
Streaming: Renders and outputs in real-time, line by line
Markdown support: Tested against the CommonMark and GFM test suites
Performance: ~ 10 to 100x faster than existing renderers in my benchmarks ~ 2MB RAM regardless of input size ~ 300KB binary, no deps
Limitaions: Markdown was not designed with streaming in mind. However much of the Markdown today is generated incrementally, by LLMs. In practice, when Markdown is generated properly, it rarely uses features that depend on future output, so the limitations are almost nonexistent.
For more details, please see the GitHub repository. I’d love to hear your feedback. (In my benchmarks, glow - the most popular cli renderer, was about 100x slower and used about 100x more RAM, which is quite unexpeected that I'd appreciate it if anyone could review or run a benchmarks to verify)
https://github.com/cjccjj/mdflow