markdown-to-ansi
Render Markdown as ANSI-formatted terminal text
Converts CommonMark Markdown into richly formatted ANSI terminal output. Powered by pulldown-cmark for parsing and syntect for syntax highlighting (base16-ocean.dark theme).
Supported elements
- Headings (bold)
- Bold, italic, and inline
code(colored) - Links rendered as clickable OSC 8 terminal hyperlinks
- Fenced code blocks with syntax highlighting and background padding
- Tables with Unicode box-drawing borders, alignment, and bold headers
- Ordered and unordered lists with nested indentation
- Text wrapping that respects terminal width and preserves ANSI escapes
API
render(text, opts)-- full block-level rendering (paragraphs, headings, code blocks, lists, tables)render_inline(text, opts)-- inline-only rendering (bold, italic, code spans, links)has_syntax(lang)-- check if a language token has a syntax definition
Usage
use ;
let opts = Options ;
// Full document rendering
let output = render;
println!;
// Inline-only rendering (no paragraph wrappers)
let inline = render_inline;
println!;
License
Apache-2.0