function
markdown.html
input: string | ArrayBufferLike | TypedArray<ArrayBufferLike> | DataView<ArrayBufferLike>,
): string;
Render markdown to an HTML string.
@param input
The markdown string or buffer to render
@param options
Parser options
@returns
An HTML string
const html = Bun.markdown.html("# Hello **world**");
// "<h1>Hello <strong>world</strong></h1>\n"
// With options
const html = Bun.markdown.html("## Hello", { headings: { ids: true } });
// '<h2 id="hello">Hello</h2>\n'Referenced types
interface Options
Options for configuring the markdown parser.
By default, GFM extensions (tables, strikethrough, task lists) are enabled.
- autolinks?: boolean | { email: boolean; url: boolean; www: boolean }
Enable autolinks. Pass
trueto enable all autolink types (URL, WWW, email), or an object to enable individually.// Enable all autolinks { autolinks: true } // Enable only URL and email autolinks { autolinks: { url: true, email: true } } - headings?: boolean | { autolink: boolean; ids: boolean }
Configure heading IDs and autolink headings. Pass
trueto enable both heading IDs and autolink headings, or an object to configure individually.// Enable both heading IDs and autolink headings { headings: true } // Enable only heading IDs { headings: { ids: true } } - tagFilter?: boolean
Enable the GFM tag filter, which replaces
<with<for disallowed HTML tags (e.g.<script>,<style>,<iframe>). Default:false. - underline?: boolean
Enable underline syntax (
__text__renders as<u>instead of<strong>). Default:false.