{"slug": "show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram", "title": "Show HN: Tiny Markdown CLI renderer – Streaming, 10x faster, 2MB flat RAM", "summary": "Hacker News user 'mdflow' released mdflow v0.1.2, a streaming Markdown CLI renderer written in C that claims to be 10 times faster than alternatives while using flat memory (2MB RAM). The tool supports CommonMark (tested against all 652 specification examples) and GFM features like tables, strikethrough, task lists, and footnotes, and is designed for real-time streaming output, making it suitable for AI applications and resource-constrained devices.", "body_md": "Parser derived from the proven[MD4C], restructured for true streaming.\n\n**Real-time Streaming**- must have for AI** CommonMark + GFM support tested**- tested against the CommonMark specification (652 examples)** Very Fast**- 10 times faster than many others** Flat memory**- use little memory and stays flat as input grows** Lightweight**- tiny binary easy to embed in an app or resource-constrained devices\n\n| mdflow | streamdown | mdcat | glow (glamour) | ||\n|---|---|---|---|---|---|\n| Capabilities | Streaming | ✅ | ✅ | ❌ | ❌ |\n| Buffering | Single line | Single line | Whole doc | Whole doc | |\n| CommonMark | ✅ Tested* | ❌ | ✅ Tested | ❌ | |\n| GFM tables | ✅ | ✅ | |||\n| Render time | 1 MB input | ||||\n| 10 MB input | |||||\n| 100 MB input | - | - | |||\n| Peak RAM | 1 MB input | ||||\n| 10 MB input | |||||\n| 100 MB input | - | - | |||\n| Binary | Language | C | Python | Rust | Go |\n| Size | - |\n\n1. See \"CommonMark + GFM support, extensions, and limitations\" for tested coverage and known differences.\n\n2. streamdown and glow did not finish the 100 MB test within 100 seconds.\n\n3. Input consisted of mixed Markdown. Performance varies by content.\n\n4. Benchmarked on GitHub Actions (Ubuntu 24.04, AMD EPYC 7763, 4 vCPUs)\n\n5. mdflow v0.1.2, streamdown 0.36.6, glow v3.0.0, and mdcat v2.7.1.\n\n**CommonMark + GFM support**- tables, strikethrough, task lists, autolinks, footnotes, and admonitions, with known differences and streaming limitations documented below.**Extras**- highlights.** Tables**- box-drawing borders, alignment, automatic layout, and wrapping that preserves styling.** Unicode-correct**- tested with CJK and emoji.** Syntax highlighting**- simplified, generic highlighting using five styles, applied to code blocks in major programming languages.** Inline HTML**- tags and entities styled for the terminal, with comments hidden.** HTML blocks**- raw HTML scanned and styled, entities decoded, comments hidden, and Markdown inside is left literal.** Clickable links**- links, autolinks, and emails are OSC 8 terminal hyperlinks.** Color themes**- a default theme that respects the terminal's local color palette, a TERM_256 theme that uses a more stable 256-color palette, and a plain mode that disables ANSI styling.\n\nThis section describes mdflow's current level of Markdown support and its known differences. It is not a claim of full conformance. CommonMark and GFM define expected HTML output in their examples. This section only addresses the parser, not mdflow's ANSI renderer or its terminal presentation.\n\nmdflow is tested against all 652 CommonMark specification examples and the GFM features listed above. The complete example set is included in the test suite. MD4C is fully CommonMark-compliant; mdflow's parser produces output identical to MD4C for all examples except those involving a limitation documented below.\n\nA proper live Markdown generator already avoids features that depend on future input. In static documents, the practical impact remains small.\n\n| Feature | mdflow behavior | Practical impact |\n|---|---|---|\n| Tight/loose lists | The first list item may retain tight. | No visible difference in the terminal. |\n| Multi-line Setext headings | Only the last line becomes a heading. | Affects only uncommon multi-line Setext headings. |\n\n| Feature | mdflow behavior | Practical impact |\n|---|---|---|\n| Reference links | Reference shown immediately without resolving definition, and definitions appear at the end. | Rare in live Markdown. Not fully functional in a terminal anyway. No content is lost. |\n| Footnotes | Footnote reference shown immediately without validating definition. | Rare in live Markdown. No content is lost. |\n\n**Syntax highlighting**- current highlighting is lightweight and generic, rather than language-specific.** No pager or TUI**- mdflow renders; scrolling is left to`more`\n\nor`less -R`\n\n.**Customization**- two built-in themes and one fixed configuration object are exposed; user-defined themes and additional feature flags are not exposed.\n\nFor Linux and macOS, installs to `~/.local/bin`\n\n:\n\n```\ncurl -fsSL https://raw.githubusercontent.com/cjccjj/mdflow/main/install.sh | sh\n```\n\nOr download a binary from [Releases](https://github.com/cjccjj/mdflow/releases) (Linux x86_64/arm64, macOS arm64).\n\nPipe Markdown into mdflow - live LLM output, live logs, files, or anything that streams:\n\n```\nmy-ai-tool \"show me a markdown demo\" | mdflow\ncat README.md | mdflow\ncurl -sL https://raw.githubusercontent.com/cjccjj/mdflow/main/assets/demo.md | mdflow\n```\n\nTo render a file:\n\n```\nmdflow < README.md\nmdflow README.md\n```\n\nTo quickly add Markdown rendering to your CLI tool, add this Bash function to\n`~/.bashrc`\n\n:\n\n```\nmy-ai-tool() {\n  command my-ai-tool \"$@\" | mdflow\n  local s=(\"${PIPESTATUS[@]}\")\n  return \"$((s[0] ? s[0] : s[1]))\" \n  }\n```\n\nReload the configuration, and use the tool normally:\n\n```\nsource ~/.bashrc\nmy-ai-tool \"explain this code\"\n```\n\nFor paging long documents, pipe to `more`\n\nor `less -R`\n\n.\n\n```\nmdflow < README.md | more\n```\n\n`-h`\n\n,`--help`\n\n: Show usage.`--typewriter-off`\n\n: Typewriter pacing activates only when a live, slow stream is detected. This forces it off.`--osc8-off`\n\n: OSC 8 hyperlinks are on by default. This disables them for terminals such as Apple Terminal.`--theme-term-256`\n\n: Use the TERM_256 rendering theme, which is more reliable across terminals. If omitted, the DEFAULT rendering theme is used.`--plain`\n\n: Select plain output mode, disabling renderer-generated SGR and OSC 8 sequences.\n\nmdflow is also a small C library with a small libc-only API:\n\n```\n#include \"mdflow.h\"\n\nmdflow_config_t config;\nmdflow_t* mf;\n\nconfig.theme = MDFLOW_THEME_DEFAULT;\nconfig.plain = 1;\nconfig.osc8 = 1;\nmf = mdflow_open(80, &config, my_output_callback, my_userdata);\nmdflow_write(mf, \"# Hello\\n\", 8);\nmdflow_close(mf);\ncmake -S . -B build\ncmake --build build\n```\n\nBuilding requires only a C compiler and CMake. GCC and Clang builds enable `-Wall`\n\n, `-Wextra`\n\n, and `-Wshadow`\n\n.\n\n``` php\nstdin -> parser (streaming) -> renderer (streaming) -> stdout\n```\n\nTwo components, both streaming, bundled into one library - no AST, no document buffer.\n\n**Parser (MD4CS)** - [MD4C](https://github.com/mity/md4c) is a fast SAX-like Markdown parser with a flat-buffer design, though it still buffers in full and fires all callbacks at the end, because many features depend on input that has not arrived yet.\n\nWhen analyzed feature by feature, some require only one line of lookahead; some require unbounded lookahead but style can be determined earlier. mdflow's parser MD4CS, builds on top of MD4C, reconstructs the features that require handling to enable true streaming. It can thus emit callbacks in the first pass and free memory immediately.\n\n**Renderer (md4cs-ansi)** - maps parser callbacks to styled terminal output.\n\n**Sub-modules:**\n\n`highlight.c`\n\n- single-pass lightweight code highlighting, derived from[microlight](https://github.com/asvd/microlight)(MIT)`html.c`\n\n- HTML tag/entity scanner that styles raw HTML- tables - box-drawing layout that redraws when column widths change mid-stream\n\n[MD4C](https://github.com/mity/md4c)by Martin Mitas (MIT) - the parser mdflow is built on.[microlight](https://github.com/asvd/microlight)by asvd (MIT) - the code highlighter is derived from it.\n\nMIT. See [LICENSE.md](/cjccjj/mdflow/blob/main/LICENSE.md) and the license comments in the source file headers.", "url": "https://wpnews.pro/news/show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram", "canonical_source": "https://github.com/cjccjj/mdflow", "published_at": "2026-09-03 06:45:41+00:00", "updated_at": "2026-09-03 06:52:03.989023+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools"], "entities": ["mdflow", "MD4C", "CommonMark", "GFM", "Hacker News"], "alternates": {"html": "https://wpnews.pro/news/show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram", "markdown": "https://wpnews.pro/news/show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram.md", "text": "https://wpnews.pro/news/show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram.txt", "jsonld": "https://wpnews.pro/news/show-hn-tiny-markdown-cli-renderer-streaming-10x-faster-2mb-flat-ram.jsonld"}}