Marcli is a Rust library that renders CommonMark Markdown as richly styled ANSI terminal output. It uses comrak (GitHub's Markdown parser) for parsing and syntect (Sublime Text grammars) for syntax highlighting. The API is minimal — a single render() function call returns a styled string. Supported elements include headings with color hierarchy, bullet/ordered lists with Unicode markers, fenced code blocks with box-drawing borders and syntax highlighting, tables, task lists, block quotes, and links. Every visual aspect is controlled via a flat Theme struct that can be loaded from TOML files. Additional options include CRLF support for web terminals (xterm.js) and an escape_sequences flag to strip ANSI codes for logging or piping. The library has only six dependencies and no async runtime, making it suitable for CLI tools that need styled help text or error messages without pulling in a full TUI framework.

8m read timeFrom rocket-science.ru
Post cover image
Table of contents
What It DoesSupported ElementsSyntax Highlighting That Works Without ConfigurationFull Theming via TOMLCRLF Support for xterm.js and Web TerminalsStripping ANSI for Plain TextThe Dependency StoryWhy Marcli Instead of the AlternativesThe Argument for LightweightLinks
2.9K Impressions