Expand description
§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 markdown_to_ansi::{render, render_inline, Options};
let opts = Options {
syntax_highlight: true,
width: Some(80),
code_bg: true,
};
// Full document rendering
let output = render("# Hello
This is **bold**.", &opts);
println!("{output}");
// Inline-only rendering (no paragraph wrappers)
let inline = render_inline("Use `foo` for **bar**", &opts);
println!("{inline}");§License
Apache-2.0
Structs§
- Options
- Options controlling rendering behavior.
Functions§
- has_
syntax - Returns true if a syntax definition exists for the given language token.
- render
- Render markdown to ANSI text (block-level: paragraphs, headers, code blocks, lists, tables).
- render_
inline - Render inline markdown only (code spans, bold, links, raw URLs).