function
bun.markdown.ansi
input: string | ArrayBufferLike | TypedArray<ArrayBufferLike> | DataView<ArrayBufferLike>,
): string;
Render markdown to an ANSI-colored terminal string.
Supports headings, lists, tables, inline styles, syntax-highlighted code blocks, links, images, and blockquotes. By default, enables all GFM extensions plus wikilinks, underline, and LaTeX math.
@param input
The markdown string or buffer to render
@param theme
Optional theme overrides
@returns
An ANSI-colored string
const out = Bun.markdown.ansi("# Hello\n\n**bold** and *italic*\n");
process.stdout.write(out);
// Plain text, no escape codes
const plain = Bun.markdown.ansi("# Hello", { colors: false });
// Enable clickable OSC 8 hyperlinks
const linked = Bun.markdown.ansi("[docs](https://bun.com)", {
hyperlinks: true,
});
// Inline images via Kitty Graphics Protocol
const withImg = Bun.markdown.ansi("", {
kittyGraphics: true,
});
// Custom width
const wrapped = Bun.markdown.ansi(longText, { columns: 60 });